Line 1... |
Line 1... |
1 |
package org.tela_botanica.client.vues.collection;
|
1 |
package org.tela_botanica.client.vues.collection;
|
Line 2... |
Line 2... |
2 |
|
2 |
|
3 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
Line -... |
Line 4... |
- |
|
4 |
import java.util.List;
|
4 |
import java.util.List;
|
5 |
|
- |
|
6 |
import org.tela_botanica.client.ComposantClass;
|
5 |
|
7 |
import org.tela_botanica.client.Mediateur;
|
- |
|
8 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
- |
|
9 |
import org.tela_botanica.client.composants.InfoLogger;
|
6 |
import org.tela_botanica.client.Mediateur;
|
10 |
import org.tela_botanica.client.composants.pagination.ProxyProjets;
|
7 |
import org.tela_botanica.client.composants.InfoLogger;
|
11 |
import org.tela_botanica.client.composants.pagination.ProxyPublications;
|
8 |
import org.tela_botanica.client.images.Images;
|
12 |
import org.tela_botanica.client.images.Images;
|
9 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
13 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
10 |
import org.tela_botanica.client.modeles.Information;
|
14 |
import org.tela_botanica.client.modeles.Information;
|
Line 21... |
Line 25... |
21 |
import org.tela_botanica.client.vues.FormulaireOnglet;
|
25 |
import org.tela_botanica.client.vues.FormulaireOnglet;
|
22 |
import org.tela_botanica.client.vues.publication.PublicationForm;
|
26 |
import org.tela_botanica.client.vues.publication.PublicationForm;
|
Line 23... |
Line 27... |
23 |
|
27 |
|
24 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
28 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
- |
|
29 |
import com.extjs.gxt.ui.client.core.XTemplate;
|
- |
|
30 |
import com.extjs.gxt.ui.client.data.ModelData;
|
25 |
import com.extjs.gxt.ui.client.core.XTemplate;
|
31 |
import com.extjs.gxt.ui.client.data.ModelType;
|
26 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
32 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
27 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
33 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
28 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
34 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
29 |
import com.extjs.gxt.ui.client.event.Events;
|
35 |
import com.extjs.gxt.ui.client.event.Events;
|
Line 37... |
Line 43... |
37 |
import com.extjs.gxt.ui.client.widget.Info;
|
43 |
import com.extjs.gxt.ui.client.widget.Info;
|
38 |
import com.extjs.gxt.ui.client.widget.Text;
|
44 |
import com.extjs.gxt.ui.client.widget.Text;
|
39 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
45 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
40 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
46 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
41 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
47 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
- |
|
48 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
42 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
49 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
- |
|
50 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
43 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
51 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
44 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
52 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
45 |
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
53 |
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
46 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
54 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
47 |
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
|
55 |
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
|
Line 66... |
Line 74... |
66 |
private ToolBar barreOutils = null;
|
74 |
private ToolBar barreOutils = null;
|
67 |
private EditorGrid<CollectionAPublication> grille;
|
75 |
private EditorGrid<CollectionAPublication> grille;
|
Line 68... |
Line 76... |
68 |
|
76 |
|
69 |
private CollectionAPublicationListe publicationsAjoutees = null;
|
77 |
private CollectionAPublicationListe publicationsAjoutees = null;
|
70 |
private CollectionAPublicationListe publicationsSupprimees = null;
|
78 |
private CollectionAPublicationListe publicationsSupprimees = null;
|
71 |
private ComboBox<Publication> publicationsSaisiesComboBox = null;
|
79 |
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null;
|
72 |
private Button publicationsBoutonSupprimer = null;
|
80 |
private Button publicationsBoutonSupprimer = null;
|
Line 73... |
Line 81... |
73 |
private Button publicationsBoutonModifier = null;
|
81 |
private Button publicationsBoutonModifier = null;
|
Line 247... |
Line 255... |
247 |
Button bouton = new Button(i18nC.rafraichir());
|
255 |
Button bouton = new Button(i18nC.rafraichir());
|
248 |
bouton.setIcon(Images.ICONES.rafraichir());
|
256 |
bouton.setIcon(Images.ICONES.rafraichir());
|
249 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
257 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
250 |
public void componentSelected(ButtonEvent ce) {
|
258 |
public void componentSelected(ButtonEvent ce) {
|
251 |
actualiserGrille();
|
259 |
actualiserGrille();
|
252 |
}
|
260 |
}
|
253 |
});
|
261 |
});
|
254 |
return bouton;
|
262 |
return bouton;
|
255 |
}
|
263 |
}
|
Line 256... |
Line 264... |
256 |
|
264 |
|
Line 261... |
Line 269... |
261 |
grille.getStore().removeAll();
|
269 |
grille.getStore().removeAll();
|
262 |
layout();
|
270 |
layout();
|
263 |
}
|
271 |
}
|
264 |
}
|
272 |
}
|
Line 265... |
Line 273... |
265 |
|
273 |
|
266 |
private ComboBox<Publication> creerComboBoxPublicationsSaisis() {
|
- |
|
Line -... |
Line 274... |
- |
|
274 |
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() {
|
267 |
ListStore<Publication> publicationsSaisiesStore = new ListStore<Publication>();
|
275 |
|
268 |
|
276 |
ModelType modelTypePublications = new ModelType();
|
- |
|
277 |
modelTypePublications.setRoot("publications");
|
269 |
ComboBox<Publication> comboBox = new ComboBox<Publication>();
|
278 |
modelTypePublications.setTotalName("nbElements");
|
270 |
comboBox.setWidth(400);
|
279 |
modelTypePublications.addField("ccapu_id_collection");
|
271 |
comboBox.setEmptyText(i18nC.chercherPublicationSaisi());
|
280 |
modelTypePublications.addField("ccapu_id_publication");
|
- |
|
281 |
modelTypePublications.addField("cc_nom");
|
272 |
comboBox.setTriggerAction(TriggerAction.ALL);
|
282 |
modelTypePublications.addField("cc_id_collection");
|
273 |
comboBox.setEditable(true);
|
283 |
modelTypePublications.addField("cpu_id_publication");
|
- |
|
284 |
modelTypePublications.addField("cpu_fmt_nom_complet");
|
- |
|
285 |
modelTypePublications.addField("cpu_titre");
|
- |
|
286 |
modelTypePublications.addField("cpu_nom");
|
- |
|
287 |
modelTypePublications.addField("cpu_fmt_auteur");
|
- |
|
288 |
modelTypePublications.addField("cpu_indication_nvt");
|
- |
|
289 |
modelTypePublications.addField("cpu_truk_pages");
|
274 |
comboBox.setDisplayField("fmt_nom_complet");
|
290 |
modelTypePublications.addField("cpu_fascicule");
|
- |
|
291 |
modelTypePublications.addField("cpu_date_parution");
|
- |
|
292 |
modelTypePublications.addField("cpu_ce_truk_editeur");
|
- |
|
293 |
modelTypePublications.addField("cpu_ce_projet");
|
- |
|
294 |
|
- |
|
295 |
String displayNamePublications = "cpu_fmt_nom_complet";
|
- |
|
296 |
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null);
|
- |
|
297 |
|
275 |
comboBox.setStore(publicationsSaisiesStore);
|
298 |
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications);
|
- |
|
299 |
publicationsCombo.getCombo().setTabIndex(tabIndex++);
|
276 |
comboBox.addKeyListener(new KeyListener() {
|
300 |
publicationsCombo.getCombo().setForceSelection(true);
|
- |
|
301 |
|
- |
|
302 |
publicationsCombo.getCombo().setValidator(new Validator() {
|
277 |
public void componentKeyUp(ComponentEvent ce) {
|
303 |
public String validate(Field<?> field, String value) {
|
- |
|
304 |
String retour = null;
|
- |
|
305 |
if (field.getRawValue().equals("")) {
|
278 |
if (publicationsSaisiesComboBox.getRawValue() != null && publicationsSaisiesComboBox.getRawValue().length() > 0) {
|
306 |
field.setValue(null);
|
279 |
if (!ce.isNavKeyPress()) {
|
307 |
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) {
|
- |
|
308 |
String contenuBrut = field.getRawValue();
|
- |
|
309 |
field.setValue(null);
|
280 |
obtenirPublicationsSaisies(publicationsSaisiesComboBox.getRawValue());
|
310 |
field.setRawValue(contenuBrut);
|
- |
|
311 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
281 |
}
|
312 |
}
|
282 |
}
|
313 |
return retour;
|
- |
|
314 |
}
|
283 |
}
|
315 |
});
|
284 |
});
|
316 |
|
285 |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() {
|
317 |
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
|
286 |
public void handleEvent(BaseEvent be) {
|
318 |
public void handleEvent(BaseEvent be) {
|
287 |
if (publicationsSaisiesComboBox.getValue() instanceof Publication) {
|
319 |
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) {
|
288 |
Publication publicationSaisieSelectionne = publicationsSaisiesComboBox.getValue();
|
320 |
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur());
|
289 |
ajouterDansGrille(publicationSaisieSelectionne);
|
321 |
ajouterDansGrille(publicationSaisieSelectionne);
|
290 |
publicationsSaisiesComboBox.setValue(null);
|
322 |
publicationsSaisiesComboBox.getCombo().setValue(null);
|
291 |
}
|
323 |
}
|
- |
|
324 |
}
|
292 |
}
|
325 |
});
|
293 |
});
|
326 |
|
Line 294... |
Line 327... |
294 |
return comboBox;
|
327 |
return publicationsCombo;
|
295 |
}
|
328 |
}
|
296 |
|
329 |
|
Line 428... |
Line 461... |
428 |
|
461 |
|
429 |
public void rafraichir(Object nouvellesDonnees) {
|
462 |
public void rafraichir(Object nouvellesDonnees) {
|
430 |
if (nouvellesDonnees instanceof Information) {
|
463 |
if (nouvellesDonnees instanceof Information) {
|
431 |
Information info = (Information) nouvellesDonnees;
|
464 |
Information info = (Information) nouvellesDonnees;
|
432 |
rafraichirInformation(info);
|
- |
|
433 |
} else if (nouvellesDonnees instanceof PublicationListe) {
|
- |
|
434 |
PublicationListe listePublications = (PublicationListe) nouvellesDonnees;
|
- |
|
435 |
rafraichirPublicationListe(listePublications);
|
465 |
rafraichirInformation(info);
|
436 |
} else {
|
466 |
} else {
|
437 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
467 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
438 |
}
|
468 |
}
|
439 |
}
|
- |
|
440 |
|
- |
|
441 |
private void rafraichirPublicationListe(PublicationListe listePublications) {
|
- |
|
442 |
publicationsSaisiesComboBox.getStore().removeAll();
|
- |
|
443 |
publicationsSaisiesComboBox.getStore().add(listePublications.toList());
|
- |
|
444 |
publicationsSaisiesComboBox.expand();
|
- |
|
Line 445... |
Line 469... |
445 |
}
|
469 |
}
|
446 |
|
470 |
|
447 |
public void rafraichirInformation(Information info) {
|
471 |
public void rafraichirInformation(Information info) {
|
448 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
472 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
Line 530... |
Line 554... |
530 |
mediateur.supprimerCollectionAPublication(this, publicationsSupprimees);
|
554 |
mediateur.supprimerCollectionAPublication(this, publicationsSupprimees);
|
531 |
}
|
555 |
}
|
532 |
}
|
556 |
}
|
533 |
}
|
557 |
}
|
534 |
}
|
558 |
}
|
535 |
|
- |
|
536 |
private void obtenirPublicationsSaisies(String nom) {
|
- |
|
537 |
mediateur.selectionnerPublicationParNomComplet(this, null, "%"+nom+"%");
|
- |
|
538 |
}
|
- |
|
539 |
}
|
559 |
}
|