Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 865 Rev 915
Line 31... Line 31...
31
import com.extjs.gxt.ui.client.widget.grid.Grid;
31
import com.extjs.gxt.ui.client.widget.grid.Grid;
32
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
32
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
33
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
33
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
34
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
34
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
35
import com.google.gwt.core.client.GWT;
35
import com.google.gwt.core.client.GWT;
36
import com.google.gwt.i18n.client.Dictionary;
-
 
Line 37... Line 36...
37
 
36
 
Line 38... Line 37...
38
public class PersonneListeVue extends ContentPanel implements Rafraichissable {
37
public class PersonneListeVue extends ContentPanel implements Rafraichissable {
Line 39... Line 38...
39
	
38
	
40
	private Mediateur mediateur = null ;
39
	private Mediateur mediateur = null ;
41
	
-
 
42
	private Grid<Personne> grille = null;
40
	
43
	private ListStore<Personne> store = null;
41
	private Grid<Personne> grille = null;
44
	private Personne personneSelectionnee = null;
42
	private ListStore<Personne> store = null;
45
	private BarrePaginationVue pagination;
43
	private BarrePaginationVue pagination = null;
46
	private ColumnModel modeleColonnes;
44
	private ColumnModel modeleColonnes = null;
Line 47... Line 45...
47
	private final int nbElementsPage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage"));
45
	private Button ajouter = null;
48
	private final Button supprimer;
46
	private Button modifier = null;
Line 49... Line 47...
49
	private Button modifier;
47
	private Button supprimer = null;
50
	
48
	
Line 51... Line 49...
51
	public PersonneListeVue() {
49
	public PersonneListeVue() {
52
		mediateur = Registry.get(RegistreId.MEDIATEUR);
50
		mediateur = Registry.get(RegistreId.MEDIATEUR);
53
		
51
		
54
		setHeading(Mediateur.i18nC.personneListeLabel());
52
		setHeading(Mediateur.i18nC.personneListeLabel());
55
		setLayout(new FitLayout());
53
		setLayout(new FitLayout());
56
		
54
		
57
		//Définition de la barre d'outil
55
		//Définition de la barre d'outil
58
		ToolBar toolBar = new ToolBar();
56
		ToolBar toolBar = new ToolBar();
59
		Button ajouter = new Button(Mediateur.i18nC.ajouter());
57
		ajouter = new Button(Mediateur.i18nC.ajouter());
60
		ajouter.setIcon(Images.ICONES.ajouter());
58
		ajouter.setIcon(Images.ICONES.ajouter());
61
		ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
Line 62... Line 59...
62
			public void componentSelected(ButtonEvent ce) {  
59
		ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {  
63
				mediateur.clicAjouterPersonne();
60
			public void componentSelected(ButtonEvent ce) {  
64
			}  
61
				mediateur.clicAjouterPersonne();
65
		});
62
			}  
66
		toolBar.add(ajouter);
-
 
67
		final Rafraichissable r = this ;
-
 
68
 
63
		});
69
		modifier = new Button(Mediateur.i18nC.modifier());
-
 
70
		modifier.setIcon(Images.ICONES.formModifier());
-
 
71
		modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
72
			public void componentSelected(ButtonEvent ce) {  
-
 
73
				
-
 
74
				//A déplacer dans médiateur
-
 
75
				int tailleSelection = grille.getSelectionModel().getSelectedItems().size();
-
 
76
				if ( tailleSelection == 0)	{
64
		toolBar.add(ajouter);
77
					Info.display("Information", "Veuillez sélectionner une personne.");
65
 
78
				}	else if (tailleSelection > 1) {
66
		modifier = new Button(Mediateur.i18nC.modifier());
Line 79... Line 67...
79
					Info.display("Information", "Veuillez sélectionner une seule personne à la fois.");
67
		modifier.setIcon(Images.ICONES.formModifier());
-
 
68
		modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {  
80
				} else {
69
			public void componentSelected(ButtonEvent ce) {  
81
					mediateur.clicModifierPersonne(personneSelectionnee);
70
				mediateur.clicModifierPersonne(grille.getSelectionModel().getSelectedItems());
82
				}
71
			}  
83
			}  
72
		});
84
		});
73
		toolBar.add(modifier);
85
		toolBar.add(modifier);
-
 
86
		
74
		
87
		supprimer = new Button(Mediateur.i18nC.supprimer());
-
 
88
		supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
-
 
89
			public void componentSelected(ButtonEvent ce) {  
-
 
90
				mediateur.clicSupprimerPersonne(r, grille.getSelectionModel().getSelectedItems());
75
		supprimer = new Button(Mediateur.i18nC.supprimer());
Line 91... Line 76...
91
			}  
76
		supprimer.setIcon(Images.ICONES.supprimer());
92
		});
77
		supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
93
		supprimer.setIcon(Images.ICONES.supprimer());
78
			public void componentSelected(ButtonEvent ce) {  
Line 115... Line 100...
115
 
100
 
116
		// Définition de la grille
101
		// Définition de la grille
117
		GridSelectionModel<Personne> gsmSelectionGrille = new GridSelectionModel<Personne>();
102
		GridSelectionModel<Personne> gsmSelectionGrille = new GridSelectionModel<Personne>();
118
		gsmSelectionGrille.addSelectionChangedListener(new SelectionChangedListener<Personne>() {
103
		gsmSelectionGrille.addSelectionChangedListener(new SelectionChangedListener<Personne>() {
119
			public void selectionChanged(SelectionChangedEvent<Personne> event) {
104
			public void selectionChanged(SelectionChangedEvent<Personne> event) {
120
				Personne p = (Personne) event.getSelectedItem();
105
				Personne personneSelectionnee = (Personne) event.getSelectedItem();
121
				personneSelectionnee = p;
-
 
122
				clicListe(p);
106
				clicListe(personneSelectionnee);
123
			}
107
			}
Line 124... Line 108...
124
		});
108
		});
125
		
109
		
Line 137... Line 121...
137
			public void handleEvent(BaseEvent be) {
121
			public void handleEvent(BaseEvent be) {
138
				grille.getStore().sort("fmt_nom_complet", SortDir.ASC);
122
				grille.getStore().sort("fmt_nom_complet", SortDir.ASC);
139
				grille.getSelectionModel().select(0, false);
123
				grille.getSelectionModel().select(0, false);
140
			}
124
			}
141
		});
