1 |
package org.tela_botanica.client.vues.projet;
|
1 |
package org.tela_botanica.client.vues.projet;
|
2 |
|
2 |
|
3 |
import java.text.ParseException;
|
3 |
import java.text.ParseException;
|
4 |
import java.util.ArrayList;
|
4 |
import java.util.ArrayList;
|
5 |
import java.util.Arrays;
|
5 |
import java.util.Arrays;
|
6 |
import java.util.Comparator;
|
6 |
import java.util.Comparator;
|
7 |
import java.util.Iterator;
|
7 |
import java.util.Iterator;
|
8 |
import java.util.List;
|
8 |
import java.util.List;
|
9 |
|
9 |
|
10 |
import org.tela_botanica.client.Mediateur;
|
10 |
import org.tela_botanica.client.Mediateur;
|
11 |
import org.tela_botanica.client.RegistreId;
|
11 |
import org.tela_botanica.client.RegistreId;
|
12 |
import org.tela_botanica.client.composants.ChampFiltreRecherche;
|
12 |
import org.tela_botanica.client.composants.ChampFiltreRecherche;
|
13 |
import org.tela_botanica.client.composants.InfoLogger;
|
13 |
import org.tela_botanica.client.composants.InfoLogger;
|
14 |
import org.tela_botanica.client.i18n.Constantes;
|
14 |
import org.tela_botanica.client.i18n.Constantes;
|
15 |
import org.tela_botanica.client.images.Images;
|
15 |
import org.tela_botanica.client.images.Images;
|
16 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
16 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
17 |
import org.tela_botanica.client.modeles.Information;
|
17 |
import org.tela_botanica.client.modeles.Information;
|
18 |
import org.tela_botanica.client.modeles.Utilisateur;
|
18 |
import org.tela_botanica.client.modeles.Utilisateur;
|
19 |
import org.tela_botanica.client.modeles.projet.Projet;
|
19 |
import org.tela_botanica.client.modeles.projet.Projet;
|
20 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
20 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
21 |
import org.tela_botanica.client.modeles.publication.Publication;
|
21 |
import org.tela_botanica.client.modeles.publication.Publication;
|
22 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
22 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
23 |
import org.tela_botanica.client.util.Debug;
|
23 |
import org.tela_botanica.client.util.Debug;
|
24 |
import org.tela_botanica.client.util.UtilString;
|
24 |
import org.tela_botanica.client.util.UtilString;
|
25 |
import org.tela_botanica.client.vues.BarrePaginationVue;
|
25 |
import org.tela_botanica.client.vues.BarrePaginationVue;
|
26 |
|
26 |
|
27 |
import com.extjs.gxt.ui.client.Registry;
|
27 |
import com.extjs.gxt.ui.client.Registry;
|
28 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
28 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
29 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
29 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
30 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
30 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
31 |
import com.extjs.gxt.ui.client.event.Events;
|
31 |
import com.extjs.gxt.ui.client.event.Events;
|
32 |
import com.extjs.gxt.ui.client.event.Listener;
|
32 |
import com.extjs.gxt.ui.client.event.Listener;
|
33 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
33 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
34 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
34 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
35 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
35 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
36 |
import com.extjs.gxt.ui.client.store.ListStore;
|
36 |
import com.extjs.gxt.ui.client.store.ListStore;
|
37 |
import com.extjs.gxt.ui.client.store.StoreSorter;
|
37 |
import com.extjs.gxt.ui.client.store.StoreSorter;
|
38 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
38 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
39 |
import com.extjs.gxt.ui.client.widget.Info;
|
39 |
import com.extjs.gxt.ui.client.widget.Info;
|
40 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
40 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
41 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
41 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
42 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
42 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
43 |
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
43 |
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
44 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
44 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
45 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
45 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
46 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
46 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
47 |
import com.google.gwt.core.client.GWT;
|
47 |
import com.google.gwt.core.client.GWT;
|
48 |
import com.google.gwt.user.client.Window;
|
48 |
import com.google.gwt.user.client.Window;
|
49 |
|
49 |
|
50 |
public class ProjetListeVue extends ContentPanel implements Rafraichissable {
|
50 |
public class ProjetListeVue extends ContentPanel implements Rafraichissable {
|
51 |
|
51 |
|
52 |
private Mediateur mediateur = null;
|
52 |
private Mediateur mediateur = null;
|
53 |
private Constantes i18nC = null;
|
53 |
private Constantes i18nC = null;
|
54 |
|
54 |
|
55 |
private Grid<Projet> grille = null;
|
55 |
private Grid<Projet> grille = null;
|
56 |
private ListStore<Projet> store = null;
|
56 |
private ListStore<Projet> store = null;
|
57 |
private ColumnModel modeleDesColonnes = null;
|
57 |
private ColumnModel modeleDesColonnes = null;
|
58 |
|
58 |
|
59 |
private ChampFiltreRecherche champFiltreRecherche = null;
|
59 |
private ChampFiltreRecherche champFiltreRecherche = null;
|
60 |
private BarrePaginationVue pagination = null;
|
60 |
private BarrePaginationVue pagination = null;
|
61 |
|
61 |
|
62 |
private Button ajouter;
|
62 |
private Button ajouter;
|
63 |
private Button modifier;
|
63 |
private Button modifier;
|
64 |
private Button supprimer;
|
64 |
private Button supprimer;
|
65 |
|
65 |
|
66 |
private int indexElementSelectionne = 0;
|
66 |
private int indexElementSelectionne = 0;
|
67 |
private Projet projetSelectionne = null;
|
67 |
private Projet projetSelectionne = null;
|
68 |
|
68 |
|
69 |
public ProjetListeVue(Mediateur mediateurCourant) {
|
69 |
public ProjetListeVue(Mediateur mediateurCourant) {
|
70 |
super();
|
70 |
super();
|
71 |
mediateur = mediateurCourant;
|
71 |
mediateur = mediateurCourant;
|
72 |
i18nC = Mediateur.i18nC;
|
72 |
i18nC = Mediateur.i18nC;
|
73 |
|
73 |
|
74 |
setLayout(new FitLayout());
|
74 |
setLayout(new FitLayout());
|
75 |
setHeading("Projets");
|
75 |
setHeadingHtml("Projets");
|
76 |
|
76 |
|
77 |
ToolBar toolBar = new ToolBar();
|
77 |
ToolBar toolBar = new ToolBar();
|
78 |
ajouter = new Button(i18nC.ajouter());
|
78 |
ajouter = new Button(i18nC.ajouter());
|
79 |
ajouter.setIcon(Images.ICONES.ajouter());
|
79 |
ajouter.setIcon(Images.ICONES.ajouter());
|
80 |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
80 |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
81 |
public void componentSelected(ButtonEvent be) {
|
81 |
public void componentSelected(ButtonEvent be) {
|
82 |
mediateur.clicAjouterProjet();
|
82 |
mediateur.clicAjouterProjet();
|
83 |
}
|
83 |
}
|
84 |
});
|
84 |
});
|
85 |
ajouter.setToolTip(i18nC.indicationCreerUneFiche()+" "+i18nC.projetSingulier());
|
85 |
ajouter.setToolTip(i18nC.indicationCreerUneFiche()+" "+i18nC.projetSingulier());
|
86 |
toolBar.add(ajouter);
|
86 |
toolBar.add(ajouter);
|
87 |
|
87 |
|
88 |
modifier = new Button(i18nC.modifier());
|
88 |
modifier = new Button(i18nC.modifier());
|
89 |
modifier.setIcon(Images.ICONES.formModifier());
|
89 |
modifier.setIcon(Images.ICONES.formModifier());
|
90 |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
90 |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
91 |
public void componentSelected(ButtonEvent be) {
|
91 |
public void componentSelected(ButtonEvent be) {
|
92 |
mediateur.clicModifierProjet(grille.getSelectionModel().getSelectedItems());
|
92 |
mediateur.clicModifierProjet(grille.getSelectionModel().getSelectedItems());
|
93 |
indexElementSelectionne = store.indexOf(grille.getSelectionModel().getSelectedItem());
|
93 |
indexElementSelectionne = store.indexOf(grille.getSelectionModel().getSelectedItem());
|
94 |
}
|
94 |
}
|
95 |
});
|
95 |
});
|
96 |
modifier.setToolTip(i18nC.indicationModifierUneFiche());
|
96 |
modifier.setToolTip(i18nC.indicationModifierUneFiche());
|
97 |
toolBar.add(modifier);
|
97 |
toolBar.add(modifier);
|
98 |
|
98 |
|
99 |
supprimer = new Button(i18nC.supprimer());
|
99 |
supprimer = new Button(i18nC.supprimer());
|
100 |
supprimer.setIcon(Images.ICONES.supprimer());
|
100 |
supprimer.setIcon(Images.ICONES.supprimer());
|
101 |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
101 |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
102 |
public void componentSelected(ButtonEvent be) {
|
102 |
public void componentSelected(ButtonEvent be) {
|
103 |
mediateur.clicSupprimerProjet(grille.getSelectionModel().getSelectedItems());
|
103 |
mediateur.clicSupprimerProjet(grille.getSelectionModel().getSelectedItems());
|
104 |
}
|
104 |
}
|
105 |
});
|
105 |
});
|
106 |
supprimer.setToolTip(i18nC.indicationSupprimerUneFiche());
|
106 |
supprimer.setToolTip(i18nC.indicationSupprimerUneFiche());
|
107 |
toolBar.add(supprimer);
|
107 |
toolBar.add(supprimer);
|
108 |
|
108 |
|
109 |
setTopComponent(toolBar);
|
109 |
setTopComponent(toolBar);
|
110 |
|
110 |
|
111 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
111 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
112 |
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
|
112 |
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste
|
113 |
colonnes.add(new ColumnConfig("id_projet", i18nC.id(), 20));
|
113 |
colonnes.add(new ColumnConfig("id_projet", i18nC.id(), 20));
|
114 |
colonnes.add(new ColumnConfig("nom", i18nC.nom(), 200));
|
114 |
colonnes.add(new ColumnConfig("nom", i18nC.nom(), 200));
|
115 |
colonnes.add(new ColumnConfig("abreviation", i18nC.projetAbreviation(), 200));
|
115 |
colonnes.add(new ColumnConfig("abreviation", i18nC.projetAbreviation(), 200));
|
116 |
colonnes.add(new ColumnConfig("resume", i18nC.projetResume(), 300));
|
116 |
colonnes.add(new ColumnConfig("resume", i18nC.projetResume(), 300));
|
117 |
colonnes.add(new ColumnConfig("url", i18nC.projetUrl(), 200));
|
117 |
colonnes.add(new ColumnConfig("url", i18nC.projetUrl(), 200));
|
118 |
colonnes.add(new ColumnConfig("mot_cles", i18nC.projetMotsCles(), 280));
|
118 |
colonnes.add(new ColumnConfig("mot_cles", i18nC.projetMotsCles(), 280));
|
119 |
|
119 |
|
120 |
modeleDesColonnes = new ColumnModel(colonnes);
|
120 |
modeleDesColonnes = new ColumnModel(colonnes);
|
121 |
|
121 |
|
122 |
GridSelectionModel<Projet> modeleDeSelection = new GridSelectionModel<Projet>();
|
122 |
GridSelectionModel<Projet> modeleDeSelection = new GridSelectionModel<Projet>();
|
123 |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Projet>() {
|
123 |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Projet>() {
|
124 |
public void selectionChanged(SelectionChangedEvent<Projet> event) {
|
124 |
public void selectionChanged(SelectionChangedEvent<Projet> event) {
|
125 |
projetSelectionne = (Projet) event.getSelectedItem();
|
125 |
projetSelectionne = (Projet) event.getSelectedItem();
|
126 |
clicListe(projetSelectionne);
|
126 |
clicListe(projetSelectionne);
|
127 |
}
|
127 |
}
|
128 |
});
|
128 |
});
|
129 |
|
129 |
|
130 |
store = new ListStore<Projet>();
|
130 |
store = new ListStore<Projet>();
|
131 |
Comparator<Object> compStp = new Comparator<Object>() {
|
131 |
Comparator<Object> compStp = new Comparator<Object>() {
|
132 |
@Override
|
132 |
@Override
|
133 |
public int compare(Object o1, Object o2) {
|
133 |
public int compare(Object o1, Object o2) {
|
134 |
return comparerNaturellementChampProjet(o1,o2);
|
134 |
return comparerNaturellementChampProjet(o1,o2);
|
135 |
}
|
135 |
}
|
136 |
};
|
136 |
};
|
137 |
StoreSorter<Projet> stp = new StoreSorter<Projet>(compStp);
|
137 |
StoreSorter<Projet> stp = new StoreSorter<Projet>(compStp);
|
138 |
store.setStoreSorter(stp);
|
138 |
store.setStoreSorter(stp);
|
139 |
store.sort("id_projet", SortDir.ASC);
|
139 |
store.sort("id_projet", SortDir.ASC);
|
140 |
|
140 |
|
141 |
grille = new Grid<Projet>(store, modeleDesColonnes);
|
141 |
grille = new Grid<Projet>(store, modeleDesColonnes);
|
142 |
grille.setWidth("100%");
|
142 |
grille.setWidth("100%");
|
143 |
grille.setAutoExpandColumn("nom");
|
143 |
grille.setAutoExpandColumn("nom");
|
144 |
grille.getView().setAutoFill(true);
|
144 |
grille.getView().setAutoFill(true);
|
145 |
grille.getView().setForceFit(true);
|
145 |
grille.getView().setForceFit(true);
|
146 |
grille.setSelectionModel(modeleDeSelection);
|
146 |
grille.setSelectionModel(modeleDeSelection);
|
147 |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
|
147 |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() {
|
148 |
public void handleEvent(BaseEvent be) {
|
148 |
public void handleEvent(BaseEvent be) {
|
149 |
grille.getSelectionModel().select(0, false);
|
149 |
grille.getSelectionModel().select(0, false);
|
150 |
}
|
150 |
}
|
151 |
});
|
151 |
});
|
152 |
|
152 |
|
153 |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
|
153 |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
|
154 |
public void handleEvent(BaseEvent be) {
|
154 |
public void handleEvent(BaseEvent be) {
|
155 |
modifier.fireEvent(Events.Select);
|
155 |
modifier.fireEvent(Events.Select);
|
156 |
}
|
156 |
}
|
157 |
});
|
157 |
});
|
158 |
add(grille);
|
158 |
add(grille);
|
159 |
|
159 |
|
160 |
ProjetListe projetListe = new ProjetListe();
|
160 |
ProjetListe projetListe = new ProjetListe();
|
161 |
champFiltreRecherche = new ChampFiltreRecherche(mediateurCourant, toolBar, projetListe);
|
161 |
champFiltreRecherche = new ChampFiltreRecherche(mediateurCourant, toolBar, projetListe);
|
162 |
// Définition de la barre de pagination
|
162 |
// Définition de la barre de pagination
|
163 |
pagination = new BarrePaginationVue(projetListe, mediateur);
|
163 |
pagination = new BarrePaginationVue(projetListe, mediateur);
|
164 |
setBottomComponent(pagination);
|
164 |
setBottomComponent(pagination);
|
165 |
}
|
165 |
}
|
166 |
|
166 |
|
167 |
private int comparerNaturellementChampProjet(Object o1, Object o2) {
|
167 |
private int comparerNaturellementChampProjet(Object o1, Object o2) {
|
168 |
int compare = 0;
|
168 |
int compare = 0;
|
169 |
String s1 = (String)o1;
|
169 |
String s1 = (String)o1;
|
170 |
String s2 = (String)o2;
|
170 |
String s2 = (String)o2;
|
171 |
try {
|
171 |
try {
|
172 |
Integer i1 = Integer.parseInt(s1);
|
172 |
Integer i1 = Integer.parseInt(s1);
|
173 |
Integer i2 = Integer.parseInt(s2);
|
173 |
Integer i2 = Integer.parseInt(s2);
|
174 |
compare = i1.compareTo(i2);
|
174 |
compare = i1.compareTo(i2);
|
175 |
} catch (NumberFormatException e) {
|
175 |
} catch (NumberFormatException e) {
|
176 |
compare = s1.compareTo(s2);
|
176 |
compare = s1.compareTo(s2);
|
177 |
}
|
177 |
}
|
178 |
return compare;
|
178 |
return compare;
|
179 |
}
|
179 |
}
|
180 |
|
180 |
|
181 |
public ListStore<Projet> getStore() {
|
181 |
public ListStore<Projet> getStore() {
|
182 |
return store;
|
182 |
return store;
|
183 |
}
|
183 |
}
|
184 |
|
184 |
|
185 |
private void clicListe(Projet projet) {
|
185 |
private void clicListe(Projet projet) {
|
186 |
mediateur.clicListeProjet(projet);
|
186 |
mediateur.clicListeProjet(projet);
|
187 |
}
|
187 |
}
|
188 |
|
188 |
|
189 |
private void gererEtatActivationBouton() {
|
189 |
private void gererEtatActivationBouton() {
|
190 |
int nbreElementDuMagazin = store.getCount();
|
190 |
int nbreElementDuMagazin = store.getCount();
|
191 |
ajouter.enable();
|
191 |
ajouter.enable();
|
192 |
if (nbreElementDuMagazin <= 0) {
|
192 |
if (nbreElementDuMagazin <= 0) {
|
193 |
supprimer.disable();
|
193 |
supprimer.disable();
|
194 |
modifier.disable();
|
194 |
modifier.disable();
|
195 |
} else if (nbreElementDuMagazin > 0) {
|
195 |
} else if (nbreElementDuMagazin > 0) {
|
196 |
modifier.enable();
|
196 |
modifier.enable();
|
197 |
if (mediateur.getUtilisateur().isIdentifie()) {
|
197 |
if (mediateur.getUtilisateur().isIdentifie()) {
|
198 |
supprimer.enable();
|
198 |
supprimer.enable();
|
199 |
}
|
199 |
}
|
200 |
}
|
200 |
}
|
201 |
}
|
201 |
}
|
202 |
|
202 |
|
203 |
public void rafraichir(Object nouvellesDonnees) {
|
203 |
public void rafraichir(Object nouvellesDonnees) {
|
204 |
if (nouvellesDonnees instanceof ProjetListe) {
|
204 |
if (nouvellesDonnees instanceof ProjetListe) {
|
205 |
ProjetListe projets = (ProjetListe) nouvellesDonnees;
|
205 |
ProjetListe projets = (ProjetListe) nouvellesDonnees;
|
206 |
champFiltreRecherche.setListePaginable(projets);
|
206 |
champFiltreRecherche.setListePaginable(projets);
|
207 |
pagination.setlistePaginable(projets);
|
207 |
pagination.setlistePaginable(projets);
|
208 |
pagination.rafraichir(projets.getPageTable());
|
208 |
pagination.rafraichir(projets.getPageTable());
|
209 |
|
209 |
|
210 |
if (projets != null) {
|
210 |
if (projets != null) {
|
211 |
List<Projet> projetsListe = projets.toList();
|
211 |
List<Projet> projetsListe = projets.toList();
|
212 |
store.removeAll();
|
212 |
store.removeAll();
|
213 |
if (mediateur.getProjetId() != null) {
|
213 |
if (mediateur.getProjetId() != null) {
|
214 |
String projetIdSelectionne = mediateur.getProjetId();
|
214 |
String projetIdSelectionne = mediateur.getProjetId();
|
215 |
Iterator<Projet> it = projetsListe.iterator();
|
215 |
Iterator<Projet> it = projetsListe.iterator();
|
216 |
while (it.hasNext()) {
|
216 |
while (it.hasNext()) {
|
217 |
Projet projetCourant = it.next();
|
217 |
Projet projetCourant = it.next();
|
218 |
if (projetCourant.getId().equals(projetIdSelectionne)) {
|
218 |
if (projetCourant.getId().equals(projetIdSelectionne)) {
|
219 |
store.add(projetCourant);
|
219 |
store.add(projetCourant);
|
220 |
}
|
220 |
}
|
221 |
}
|
221 |
}
|
222 |
} else {
|
222 |
} else {
|
223 |
store.add(projetsListe);
|
223 |
store.add(projetsListe);
|
224 |
}
|
224 |
}
|
225 |
mediateur.actualiserPanneauCentral();
|
225 |
mediateur.actualiserPanneauCentral();
|
226 |
}
|
226 |
}
|
227 |
} else if (nouvellesDonnees instanceof Information) {
|
227 |
} else if (nouvellesDonnees instanceof Information) {
|
228 |
Information info = (Information) nouvellesDonnees;
|
228 |
Information info = (Information) nouvellesDonnees;
|
229 |
if (info.getType().equals("maj_utilisateur")) {
|
229 |
if (info.getType().equals("maj_utilisateur")) {
|
230 |
gererEtatActivationBouton();
|
230 |
gererEtatActivationBouton();
|
231 |
} else if (info.getType().equals("projet_modifie")) {
|
231 |
} else if (info.getType().equals("projet_modifie")) {
|
232 |
if(projetSelectionne != null) {
|
232 |
if(projetSelectionne != null) {
|
233 |
store.remove(indexElementSelectionne);
|
233 |
store.remove(indexElementSelectionne);
|
234 |
projetSelectionne = null;
|
234 |
projetSelectionne = null;
|
235 |
}
|
235 |
}
|
236 |
Projet projetModifie = (Projet)info.getDonnee(0);
|
236 |
Projet projetModifie = (Projet)info.getDonnee(0);
|
237 |
// au cas ou le bouton appliquer aurait été cliqué avant de valider
|
237 |
// au cas ou le bouton appliquer aurait été cliqué avant de valider
|
238 |
store.remove(projetModifie);
|
238 |
store.remove(projetModifie);
|
239 |
store.insert(projetModifie, indexElementSelectionne);
|
239 |
store.insert(projetModifie, indexElementSelectionne);
|
240 |
|
240 |
|
241 |
projetSelectionne = projetModifie;
|
241 |
projetSelectionne = projetModifie;
|
242 |
int indexElementSelectionne = store.indexOf(projetSelectionne);
|
242 |
int indexElementSelectionne = store.indexOf(projetSelectionne);
|
243 |
grille.getSelectionModel().select(indexElementSelectionne, false);
|
243 |
grille.getSelectionModel().select(indexElementSelectionne, false);
|
244 |
grille.getView().focusRow(indexElementSelectionne);
|
244 |
grille.getView().focusRow(indexElementSelectionne);
|
245 |
clicListe(projetModifie);
|
245 |
clicListe(projetModifie);
|
246 |
} else if (info.getType().equals("suppression_projet")) {
|
246 |
} else if (info.getType().equals("suppression_projet")) {
|
247 |
String message = info.toString();
|
247 |
String message = info.toString();
|
248 |
if (info.getDonnee(0) != null) {
|
248 |
if (info.getDonnee(0) != null) {
|
249 |
message = (String) info.getDonnee(0);
|
249 |
message = (String) info.getDonnee(0);
|
250 |
}
|
250 |
}
|
251 |
String idsNonSuppr = info.getDonnee(1).toString();
|
251 |
String idsNonSuppr = info.getDonnee(1).toString();
|
252 |
if (!UtilString.isEmpty(idsNonSuppr)) {
|
252 |
if (!UtilString.isEmpty(idsNonSuppr)) {
|
253 |
message = "Les projets " + idsNonSuppr + " n'ont pas été supprimés car ils sont liés à d'autres éléments";
|
253 |
message = "Les projets " + idsNonSuppr + " n'ont pas été supprimés car ils sont liés à d'autres éléments";
|
254 |
}
|
254 |
}
|
255 |
|
255 |
|
256 |
InfoLogger.display(i18nC.projetTitreSuppression(), message, true);
|
256 |
InfoLogger.display(i18nC.projetTitreSuppression(), message, true);
|
257 |
supprimerProjetsSelectionnees(Arrays.asList(idsNonSuppr.split(",")));
|
257 |
supprimerProjetsSelectionnees(Arrays.asList(idsNonSuppr.split(",")));
|
258 |
gererEtatActivationBouton();
|
258 |
gererEtatActivationBouton();
|
259 |
}
|
259 |
}
|
260 |
} else {
|
260 |
} else {
|
261 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
261 |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
|
262 |
}
|
262 |
}
|
263 |
layout();
|
263 |
layout();
|
264 |
}
|
264 |
}
|
265 |
|
265 |
|
266 |
public void supprimerProjetsSelectionnees(List<String> idsNonSuppr) {
|
266 |
public void supprimerProjetsSelectionnees(List<String> idsNonSuppr) {
|
267 |
List<Projet> selPub = grille.getSelectionModel().getSelectedItems();
|
267 |
List<Projet> selPub = grille.getSelectionModel().getSelectedItems();
|
268 |
for (Iterator<Projet> it = selPub.iterator(); it.hasNext();) {
|
268 |
for (Iterator<Projet> it = selPub.iterator(); it.hasNext();) {
|
269 |
Projet projetCourant = it.next();
|
269 |
Projet projetCourant = it.next();
|
270 |
if (!idsNonSuppr.contains(projetCourant.getId().toString())) {
|
270 |
if (!idsNonSuppr.contains(projetCourant.getId().toString())) {
|
271 |
grille.getStore().remove(projetCourant);
|
271 |
grille.getStore().remove(projetCourant);
|
272 |
}
|
272 |
}
|
273 |
}
|
273 |
}
|
274 |
|
274 |
|
275 |
//Mettre à jour les filtres
|
275 |
//Mettre à jour les filtres
|
276 |
mediateur.mettreFiltreAJour(grille.getStore().getModels());
|
276 |
mediateur.mettreFiltreAJour(grille.getStore().getModels());
|
277 |
layout(true);
|
277 |
layout(true);
|
278 |
}
|
278 |
}
|
279 |
}
|
279 |
}
|