Subversion Repositories eFlore/Applications.coel

Rev

Rev 908 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 908 Rev 924
Line 25... Line 25...
25
import com.extjs.gxt.ui.client.event.SelectionListener;
25
import com.extjs.gxt.ui.client.event.SelectionListener;
26
import com.extjs.gxt.ui.client.store.ListStore;
26
import com.extjs.gxt.ui.client.store.ListStore;
27
import com.extjs.gxt.ui.client.widget.ContentPanel;
27
import com.extjs.gxt.ui.client.widget.ContentPanel;
28
import com.extjs.gxt.ui.client.widget.button.Button;
28
import com.extjs.gxt.ui.client.widget.button.Button;
29
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
29
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
30
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
-
 
31
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
30
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
32
import com.extjs.gxt.ui.client.widget.grid.Grid;
31
import com.extjs.gxt.ui.client.widget.grid.Grid;
33
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
-
 
34
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
32
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
35
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
33
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
36
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
34
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
37
import com.google.gwt.core.client.GWT;
35
import com.google.gwt.core.client.GWT;
38
import com.google.gwt.user.client.Window;
-
 
Line 39... Line 36...
39
 
36
 
Line 40... Line 37...
40
public class ProjetListeVue extends ContentPanel implements Rafraichissable {
37
public class ProjetListeVue extends ContentPanel implements Rafraichissable {
41
 
38
 
Line 48... Line 45...
48
 
45
 
49
	private Button ajouter;
46
	private Button ajouter;
50
	private Button modifier;
47
	private Button modifier;
Line 51... Line -...
51
	private Button supprimer;
-
 
52
	
-
 
53
	private boolean enSuppression = false;
48
	private Button supprimer;
54
 
49
	
55
	public ProjetListeVue(Mediateur mediateurCourant) {
50
	public ProjetListeVue(Mediateur mediateurCourant) {
56
		super();
51
		super();
Line 70... Line 65...
70
		});
65
		});
71
		toolBar.add(ajouter);
66
		toolBar.add(ajouter);
Line 72... Line 67...
72
 
67
 
73
		modifier = new Button(i18nC.modifier());
68
		modifier = new Button(i18nC.modifier());
74
		modifier.setIcon(Images.ICONES.formModifier());
-
 
75
		toolBar.add(modifier);
69
		modifier.setIcon(Images.ICONES.formModifier());
76
		modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {  
70
		modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {  
77
			public void componentSelected(ButtonEvent be) { 
-
 
78
				int tailleSel = grille.getSelectionModel().getSelectedItems().size();
-
 
79
				if(tailleSel > 0) {
-
 
80
					if(grille.getSelectionModel().getSelectedItems().size() > 1) {
-
 
81
						Window.alert("Veuillez ne sélectionner qu'un seul projet à modifier");
-
 
82
					} else {
71
			public void componentSelected(ButtonEvent be) { 
83
						mediateur.clicModifierProjet(grille.getSelectionModel().getSelectedItems());
-
 
84
					}
-
 
85
				}
72
				mediateur.clicModifierProjet(grille.getSelectionModel().getSelectedItems());
86
			}  
73
			}  
-
 
74
		});
Line 87... Line 75...
87
		});
75
		toolBar.add(modifier);
88
		
76
		
89
		supprimer = new Button(i18nC.supprimer());
-
 
90
		supprimer.setIcon(Images.ICONES.supprimer());
77
		supprimer = new Button(i18nC.supprimer());
91
		toolBar.add(supprimer);
78
		supprimer.setIcon(Images.ICONES.supprimer());
92
		supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
79
		supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
93
			public void componentSelected(ButtonEvent be) { 
80
			public void componentSelected(ButtonEvent be) { 
94
				mediateur.clicSupprimerProjet(grille.getSelectionModel().getSelectedItems());
81
				mediateur.clicSupprimerProjet(grille.getSelectionModel().getSelectedItems());
-
 
82
			}  
Line 95... Line 83...
95
			}  
83
		});
Line 96... Line 84...
96
		});
