934 |
jpm |
1 |
package org.tela_botanica.client.vues.collection;
|
719 |
jp_milcent |
2 |
|
|
|
3 |
import java.util.ArrayList;
|
1513 |
jpm |
4 |
import java.util.HashMap;
|
719 |
jp_milcent |
5 |
import java.util.List;
|
|
|
6 |
|
1513 |
jpm |
7 |
import org.tela_botanica.client.ComposantClass;
|
719 |
jp_milcent |
8 |
import org.tela_botanica.client.Mediateur;
|
1513 |
jpm |
9 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
|
|
10 |
import org.tela_botanica.client.composants.GrillePaginable;
|
1239 |
cyprien |
11 |
import org.tela_botanica.client.composants.InfoLogger;
|
1513 |
jpm |
12 |
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne;
|
|
|
13 |
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPublication;
|
|
|
14 |
import org.tela_botanica.client.composants.pagination.ProxyProjets;
|
|
|
15 |
import org.tela_botanica.client.composants.pagination.ProxyPublications;
|
719 |
jp_milcent |
16 |
import org.tela_botanica.client.images.Images;
|
|
|
17 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
|
|
18 |
import org.tela_botanica.client.modeles.Information;
|
907 |
jpm |
19 |
import org.tela_botanica.client.modeles.aDonnee;
|
935 |
jpm |
20 |
import org.tela_botanica.client.modeles.collection.Collection;
|
|
|
21 |
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
|
|
|
22 |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe;
|
|
|
23 |
import org.tela_botanica.client.modeles.publication.Publication;
|
|
|
24 |
import org.tela_botanica.client.modeles.publication.PublicationListe;
|
907 |
jpm |
25 |
import org.tela_botanica.client.util.Debug;
|
934 |
jpm |
26 |
import org.tela_botanica.client.vues.FenetreForm;
|
|
|
27 |
import org.tela_botanica.client.vues.Formulaire;
|
|
|
28 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
|
|
29 |
import org.tela_botanica.client.vues.FormulaireOnglet;
|
935 |
jpm |
30 |
import org.tela_botanica.client.vues.publication.PublicationForm;
|
719 |
jp_milcent |
31 |
|
1284 |
gduche |
32 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
799 |
jpm |
33 |
import com.extjs.gxt.ui.client.core.XTemplate;
|
1513 |
jpm |
34 |
import com.extjs.gxt.ui.client.data.ModelData;
|
|
|
35 |
import com.extjs.gxt.ui.client.data.ModelType;
|
775 |
jpm |
36 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
719 |
jp_milcent |
37 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
|
38 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
775 |
jpm |
39 |
import com.extjs.gxt.ui.client.event.Events;
|
719 |
jp_milcent |
40 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
|
|
41 |
import com.extjs.gxt.ui.client.event.Listener;
|
|
|
42 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
|
43 |
import com.extjs.gxt.ui.client.store.ListStore;
|
|
|
44 |
import com.extjs.gxt.ui.client.store.Store;
|
|
|
45 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
|
|
46 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
47 |
import com.extjs.gxt.ui.client.widget.Info;
|
862 |
jpm |
48 |
import com.extjs.gxt.ui.client.widget.Text;
|
719 |
jp_milcent |
49 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
775 |
jpm |
50 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
719 |
jp_milcent |
51 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
1513 |
jpm |
52 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
775 |
jpm |
53 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
1513 |
jpm |
54 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
719 |
jp_milcent |
55 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
|
|
56 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
910 |
jpm |
57 |
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
719 |
jp_milcent |
58 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
907 |
jpm |
59 |
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
|
910 |
jpm |
60 |
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
|
|
61 |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
719 |
jp_milcent |
62 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
1513 |
jpm |
63 |
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig;
|
799 |
jpm |
64 |
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
|
719 |
jp_milcent |
65 |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
|
|
|
66 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
1284 |
gduche |
67 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
719 |
jp_milcent |
68 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
|
|
69 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
|
|
70 |
import com.google.gwt.core.client.GWT;
|
|
|
71 |
|
|
|
72 |
public class CollectionFormPublication extends FormulaireOnglet implements Rafraichissable {
|
883 |
jpm |
73 |
|
1083 |
jpm |
74 |
public static final String ID = "publication";
|
883 |
jpm |
75 |
private Collection collection = null;
|
|
|
76 |
private static int idGenere = 1;
|
|
|
77 |
|
719 |
jp_milcent |
78 |
private ContentPanel panneauPrincipal = null;
|
|
|
79 |
private ToolBar barreOutils = null;
|
1513 |
jpm |
80 |
private GrillePaginable<ModelData> grille;
|
719 |
jp_milcent |
81 |
|
907 |
jpm |
82 |
private CollectionAPublicationListe publicationsAjoutees = null;
|
|
|
83 |
private CollectionAPublicationListe publicationsSupprimees = null;
|
1513 |
jpm |
84 |
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null;
|
719 |
jp_milcent |
85 |
private Button publicationsBoutonSupprimer = null;
|
|
|
86 |
private Button publicationsBoutonModifier = null;
|
|
|
87 |
|
781 |
jpm |
88 |
private FenetreForm fenetreFormulaire = null;
|
|
|
89 |
|
719 |
jp_milcent |
90 |
public CollectionFormPublication(Formulaire formulaireCourrant) {
|
1284 |
gduche |
91 |
|
719 |
jp_milcent |
92 |
initialiserOnglet(formulaireCourrant);
|
1083 |
jpm |
93 |
setId(ID);
|
719 |
jp_milcent |
94 |
setText(Mediateur.i18nC.collectionPublication());
|
|
|
95 |
setStyleAttribute("padding", "0");
|
1513 |
jpm |
96 |
|
|
|
97 |
initialiser();
|
|
|
98 |
|
719 |
jp_milcent |
99 |
panneauPrincipal = creerPanneauContenantGrille();
|
1284 |
gduche |
100 |
setLayout(new FitLayout());
|
719 |
jp_milcent |
101 |
barreOutils = creerBarreOutilsGrille();
|
|
|
102 |
panneauPrincipal.setTopComponent(barreOutils);
|
|
|
103 |
grille = creerGrille();
|
1284 |
gduche |
104 |
panneauPrincipal.setLayout(new FitLayout());
|
|
|
105 |
panneauPrincipal.add(grille);
|
|
|
106 |
|
1513 |
jpm |
107 |
add(panneauPrincipal);
|
719 |
jp_milcent |
108 |
}
|
|
|
109 |
|
|
|
110 |
private void initialiser() {
|
|
|
111 |
// Remise à zéro des modification dans la liste des auteurs
|
883 |
jpm |
112 |
idGenere = 1;
|
907 |
jpm |
113 |
publicationsAjoutees = new CollectionAPublicationListe();
|
|
|
114 |
publicationsSupprimees = new CollectionAPublicationListe();
|
719 |
jp_milcent |
115 |
|
883 |
jpm |
116 |
collection = ((CollectionForm) formulaire).collection;
|
719 |
jp_milcent |
117 |
}
|
883 |
jpm |
118 |
|
719 |
jp_milcent |
119 |
private ContentPanel creerPanneauContenantGrille() {
|
|
|
120 |
ContentPanel panneau = new ContentPanel();
|
|
|
121 |
|
|
|
122 |
panneau.setHeading(i18nC.collectionPublicationTitre());
|
|
|
123 |
panneau.setIcon(Images.ICONES.table());
|
|
|
124 |
panneau.setLayout(new FitLayout());
|
|
|
125 |
panneau.setFrame(true);
|
|
|
126 |
|
|
|
127 |
return panneau;
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
private ToolBar creerBarreOutilsGrille() {
|
|
|
131 |
ToolBar barreOutils = new ToolBar();
|
|
|
132 |
|
|
|
133 |
Button ajouterBouton = creerBoutonAjouter();
|
|
|
134 |
barreOutils.add(ajouterBouton);
|
|
|
135 |
|
862 |
jpm |
136 |
barreOutils.add(new Text(" ou "));
|
|
|
137 |
|
|
|
138 |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis();
|
|
|
139 |
barreOutils.add(publicationsSaisiesComboBox);
|
|
|
140 |
|
719 |
jp_milcent |
141 |
barreOutils.add(new SeparatorToolItem());
|
|
|
142 |
|
|
|
143 |
publicationsBoutonModifier = creerBoutonModifier();
|
|
|
144 |
barreOutils.add(publicationsBoutonModifier);
|
|
|
145 |
|
|
|
146 |
barreOutils.add(new SeparatorToolItem());
|
|
|
147 |
|
|
|
148 |
publicationsBoutonSupprimer = creerBoutonSupprimer();
|
|
|
149 |
barreOutils.add(publicationsBoutonSupprimer);
|
|
|
150 |
|
|
|
151 |
barreOutils.add(new SeparatorToolItem());
|
|
|
152 |
|
|
|
153 |
Button rafraichirBouton = creerBoutonRafraichir();
|
|
|
154 |
barreOutils.add(rafraichirBouton);
|
|
|
155 |
|
|
|
156 |
return barreOutils;
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
private Button creerBoutonAjouter() {
|
|
|
160 |
Button bouton = new Button(i18nC.ajouter());
|
|
|
161 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
|
|
162 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
163 |
public void componentSelected(ButtonEvent ce) {
|
1468 |
jpm |
164 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePublication(Formulaire.MODE_AJOUTER);
|
781 |
jpm |
165 |
fenetreFormulaire.show();
|
719 |
jp_milcent |
166 |
}
|
|
|
167 |
});
|
|
|
168 |
return bouton;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
private Button creerBoutonModifier() {
|
|
|
172 |
Button bouton = new Button(i18nC.modifier());
|
|
|
173 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
|
|
174 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
175 |
public void componentSelected(ButtonEvent ce) {
|
1513 |
jpm |
176 |
ModelData publicationSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
|
719 |
jp_milcent |
177 |
if (publicationSaisieSelectionnee == null) {
|
1239 |
cyprien |
178 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
|
719 |
jp_milcent |
179 |
} else {
|
1468 |
jpm |
180 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePublication(Formulaire.MODE_MODIFIER);
|
781 |
jpm |
181 |
fenetreFormulaire.show();
|
719 |
jp_milcent |
182 |
}
|
|
|
183 |
}
|
|
|
184 |
});
|
|
|
185 |
return bouton;
|
|
|
186 |
}
|
775 |
jpm |
187 |
|
1468 |
jpm |
188 |
private FenetreForm creerFenetreModaleAvecFormulairePublication(String mode) {
|
781 |
jpm |
189 |
String publicationId = null;
|
|
|
190 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
1513 |
jpm |
191 |
CollectionAPublication publicationSaisiSelectionne = new CollectionAPublication(grille.getGrille().getSelectionModel().getSelectedItem(), false);
|
907 |
jpm |
192 |
publicationId = publicationSaisiSelectionne.getIdPublication();
|
781 |
jpm |
193 |
}
|
|
|
194 |
|
775 |
jpm |
195 |
final FenetreForm fenetre = new FenetreForm("");
|
781 |
jpm |
196 |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId);
|
775 |
jpm |
197 |
fenetre.add(formulaire);
|
|
|
198 |
return fenetre;
|
|
|
199 |
}
|
|
|
200 |
|
781 |
jpm |
201 |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) {
|
786 |
jpm |
202 |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this);
|
775 |
jpm |
203 |
FormPanel panneauFormulaire = formulairePublication.getFormulaire();
|
|
|
204 |
fenetre.setHeading(panneauFormulaire.getHeading());
|
|
|
205 |
panneauFormulaire.setHeaderVisible(false);
|
|
|
206 |
panneauFormulaire.setTopComponent(null);
|
957 |
jpm |
207 |
|
|
|
208 |
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre.
|
|
|
209 |
panneauFormulaire.getBottomComponent().hide();
|
775 |
jpm |
210 |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication);
|
|
|
211 |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
|
957 |
jpm |
212 |
fenetre.setBottomComponent(barreValidation);
|
775 |
jpm |
213 |
|
|
|
214 |
return formulairePublication;
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) {
|
|
|
218 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
|
|
219 |
public void componentSelected(ButtonEvent ce) {
|
|
|
220 |
String code = ((Button) ce.getComponent()).getData("code");
|
|
|
221 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
786 |
jpm |
222 |
if (formulaire.soumettreFormulaire()) {
|
|
|
223 |
fenetre.hide();
|
|
|
224 |
}
|
775 |
jpm |
225 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
782 |
jpm |
226 |
formulaire.soumettreFormulaire();
|
775 |
jpm |
227 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
|
|
228 |
fenetre.hide();
|
|
|
229 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
|
781 |
jpm |
230 |
fenetreFormulaire.hide();
|
1468 |
jpm |
231 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePublication(formulaire.mode);
|
781 |
jpm |
232 |
fenetreFormulaire.show();
|
775 |
jpm |
233 |
}
|
|
|
234 |
}
|
|
|
235 |
};
|
|
|
236 |
|
|
|
237 |
return ecouteur;
|
|
|
238 |
}
|
781 |
jpm |
239 |
|
719 |
jp_milcent |
240 |
private Button creerBoutonSupprimer() {
|
|
|
241 |
Button bouton = new Button(i18nC.supprimer());
|
|
|
242 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
|
|
243 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
244 |
public void componentSelected(ButtonEvent ce) {
|
1513 |
jpm |
245 |
CollectionAPublication publicationSaisieSelectionnee = new CollectionAPublication(grille.getGrille().getSelectionModel().getSelectedItem(), false);
|
719 |
jp_milcent |
246 |
if (publicationSaisieSelectionnee == null) {
|
1239 |
cyprien |
247 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
|
719 |
jp_milcent |
248 |
} else {
|
|
|
249 |
supprimerDansGrille(publicationSaisieSelectionnee);
|
|
|
250 |
}
|
|
|
251 |
}
|
|
|
252 |
});
|
|
|
253 |
return bouton;
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
private Button creerBoutonRafraichir() {
|
|
|
257 |
Button bouton = new Button(i18nC.rafraichir());
|
|
|
258 |
bouton.setIcon(Images.ICONES.rafraichir());
|
|
|
259 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
|
260 |
public void componentSelected(ButtonEvent ce) {
|
883 |
jpm |
261 |
actualiserGrille();
|
1513 |
jpm |
262 |
}
|
719 |
jp_milcent |
263 |
});
|
|
|
264 |
return bouton;
|
|
|
265 |
}
|
|
|
266 |
|
883 |
jpm |
267 |
private void actualiserGrille() {
|
|
|
268 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
1367 |
cyprien |
269 |
mediateur.selectionnerCollectionAPublication(this, collection.getId(), null);
|
883 |
jpm |
270 |
} else {
|
|
|
271 |
grille.getStore().removeAll();
|
|
|
272 |
layout();
|
|
|
273 |
}
|
|
|
274 |
}
|
|
|
275 |
|
1513 |
jpm |
276 |
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() {
|
719 |
jp_milcent |
277 |
|
1513 |
jpm |
278 |
ModelType modelTypePublications = new ModelType();
|
|
|
279 |
modelTypePublications.setRoot("publications");
|
|
|
280 |
modelTypePublications.setTotalName("nbElements");
|
|
|
281 |
modelTypePublications.addField("ccapu_id_collection");
|
|
|
282 |
modelTypePublications.addField("ccapu_id_publication");
|
|
|
283 |
modelTypePublications.addField("cc_nom");
|
|
|
284 |
modelTypePublications.addField("cc_id_collection");
|
|
|
285 |
modelTypePublications.addField("cpu_id_publication");
|
|
|
286 |
modelTypePublications.addField("cpu_fmt_nom_complet");
|
|
|
287 |
modelTypePublications.addField("cpu_titre");
|
|
|
288 |
modelTypePublications.addField("cpu_nom");
|
|
|
289 |
modelTypePublications.addField("cpu_fmt_auteur");
|
|
|
290 |
modelTypePublications.addField("cpu_indication_nvt");
|
|
|
291 |
modelTypePublications.addField("cpu_truk_pages");
|
|
|
292 |
modelTypePublications.addField("cpu_fascicule");
|
|
|
293 |
modelTypePublications.addField("cpu_date_parution");
|
|
|
294 |
modelTypePublications.addField("cpu_ce_truk_editeur");
|
|
|
295 |
modelTypePublications.addField("cpu_ce_projet");
|
|
|
296 |
|
|
|
297 |
String displayNamePublications = "cpu_fmt_nom_complet";
|
|
|
298 |
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null);
|
|
|
299 |
|
|
|
300 |
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications);
|
|
|
301 |
publicationsCombo.getCombo().setTabIndex(tabIndex++);
|
|
|
302 |
publicationsCombo.getCombo().setForceSelection(true);
|
|
|
303 |
|
|
|
304 |
publicationsCombo.getCombo().setValidator(new Validator() {
|
|
|
305 |
public String validate(Field<?> field, String value) {
|
|
|
306 |
String retour = null;
|
|
|
307 |
if (field.getRawValue().equals("")) {
|
|
|
308 |
field.setValue(null);
|
|
|
309 |
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) {
|
|
|
310 |
String contenuBrut = field.getRawValue();
|
|
|
311 |
field.setValue(null);
|
|
|
312 |
field.setRawValue(contenuBrut);
|
|
|
313 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
719 |
jp_milcent |
314 |
}
|
1513 |
jpm |
315 |
return retour;
|
719 |
jp_milcent |
316 |
}
|
|
|
317 |
});
|
1513 |
jpm |
318 |
|
|
|
319 |
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
|
775 |
jpm |
320 |
public void handleEvent(BaseEvent be) {
|
1513 |
jpm |
321 |
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) {
|
|
|
322 |
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur(), false);
|
862 |
jpm |
323 |
ajouterDansGrille(publicationSaisieSelectionne);
|
1513 |
jpm |
324 |
publicationsSaisiesComboBox.getCombo().setValue(null);
|
775 |
jpm |
325 |
}
|
|
|
326 |
}
|
|
|
327 |
});
|
1513 |
jpm |
328 |
|
|
|
329 |
return publicationsCombo;
|
719 |
jp_milcent |
330 |
}
|
907 |
jpm |
331 |
|
719 |
jp_milcent |
332 |
private void ajouterDansGrille(Publication publication) {
|
907 |
jpm |
333 |
ajouterDansGrille(publication, 0);
|
|
|
334 |
}
|
|
|
335 |
|
|
|
336 |
private void ajouterDansGrille(Publication publication, int index) {
|
1513 |
jpm |
337 |
if (publication != null) {
|
|
|
338 |
CollectionAPublication publicationLiee = new CollectionAPublication(false);
|
907 |
jpm |
339 |
publicationLiee.setPublication(publication);
|
|
|
340 |
publicationLiee.setIdPublication(publication.getId());
|
1513 |
jpm |
341 |
|
907 |
jpm |
342 |
// Gestion de l'id de la collection
|
|
|
343 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
344 |
publicationLiee.setIdCollection(collection.getId());
|
719 |
jp_milcent |
345 |
}
|
907 |
jpm |
346 |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
|
910 |
jpm |
347 |
|
1513 |
jpm |
348 |
grille.getGrille().stopEditing();
|
|
|
349 |
grille.getGrille().getStore().insert(publicationLiee, 0);
|
|
|
350 |
grille.getGrille().startEditing(index, 0);
|
|
|
351 |
grille.getGrille().getSelectionModel().select(index, false);
|
719 |
jp_milcent |
352 |
}
|
|
|
353 |
}
|
|
|
354 |
|
907 |
jpm |
355 |
private void supprimerDansGrille(CollectionAPublication publicationLiee) {
|
|
|
356 |
if (publicationLiee != null) {
|
719 |
jp_milcent |
357 |
// Ajout de la personne supprimée à la liste
|
907 |
jpm |
358 |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
|
|
|
359 |
&& publicationLiee.getId() != null
|
|
|
360 |
&& !publicationLiee.getId().equals("")) {
|
|
|
361 |
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
|
719 |
jp_milcent |
362 |
}
|
|
|
363 |
|
|
|
364 |
// Suppression de l'enregistrement de la grille
|
907 |
jpm |
365 |
grille.getStore().remove(publicationLiee);
|
719 |
jp_milcent |
366 |
}
|
|
|
367 |
}
|
1513 |
jpm |
368 |
|
|
|
369 |
private GrillePaginable<ModelData> creerGrille() {
|
|
|
370 |
|
|
|
371 |
GrillePaginable<ModelData> grillePublications = null;
|
|
|
372 |
|
|
|
373 |
// ModelType
|
|
|
374 |
ModelType modelTypeCollectionAPublication = new ModelType();
|
|
|
375 |
modelTypeCollectionAPublication.setRoot("collectionsAPublication");
|
|
|
376 |
modelTypeCollectionAPublication.setTotalName("nbElements");
|
|
|
377 |
modelTypeCollectionAPublication.addField("ccapu_id_collection");
|
|
|
378 |
modelTypeCollectionAPublication.addField("ccapu_id_publication");
|
|
|
379 |
modelTypeCollectionAPublication.addField("ccapu_mark_licence");
|
|
|
380 |
modelTypeCollectionAPublication.addField("cpu_id_publication");
|
|
|
381 |
modelTypeCollectionAPublication.addField("cpu_fmt_auteur");
|
|
|
382 |
modelTypeCollectionAPublication.addField("cpu_titre");
|
|
|
383 |
modelTypeCollectionAPublication.addField("cpu_collection");
|
|
|
384 |
modelTypeCollectionAPublication.addField("cpu_ce_truk_editeur");
|
|
|
385 |
modelTypeCollectionAPublication.addField("cpu_date_parution");
|
|
|
386 |
modelTypeCollectionAPublication.addField("cpu_fascicule");
|
|
|
387 |
modelTypeCollectionAPublication.addField("cpu_truk_pages");
|
|
|
388 |
modelTypeCollectionAPublication.addField("cpu_indication_nvt");
|
|
|
389 |
|
|
|
390 |
// Proxy
|
|
|
391 |
ProxyCollectionAPublication<ModelData> proxyCollectionAPublication = new ProxyCollectionAPublication<ModelData>(null, collection.getId());
|
719 |
jp_milcent |
392 |
|
1513 |
jpm |
393 |
// Colonnes
|
|
|
394 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
799 |
jpm |
395 |
RowNumberer numeroPlugin = new RowNumberer();
|
|
|
396 |
numeroPlugin.setHeader("#");
|
|
|
397 |
XTemplate infoTpl = XTemplate.create("<p>"+
|
1513 |
jpm |
398 |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {cpu_fmt_auteur}<br />"+
|
|
|
399 |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {cpu_titre}<br />"+
|
|
|
400 |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {cpu_collection}<br />"+
|
799 |
jpm |
401 |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+
|
|
|
402 |
"</p>");
|
|
|
403 |
RowExpander expansionPlugin = new RowExpander();
|
|
|
404 |
expansionPlugin.setTemplate(infoTpl);
|
|
|
405 |
colonnes.add(expansionPlugin);
|
|
|
406 |
colonnes.add(numeroPlugin);
|
1513 |
jpm |
407 |
colonnes.add(new ColumnConfig("cpu_fmt_auteur", i18nC.publicationAuteurs(), 150));
|
|
|
408 |
colonnes.add(new ColumnConfig("cpu_titre", i18nC.publicationTitre(), 150));
|
|
|
409 |
colonnes.add(new ColumnConfig("cpu_collection", i18nC.publicationRevueCollection(), 75));
|
910 |
jpm |
410 |
colonnes.add(creerColonneEditeur());
|
|
|
411 |
colonnes.add(creerColonneAnneePublication());
|
1513 |
jpm |
412 |
colonnes.add(new ColumnConfig("cpu_indication_nvt", i18nC.publicationNvt(), 75));
|
|
|
413 |
colonnes.add(new ColumnConfig("cpu_fascicule", i18nC.publicationFascicule(), 75));
|
|
|
414 |
colonnes.add(new ColumnConfig("cpu_truk_pages", i18nC.publicationPage(), 50));
|
719 |
jp_milcent |
415 |
|
1513 |
jpm |
416 |
HashMap<String, String> virtualFields = new HashMap<String, String>();
|
|
|
417 |
virtualFields.put("_editeur_", "cpu_ce_truk_editeur");
|
|
|
418 |
virtualFields.put("_annee_", "cpu_date_parution");
|
|
|
419 |
virtualFields.put("_etat_", "");
|
719 |
jp_milcent |
420 |
|
1513 |
jpm |
421 |
// Modele de selection
|
|
|
422 |
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
|
719 |
jp_milcent |
423 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
823 |
jpm |
424 |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info");
|
719 |
jp_milcent |
425 |
|
1513 |
jpm |
426 |
// Grille
|
|
|
427 |
grillePublications = new GrillePaginable<ModelData>(modelTypeCollectionAPublication, virtualFields, proxyCollectionAPublication, colonnes, modeleDeColonnes);
|
|
|
428 |
grillePublications.getGrille().setBorders(true);
|
|
|
429 |
grillePublications.getGrille().setSelectionModel(modeleDeSelection);
|
|
|
430 |
grillePublications.getGrille().addPlugin(expansionPlugin);
|
|
|
431 |
grillePublications.getGrille().addPlugin(numeroPlugin);
|
|
|
432 |
grillePublications.getGrille().getView().setForceFit(true);
|
|
|
433 |
grillePublications.getGrille().setAutoExpandColumn("titre");
|
|
|
434 |
grillePublications.getGrille().setStripeRows(true);
|
|
|
435 |
grillePublications.getGrille().setTrackMouseOver(true);
|
719 |
jp_milcent |
436 |
|
1513 |
jpm |
437 |
// Rajouter des écouteurs
|
|
|
438 |
grillePublications.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
|
|
|
439 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
|
|
440 |
actualiserEtatBoutonsBarreOutils();
|
|
|
441 |
}
|
|
|
442 |
});
|
|
|
443 |
grillePublications.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
|
|
|
444 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
|
|
445 |
actualiserEtatBoutonsBarreOutils();
|
|
|
446 |
}
|
|
|
447 |
});
|
|
|
448 |
|
719 |
jp_milcent |
449 |
return grillePublications;
|
|
|
450 |
}
|
910 |
jpm |
451 |
|
|
|
452 |
private ColumnConfig creerColonneEditeur() {
|
1513 |
jpm |
453 |
GridCellRenderer<ModelData> editeurRendu = new GridCellRenderer<ModelData>() {
|
|
|
454 |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
|
|
|
455 |
String editeur = (new CollectionAPublication(model, false)).getPublication().getNomEditeur();
|
910 |
jpm |
456 |
model.set("_editeur_", editeur);
|
|
|
457 |
return editeur;
|
|
|
458 |
}
|
|
|
459 |
};
|
|
|
460 |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135);
|
|
|
461 |
editeurColonne.setRenderer(editeurRendu);
|
|
|
462 |
return editeurColonne;
|
|
|
463 |
}
|
|
|
464 |
|
|
|
465 |
private ColumnConfig creerColonneAnneePublication() {
|
1513 |
jpm |
466 |
GridCellRenderer<ModelData> datePublicationRendu = new GridCellRenderer<ModelData>() {
|
|
|
467 |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
|
|
|
468 |
String annee = (new CollectionAPublication(model, false)).getPublication().getAnneeParution();
|
910 |
jpm |
469 |
model.set("_annee_", annee);
|
|
|
470 |
return annee;
|
|
|
471 |
}
|
|
|
472 |
};
|
|
|
473 |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75);
|
|
|
474 |
datePublicationColonne.setRenderer(datePublicationRendu);
|
|
|
475 |
return datePublicationColonne;
|
|
|
476 |
}
|
799 |
jpm |
477 |
|
719 |
jp_milcent |
478 |
public void actualiserEtatBoutonsBarreOutils() {
|
|
|
479 |
// Activation des boutons si la grille contient un élément
|
|
|
480 |
if (grille.getStore().getCount() > 0) {
|
|
|
481 |
publicationsBoutonSupprimer.enable();
|
|
|
482 |
publicationsBoutonModifier.enable();
|
|
|
483 |
}
|
|
|
484 |
// Désactivation des boutons si la grille ne contient plus d'élément
|
|
|
485 |
if (grille.getStore().getCount() == 0) {
|
|
|
486 |
publicationsBoutonSupprimer.disable();
|
|
|
487 |
publicationsBoutonModifier.disable();
|
|
|
488 |
}
|
|
|
489 |
}
|
|
|
490 |
|
|
|
491 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
492 |
if (nouvellesDonnees instanceof Information) {
|
|
|
493 |
Information info = (Information) nouvellesDonnees;
|
|
|
494 |
rafraichirInformation(info);
|
|
|
495 |
} else {
|
|
|
496 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
|
|
497 |
}
|
|
|
498 |
}
|
|
|
499 |
|
|
|
500 |
public void rafraichirInformation(Information info) {
|
|
|
501 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
|
|
502 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
|
|
503 |
}
|
|
|
504 |
String type = info.getType();
|
|
|
505 |
if (type.equals("liste_collection_a_publication")) {
|
|
|
506 |
if (info.getDonnee(0) != null) {
|
|
|
507 |
initialiser();
|
907 |
jpm |
508 |
collection.setPublicationsLiees((CollectionAPublicationListe) info.getDonnee(0));
|
719 |
jp_milcent |
509 |
peupler();
|
|
|
510 |
}
|
1098 |
jpm |
511 |
} else if (info.getType().equals("ajout_collection")) {
|
|
|
512 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
|
|
513 |
String collectionId = (String) info.getDonnee(0);
|
|
|
514 |
|
|
|
515 |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les publications liées
|
|
|
516 |
// En mode AJOUT, il ne peut que y avoir des publications liées ajoutées
|
|
|
517 |
mediateur.ajouterCollectionAPublication(this, collectionId, publicationsAjoutees);
|
|
|
518 |
}
|
786 |
jpm |
519 |
} else if (type.equals("publication_modifiee")) {
|
1513 |
jpm |
520 |
if (info.getDonnee(0) != null) {
|
|
|
521 |
Publication publication = (Publication) info.getDonnee(0);
|
|
|
522 |
ModelData publicationDansGrille = null;
|
|
|
523 |
publicationDansGrille = grille.getStore().findModel("cpu_id_publication", publication.getId());
|
|
|
524 |
int index = grille.getStore().indexOf(publicationDansGrille);
|
799 |
jpm |
525 |
grille.getStore().remove(publicationDansGrille);
|
907 |
jpm |
526 |
ajouterDansGrille(publication, index);
|
786 |
jpm |
527 |
}
|
1513 |
jpm |
528 |
} else if (type.equals("publication_ajoutee")) {
|
799 |
jpm |
529 |
if (info.getDonnee(0) != null) {
|
|
|
530 |
Publication publication = (Publication) info.getDonnee(0);
|
907 |
jpm |
531 |
ajouterDansGrille(publication);
|
799 |
jpm |
532 |
}
|
907 |
jpm |
533 |
} else if (type.equals("suppression_collection_a_publication")) {
|
1239 |
cyprien |
534 |
InfoLogger.display("Suppression des publications liées à la collection", info.toString());
|
907 |
jpm |
535 |
} else if (type.equals("ajout_collection_a_publication")) {
|
1239 |
cyprien |
536 |
InfoLogger.display("Ajout des publications liées à la collection", info.toString());
|
786 |
jpm |
537 |
} else {
|
|
|
538 |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null);
|
719 |
jp_milcent |
539 |
}
|
|
|
540 |
}
|
|
|
541 |
|
883 |
jpm |
542 |
public void peupler() {
|
907 |
jpm |
543 |
grille.getStore().removeAll();
|
|
|
544 |
grille.getStore().add(collection.getPublicationsLiees().toList());
|
719 |
jp_milcent |
545 |
layout();
|
1239 |
cyprien |
546 |
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok());
|
719 |
jp_milcent |
547 |
}
|
|
|
548 |
|
907 |
jpm |
549 |
public void collecter() {
|
|
|
550 |
if (etreAccede()) {
|
910 |
jpm |
551 |
int nbrePublication = grille.getStore().getCount();
|
|
|
552 |
for (int i = 0; i < nbrePublication; i++) {
|
1513 |
jpm |
553 |
ModelData publicationLiee = grille.getStore().getAt(i);
|
|
|
554 |
CollectionAPublication cap = new CollectionAPublication(grille.getStore().getAt(i), false);
|
907 |
jpm |
555 |
if (publicationLiee.get("_etat_") != null) {
|
|
|
556 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
|
|
557 |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
|
1513 |
jpm |
558 |
publicationsSupprimees.put("id"+idGenere++, cap);
|
907 |
jpm |
559 |
|
1513 |
jpm |
560 |
CollectionAPublication relationAAjouter = (CollectionAPublication) cap.cloner(new CollectionAPublication());
|
907 |
jpm |
561 |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter);
|
|
|
562 |
}
|
|
|
563 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
1513 |
jpm |
564 |
publicationsAjoutees.put("id"+idGenere++, cap);
|
907 |
jpm |
565 |
}
|
|
|
566 |
// Initialisation de la grille
|
|
|
567 |
publicationLiee.set("_etat_", "");
|
|
|
568 |
}
|
|
|
569 |
}
|
|
|
570 |
grille.getStore().commitChanges();
|
|
|
571 |
}
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
public void soumettre() {
|
|
|
575 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
|
|
576 |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) {
|
1239 |
cyprien |
577 |
InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
907 |
jpm |
578 |
} else {
|
|
|
579 |
// Ajout des relations CollectionAPublication
|
|
|
580 |
if (publicationsAjoutees.size() != 0) {
|
|
|
581 |
mediateur.ajouterCollectionAPublication(this, collection.getId(), publicationsAjoutees);
|
|
|
582 |
}
|
|
|
583 |
// Suppression des relations CollectionAPublication
|
|
|
584 |
if (publicationsSupprimees.size() != 0) {
|
|
|
585 |
mediateur.supprimerCollectionAPublication(this, publicationsSupprimees);
|
|
|
586 |
}
|
|
|
587 |
}
|
|
|
588 |
}
|
|
|
589 |
}
|
719 |
jp_milcent |
590 |
}
|