125
		});
142
		
-
 
143
		grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
126
		grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
144
 
-
 
145
			@Override
127
			@Override
146
			public void handleEvent(BaseEvent be) {
128
			public void handleEvent(BaseEvent be) {
147
				modifier.fireEvent(Events.Select);
129
				modifier.fireEvent(Events.Select);
148
			}
130
			}
149
			
-
 
150
		});
131
		});
151
		add(grille);
132
		add(grille);
Line 152... Line 133...
152
		
133
		
153
		// Définition de la barre de pagination
134
		// Définition de la barre de pagination
Line 158... Line 139...
158
	private void clicListe(Personne personne) {
139
	private void clicListe(Personne personne) {
159
		if (personne != null && store.getCount() > 0) {
140
		if (personne != null && store.getCount() > 0) {
160
			mediateur.clicListePersonne(personne);
141
			mediateur.clicListePersonne(personne);
161
		}
142
		}
162
	}
143
	}
163
 
144
	
-
 
145
	private void clicSupprimerPersonne(List<Personne> personnesASupprimer) {
-
 
146
		if (store.getCount() > 0) {
-
 
147
			mediateur.clicSupprimerPersonne(this, personnesASupprimer);
-
 
148
		}
-
 
149
	}
-
 
150
	
164
	private void gererEtatActivationBouton()	{
151
	private void gererEtatActivationBouton()	{
165
			
-
 
166
		if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false)	{			
152
		int nbreElementDuMagazin = store.getCount();
-
 
153
		ajouter.enable();
-
 
154
		if (nbreElementDuMagazin == 0) {
167
			supprimer.setEnabled(false);
155
			supprimer.disable();
168
		} else	{
156
			modifier.disable();
169
			
-
 
-
 
157
		} else if (nbreElementDuMagazin > 0) {
-
 
158
			modifier.enable();
-
 
159
			if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) {
170
			supprimer.setEnabled(true);
160
				supprimer.enable();
-
 
161
			}
171
		}
162
		}
172
			
-
 
173
	}
163
	}
Line 174... Line 164...
174
	
164
	
175
	public void rafraichir(Object nouvellesDonnees) {
165
	public void rafraichir(Object nouvellesDonnees) {
176
		if (nouvellesDonnees instanceof PersonneListe) {
-
 
177
			
166
		if (nouvellesDonnees instanceof PersonneListe) {
Line 178... Line 167...
178
			PersonneListe listePersonnes = (PersonneListe) nouvellesDonnees;
167
			PersonneListe listePersonnes = (PersonneListe) nouvellesDonnees;
179
			
168
			
Line 180... Line 169...
180
			pagination.setlistePaginable(listePersonnes);
169
			pagination.setlistePaginable(listePersonnes);
181
			pagination.rafraichir(listePersonnes.getPageTable());
170
			pagination.rafraichir(listePersonnes.getPageTable());
182
			
-
 
183
			if (listePersonnes != null) {
171
			
184
				List<Personne> liste = (List<Personne>) listePersonnes.toList();
172
			if (listePersonnes != null) {
185
				
-
 
Line 186... Line 173...
186
				ListStore<Personne> store = new ListStore<Personne>();
173
				List<Personne> liste = (List<Personne>) listePersonnes.toList();
187
				store.add(liste);
174
				store.removeAll();
188
				grille.reconfigure(store, modeleColonnes);
-
 
189
				
175
				store.add(liste);
190
				mediateur.actualiserPanneauCentral();
176
				
191
				grille.fireEvent(Events.ViewReady);
-
 
192
				
177
				mediateur.actualiserPanneauCentral();
193
			}
178
				grille.fireEvent(Events.ViewReady);
194
		} else if (nouvellesDonnees instanceof Information)	{
179
			}
195
			
-
 
196
			Information info = (Information) nouvellesDonnees;
180
		} else if (nouvellesDonnees instanceof Information)	{
197
			if (info.getType().equals("suppression_personne")) 	{
-
 
-
 
181
			Information info = (Information) nouvellesDonnees;
198
				Info.display("Suppression de personne", info.getMessages().toString());	
182
			if (info.getType().equals("suppression_personne")) 	{
199
				//Rechargement de la liste
183
				Info.display("Suppression de personne", info.getMessages().toString());	
200
				pagination.getlistePaginable().recharger();
184
				pagination.getlistePaginable().recharger();
201
				
185
				gererEtatActivationBouton();
202
			} else if (info.getType().equals("maj_utilisateur"))	{
186
			} else if (info.getType().equals("maj_utilisateur"))	{
203
				gererEtatActivationBouton();
187
				gererEtatActivationBouton();
204
			} else {
188
			} else {
205
				Info.display("Erreur", info.getMessages().toString());
189
				Info.display("Erreur", info.getMessages().toString());
Line 206... Line -...
206
			}
-
 
207
		} else {
-
 
208
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
190
			}
209
		}
191
		} else {
210
		
192
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);