84
		toolBar.add(supprimer);
97
 
85
 
Line 119... Line 107...
119
		store = new ListStore<Projet>();
107
		store = new ListStore<Projet>();
120
		store.sort("titre", SortDir.ASC);
108
		store.sort("titre", SortDir.ASC);
Line 121... Line 109...
121
		
109
		
122
		grille = new Grid<Projet>(store, modeleDesColonnes);
110
		grille = new Grid<Projet>(store, modeleDesColonnes);
123
		grille.setWidth("100%");
111
		grille.setWidth("100%");
124
		//grille.setAutoExpandColumn("titre");
112
		grille.setAutoExpandColumn("nom");
125
		grille.getView().setAutoFill(true);
113
		grille.getView().setAutoFill(true);
126
		grille.getView().setForceFit(true);
114
		grille.getView().setForceFit(true);
127
		grille.setSelectionModel(modeleDeSelection);
115
		grille.setSelectionModel(modeleDeSelection);
128
		grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
116
		grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
Line 131... Line 119...
131
				grille.getSelectionModel().select(0, false);
119
				grille.getSelectionModel().select(0, false);
132
			}
120
			}
133
		});
121
		});
Line 134... Line 122...
134
		
122
		
135
		grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
-
 
136
 
123
		grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
137
			@Override
124
			@Override
138
			public void handleEvent(BaseEvent be) {
125
			public void handleEvent(BaseEvent be) {
139
				modifier.fireEvent(Events.Select);
126
				modifier.fireEvent(Events.Select);
140
			}
-
 
141
			
127
			}
142
		});
128
		});
143
		add(grille);
129
		add(grille);
Line 144... Line 130...
144
	}
130
	}
Line 169... Line 155...
169
	}
155
	}
Line 170... Line 156...
170
	
156
	
171
	public void rafraichir(Object nouvellesDonnees) {
157
	public void rafraichir(Object nouvellesDonnees) {
172
		if (nouvellesDonnees instanceof ProjetListe) {
158
		if (nouvellesDonnees instanceof ProjetListe) {
173
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
-
 
174
 
159
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
175
			if (projets != null) {
160
			if (projets != null) {
176
				List<Projet> liste = projets.toList();
161
				List<Projet> liste = projets.toList();
177
				store = new ListStore<Projet>();
162
				store = new ListStore<Projet>();
178
				store.removeAll();
163
				store.removeAll();
179
				store.add(liste);
-
 
180
				grille.reconfigure(store, modeleDesColonnes);
164
				store.add(liste);
181
				grille.getSelectionModel().select(0, false);
-
 
182
				
-
 
183
				repaint();
165
				mediateur.actualiserPanneauCentral();
184
			}
-
 
185
			
-
 
186
			//mediateur.actualiserPanneauCentral();
-
 
187
			gererEtatActivationBouton();
-
 
188
			layout(true);
166
			}
189
		} else if (nouvellesDonnees instanceof Information) {
167
		} else if (nouvellesDonnees instanceof Information) {
190
			Information info = (Information) nouvellesDonnees;
168
			Information info = (Information) nouvellesDonnees;
191
			if (info.getType().equals("maj_utilisateur")) {
169
			if (info.getType().equals("maj_utilisateur")) {
192
				gererEtatActivationBouton();
-
 
193
			}
-
 
194
			
170
				gererEtatActivationBouton();
195
			if (info.getType().equals("suppression_projet")) {
171
			} else if (info.getType().equals("suppression_projet")) {
196
				supprimerProjetsSelectionnees();
-
 
197
				enSuppression = true;
172
				supprimerProjetsSelectionnees();
198
			}
-
 
199
			
-
 
200
			if (info.getType().equals("suppression_auteur") && enSuppression) {
-
 
201
				supprimerProjetsSelectionnees();
-
 
202
				enSuppression = false;
-
 
203
			}
-
 
204
	
173
			}
205
		} else {
174
		} else {
206
			GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
175
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
207
		}
176
		}
Line 208... Line 177...
208
	}
177
	}
209
 
178