Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 910 Rev 919
Line 9... Line 9...
9
import org.tela_botanica.client.i18n.Constantes;
9
import org.tela_botanica.client.i18n.Constantes;
10
import org.tela_botanica.client.images.Images;
10
import org.tela_botanica.client.images.Images;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
11
import org.tela_botanica.client.interfaces.Rafraichissable;
12
import org.tela_botanica.client.modeles.Information;
12
import org.tela_botanica.client.modeles.Information;
13
import org.tela_botanica.client.modeles.Publication;
13
import org.tela_botanica.client.modeles.Publication;
-
 
14
import org.tela_botanica.client.modeles.PublicationAPersonneListe;
14
import org.tela_botanica.client.modeles.PublicationListe;
15
import org.tela_botanica.client.modeles.PublicationListe;
15
import org.tela_botanica.client.modeles.Utilisateur;
16
import org.tela_botanica.client.modeles.Utilisateur;
16
import org.tela_botanica.client.util.Debug;
17
import org.tela_botanica.client.util.Debug;
Line 17... Line 18...
17
 
18
 
Line 49... Line 50...
49
 
50
 
50
	private Button ajouter;
51
	private Button ajouter;
51
	private Button modifier;
52
	private Button modifier;
Line 52... Line -...
52
	private Button supprimer;
-
 
53
	
-
 
54
	private boolean enSuppression = false;
53
	private Button supprimer;
55
 
54
	
56
	public PublicationListeVue(Mediateur mediateurCourant) {
55
	public PublicationListeVue(Mediateur mediateurCourant) {
Line 57... Line 56...
57
		mediateur = mediateurCourant;
56
		mediateur = mediateurCourant;
58
		i18nC = Mediateur.i18nC;
57
		i18nC = Mediateur.i18nC;
Line -... Line 58...
-
 
58
		
59
		
59
		setLayout(new FitLayout());
60
		setLayout(new FitLayout());
60
		setHeading("Publications");
61
		setHeading("Publications");
61
		
62
		
62
		// Gestion de la barre d'outil
63
		ToolBar toolBar = new ToolBar();
63
		ToolBar toolBar = new ToolBar();
Line 70... Line 70...
70
		});
70
		});
71
		toolBar.add(ajouter);
71
		toolBar.add(ajouter);
Line 72... Line 72...
72
 
72
 
73
		modifier = new Button(i18nC.modifier());
73
		modifier = new Button(i18nC.modifier());
74
		modifier.setIcon(Images.ICONES.formModifier());
-
 
75
		toolBar.add(modifier);
74
		modifier.setIcon(Images.ICONES.formModifier());
76
		modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {  
75
		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'une seule publication à modifier");
-
 
82
					} else {
76
			public void componentSelected(ButtonEvent be) { 
83
						mediateur.clicModifierPublication(grille.getSelectionModel().getSelectedItems());
-
 
84
					}
-
 
85
				}
77
				mediateur.clicModifierPublication(grille.getSelectionModel().getSelectedItems());
86
			}  
78
			}  
-
 
79
		});
Line 87... Line 80...
87
		});
80
		toolBar.add(modifier);
88
		
81
		
89
		supprimer = new Button(i18nC.supprimer());
-
 
90
		supprimer.setIcon(Images.ICONES.supprimer());
82
		supprimer = new Button(i18nC.supprimer());
91
		toolBar.add(supprimer);
83
		supprimer.setIcon(Images.ICONES.supprimer());
92
		supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
84
		supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
93
			public void componentSelected(ButtonEvent be) { 
85
			public void componentSelected(ButtonEvent be) { 
94
				mediateur.clicSupprimerPublication(grille.getSelectionModel().getSelectedItems());
86
				mediateur.clicSupprimerPublication(grille.getSelectionModel().getSelectedItems());
95
			}  
-
 
-
 
87
			}  
96
		});
88
		});
Line -... Line 89...
-
 
89
		toolBar.add(supprimer);
97
 
90
		setTopComponent(toolBar);
98
		setTopComponent(toolBar);
91
 
99
 
92
		// Gestion de la grille
100
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
93
		List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
101
		// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
94
		// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
