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