1 |
package org.tela_botanica.client.vues.personne;
|
1 |
package org.tela_botanica.client.vues.personne;
|
2 |
|
2 |
|
3 |
import java.util.ArrayList;
|
3 |
import java.util.ArrayList;
|
4 |
import java.util.HashMap;
|
4 |
import java.util.HashMap;
|
5 |
import java.util.Iterator;
|
5 |
import java.util.Iterator;
|
6 |
import java.util.LinkedList;
|
6 |
import java.util.LinkedList;
|
7 |
import java.util.List;
|
7 |
import java.util.List;
|
8 |
|
8 |
|
9 |
import org.tela_botanica.client.ComposantClass;
|
9 |
import org.tela_botanica.client.ComposantClass;
|
10 |
import org.tela_botanica.client.Mediateur;
|
10 |
import org.tela_botanica.client.Mediateur;
|
11 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
11 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
12 |
import org.tela_botanica.client.composants.GrillePaginable;
|
12 |
import org.tela_botanica.client.composants.GrillePaginable;
|
13 |
import org.tela_botanica.client.composants.InfoLogger;
|
13 |
import org.tela_botanica.client.composants.InfoLogger;
|
14 |
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPublication;
|
14 |
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPublication;
|
15 |
import org.tela_botanica.client.composants.pagination.ProxyPublications;
|
15 |
import org.tela_botanica.client.composants.pagination.ProxyPublications;
|
16 |
import org.tela_botanica.client.composants.pagination.ProxyPublicationsAPersonne;
|
16 |
import org.tela_botanica.client.composants.pagination.ProxyPublicationsAPersonne;
|
17 |
import org.tela_botanica.client.images.Images;
|
17 |
import org.tela_botanica.client.images.Images;
|
18 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
18 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
19 |
import org.tela_botanica.client.modeles.Information;
|
19 |
import org.tela_botanica.client.modeles.Information;
|
20 |
import org.tela_botanica.client.modeles.Valeur;
|
20 |
import org.tela_botanica.client.modeles.Valeur;
|
21 |
import org.tela_botanica.client.modeles.ValeurListe;
|
21 |
import org.tela_botanica.client.modeles.ValeurListe;
|
22 |
import org.tela_botanica.client.modeles.aDonnee;
|
22 |
import org.tela_botanica.client.modeles.aDonnee;
|
23 |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
|
23 |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne;
|
24 |
import org.tela_botanica.client.modeles.personne.Personne;
|
24 |
import org.tela_botanica.client.modeles.personne.Personne;
|
25 |
import org.tela_botanica.client.modeles.publication.Publication;
|
25 |
import org.tela_botanica.client.modeles.publication.Publication;
|
26 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
26 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
27 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
27 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
28 |
import org.tela_botanica.client.modeles.publication.PublicationListe;
|
28 |
import org.tela_botanica.client.modeles.publication.PublicationListe;
|
29 |
import org.tela_botanica.client.util.Debug;
|
29 |
import org.tela_botanica.client.util.Debug;
|
30 |
import org.tela_botanica.client.util.UtilString;
|
30 |
import org.tela_botanica.client.util.UtilString;
|
31 |
import org.tela_botanica.client.vues.FenetreForm;
|
31 |
import org.tela_botanica.client.vues.FenetreForm;
|
32 |
import org.tela_botanica.client.vues.Formulaire;
|
32 |
import org.tela_botanica.client.vues.Formulaire;
|
33 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
33 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
34 |
import org.tela_botanica.client.vues.FormulaireOnglet;
|
34 |
import org.tela_botanica.client.vues.FormulaireOnglet;
|
35 |
import org.tela_botanica.client.vues.publication.PublicationForm;
|
35 |
import org.tela_botanica.client.vues.publication.PublicationForm;
|
36 |
|
36 |
|
37 |
import com.extjs.gxt.ui.client.core.XTemplate;
|
37 |
import com.extjs.gxt.ui.client.core.XTemplate;
|
38 |
import com.extjs.gxt.ui.client.data.ModelData;
|
38 |
import com.extjs.gxt.ui.client.data.ModelData;
|
39 |
import com.extjs.gxt.ui.client.data.ModelType;
|
39 |
import com.extjs.gxt.ui.client.data.ModelType;
|
40 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
40 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
41 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
41 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
42 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
42 |
import com.extjs.gxt.ui.client.event.ComponentEvent;
|
43 |
import com.extjs.gxt.ui.client.event.Events;
|
43 |
import com.extjs.gxt.ui.client.event.Events;
|
44 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
44 |
import com.extjs.gxt.ui.client.event.KeyListener;
|
45 |
import com.extjs.gxt.ui.client.event.Listener;
|
45 |
import com.extjs.gxt.ui.client.event.Listener;
|
46 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
46 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
47 |
import com.extjs.gxt.ui.client.store.ListStore;
|
47 |
import com.extjs.gxt.ui.client.store.ListStore;
|
48 |
import com.extjs.gxt.ui.client.store.Store;
|
48 |
import com.extjs.gxt.ui.client.store.Store;
|
49 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
49 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
50 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
50 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
51 |
import com.extjs.gxt.ui.client.widget.Info;
|
51 |
import com.extjs.gxt.ui.client.widget.Info;
|
52 |
import com.extjs.gxt.ui.client.widget.Text;
|
52 |
import com.extjs.gxt.ui.client.widget.Text;
|
53 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
53 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
54 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
54 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
55 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
55 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
56 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
56 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
57 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
57 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
58 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
58 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
59 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
59 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
60 |
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
|
60 |
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
|
61 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
61 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
62 |
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
62 |
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
63 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
63 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
64 |
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
64 |
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
65 |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
65 |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
66 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
66 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
67 |
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
|
67 |
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
|
68 |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
|
68 |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
|
69 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
69 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
70 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
70 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
71 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
71 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
72 |
import com.google.gwt.core.client.GWT;
|
72 |
import com.google.gwt.core.client.GWT;
|
73 |
|
73 |
|
74 |
public class PersonneFormPublication extends FormulaireOnglet implements Rafraichissable {
|
74 |
public class PersonneFormPublication extends FormulaireOnglet implements Rafraichissable {
|
75 |
|
75 |
|
76 |
private Personne personneSelectionnee = null;
|
76 |
private Personne personneSelectionnee = null;
|
77 |
private static int idGenere = 1;
|
77 |
private static int idGenere = 1;
|
78 |
|
78 |
|
79 |
private ContentPanel panneauPrincipal = null;
|
79 |
private ContentPanel panneauPrincipal = null;
|
80 |
private ToolBar barreOutils = null;
|
80 |
private ToolBar barreOutils = null;
|
81 |
private GrillePaginable<ModelData> grille;
|
81 |
private GrillePaginable<ModelData> grille;
|
82 |
|
82 |
|
83 |
private PublicationAPersonneListe publicationsAjoutees = null;
|
83 |
private PublicationAPersonneListe publicationsAjoutees = null;
|
84 |
private PublicationAPersonneListe publicationsSupprimees = null;
|
84 |
private PublicationAPersonneListe publicationsSupprimees = null;
|
85 |
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null;
|
85 |
private ChampComboBoxRechercheTempsReelPaginable publicationsSaisiesComboBox = null;
|
86 |
private Button publicationsBoutonSupprimer = null;
|
86 |
private Button publicationsBoutonSupprimer = null;
|
87 |
private Button publicationsBoutonModifier = null;
|
87 |
private Button publicationsBoutonModifier = null;
|
88 |
private ComboBox<Valeur> typeRelationCombo = null;
|
88 |
private ComboBox<Valeur> typeRelationCombo = null;
|
89 |
private List<Valeur> roles = null;
|
89 |
private List<Valeur> roles = null;
|
90 |
private PublicationAPersonneListe listePublicationsLiees = new PublicationAPersonneListe();
|
90 |
private PublicationAPersonneListe listePublicationsLiees = new PublicationAPersonneListe();
|
91 |
boolean personneRecue = false;
|
91 |
boolean personneRecue = false;
|
92 |
boolean rolesRecus = false;
|
92 |
boolean rolesRecus = false;
|
93 |
|
93 |
|
94 |
private FenetreForm fenetreFormulaire = null;
|
94 |
private FenetreForm fenetreFormulaire = null;
|
95 |
|
95 |
|
96 |
public PersonneFormPublication(Formulaire formulaireCourrant) {
|
96 |
public PersonneFormPublication(Formulaire formulaireCourrant) {
|
97 |
initialiserOnglet(formulaireCourrant);
|
97 |
initialiserOnglet(formulaireCourrant);
|
98 |
setId("publication");
|
98 |
setId("publication");
|
99 |
setText(Mediateur.i18nC.personneOngletPublication());
|
99 |
setText(Mediateur.i18nC.personneOngletPublication());
|
100 |
setStyleAttribute("padding", "0");
|
100 |
setStyleAttribute("padding", "0");
|
101 |
|
101 |
|
102 |
initialiser();
|
102 |
initialiser();
|
103 |
|
103 |
|
104 |
panneauPrincipal = creerPanneauContenantGrille();
|
104 |
panneauPrincipal = creerPanneauContenantGrille();
|
105 |
setLayout(new FitLayout());
|
105 |
setLayout(new FitLayout());
|
106 |
barreOutils = creerBarreOutilsGrille();
|
106 |
barreOutils = creerBarreOutilsGrille();
|
107 |
panneauPrincipal.setTopComponent(barreOutils);
|
107 |
panneauPrincipal.setTopComponent(barreOutils);
|
108 |
panneauPrincipal.setLayout(new FitLayout());
|
108 |
panneauPrincipal.setLayout(new FitLayout());
|
109 |
grille = creerGrille();
|
109 |
grille = creerGrille();
|
110 |
panneauPrincipal.add(grille);
|
110 |
panneauPrincipal.add(grille);
|
111 |
add(panneauPrincipal);
|
111 |
add(panneauPrincipal);
|
112 |
}
|
112 |
}
|
113 |
|
113 |
|
114 |
private void initialiser() {
|
114 |
private void initialiser() {
|
115 |
// Remise à zéro des modification dans la liste des auteurs
|
115 |
// Remise à zéro des modification dans la liste des auteurs
|
116 |
idGenere = 1;
|
116 |
idGenere = 1;
|
117 |
publicationsAjoutees = new PublicationAPersonneListe();
|
117 |
publicationsAjoutees = new PublicationAPersonneListe();
|
118 |
publicationsSupprimees = new PublicationAPersonneListe();
|
118 |
publicationsSupprimees = new PublicationAPersonneListe();
|
119 |
}
|
119 |
}
|
120 |
|
120 |
|
121 |
public void mettreAJourPersonne() {
|
121 |
public void mettreAJourPersonne() {
|
122 |
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee;
|
122 |
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee;
|
123 |
}
|
123 |
}
|
124 |
|
124 |
|
125 |
private ContentPanel creerPanneauContenantGrille() {
|
125 |
private ContentPanel creerPanneauContenantGrille() {
|
126 |
ContentPanel panneau = new ContentPanel();
|
126 |
ContentPanel panneau = new ContentPanel();
|
127 |
|
127 |
|
128 |
panneau.setHeading(i18nC.personneOngletPublication()+" " + i18nC.personnePublication());
|
128 |
panneau.setHeadingHtml(i18nC.personneOngletPublication()+" " + i18nC.personnePublication());
|
129 |
panneau.setIcon(Images.ICONES.table());
|
129 |
panneau.setIcon(Images.ICONES.table());
|
130 |
panneau.setLayout(new FitLayout());
|
130 |
panneau.setLayout(new FitLayout());
|
131 |
panneau.setFrame(true);
|
131 |
panneau.setFrame(true);
|
132 |
|
132 |
|
133 |
return panneau;
|
133 |
return panneau;
|
134 |
}
|
134 |
}
|
135 |
|
135 |
|
136 |
private ToolBar creerBarreOutilsGrille() {
|
136 |
private ToolBar creerBarreOutilsGrille() {
|
137 |
ToolBar barreOutils = new ToolBar();
|
137 |
ToolBar barreOutils = new ToolBar();
|
138 |
|
138 |
|
139 |
Button ajouterBouton = creerBoutonAjouter();
|
139 |
Button ajouterBouton = creerBoutonAjouter();
|
140 |
barreOutils.add(ajouterBouton);
|
140 |
barreOutils.add(ajouterBouton);
|
141 |
|
141 |
|
142 |
barreOutils.add(new Text(" "));
|
142 |
barreOutils.add(new Text(" "));
|
143 |
|
143 |
|
144 |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis();
|
144 |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis();
|
145 |
barreOutils.add(publicationsSaisiesComboBox);
|
145 |
barreOutils.add(publicationsSaisiesComboBox);
|
146 |
|
146 |
|
147 |
barreOutils.add(new SeparatorToolItem());
|
147 |
barreOutils.add(new SeparatorToolItem());
|
148 |
|
148 |
|
149 |
publicationsBoutonModifier = creerBoutonModifier();
|
149 |
publicationsBoutonModifier = creerBoutonModifier();
|
150 |
barreOutils.add(publicationsBoutonModifier);
|
150 |
barreOutils.add(publicationsBoutonModifier);
|
151 |
|
151 |
|
152 |
barreOutils.add(new SeparatorToolItem());
|
152 |
barreOutils.add(new SeparatorToolItem());
|
153 |
|
153 |
|
154 |
publicationsBoutonSupprimer = creerBoutonSupprimer();
|
154 |
publicationsBoutonSupprimer = creerBoutonSupprimer();
|
155 |
barreOutils.add(publicationsBoutonSupprimer);
|
155 |
barreOutils.add(publicationsBoutonSupprimer);
|
156 |
|
156 |
|
157 |
barreOutils.add(new SeparatorToolItem());
|
157 |
barreOutils.add(new SeparatorToolItem());
|
158 |
|
158 |
|
159 |
Button rafraichirBouton = creerBoutonRafraichir();
|
159 |
Button rafraichirBouton = creerBoutonRafraichir();
|
160 |
barreOutils.add(rafraichirBouton);
|
160 |
barreOutils.add(rafraichirBouton);
|
161 |
|
161 |
|
162 |
return barreOutils;
|
162 |
return barreOutils;
|
163 |
}
|
163 |
}
|
164 |
|
164 |
|
165 |
private Button creerBoutonAjouter() {
|
165 |
private Button creerBoutonAjouter() {
|
166 |
Button bouton = new Button(i18nC.ajouter());
|
166 |
Button bouton = new Button(i18nC.ajouter());
|
167 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
167 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
168 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
168 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
169 |
public void componentSelected(ButtonEvent ce) {
|
169 |
public void componentSelected(ButtonEvent ce) {
|
170 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
|
170 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
|
171 |
fenetreFormulaire.show();
|
171 |
fenetreFormulaire.show();
|
172 |
}
|
172 |
}
|
173 |
});
|
173 |
});
|
174 |
return bouton;
|
174 |
return bouton;
|
175 |
}
|
175 |
}
|
176 |
|
176 |
|
177 |
private Button creerBoutonModifier() {
|
177 |
private Button creerBoutonModifier() {
|
178 |
Button bouton = new Button(i18nC.modifier());
|
178 |
Button bouton = new Button(i18nC.modifier());
|
179 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
179 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
180 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
180 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
181 |
public void componentSelected(ButtonEvent ce) {
|
181 |
public void componentSelected(ButtonEvent ce) {
|
182 |
ModelData publicationSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
|
182 |
ModelData publicationSaisieSelectionnee = grille.getGrille().getSelectionModel().getSelectedItem();
|
183 |
|
183 |
|
184 |
if (publicationSaisieSelectionnee == null) {
|
184 |
if (publicationSaisieSelectionnee == null) {
|
185 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
|
185 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
|
186 |
} else {
|
186 |
} else {
|
187 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
|
187 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
|
188 |
fenetreFormulaire.show();
|
188 |
fenetreFormulaire.show();
|
189 |
}
|
189 |
}
|
190 |
}
|
190 |
}
|
191 |
});
|
191 |
});
|
192 |
return bouton;
|
192 |
return bouton;
|
193 |
}
|
193 |
}
|
194 |
|
194 |
|
195 |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
|
195 |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
|
196 |
String publicationId = null;
|
196 |
String publicationId = null;
|
197 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
197 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
198 |
PublicationAPersonne publicationSaisiSelectionne = new PublicationAPersonne(grille.getGrille().getSelectionModel().getSelectedItem(), false);
|
198 |
PublicationAPersonne publicationSaisiSelectionne = new PublicationAPersonne(grille.getGrille().getSelectionModel().getSelectedItem(), false);
|
199 |
publicationId = publicationSaisiSelectionne.getIdPublication();
|
199 |
publicationId = publicationSaisiSelectionne.getIdPublication();
|
200 |
}
|
200 |
}
|
201 |
|
201 |
|
202 |
final FenetreForm fenetre = new FenetreForm("");
|
202 |
final FenetreForm fenetre = new FenetreForm("");
|
203 |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId);
|
203 |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId);
|
204 |
fenetre.add(formulaire);
|
204 |
fenetre.add(formulaire);
|
205 |
return fenetre;
|
205 |
return fenetre;
|
206 |
}
|
206 |
}
|
207 |
|
207 |
|
208 |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) {
|
208 |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) {
|
209 |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this);
|
209 |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this);
|
210 |
FormPanel panneauFormulaire = formulairePublication.getFormulaire();
|
210 |
FormPanel panneauFormulaire = formulairePublication.getFormulaire();
|
211 |
fenetre.setHeading(panneauFormulaire.getHeading());
|
211 |
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml());
|
212 |
panneauFormulaire.setHeaderVisible(false);
|
212 |
panneauFormulaire.setHeaderVisible(false);
|
213 |
panneauFormulaire.setTopComponent(null);
|
213 |
panneauFormulaire.setTopComponent(null);
|
214 |
|
214 |
|
215 |
// 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.
|
215 |
// 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.
|
216 |
panneauFormulaire.getBottomComponent().hide();
|
216 |
panneauFormulaire.getBottomComponent().hide();
|
217 |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication);
|
217 |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication);
|
218 |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
|
218 |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
|
219 |
fenetre.setBottomComponent(barreValidation);
|
219 |
fenetre.setBottomComponent(barreValidation);
|
220 |
|
220 |
|
221 |
return formulairePublication;
|
221 |
return formulairePublication;
|
222 |
}
|
222 |
}
|
223 |
|
223 |
|
224 |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) {
|
224 |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) {
|
225 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
225 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
226 |
public void componentSelected(ButtonEvent ce) {
|
226 |
public void componentSelected(ButtonEvent ce) {
|
227 |
String code = ((Button) ce.getComponent()).getData("code");
|
227 |
String code = ((Button) ce.getComponent()).getData("code");
|
228 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
228 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
229 |
if (formulaire.soumettreFormulaire()) {
|
229 |
if (formulaire.soumettreFormulaire()) {
|
230 |
fenetre.hide();
|
230 |
fenetre.hide();
|
231 |
}
|
231 |
}
|
232 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
232 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
233 |
formulaire.soumettreFormulaire();
|
233 |
formulaire.soumettreFormulaire();
|
234 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
234 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
235 |
fenetre.hide();
|
235 |
fenetre.hide();
|
236 |
}
|
236 |
}
|
237 |
}
|
237 |
}
|
238 |
};
|
238 |
};
|
239 |
|
239 |
|
240 |
return ecouteur;
|
240 |
return ecouteur;
|
241 |
}
|
241 |
}
|
242 |
|
242 |
|
243 |
private Button creerBoutonSupprimer() {
|
243 |
private Button creerBoutonSupprimer() {
|
244 |
Button bouton = new Button(i18nC.supprimer());
|
244 |
Button bouton = new Button(i18nC.supprimer());
|
245 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
245 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
246 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
246 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
247 |
public void componentSelected(ButtonEvent ce) {
|
247 |
public void componentSelected(ButtonEvent ce) {
|
248 |
List<ModelData> listeDonneesSelectionnees = grille.getGrille().getSelectionModel().getSelectedItems();
|
248 |
List<ModelData> listeDonneesSelectionnees = grille.getGrille().getSelectionModel().getSelectedItems();
|
249 |
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
|
249 |
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
|
250 |
PublicationAPersonne publicationSaisieSelectionnee = new PublicationAPersonne(donneeSelectionnee, false);
|
250 |
PublicationAPersonne publicationSaisieSelectionnee = new PublicationAPersonne(donneeSelectionnee, false);
|
251 |
supprimerDansGrille(publicationSaisieSelectionnee, donneeSelectionnee);
|
251 |
supprimerDansGrille(publicationSaisieSelectionnee, donneeSelectionnee);
|
252 |
}
|
252 |
}
|
253 |
}
|
253 |
}
|
254 |
});
|
254 |
});
|
255 |
return bouton;
|
255 |
return bouton;
|
256 |
}
|
256 |
}
|
257 |
|
257 |
|
258 |
private Button creerBoutonRafraichir() {
|
258 |
private Button creerBoutonRafraichir() {
|
259 |
Button bouton = new Button(i18nC.rafraichir());
|
259 |
Button bouton = new Button(i18nC.rafraichir());
|
260 |
bouton.setIcon(Images.ICONES.rafraichir());
|
260 |
bouton.setIcon(Images.ICONES.rafraichir());
|
261 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
261 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
262 |
public void componentSelected(ButtonEvent ce) {
|
262 |
public void componentSelected(ButtonEvent ce) {
|
263 |
actualiserGrille();
|
263 |
actualiserGrille();
|
264 |
}
|
264 |
}
|
265 |
});
|
265 |
});
|
266 |
return bouton;
|
266 |
return bouton;
|
267 |
}
|
267 |
}
|
268 |
|
268 |
|
269 |
private void actualiserGrille() {
|
269 |
private void actualiserGrille() {
|
270 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
270 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
271 |
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), "%", null);
|
271 |
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), "%", null);
|
272 |
} else {
|
272 |
} else {
|
273 |
grille.getStore().removeAll();
|
273 |
grille.getStore().removeAll();
|
274 |
layout();
|
274 |
layout();
|
275 |
}
|
275 |
}
|
276 |
}
|
276 |
}
|
277 |
|
277 |
|
278 |
|
278 |
|
279 |
|
279 |
|
280 |
|
280 |
|
281 |
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() {
|
281 |
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPublicationsSaisis() {
|
282 |
|
282 |
|
283 |
ModelType modelTypePublications = new ModelType();
|
283 |
ModelType modelTypePublications = new ModelType();
|
284 |
modelTypePublications.setRoot("publications");
|
284 |
modelTypePublications.setRoot("publications");
|
285 |
modelTypePublications.setTotalName("nbElements");
|
285 |
modelTypePublications.setTotalName("nbElements");
|
286 |
modelTypePublications.addField("ccapu_id_personne");
|
286 |
modelTypePublications.addField("ccapu_id_personne");
|
287 |
modelTypePublications.addField("ccapu_id_publication");
|
287 |
modelTypePublications.addField("ccapu_id_publication");
|
288 |
modelTypePublications.addField("cpu_id_publication");
|
288 |
modelTypePublications.addField("cpu_id_publication");
|
289 |
modelTypePublications.addField("cpu_fmt_nom_complet");
|
289 |
modelTypePublications.addField("cpu_fmt_nom_complet");
|
290 |
modelTypePublications.addField("cpu_titre");
|
290 |
modelTypePublications.addField("cpu_titre");
|
291 |
modelTypePublications.addField("cpu_nom");
|
291 |
modelTypePublications.addField("cpu_nom");
|
292 |
modelTypePublications.addField("cpu_fmt_auteur");
|
292 |
modelTypePublications.addField("cpu_fmt_auteur");
|
293 |
modelTypePublications.addField("cpu_indication_nvt");
|
293 |
modelTypePublications.addField("cpu_indication_nvt");
|
294 |
modelTypePublications.addField("cpu_truk_pages");
|
294 |
modelTypePublications.addField("cpu_truk_pages");
|
295 |
modelTypePublications.addField("cpu_fascicule");
|
295 |
modelTypePublications.addField("cpu_fascicule");
|
296 |
modelTypePublications.addField("cpu_date_parution");
|
296 |
modelTypePublications.addField("cpu_date_parution");
|
297 |
modelTypePublications.addField("cpu_ce_truk_editeur");
|
297 |
modelTypePublications.addField("cpu_ce_truk_editeur");
|
298 |
modelTypePublications.addField("cpu_ce_projet");
|
298 |
modelTypePublications.addField("cpu_ce_projet");
|
299 |
modelTypePublications.addField("cpu_collection");
|
299 |
modelTypePublications.addField("cpu_collection");
|
300 |
|
300 |
|
301 |
String displayNamePublications = "cpu_fmt_nom_complet";
|
301 |
String displayNamePublications = "cpu_fmt_nom_complet";
|
302 |
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null);
|
302 |
ProxyPublications<ModelData> proxyPublications= new ProxyPublications<ModelData>(null);
|
303 |
|
303 |
|
304 |
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications);
|
304 |
final ChampComboBoxRechercheTempsReelPaginable publicationsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPublications, modelTypePublications, displayNamePublications);
|
305 |
publicationsCombo.getCombo().setTabIndex(tabIndex++);
|
305 |
publicationsCombo.getCombo().setTabIndex(tabIndex++);
|
306 |
publicationsCombo.getCombo().setForceSelection(true);
|
306 |
publicationsCombo.getCombo().setForceSelection(true);
|
307 |
|
307 |
|
308 |
publicationsCombo.getCombo().setValidator(new Validator() {
|
308 |
publicationsCombo.getCombo().setValidator(new Validator() {
|
309 |
public String validate(Field<?> field, String value) {
|
309 |
public String validate(Field<?> field, String value) {
|
310 |
String retour = null;
|
310 |
String retour = null;
|
311 |
if (field.getRawValue().equals("")) {
|
311 |
if (field.getRawValue().equals("")) {
|
312 |
field.setValue(null);
|
312 |
field.setValue(null);
|
313 |
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) {
|
313 |
} else if (publicationsCombo.getStore().findModel("cpu_fmt_nom_complet", field.getRawValue()) == null) {
|
314 |
String contenuBrut = field.getRawValue();
|
314 |
String contenuBrut = field.getRawValue();
|
315 |
field.setValue(null);
|
315 |
field.setValue(null);
|
316 |
field.setRawValue(contenuBrut);
|
316 |
field.setRawValue(contenuBrut);
|
317 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
317 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
318 |
}
|
318 |
}
|
319 |
return retour;
|
319 |
return retour;
|
320 |
}
|
320 |
}
|
321 |
});
|
321 |
});
|
322 |
|
322 |
|
323 |
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
|
323 |
publicationsCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
|
324 |
public void handleEvent(BaseEvent be) {
|
324 |
public void handleEvent(BaseEvent be) {
|
325 |
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) {
|
325 |
if (publicationsSaisiesComboBox.getValeur() instanceof ModelData) {
|
326 |
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur(), false);
|
326 |
Publication publicationSaisieSelectionne = new Publication(publicationsSaisiesComboBox.getValeur(), false);
|
327 |
ajouterDansGrille(publicationSaisieSelectionne);
|
327 |
ajouterDansGrille(publicationSaisieSelectionne);
|
328 |
publicationsSaisiesComboBox.getCombo().setValue(null);
|
328 |
publicationsSaisiesComboBox.getCombo().setValue(null);
|
329 |
}
|
329 |
}
|
330 |
}
|
330 |
}
|
331 |
});
|
331 |
});
|
332 |
|
332 |
|
333 |
return publicationsCombo;
|
333 |
return publicationsCombo;
|
334 |
}
|
334 |
}
|
335 |
|
335 |
|
336 |
private void ajouterDansGrille(Publication publication) {
|
336 |
private void ajouterDansGrille(Publication publication) {
|
337 |
ajouterDansGrille(publication, 0);
|
337 |
ajouterDansGrille(publication, 0);
|
338 |
}
|
338 |
}
|
339 |
|
339 |
|
340 |
private void ajouterDansGrille(Publication publication, int index) {
|
340 |
private void ajouterDansGrille(Publication publication, int index) {
|
341 |
if (publication != null) {
|
341 |
if (publication != null) {
|
342 |
if (!listePublicationsLiees.containsKey(publication.getId())) {
|
342 |
if (!listePublicationsLiees.containsKey(publication.getId())) {
|
343 |
PublicationAPersonne publicationLiee = new PublicationAPersonne(false);
|
343 |
PublicationAPersonne publicationLiee = new PublicationAPersonne(false);
|
344 |
publicationLiee.setPersonne(personneSelectionnee);
|
344 |
publicationLiee.setPersonne(personneSelectionnee);
|
345 |
publicationLiee.setPublicationLiee(publication);
|
345 |
publicationLiee.setPublicationLiee(publication);
|
346 |
publicationLiee.setIdPublication(publication.getId());
|
346 |
publicationLiee.setIdPublication(publication.getId());
|
347 |
|
347 |
|
348 |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
|
348 |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE);
|
349 |
listePublicationsLiees.put(publication.getId(), publicationLiee);
|
349 |
listePublicationsLiees.put(publication.getId(), publicationLiee);
|
350 |
|
350 |
|
351 |
// Ajout à la grille
|
351 |
// Ajout à la grille
|
352 |
grille.getGrille().stopEditing();
|
352 |
grille.getGrille().stopEditing();
|
353 |
grille.getGrille().getStore().insert(publicationLiee, 0);
|
353 |
grille.getGrille().getStore().insert(publicationLiee, 0);
|
354 |
grille.getGrille().startEditing(index, 0);
|
354 |
grille.getGrille().startEditing(index, 0);
|
355 |
grille.getGrille().getSelectionModel().select(index, false);
|
355 |
grille.getGrille().getSelectionModel().select(index, false);
|
356 |
} else {
|
356 |
} else {
|
357 |
InfoLogger.display("Information", "La publication choisie existe déjà dans la liste.");
|
357 |
InfoLogger.display("Information", "La publication choisie existe déjà dans la liste.");
|
358 |
}
|
358 |
}
|
359 |
}
|
359 |
}
|
360 |
}
|
360 |
}
|
361 |
|
361 |
|
362 |
/**
|
362 |
/**
|
363 |
* Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees
|
363 |
* Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees
|
364 |
*/
|
364 |
*/
|
365 |
private void mettreAJourGrille() {
|
365 |
private void mettreAJourGrille() {
|
366 |
|
366 |
|
367 |
grille.getStore().removeAll();
|
367 |
grille.getStore().removeAll();
|
368 |
grille.getStore().add(listePublicationsLiees.toList());
|
368 |
grille.getStore().add(listePublicationsLiees.toList());
|
369 |
}
|
369 |
}
|
370 |
|
370 |
|
371 |
private void supprimerDansGrille(PublicationAPersonne publicationLiee, ModelData publicationLieeModele) {
|
371 |
private void supprimerDansGrille(PublicationAPersonne publicationLiee, ModelData publicationLieeModele) {
|
372 |
if (publicationLiee != null) {
|
372 |
if (publicationLiee != null) {
|
373 |
// Ajout de la personne supprimée à la liste
|
373 |
// Ajout de la personne supprimée à la liste
|
374 |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
|
374 |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE))
|
375 |
&& publicationLiee.getId() != null
|
375 |
&& publicationLiee.getId() != null
|
376 |
&& !publicationLiee.getId().equals("")) {
|
376 |
&& !publicationLiee.getId().equals("")) {
|
377 |
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
|
377 |
publicationsSupprimees.put("id"+idGenere++, publicationLiee);
|
378 |
}
|
378 |
}
|
379 |
// Suppression de l'enregistrement de la grille
|
379 |
// Suppression de l'enregistrement de la grille
|
380 |
grille.getStore().remove(publicationLieeModele);
|
380 |
grille.getStore().remove(publicationLieeModele);
|
381 |
}
|
381 |
}
|
382 |
}
|
382 |
}
|
383 |
|
383 |
|
384 |
private GrillePaginable<ModelData> creerGrille() {
|
384 |
private GrillePaginable<ModelData> creerGrille() {
|
385 |
|
385 |
|
386 |
GrillePaginable<ModelData> grillePublications = null;
|
386 |
GrillePaginable<ModelData> grillePublications = null;
|
387 |
|
387 |
|
388 |
// ModelType
|
388 |
// ModelType
|
389 |
ModelType modelTypePublicationAPersonne = new ModelType();
|
389 |
ModelType modelTypePublicationAPersonne = new ModelType();
|
390 |
modelTypePublicationAPersonne.setRoot("publicationsAPersonne");
|
390 |
modelTypePublicationAPersonne.setRoot("publicationsAPersonne");
|
391 |
modelTypePublicationAPersonne.setTotalName("nbElements");
|
391 |
modelTypePublicationAPersonne.setTotalName("nbElements");
|
392 |
modelTypePublicationAPersonne.addField("cpuap_id_personne");
|
392 |
modelTypePublicationAPersonne.addField("cpuap_id_personne");
|
393 |
modelTypePublicationAPersonne.addField("cpuap_id_publication");
|
393 |
modelTypePublicationAPersonne.addField("cpuap_id_publication");
|
394 |
modelTypePublicationAPersonne.addField("cpuap_id_role");
|
394 |
modelTypePublicationAPersonne.addField("cpuap_id_role");
|
395 |
modelTypePublicationAPersonne.addField("cpu_id_publication");
|
395 |
modelTypePublicationAPersonne.addField("cpu_id_publication");
|
396 |
modelTypePublicationAPersonne.addField("cpu_fmt_auteur");
|
396 |
modelTypePublicationAPersonne.addField("cpu_fmt_auteur");
|
397 |
modelTypePublicationAPersonne.addField("cpu_titre");
|
397 |
modelTypePublicationAPersonne.addField("cpu_titre");
|
398 |
modelTypePublicationAPersonne.addField("cpu_collection");
|
398 |
modelTypePublicationAPersonne.addField("cpu_collection");
|
399 |
modelTypePublicationAPersonne.addField("cpu_ce_truk_editeur");
|
399 |
modelTypePublicationAPersonne.addField("cpu_ce_truk_editeur");
|
400 |
modelTypePublicationAPersonne.addField("cpu_date_parution");
|
400 |
modelTypePublicationAPersonne.addField("cpu_date_parution");
|
401 |
modelTypePublicationAPersonne.addField("cpu_fascicule");
|
401 |
modelTypePublicationAPersonne.addField("cpu_fascicule");
|
402 |
modelTypePublicationAPersonne.addField("cpu_truk_pages");
|
402 |
modelTypePublicationAPersonne.addField("cpu_truk_pages");
|
403 |
modelTypePublicationAPersonne.addField("cpu_indication_nvt");
|
403 |
modelTypePublicationAPersonne.addField("cpu_indication_nvt");
|
404 |
|
404 |
|
405 |
// Proxy
|
405 |
// Proxy
|
406 |
ProxyPublicationsAPersonne<ModelData> proxyPublicationsAPersonne = new ProxyPublicationsAPersonne<ModelData>(null, null, null);
|
406 |
ProxyPublicationsAPersonne<ModelData> proxyPublicationsAPersonne = new ProxyPublicationsAPersonne<ModelData>(null, null, null);
|
407 |
|
407 |
|
408 |
// Colonnes
|
408 |
// Colonnes
|
409 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
409 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
410 |
RowNumberer numeroPlugin = new RowNumberer();
|
410 |
RowNumberer numeroPlugin = new RowNumberer();
|
411 |
numeroPlugin.setHeader("#");
|
411 |
numeroPlugin.setHeaderHtml("#");
|
412 |
XTemplate infoTpl = XTemplate.create("<p>"+
|
412 |
XTemplate infoTpl = XTemplate.create("<p>"+
|
413 |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {cpu_fmt_auteur}<br />"+
|
413 |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {cpu_fmt_auteur}<br />"+
|
414 |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {cpu_titre}<br />"+
|
414 |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {cpu_titre}<br />"+
|
415 |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {cpu_collection}<br />"+
|
415 |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {cpu_collection}<br />"+
|
416 |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+
|
416 |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+
|
417 |
"</p>");
|
417 |
"</p>");
|
418 |
RowExpander expansionPlugin = new RowExpander();
|
418 |
RowExpander expansionPlugin = new RowExpander();
|
419 |
expansionPlugin.setTemplate(infoTpl);
|
419 |
expansionPlugin.setTemplate(infoTpl);
|
420 |
colonnes.add(expansionPlugin);
|
420 |
colonnes.add(expansionPlugin);
|
421 |
colonnes.add(numeroPlugin);
|
421 |
colonnes.add(numeroPlugin);
|
422 |
colonnes.add(creerColonneTypeRelation());
|
422 |
colonnes.add(creerColonneTypeRelation());
|
423 |
colonnes.add(new ColumnConfig("cpu_fmt_auteur", i18nC.publicationAuteurs(), 150));
|
423 |
colonnes.add(new ColumnConfig("cpu_fmt_auteur", i18nC.publicationAuteurs(), 150));
|
424 |
colonnes.add(new ColumnConfig("cpu_titre", i18nC.publicationTitre(), 150));
|
424 |
colonnes.add(new ColumnConfig("cpu_titre", i18nC.publicationTitre(), 150));
|
425 |
colonnes.add(new ColumnConfig("cpu_collection", i18nC.publicationRevueCollection(), 75));
|
425 |
colonnes.add(new ColumnConfig("cpu_collection", i18nC.publicationRevueCollection(), 75));
|
426 |
colonnes.add(creerColonneEditeur());
|
426 |
colonnes.add(creerColonneEditeur());
|
427 |
colonnes.add(creerColonneAnneePublication());
|
427 |
colonnes.add(creerColonneAnneePublication());
|
428 |
colonnes.add(new ColumnConfig("cpu_indication_nvt", i18nC.publicationNvt(), 75));
|
428 |
colonnes.add(new ColumnConfig("cpu_indication_nvt", i18nC.publicationNvt(), 75));
|
429 |
colonnes.add(new ColumnConfig("cpu_fascicule", i18nC.publicationFascicule(), 75));
|
429 |
colonnes.add(new ColumnConfig("cpu_fascicule", i18nC.publicationFascicule(), 75));
|
430 |
colonnes.add(new ColumnConfig("cpu_truk_pages", i18nC.publicationPage(), 50));
|
430 |
colonnes.add(new ColumnConfig("cpu_truk_pages", i18nC.publicationPage(), 50));
|
431 |
|
431 |
|
432 |
HashMap<String, String> virtualFields = new HashMap<String, String>();
|
432 |
HashMap<String, String> virtualFields = new HashMap<String, String>();
|
433 |
virtualFields.put("_editeur_", "cpu_ce_truk_editeur");
|
433 |
virtualFields.put("_editeur_", "cpu_ce_truk_editeur");
|
434 |
virtualFields.put("_annee_", "cpu_date_parution");
|
434 |
virtualFields.put("_annee_", "cpu_date_parution");
|
435 |
virtualFields.put("_role_", "cpuap_id_role");
|
435 |
virtualFields.put("_role_", "cpuap_id_role");
|
436 |
virtualFields.put("_etat_", "");
|
436 |
virtualFields.put("_etat_", "");
|
437 |
|
437 |
|
438 |
// Modele de selection
|
438 |
// Modele de selection
|
439 |
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
|
439 |
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
|
440 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
440 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
441 |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info");
|
441 |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info");
|
442 |
|
442 |
|
443 |
// Grille
|
443 |
// Grille
|
444 |
grillePublications = new GrillePaginable<ModelData>(modelTypePublicationAPersonne, virtualFields, proxyPublicationsAPersonne, colonnes, modeleDeColonnes);
|
444 |
grillePublications = new GrillePaginable<ModelData>(modelTypePublicationAPersonne, virtualFields, proxyPublicationsAPersonne, colonnes, modeleDeColonnes);
|
445 |
grillePublications.getGrille().setBorders(true);
|
445 |
grillePublications.getGrille().setBorders(true);
|
446 |
grillePublications.getGrille().setSelectionModel(modeleDeSelection);
|
446 |
grillePublications.getGrille().setSelectionModel(modeleDeSelection);
|
447 |
grillePublications.getGrille().addPlugin(expansionPlugin);
|
447 |
grillePublications.getGrille().addPlugin(expansionPlugin);
|
448 |
grillePublications.getGrille().addPlugin(numeroPlugin);
|
448 |
grillePublications.getGrille().addPlugin(numeroPlugin);
|
449 |
grillePublications.getGrille().getView().setForceFit(true);
|
449 |
grillePublications.getGrille().getView().setForceFit(true);
|
450 |
grillePublications.getGrille().setAutoExpandColumn("titre");
|
450 |
grillePublications.getGrille().setAutoExpandColumn("titre");
|
451 |
grillePublications.getGrille().setStripeRows(true);
|
451 |
grillePublications.getGrille().setStripeRows(true);
|
452 |
grillePublications.getGrille().setTrackMouseOver(true);
|
452 |
grillePublications.getGrille().setTrackMouseOver(true);
|
453 |
|
453 |
|
454 |
// Rajouter des écouteurs
|
454 |
// Rajouter des écouteurs
|
455 |
grillePublications.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
|
455 |
grillePublications.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
|
456 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
456 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
457 |
actualiserEtatBoutonsBarreOutils();
|
457 |
actualiserEtatBoutonsBarreOutils();
|
458 |
}
|
458 |
}
|
459 |
});
|
459 |
});
|
460 |
grillePublications.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
|
460 |
grillePublications.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
|
461 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
461 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
462 |
actualiserEtatBoutonsBarreOutils();
|
462 |
actualiserEtatBoutonsBarreOutils();
|
463 |
}
|
463 |
}
|
464 |
});
|
464 |
});
|
465 |
grillePublications.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
|
465 |
grillePublications.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
|
466 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
466 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
467 |
if (ce.getModel().get("_role_") != null && ce.getRecord().isModified("_role_") && ce.getModel().get("_etat_") != null && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
467 |
if (ce.getModel().get("_role_") != null && ce.getRecord().isModified("_role_") && ce.getModel().get("_etat_") != null && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
468 |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
|
468 |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE);
|
469 |
}
|
469 |
}
|
470 |
}
|
470 |
}
|
471 |
});
|
471 |
});
|
472 |
|
472 |
|
473 |
return grillePublications;
|
473 |
return grillePublications;
|
474 |
}
|
474 |
}
|
475 |
|
475 |
|
476 |
private ColumnConfig creerColonneEditeur() {
|
476 |
private ColumnConfig creerColonneEditeur() {
|
477 |
GridCellRenderer<ModelData> editeurRendu = new GridCellRenderer<ModelData>() {
|
477 |
GridCellRenderer<ModelData> editeurRendu = new GridCellRenderer<ModelData>() {
|
478 |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
|
478 |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
|
479 |
PublicationAPersonne pap = new PublicationAPersonne(model, true);
|
479 |
PublicationAPersonne pap = new PublicationAPersonne(model, true);
|
480 |
String editeur = pap.getPublicationLiee().getNomEditeur();
|
480 |
String editeur = pap.getPublicationLiee().getNomEditeur();
|
481 |
model.set("_editeur_", editeur);
|
481 |
model.set("_editeur_", editeur);
|
482 |
return editeur;
|
482 |
return editeur;
|
483 |
}
|
483 |
}
|
484 |
};
|
484 |
};
|
485 |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135);
|
485 |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135);
|
486 |
editeurColonne.setRenderer(editeurRendu);
|
486 |
editeurColonne.setRenderer(editeurRendu);
|
487 |
return editeurColonne;
|
487 |
return editeurColonne;
|
488 |
}
|
488 |
}
|
489 |
|
489 |
|
490 |
private ColumnConfig creerColonneAnneePublication() {
|
490 |
private ColumnConfig creerColonneAnneePublication() {
|
491 |
GridCellRenderer<ModelData> datePublicationRendu = new GridCellRenderer<ModelData>() {
|
491 |
GridCellRenderer<ModelData> datePublicationRendu = new GridCellRenderer<ModelData>() {
|
492 |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
|
492 |
public String render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
|
493 |
PublicationAPersonne pap = new PublicationAPersonne(model, true);
|
493 |
PublicationAPersonne pap = new PublicationAPersonne(model, true);
|
494 |
String annee = pap.getPublicationLiee().getAnneeParution();
|
494 |
String annee = pap.getPublicationLiee().getAnneeParution();
|
495 |
model.set("_annee_", annee);
|
495 |
model.set("_annee_", annee);
|
496 |
return annee;
|
496 |
return annee;
|
497 |
}
|
497 |
}
|
498 |
};
|
498 |
};
|
499 |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75);
|
499 |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75);
|
500 |
datePublicationColonne.setRenderer(datePublicationRendu);
|
500 |
datePublicationColonne.setRenderer(datePublicationRendu);
|
501 |
return datePublicationColonne;
|
501 |
return datePublicationColonne;
|
502 |
}
|
502 |
}
|
503 |
|
503 |
|
504 |
private ColumnConfig creerColonneTypeRelation() {
|
504 |
private ColumnConfig creerColonneTypeRelation() {
|
505 |
typeRelationCombo = new ComboBox<Valeur>();
|
505 |
typeRelationCombo = new ComboBox<Valeur>();
|
506 |
typeRelationCombo.setForceSelection(true);
|
506 |
typeRelationCombo.setForceSelection(true);
|
507 |
typeRelationCombo.setTriggerAction(TriggerAction.ALL);
|
507 |
typeRelationCombo.setTriggerAction(TriggerAction.ALL);
|
508 |
typeRelationCombo.setDisplayField("nom");
|
508 |
typeRelationCombo.setDisplayField("nom");
|
509 |
typeRelationCombo.setStore(new ListStore<Valeur>());
|
509 |
typeRelationCombo.setStore(new ListStore<Valeur>());
|
510 |
typeRelationCombo.setEditable(false);
|
510 |
typeRelationCombo.setEditable(false);
|
511 |
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE);
|
511 |
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE);
|
512 |
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire());
|
512 |
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire());
|
513 |
|
513 |
|
514 |
CellEditor editeurRelation = new CellEditor(typeRelationCombo) {
|
514 |
CellEditor editeurRelation = new CellEditor(typeRelationCombo) {
|
515 |
public Object preProcessValue(Object valeur) {
|
515 |
public Object preProcessValue(Object valeur) {
|
516 |
Valeur retour = null;
|
516 |
Valeur retour = null;
|
517 |
if (valeur != null ) {
|
517 |
if (valeur != null ) {
|
518 |
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) {
|
518 |
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) {
|
519 |
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString());
|
519 |
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString());
|
520 |
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) {
|
520 |
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) {
|
521 |
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString());
|
521 |
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString());
|
522 |
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) {
|
522 |
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) {
|
523 |
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString());
|
523 |
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString());
|
524 |
}
|
524 |
}
|
525 |
}
|
525 |
}
|
526 |
return retour;
|
526 |
return retour;
|
527 |
}
|
527 |
}
|
528 |
|
528 |
|
529 |
public Object postProcessValue(Object valeur) {
|
529 |
public Object postProcessValue(Object valeur) {
|
530 |
String retour = null;
|
530 |
String retour = null;
|
531 |
if (valeur != null ) {
|
531 |
if (valeur != null ) {
|
532 |
if (valeur instanceof Valeur) {
|
532 |
if (valeur instanceof Valeur) {
|
533 |
Valeur valeurOntologie = (Valeur) valeur;
|
533 |
Valeur valeurOntologie = (Valeur) valeur;
|
534 |
retour = valeurOntologie.getId();
|
534 |
retour = valeurOntologie.getId();
|
535 |
}
|
535 |
}
|
536 |
}
|
536 |
}
|
537 |
return retour;
|
537 |
return retour;
|
538 |
}
|
538 |
}
|
539 |
};
|
539 |
};
|
540 |
|
540 |
|
541 |
GridCellRenderer<ModelData> relationRendu = new GridCellRenderer<ModelData>() {
|
541 |
GridCellRenderer<ModelData> relationRendu = new GridCellRenderer<ModelData>() {
|
542 |
public String render(ModelData modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grille) {
|
542 |
public String render(ModelData modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grille) {
|
543 |
// Gestion du texte afficher dans la cellule
|
543 |
// Gestion du texte afficher dans la cellule
|
544 |
String role = modele.get("_role_");
|
544 |
String role = modele.get("_role_");
|
545 |
String roleNom = "";
|
545 |
String roleNom = "";
|
546 |
if (typeRelationCombo.getStore() != null && role!=null && role.matches("[0-9]+")) {
|
546 |
if (typeRelationCombo.getStore() != null && role!=null && role.matches("[0-9]+")) {
|
547 |
if (typeRelationCombo.getStore().findModel("id_valeur", role) != null) {
|
547 |
if (typeRelationCombo.getStore().findModel("id_valeur", role) != null) {
|
548 |
roleNom = typeRelationCombo.getStore().findModel("id_valeur", role).getNom();
|
548 |
roleNom = typeRelationCombo.getStore().findModel("id_valeur", role).getNom();
|
549 |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId();
|
549 |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId();
|
550 |
} else { Debug.log("role recherche="+role);
|
550 |
} else { Debug.log("role recherche="+role);
|
551 |
Debug.log("typeRelationCombo.getStore().getCount()="+typeRelationCombo.getStore().getCount());
|
551 |
Debug.log("typeRelationCombo.getStore().getCount()="+typeRelationCombo.getStore().getCount());
|
552 |
for(int i=0; i<typeRelationCombo.getStore().getCount(); i++) {
|
552 |
for(int i=0; i<typeRelationCombo.getStore().getCount(); i++) {
|
553 |
Debug.log(""+typeRelationCombo.getStore().getAt(i));
|
553 |
Debug.log(""+typeRelationCombo.getStore().getAt(i));
|
554 |
}
|
554 |
}
|
555 |
}
|
555 |
}
|
556 |
}
|
556 |
}
|
557 |
modele.set("_role_", role);
|
557 |
modele.set("_role_", role);
|
558 |
return roleNom;
|
558 |
return roleNom;
|
559 |
}
|
559 |
}
|
560 |
};
|
560 |
};
|
561 |
|
561 |
|
562 |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonne(), 75);
|
562 |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonne(), 75);
|
563 |
typeRelationColonne.setEditor(editeurRelation);
|
563 |
typeRelationColonne.setEditor(editeurRelation);
|
564 |
typeRelationColonne.setRenderer(relationRendu);
|
564 |
typeRelationColonne.setRenderer(relationRendu);
|
565 |
|
565 |
|
566 |
return typeRelationColonne;
|
566 |
return typeRelationColonne;
|
567 |
}
|
567 |
}
|
568 |
|
568 |
|
569 |
public void actualiserEtatBoutonsBarreOutils() {
|
569 |
public void actualiserEtatBoutonsBarreOutils() {
|
570 |
// Activation des boutons si la grille contient un élément
|
570 |
// Activation des boutons si la grille contient un élément
|
571 |
if (grille.getStore().getCount() > 0) {
|
571 |
if (grille.getStore().getCount() > 0) {
|
572 |
publicationsBoutonSupprimer.enable();
|
572 |
publicationsBoutonSupprimer.enable();
|
573 |
publicationsBoutonModifier.enable();
|
573 |
publicationsBoutonModifier.enable();
|
574 |
}
|
574 |
}
|
575 |
// Désactivation des boutons si la grille ne contient plus d'élément
|
575 |
// Désactivation des boutons si la grille ne contient plus d'élément
|
576 |
if (grille.getStore().getCount() == 0) {
|
576 |
if (grille.getStore().getCount() == 0) {
|
577 |
publicationsBoutonSupprimer.disable();
|
577 |
publicationsBoutonSupprimer.disable();
|
578 |
publicationsBoutonModifier.disable();
|
578 |
publicationsBoutonModifier.disable();
|
579 |
}
|
579 |
}
|
580 |
}
|
580 |
}
|
581 |
|
581 |
|
582 |
public void rafraichir(Object nouvellesDonnees) {
|
582 |
public void rafraichir(Object nouvellesDonnees) {
|
583 |
|
583 |
|
584 |
if (nouvellesDonnees instanceof Information)
|
584 |
if (nouvellesDonnees instanceof Information)
|
585 |
{
|
585 |
{
|
586 |
Information info = (Information) nouvellesDonnees;
|
586 |
Information info = (Information) nouvellesDonnees;
|
587 |
rafraichirInformation(info);
|
587 |
rafraichirInformation(info);
|
588 |
}
|
588 |
}
|
589 |
else if (nouvellesDonnees instanceof ValeurListe)
|
589 |
else if (nouvellesDonnees instanceof ValeurListe)
|
590 |
{
|
590 |
{
|
591 |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
|
591 |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
|
592 |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
|
592 |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) {
|
593 |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo);
|
593 |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo);
|
594 |
roles = listeValeurs.toList();
|
594 |
roles = listeValeurs.toList();
|
595 |
rolesRecus = true;
|
595 |
rolesRecus = true;
|
596 |
((ProxyPublicationsAPersonne)grille.getProxy()).setRolesId(roles);
|
596 |
((ProxyPublicationsAPersonne)grille.getProxy()).setRolesId(roles);
|
597 |
if (rolesRecus && personneRecue) grille.reload();
|
597 |
if (rolesRecus && personneRecue) grille.reload();
|
598 |
}
|
598 |
}
|
599 |
}
|
599 |
}
|
600 |
else if (nouvellesDonnees instanceof PublicationAPersonneListe)
|
600 |
else if (nouvellesDonnees instanceof PublicationAPersonneListe)
|
601 |
{
|
601 |
{
|
602 |
PublicationAPersonneListe papl = (PublicationAPersonneListe) nouvellesDonnees;
|
602 |
PublicationAPersonneListe papl = (PublicationAPersonneListe) nouvellesDonnees;
|
603 |
List<PublicationAPersonne> paplListe = papl.toList();
|
603 |
List<PublicationAPersonne> paplListe = papl.toList();
|
604 |
if (paplListe.size()>0){
|
604 |
if (paplListe.size()>0){
|
605 |
Iterator<PublicationAPersonne> it = paplListe.iterator();
|
605 |
Iterator<PublicationAPersonne> it = paplListe.iterator();
|
606 |
while (it.hasNext()) {
|
606 |
while (it.hasNext()) {
|
607 |
PublicationAPersonne pap = it.next();
|
607 |
PublicationAPersonne pap = it.next();
|
608 |
listePublicationsLiees.put(pap.getPublicationLiee().getId(), pap);
|
608 |
listePublicationsLiees.put(pap.getPublicationLiee().getId(), pap);
|
609 |
}
|
609 |
}
|
610 |
mettreAJourGrille();
|
610 |
mettreAJourGrille();
|
611 |
}
|
611 |
}
|
612 |
}
|
612 |
}
|
613 |
else
|
613 |
else
|
614 |
{
|
614 |
{
|
615 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
615 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
616 |
}
|
616 |
}
|
617 |
}
|
617 |
}
|
618 |
|
618 |
|
619 |
public void rafraichirInformation(Information info) {
|
619 |
public void rafraichirInformation(Information info) {
|
620 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
620 |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) {
|
621 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
621 |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null);
|
622 |
}
|
622 |
}
|
623 |
String type = info.getType();
|
623 |
String type = info.getType();
|
624 |
if (type.equals("personne")) {
|
624 |
if (type.equals("personne")) {
|
625 |
mettreAJourPersonne();
|
625 |
mettreAJourPersonne();
|
626 |
((ProxyPublicationsAPersonne)grille.getProxy()).setPersonneId(personneSelectionnee.getId());
|
626 |
((ProxyPublicationsAPersonne)grille.getProxy()).setPersonneId(personneSelectionnee.getId());
|
627 |
personneRecue = true;
|
627 |
personneRecue = true;
|
628 |
if (rolesRecus && personneRecue) grille.reload();
|
628 |
if (rolesRecus && personneRecue) grille.reload();
|
629 |
} else if (type.equals("publication_liees")) {
|
629 |
} else if (type.equals("publication_liees")) {
|
630 |
if (info.getDonnee(0) != null) {
|
630 |
if (info.getDonnee(0) != null) {
|
631 |
initialiser();
|
631 |
initialiser();
|
632 |
personneSelectionnee.setPublicationsLiees((PublicationAPersonneListe) info.getDonnee(0));
|
632 |
personneSelectionnee.setPublicationsLiees((PublicationAPersonneListe) info.getDonnee(0));
|
633 |
peupler();
|
633 |
peupler();
|
634 |
}
|
634 |
}
|
635 |
} else if (type.equals("publication_modifiee")) {
|
635 |
} else if (type.equals("publication_modifiee")) {
|
636 |
if (info.getDonnee(0) != null) {
|
636 |
if (info.getDonnee(0) != null) {
|
637 |
Publication publication = (Publication) info.getDonnee(0);
|
637 |
Publication publication = (Publication) info.getDonnee(0);
|
638 |
ModelData publicationDansGrille = grille.getStore().findModel("cpu_id_publication", publication.getId());
|
638 |
ModelData publicationDansGrille = grille.getStore().findModel("cpu_id_publication", publication.getId());
|
639 |
int index = grille.getStore().indexOf(publicationDansGrille);
|
639 |
int index = grille.getStore().indexOf(publicationDansGrille);
|
640 |
grille.getStore().remove(publicationDansGrille);
|
640 |
grille.getStore().remove(publicationDansGrille);
|
641 |
ajouterDansGrille(publication, index);
|
641 |
ajouterDansGrille(publication, index);
|
642 |
}
|
642 |
}
|
643 |
} else if (type.equals("publication_ajoutee")) {
|
643 |
} else if (type.equals("publication_ajoutee")) {
|
644 |
if (info.getDonnee(0) != null) {
|
644 |
if (info.getDonnee(0) != null) {
|
645 |
Publication publication = (Publication) info.getDonnee(0);
|
645 |
Publication publication = (Publication) info.getDonnee(0);
|
646 |
ajouterDansGrille(publication);
|
646 |
ajouterDansGrille(publication);
|
647 |
}
|
647 |
}
|
648 |
} else if (type.equals("ajout_publication_a_personne")) {
|
648 |
} else if (type.equals("ajout_publication_a_personne")) {
|
649 |
InfoLogger.display("Ajout publication à personne", info.getDonnees().toString());
|
649 |
InfoLogger.display("Ajout publication à personne", info.getDonnees().toString());
|
650 |
} else if (type.equals("suppression_publication_a_personne")) {
|
650 |
} else if (type.equals("suppression_publication_a_personne")) {
|
651 |
InfoLogger.display("Suppression publication à personne", info.getMessages().toString());
|
651 |
InfoLogger.display("Suppression publication à personne", info.getMessages().toString());
|
652 |
} else {
|
652 |
} else {
|
653 |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null);
|
653 |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null);
|
654 |
}
|
654 |
}
|
655 |
}
|
655 |
}
|
656 |
|
656 |
|
657 |
public void peupler() {
|
657 |
public void peupler() {
|
658 |
grille.getStore().removeAll();
|
658 |
grille.getStore().removeAll();
|
659 |
grille.getStore().add(personneSelectionnee.getPublicationsLiees().toList());
|
659 |
grille.getStore().add(personneSelectionnee.getPublicationsLiees().toList());
|
660 |
layout();
|
660 |
layout();
|
661 |
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok());
|
661 |
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok());
|
662 |
|
662 |
|
663 |
}
|
663 |
}
|
664 |
|
664 |
|
665 |
public void collecter() {
|
665 |
public void collecter() {
|
666 |
if (etreAccede()) {
|
666 |
if (etreAccede()) {
|
667 |
int nbrePublication = grille.getStore().getCount();
|
667 |
int nbrePublication = grille.getStore().getCount();
|
668 |
for (int i = 0; i < nbrePublication; i++) {
|
668 |
for (int i = 0; i < nbrePublication; i++) {
|
669 |
ModelData publicationLiee = grille.getStore().getAt(i);
|
669 |
ModelData publicationLiee = grille.getStore().getAt(i);
|
670 |
PublicationAPersonne pap = new PublicationAPersonne(publicationLiee, false);
|
670 |
PublicationAPersonne pap = new PublicationAPersonne(publicationLiee, false);
|
671 |
if (publicationLiee.get("_etat_") != null) {
|
671 |
if (publicationLiee.get("_etat_") != null) {
|
672 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
672 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) {
|
673 |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
|
673 |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role
|
674 |
publicationsSupprimees.put("id"+idGenere++, pap);
|
674 |
publicationsSupprimees.put("id"+idGenere++, pap);
|
675 |
PublicationAPersonne relationAAjouter = pap;
|
675 |
PublicationAPersonne relationAAjouter = pap;
|
676 |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter);
|
676 |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter);
|
677 |
}
|
677 |
}
|
678 |
|
678 |
|
679 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
679 |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) {
|
680 |
publicationsAjoutees.put("id"+idGenere++, pap);
|
680 |
publicationsAjoutees.put("id"+idGenere++, pap);
|
681 |
}
|
681 |
}
|
682 |
// Initialisation de la grille
|
682 |
// Initialisation de la grille
|
683 |
publicationLiee.set("_etat_", "");
|
683 |
publicationLiee.set("_etat_", "");
|
684 |
|
684 |
|
685 |
}
|
685 |
}
|
686 |
}
|
686 |
}
|
687 |
grille.getStore().commitChanges();
|
687 |
grille.getStore().commitChanges();
|
688 |
}
|
688 |
}
|
689 |
}
|
689 |
}
|
690 |
|
690 |
|
691 |
public List verifier() {
|
691 |
public List verifier() {
|
692 |
List lstMessageErreur = new LinkedList<String>();
|
692 |
List lstMessageErreur = new LinkedList<String>();
|
693 |
//Vérifier les roles
|
693 |
//Vérifier les roles
|
694 |
List<ModelData> listePublis = grille.getStore().getModels();
|
694 |
List<ModelData> listePublis = grille.getStore().getModels();
|
695 |
Iterator<ModelData> itPublis = listePublis.iterator();
|
695 |
Iterator<ModelData> itPublis = listePublis.iterator();
|
696 |
while (itPublis.hasNext()) {
|
696 |
while (itPublis.hasNext()) {
|
697 |
ModelData publi = itPublis.next();
|
697 |
ModelData publi = itPublis.next();
|
698 |
if (UtilString.isEmpty((String) publi.get("_role_"))) {
|
698 |
if (UtilString.isEmpty((String) publi.get("_role_"))) {
|
699 |
lstMessageErreur.add("Vous devez choisir le rôle de la relation " + (grille.getStore().indexOf(publi) + 1));
|
699 |
lstMessageErreur.add("Vous devez choisir le rôle de la relation " + (grille.getStore().indexOf(publi) + 1));
|
700 |
}
|
700 |
}
|
701 |
}
|
701 |
}
|
702 |
return lstMessageErreur;
|
702 |
return lstMessageErreur;
|
703 |
}
|
703 |
}
|
704 |
|
704 |
|
705 |
public void soumettre() {
|
705 |
public void soumettre() {
|
706 |
|
706 |
|
707 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
707 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
708 |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) {
|
708 |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) {
|
709 |
//InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
709 |
//InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié.");
|
710 |
} else {
|
710 |
} else {
|
711 |
// Ajout des relations PublicationAPersonne
|
711 |
// Ajout des relations PublicationAPersonne
|
712 |
if (publicationsAjoutees.size() != 0) {
|
712 |
if (publicationsAjoutees.size() != 0) {
|
713 |
//TODO : utiliser le role d'une liste déroulante
|
713 |
//TODO : utiliser le role d'une liste déroulante
|
714 |
mediateur.ajouterPublicationAPersonne(this, publicationsAjoutees, personneSelectionnee.getId(), null, null);
|
714 |
mediateur.ajouterPublicationAPersonne(this, publicationsAjoutees, personneSelectionnee.getId(), null, null);
|
715 |
}
|
715 |
}
|
716 |
// Suppression des relations PublicationAPersonne
|
716 |
// Suppression des relations PublicationAPersonne
|
717 |
if (publicationsSupprimees.size() != 0) {
|
717 |
if (publicationsSupprimees.size() != 0) {
|
718 |
mediateur.supprimerPublicationAPersonne(this, publicationsSupprimees);
|
718 |
mediateur.supprimerPublicationAPersonne(this, publicationsSupprimees);
|
719 |
}
|
719 |
}
|
720 |
}
|
720 |
}
|
721 |
}
|
721 |
}
|
722 |
}
|
722 |
}
|
723 |
|
723 |
|
724 |
private void obtenirPublicationsSaisies(String nom) {
|
724 |
private void obtenirPublicationsSaisies(String nom) {
|
725 |
mediateur.selectionnerPublicationParNomComplet(this, null, "%"+nom+"%");
|
725 |
mediateur.selectionnerPublicationParNomComplet(this, null, "%"+nom+"%");
|
726 |
}
|
726 |
}
|
727 |
}
|
727 |
}
|