Line 120... Line 113...
120
		store = new ListStore<Publication>();
113
		store = new ListStore<Publication>();
121
		store.sort("titre", SortDir.ASC);
114
		store.sort("titre", SortDir.ASC);
Line 122... Line 115...
122
		
115
		
123
		grille = new Grid<Publication>(store, modeleDesColonnes);
116
		grille = new Grid<Publication>(store, modeleDesColonnes);
124
		grille.setWidth("100%");
117
		grille.setWidth("100%");
125
		//grille.setAutoExpandColumn("titre");
118
		grille.setAutoExpandColumn("titre");
126
		grille.getView().setAutoFill(true);
119
		grille.getView().setAutoFill(true);
127
		grille.getView().setForceFit(true);
120
		grille.getView().setForceFit(true);
128
		grille.setSelectionModel(modeleDeSelection);
121
		grille.setSelectionModel(modeleDeSelection);
129
		grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
122
		grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
130
			@Override
123
			@Override
131
			public void handleEvent(BaseEvent be) {
124
			public void handleEvent(BaseEvent be) {
132
				grille.getSelectionModel().select(0, false);
125
				grille.getSelectionModel().select(0, false);
133
			}
126
			}
134
		});
-
 
135
		
127
		});
136
		grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
-
 
137
 
128
		grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
138
			@Override
129
			@Override
139
			public void handleEvent(BaseEvent be) {
130
			public void handleEvent(BaseEvent be) {
140
				modifier.fireEvent(Events.Select);
131
				modifier.fireEvent(Events.Select);
141
			}
-
 
142
			
132
			}
143
		});
133
		});
144
		add(grille);
134
		add(grille);
Line 145... Line 135...
145
	}
135
	}
Line 193... Line 183...
193
	}
183
	}
Line 194... Line 184...
194
	
184
	
195
	public void rafraichir(Object nouvellesDonnees) {
185
	public void rafraichir(Object nouvellesDonnees) {
196
		if (nouvellesDonnees instanceof PublicationListe) {
186
		if (nouvellesDonnees instanceof PublicationListe) {
197
			PublicationListe publications = (PublicationListe) nouvellesDonnees;
187
			PublicationListe publications = (PublicationListe) nouvellesDonnees;
198
 
188
			
199
			if (publications != null) {
189
			if (publications != null) {
200
				List<Publication> liste = publications.toList();
-
 
201
				store = new ListStore<Publication>();
190
				List<Publication> liste = publications.toList();
202
				store.removeAll();
191
				store.removeAll();
203
				store.add(liste);
-
 
-
 
192
				store.add(liste);
204
				grille.reconfigure(store, modeleDesColonnes);
193
				
205
				grille.getSelectionModel().select(0, false);
194
				mediateur.actualiserPanneauCentral();
206
			}
-
 
207
			
-
 
208
			//mediateur.actualiserPanneauCentral();
-
 
209
			gererEtatActivationBouton();
-
 
210
			layout(true);
195
			}
211
		} else if (nouvellesDonnees instanceof Information) {
196
		} else if (nouvellesDonnees instanceof Information) {
212
			Information info = (Information) nouvellesDonnees;
197
			Information info = (Information) nouvellesDonnees;
213
			if (info.getType().equals("maj_utilisateur")) {
198
			if (info.getType().equals("maj_utilisateur")) {
214
				gererEtatActivationBouton();
-
 
215
			}
-
 
216
			
199
				gererEtatActivationBouton();
217
			if (info.getType().equals("suppression_publication")) {
200
			} else if (info.getType().equals("suppression_publication")) {
218
				supprimerPublicationsSelectionnees();
-
 
219
				enSuppression = true;
-
 
220
			}
-
 
221
			
-
 
222
			if (info.getType().equals("suppression_auteur") && enSuppression) {
201
				supprimerPublicationsSelectionnees();
223
				supprimerPublicationsSelectionnees();
-
 
224
				enSuppression = false;
202
				gererEtatActivationBouton();
225
			}
-
 
226
	
203
			}
227
		} else {
204
		} else {
228
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
205
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
Line 229... Line 206...
229
		}
206
		}