1 |
package org.tela_botanica.client.vues.publication;
|
1 |
package org.tela_botanica.client.vues.publication;
|
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.List;
|
6 |
import java.util.List;
|
7 |
|
7 |
|
8 |
import org.tela_botanica.client.ComposantClass;
|
8 |
import org.tela_botanica.client.ComposantClass;
|
9 |
import org.tela_botanica.client.Mediateur;
|
9 |
import org.tela_botanica.client.Mediateur;
|
10 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
10 |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable;
|
11 |
import org.tela_botanica.client.composants.GrillePaginable;
|
11 |
import org.tela_botanica.client.composants.GrillePaginable;
|
12 |
import org.tela_botanica.client.composants.InfoLogger;
|
12 |
import org.tela_botanica.client.composants.InfoLogger;
|
13 |
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
|
13 |
import org.tela_botanica.client.composants.pagination.ProxyPersonnes;
|
14 |
import org.tela_botanica.client.composants.pagination.ProxyPersonnesAPublication;
|
14 |
import org.tela_botanica.client.composants.pagination.ProxyPersonnesAPublication;
|
15 |
import org.tela_botanica.client.composants.pagination.ProxyProjets;
|
15 |
import org.tela_botanica.client.composants.pagination.ProxyProjets;
|
16 |
import org.tela_botanica.client.composants.pagination.ProxyStructures;
|
16 |
import org.tela_botanica.client.composants.pagination.ProxyStructures;
|
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.MenuApplicationId;
|
20 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
21 |
import org.tela_botanica.client.modeles.aDonnee;
|
21 |
import org.tela_botanica.client.modeles.aDonnee;
|
22 |
import org.tela_botanica.client.modeles.personne.Personne;
|
22 |
import org.tela_botanica.client.modeles.personne.Personne;
|
23 |
import org.tela_botanica.client.modeles.projet.Projet;
|
23 |
import org.tela_botanica.client.modeles.projet.Projet;
|
24 |
import org.tela_botanica.client.modeles.publication.Publication;
|
24 |
import org.tela_botanica.client.modeles.publication.Publication;
|
25 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
25 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
26 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
26 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
27 |
import org.tela_botanica.client.modeles.structure.Structure;
|
27 |
import org.tela_botanica.client.modeles.structure.Structure;
|
28 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
28 |
import org.tela_botanica.client.synchronisation.Sequenceur;
|
29 |
import org.tela_botanica.client.util.Debug;
|
29 |
import org.tela_botanica.client.util.Debug;
|
30 |
import org.tela_botanica.client.util.Log;
|
30 |
import org.tela_botanica.client.util.Log;
|
31 |
import org.tela_botanica.client.util.Pattern;
|
31 |
import org.tela_botanica.client.util.Pattern;
|
32 |
import org.tela_botanica.client.util.UtilArray;
|
32 |
import org.tela_botanica.client.util.UtilArray;
|
33 |
import org.tela_botanica.client.util.UtilString;
|
33 |
import org.tela_botanica.client.util.UtilString;
|
34 |
import org.tela_botanica.client.vues.FenetreForm;
|
34 |
import org.tela_botanica.client.vues.FenetreForm;
|
35 |
import org.tela_botanica.client.vues.Formulaire;
|
35 |
import org.tela_botanica.client.vues.Formulaire;
|
36 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
36 |
import org.tela_botanica.client.vues.FormulaireBarreValidation;
|
37 |
import org.tela_botanica.client.vues.personne.PersonneForm;
|
37 |
import org.tela_botanica.client.vues.personne.PersonneForm;
|
38 |
|
38 |
|
39 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
39 |
import com.extjs.gxt.ui.client.Style.Scroll;
|
40 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
40 |
import com.extjs.gxt.ui.client.Style.SortDir;
|
41 |
import com.extjs.gxt.ui.client.data.BaseModelData;
|
41 |
import com.extjs.gxt.ui.client.data.BaseModelData;
|
42 |
import com.extjs.gxt.ui.client.data.LoadEvent;
|
42 |
import com.extjs.gxt.ui.client.data.LoadEvent;
|
43 |
import com.extjs.gxt.ui.client.data.Loader;
|
43 |
import com.extjs.gxt.ui.client.data.Loader;
|
44 |
import com.extjs.gxt.ui.client.data.ModelData;
|
44 |
import com.extjs.gxt.ui.client.data.ModelData;
|
45 |
import com.extjs.gxt.ui.client.data.ModelType;
|
45 |
import com.extjs.gxt.ui.client.data.ModelType;
|
46 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
46 |
import com.extjs.gxt.ui.client.event.BaseEvent;
|
47 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
47 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
48 |
import com.extjs.gxt.ui.client.event.Events;
|
48 |
import com.extjs.gxt.ui.client.event.Events;
|
49 |
import com.extjs.gxt.ui.client.event.Listener;
|
49 |
import com.extjs.gxt.ui.client.event.Listener;
|
50 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
50 |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
51 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
51 |
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
|
52 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
52 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
53 |
import com.extjs.gxt.ui.client.store.ListStore;
|
53 |
import com.extjs.gxt.ui.client.store.ListStore;
|
54 |
import com.extjs.gxt.ui.client.store.Store;
|
54 |
import com.extjs.gxt.ui.client.store.Store;
|
55 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
55 |
import com.extjs.gxt.ui.client.store.StoreEvent;
|
56 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
56 |
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
57 |
import com.extjs.gxt.ui.client.widget.Info;
|
57 |
import com.extjs.gxt.ui.client.widget.Info;
|
58 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
58 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
59 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
59 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
60 |
import com.extjs.gxt.ui.client.widget.Text;
|
60 |
import com.extjs.gxt.ui.client.widget.Text;
|
61 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
61 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
62 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
62 |
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
|
63 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
63 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
64 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
64 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
65 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
65 |
import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
66 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
66 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
67 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
67 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
68 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
68 |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
69 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
69 |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
70 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
70 |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
|
71 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
71 |
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
72 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
72 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
73 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
73 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
74 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
74 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
75 |
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
75 |
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
76 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
76 |
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
77 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
77 |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
78 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
78 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
79 |
import com.google.gwt.core.client.GWT;
|
79 |
import com.google.gwt.core.client.GWT;
|
80 |
|
80 |
|
81 |
|
81 |
|
82 |
public class PublicationForm extends Formulaire implements Rafraichissable {
|
82 |
public class PublicationForm extends Formulaire implements Rafraichissable {
|
83 |
|
83 |
|
84 |
//-------------//
|
84 |
//-------------//
|
85 |
// ATTRIBUTS //
|
85 |
// ATTRIBUTS //
|
86 |
//-------------//
|
86 |
//-------------//
|
87 |
|
87 |
|
88 |
/** Publication **/
|
88 |
/** Publication **/
|
89 |
// on se sert d'un objet Publication lorsque l'on est en mode MODIFIER
|
89 |
// on se sert d'un objet Publication lorsque l'on est en mode MODIFIER
|
90 |
private Publication publication;
|
90 |
private Publication publication;
|
91 |
// on se sert de l'identifiant d'une publication lorsque l'on est en mode AJOUTER
|
91 |
// on se sert de l'identifiant d'une publication lorsque l'on est en mode AJOUTER
|
92 |
private String publicationId = null;
|
92 |
private String publicationId = null;
|
93 |
|
93 |
|
94 |
/** Auteurs **/
|
94 |
/** Auteurs **/
|
95 |
private PublicationAPersonneListe auteursInitialListe = null;
|
95 |
private PublicationAPersonneListe auteursInitialListe = null;
|
96 |
private PublicationAPersonneListe auteursAjoutes = null;
|
96 |
private PublicationAPersonneListe auteursAjoutes = null;
|
97 |
private PublicationAPersonneListe auteursSupprimes = null;
|
97 |
private PublicationAPersonneListe auteursSupprimes = null;
|
98 |
private PublicationAPersonneListe auteursModifies = null;
|
98 |
private PublicationAPersonneListe auteursModifies = null;
|
99 |
|
99 |
|
100 |
private ContentPanel auteursFieldset = null;
|
100 |
private ContentPanel auteursFieldset = null;
|
101 |
private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
|
101 |
private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
|
102 |
|
102 |
|
103 |
private FieldSet generalitesFieldset = null;
|
103 |
private FieldSet generalitesFieldset = null;
|
104 |
private TextField<String> titreChp = null;
|
104 |
private TextField<String> titreChp = null;
|
105 |
private TextField<String> collectionChp = null;
|
105 |
private TextField<String> collectionChp = null;
|
106 |
private TextField<String> uriChp = null;
|
106 |
private TextField<String> uriChp = null;
|
107 |
|
107 |
|
108 |
private FieldSet editionFieldset = null;
|
108 |
private FieldSet editionFieldset = null;
|
109 |
private ChampComboBoxRechercheTempsReelPaginable editeurCombobox = null;
|
109 |
private ChampComboBoxRechercheTempsReelPaginable editeurCombobox = null;
|
110 |
private TextField<String> datePublicationChp = null;
|
110 |
private TextField<String> datePublicationChp = null;
|
111 |
private TextField<String> tomeChp = null;
|
111 |
private TextField<String> tomeChp = null;
|
112 |
private TextField<String> fasciculeChp = null;
|
112 |
private TextField<String> fasciculeChp = null;
|
113 |
private TextField<String> pagesChp = null;
|
113 |
private TextField<String> pagesChp = null;
|
114 |
|
114 |
|
115 |
private LayoutContainer zoneHaut, zoneBas;
|
115 |
private LayoutContainer zoneHaut, zoneBas;
|
116 |
|
116 |
|
117 |
private ToolBar barreOutils = null;
|
117 |
private ToolBar barreOutils = null;
|
118 |
private GrillePaginable<ModelData> grilleAuteurs;
|
118 |
private GrillePaginable<ModelData> grilleAuteurs;
|
119 |
private ChampComboBoxRechercheTempsReelPaginable personnesSaisiesComboBox = null;
|
119 |
private ChampComboBoxRechercheTempsReelPaginable personnesSaisiesComboBox = null;
|
120 |
private Button personnesBoutonSupprimer = null;
|
120 |
private Button personnesBoutonSupprimer = null;
|
121 |
private Button personnesBoutonModifier = null;
|
121 |
private Button personnesBoutonModifier = null;
|
122 |
private Button boutonAuteurUp = null;
|
122 |
private Button boutonAuteurUp = null;
|
123 |
private Button boutonAuteurDown = null;
|
123 |
private Button boutonAuteurDown = null;
|
124 |
|
124 |
|
125 |
private FenetreForm fenetreFormulaire = null;
|
125 |
private FenetreForm fenetreFormulaire = null;
|
126 |
private Sequenceur sequenceur;
|
126 |
private Sequenceur sequenceur;
|
127 |
|
127 |
|
128 |
private String modeDeCreation = null;
|
128 |
private String modeDeCreation = null;
|
129 |
boolean changeOrderMarker = false;
|
129 |
boolean changeOrderMarker = false;
|
130 |
|
130 |
|
131 |
|
131 |
|
132 |
//+----------------------------------------------------------------------------------------------------------------+
|
132 |
//+----------------------------------------------------------------------------------------------------------------+
|
133 |
// Constructeurs
|
133 |
// Constructeurs
|
134 |
|
134 |
|
135 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
135 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
136 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
136 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
137 |
}
|
137 |
}
|
138 |
|
138 |
|
139 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
|
139 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
|
140 |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
|
140 |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
|
141 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
141 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
142 |
}
|
142 |
}
|
143 |
|
143 |
|
144 |
|
144 |
|
145 |
//+----------------------------------------------------------------------------------------------------------------+
|
145 |
//+----------------------------------------------------------------------------------------------------------------+
|
146 |
// Initialisation
|
146 |
// Initialisation
|
147 |
|
147 |
|
148 |
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
148 |
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
149 |
sequenceur = new Sequenceur();
|
149 |
sequenceur = new Sequenceur();
|
150 |
publication = new Publication();
|
150 |
publication = new Publication();
|
151 |
publication.setId(publicationId);
|
151 |
publication.setId(publicationId);
|
152 |
this.publicationId = publicationId;
|
152 |
this.publicationId = publicationId;
|
153 |
auteursInitialListe = new PublicationAPersonneListe();
|
153 |
auteursInitialListe = new PublicationAPersonneListe();
|
154 |
initialiserAuteurs(); // Crée les listes d'auteurs ajoutés et supprimés
|
154 |
initialiserAuteurs(); // Crée les listes d'auteurs ajoutés et supprimés
|
155 |
|
155 |
|
156 |
// Si 'publicationId' est vide alors on est en mode "AJOUTER", sinon on est en mode "MODIFIER"
|
156 |
// Si 'publicationId' est vide alors on est en mode "AJOUTER", sinon on est en mode "MODIFIER"
|
157 |
modeDeCreation = (UtilString.isEmpty(publicationId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
157 |
modeDeCreation = (UtilString.isEmpty(publicationId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
158 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
|
158 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
|
159 |
panneauFormulaire.setLayout(new RowLayout());
|
159 |
panneauFormulaire.setLayout(new RowLayout());
|
160 |
panneauFormulaire.setStyleAttribute("padding", "0");
|
160 |
panneauFormulaire.setStyleAttribute("padding", "0");
|
161 |
panneauFormulaire.setHeight(600);
|
161 |
panneauFormulaire.setHeight(600);
|
162 |
|
162 |
|
163 |
zoneHaut = new LayoutContainer(new FitLayout());
|
163 |
zoneHaut = new LayoutContainer(new FitLayout());
|
164 |
zoneBas = new LayoutContainer(new FlowLayout());
|
164 |
zoneBas = new LayoutContainer(new FlowLayout());
|
165 |
panneauFormulaire.add(zoneHaut, new RowData(0.99, 0.45));
|
165 |
panneauFormulaire.add(zoneHaut, new RowData(0.99, 0.45));
|
166 |
panneauFormulaire.add(zoneBas, new RowData(0.99, 0.55));
|
166 |
panneauFormulaire.add(zoneBas, new RowData(0.99, 0.55));
|
167 |
panneauFormulaire.setScrollMode(Scroll.AUTO);
|
167 |
panneauFormulaire.setScrollMode(Scroll.AUTO);
|
168 |
genererTitreFormulaire();
|
168 |
genererTitreFormulaire();
|
169 |
|
169 |
|
170 |
creerZoneAuteurs();
|
170 |
creerZoneAuteurs();
|
171 |
zoneHaut.add(auteursFieldset);
|
171 |
zoneHaut.add(auteursFieldset);
|
172 |
|
172 |
|
173 |
creerZoneGeneralites();
|
173 |
creerZoneGeneralites();
|
174 |
zoneBas.add(generalitesFieldset);
|
174 |
zoneBas.add(generalitesFieldset);
|
175 |
|
175 |
|
176 |
creerZoneEdition();
|
176 |
creerZoneEdition();
|
177 |
zoneBas.add(editionFieldset);
|
177 |
zoneBas.add(editionFieldset);
|
178 |
|
178 |
|
179 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
179 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
180 |
mediateurCourrant.selectionnerPublication(this, publicationId, sequenceur);
|
180 |
mediateurCourrant.selectionnerPublication(this, publicationId, sequenceur);
|
181 |
sequenceur.enfilerRafraichissement(this, new Information("chargement_modifier_ok"));
|
181 |
sequenceur.enfilerRafraichissement(this, new Information("chargement_modifier_ok"));
|
182 |
}
|
182 |
}
|
183 |
}
|
183 |
}
|
184 |
|
184 |
|
185 |
private void initialiserAuteurs() {
|
185 |
private void initialiserAuteurs() {
|
186 |
auteursAjoutes = new PublicationAPersonneListe();
|
186 |
auteursAjoutes = new PublicationAPersonneListe();
|
187 |
auteursSupprimes = new PublicationAPersonneListe();
|
187 |
auteursSupprimes = new PublicationAPersonneListe();
|
188 |
auteursModifies = new PublicationAPersonneListe();
|
188 |
auteursModifies = new PublicationAPersonneListe();
|
189 |
}
|
189 |
}
|
190 |
|
190 |
|
191 |
//+----------------------------------------------------------------------------------------------------------------+
|
191 |
//+----------------------------------------------------------------------------------------------------------------+
|
192 |
// User Interface
|
192 |
// User Interface
|
193 |
|
193 |
|
194 |
private ToolBar creerBarreOutilsGrille() {
|
194 |
private ToolBar creerBarreOutilsGrille() {
|
195 |
ToolBar barreOutils = new ToolBar();
|
195 |
ToolBar barreOutils = new ToolBar();
|
196 |
|
196 |
|
197 |
Button ajouterBouton = creerBoutonAjouter();
|
197 |
Button ajouterBouton = creerBoutonAjouter();
|
198 |
barreOutils.add(ajouterBouton);
|
198 |
barreOutils.add(ajouterBouton);
|
199 |
|
199 |
|
200 |
creerComboBoxPersonnesSaisies();
|
200 |
creerComboBoxPersonnesSaisies();
|
201 |
barreOutils.add(personnesSaisiesComboBox);
|
201 |
barreOutils.add(personnesSaisiesComboBox);
|
202 |
|
202 |
|
203 |
barreOutils.add(new SeparatorToolItem());
|
203 |
barreOutils.add(new SeparatorToolItem());
|
204 |
|
204 |
|
205 |
personnesBoutonModifier = creerBoutonModifier();
|
205 |
personnesBoutonModifier = creerBoutonModifier();
|
206 |
barreOutils.add(personnesBoutonModifier);
|
206 |
barreOutils.add(personnesBoutonModifier);
|
207 |
|
207 |
|
208 |
barreOutils.add(new SeparatorToolItem());
|
208 |
barreOutils.add(new SeparatorToolItem());
|
209 |
|
209 |
|
210 |
personnesBoutonSupprimer = creerBoutonSupprimer();
|
210 |
personnesBoutonSupprimer = creerBoutonSupprimer();
|
211 |
barreOutils.add(personnesBoutonSupprimer);
|
211 |
barreOutils.add(personnesBoutonSupprimer);
|
212 |
|
212 |
|
213 |
barreOutils.add(new SeparatorToolItem());
|
213 |
barreOutils.add(new SeparatorToolItem());
|
214 |
|
214 |
|
215 |
Button rafraichirBouton = creerBoutonRafraichir();
|
215 |
Button rafraichirBouton = creerBoutonRafraichir();
|
216 |
barreOutils.add(rafraichirBouton);
|
216 |
barreOutils.add(rafraichirBouton);
|
217 |
|
217 |
|
218 |
barreOutils.add(new SeparatorToolItem());
|
218 |
barreOutils.add(new SeparatorToolItem());
|
219 |
|
219 |
|
220 |
barreOutils.add(new Text(i18nC.deplacerAuteur()));
|
220 |
barreOutils.add(new Text(i18nC.deplacerAuteur()));
|
221 |
boutonAuteurUp = creerBoutonAuteurUp();
|
221 |
boutonAuteurUp = creerBoutonAuteurUp();
|
222 |
barreOutils.add(boutonAuteurUp);
|
222 |
barreOutils.add(boutonAuteurUp);
|
223 |
boutonAuteurDown = creerBoutonAuteurDown();
|
223 |
boutonAuteurDown = creerBoutonAuteurDown();
|
224 |
barreOutils.add(boutonAuteurDown);
|
224 |
barreOutils.add(boutonAuteurDown);
|
225 |
|
225 |
|
226 |
return barreOutils;
|
226 |
return barreOutils;
|
227 |
}
|
227 |
}
|
228 |
|
228 |
|
229 |
public void actualiserEtatBoutonsBarreOutils() {
|
229 |
public void actualiserEtatBoutonsBarreOutils() {
|
230 |
// Activation des boutons si la grille contient un élément
|
230 |
// Activation des boutons si la grille contient un élément
|
231 |
if (grilleAuteurs.getStore().getCount() > 0) {
|
231 |
if (grilleAuteurs.getStore().getCount() > 0) {
|
232 |
personnesBoutonSupprimer.enable();
|
232 |
personnesBoutonSupprimer.enable();
|
233 |
personnesBoutonModifier.enable();
|
233 |
personnesBoutonModifier.enable();
|
234 |
}
|
234 |
}
|
235 |
// Désactivation des boutons si la grille ne contient plus d'élément
|
235 |
// Désactivation des boutons si la grille ne contient plus d'élément
|
236 |
if (grilleAuteurs.getStore().getCount() == 0) {
|
236 |
if (grilleAuteurs.getStore().getCount() == 0) {
|
237 |
personnesBoutonSupprimer.disable();
|
237 |
personnesBoutonSupprimer.disable();
|
238 |
personnesBoutonModifier.disable();
|
238 |
personnesBoutonModifier.disable();
|
239 |
}
|
239 |
}
|
240 |
}
|
240 |
}
|
241 |
|
241 |
|
242 |
private Button creerBoutonAuteurUp() {
|
242 |
private Button creerBoutonAuteurUp() {
|
243 |
Button bouton = new Button();
|
243 |
Button bouton = new Button();
|
244 |
bouton.setIcon(Images.ICONES.arrowUp());
|
244 |
bouton.setIcon(Images.ICONES.arrowUp());
|
245 |
bouton.setEnabled(false);
|
245 |
bouton.setEnabled(false);
|
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 |
if (grilleAuteurs.getGrille().getSelectionModel().getSelectedItem() != null) {
|
248 |
if (grilleAuteurs.getGrille().getSelectionModel().getSelectedItem() != null) {
|
249 |
mettreAJourOrdreAuteur(-1);
|
249 |
mettreAJourOrdreAuteur(-1);
|
250 |
}
|
250 |
}
|
251 |
}
|
251 |
}
|
252 |
});
|
252 |
});
|
253 |
return bouton;
|
253 |
return bouton;
|
254 |
}
|
254 |
}
|
255 |
|
255 |
|
256 |
private Button creerBoutonAuteurDown() {
|
256 |
private Button creerBoutonAuteurDown() {
|
257 |
Button bouton = new Button();
|
257 |
Button bouton = new Button();
|
258 |
bouton.setIcon(Images.ICONES.arrowDown());
|
258 |
bouton.setIcon(Images.ICONES.arrowDown());
|
259 |
bouton.setEnabled(false);
|
259 |
bouton.setEnabled(false);
|
260 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
260 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
261 |
public void componentSelected(ButtonEvent ce) {
|
261 |
public void componentSelected(ButtonEvent ce) {
|
262 |
if (grilleAuteurs.getSelectionModel().getSelectedItem() != null) {
|
262 |
if (grilleAuteurs.getSelectionModel().getSelectedItem() != null) {
|
263 |
mettreAJourOrdreAuteur(+1);
|
263 |
mettreAJourOrdreAuteur(+1);
|
264 |
}
|
264 |
}
|
265 |
}
|
265 |
}
|
266 |
});
|
266 |
});
|
267 |
return bouton;
|
267 |
return bouton;
|
268 |
}
|
268 |
}
|
269 |
|
269 |
|
270 |
private void formaterOrdreAuteurs() {
|
270 |
private void formaterOrdreAuteurs() {
|
271 |
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
|
271 |
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
|
272 |
Iterator<ModelData> itAuteurs = auteurs.iterator();
|
272 |
Iterator<ModelData> itAuteurs = auteurs.iterator();
|
273 |
while (itAuteurs.hasNext()) {
|
273 |
while (itAuteurs.hasNext()) {
|
274 |
ModelData selection = itAuteurs.next();
|
274 |
ModelData selection = itAuteurs.next();
|
275 |
PublicationAPersonne pap = new PublicationAPersonne(selection, false);
|
275 |
PublicationAPersonne pap = new PublicationAPersonne(selection, false);
|
276 |
|
276 |
|
277 |
String ordre = String.valueOf(grilleAuteurs.getStore().indexOf(selection) + 1);
|
277 |
String ordre = String.valueOf(grilleAuteurs.getStore().indexOf(selection) + 1);
|
278 |
if (pap.getOrdreAuteurs() != ordre) {
|
278 |
if (pap.getOrdreAuteurs() != ordre) {
|
279 |
selection.set("_ordre_", ordre);
|
279 |
selection.set("_ordre_", ordre);
|
280 |
grilleAuteurs.getStore().update(selection);
|
280 |
grilleAuteurs.getStore().update(selection);
|
281 |
pap.setOrdreAuteurs(ordre);
|
281 |
pap.setOrdreAuteurs(ordre);
|
282 |
auteursModifies.put(pap.getId(), pap);
|
282 |
auteursModifies.put(pap.getId(), pap);
|
283 |
}
|
283 |
}
|
284 |
}
|
284 |
}
|
285 |
}
|
285 |
}
|
286 |
|
286 |
|
287 |
private void mettreAJourOrdreAuteur(int monterOuDescendre) {
|
287 |
private void mettreAJourOrdreAuteur(int monterOuDescendre) {
|
288 |
ModelData publiAPersonneSelectionnee = grilleAuteurs.getSelectionModel().getSelectedItem();
|
288 |
ModelData publiAPersonneSelectionnee = grilleAuteurs.getSelectionModel().getSelectedItem();
|
289 |
int index = grilleAuteurs.getStore().indexOf(publiAPersonneSelectionnee);
|
289 |
int index = grilleAuteurs.getStore().indexOf(publiAPersonneSelectionnee);
|
290 |
int nouvelIndex = index + monterOuDescendre;
|
290 |
int nouvelIndex = index + monterOuDescendre;
|
291 |
|
291 |
|
292 |
if (verifierOrdreAuteur(nouvelIndex)) {
|
292 |
if (verifierOrdreAuteur(nouvelIndex)) {
|
293 |
// le marqueur suivant est obligatoire sinon les évènements liés au magasin se
|
293 |
// le marqueur suivant est obligatoire sinon les évènements liés au magasin se
|
294 |
// déclenchent et posent problème
|
294 |
// déclenchent et posent problème
|
295 |
changeOrderMarker = true;
|
295 |
changeOrderMarker = true;
|
296 |
|
296 |
|
297 |
int indexAPermuter = index + monterOuDescendre;
|
297 |
int indexAPermuter = index + monterOuDescendre;
|
298 |
ModelData publiAPersonneSwitch = grilleAuteurs.getStore().getAt(indexAPermuter);
|
298 |
ModelData publiAPersonneSwitch = grilleAuteurs.getStore().getAt(indexAPermuter);
|
299 |
String ordreAPermuter = String.valueOf((indexAPermuter + 1) - monterOuDescendre);
|
299 |
String ordreAPermuter = String.valueOf((indexAPermuter + 1) - monterOuDescendre);
|
300 |
publiAPersonneSwitch.set("_ordre_", ordreAPermuter);
|
300 |
publiAPersonneSwitch.set("_ordre_", ordreAPermuter);
|
301 |
grilleAuteurs.getStore().update(publiAPersonneSwitch);
|
301 |
grilleAuteurs.getStore().update(publiAPersonneSwitch);
|
302 |
PublicationAPersonne papSwitch = new PublicationAPersonne(publiAPersonneSwitch, false);
|
302 |
PublicationAPersonne papSwitch = new PublicationAPersonne(publiAPersonneSwitch, false);
|
303 |
papSwitch.setOrdreAuteurs(ordreAPermuter);
|
303 |
papSwitch.setOrdreAuteurs(ordreAPermuter);
|
304 |
auteursModifies.put(papSwitch.getId(), papSwitch);
|
304 |
auteursModifies.put(papSwitch.getId(), papSwitch);
|
305 |
|
305 |
|
306 |
grilleAuteurs.getStore().remove(publiAPersonneSelectionnee);
|
306 |
grilleAuteurs.getStore().remove(publiAPersonneSelectionnee);
|
307 |
String nouvelOrdre = String.valueOf((index + 1) + monterOuDescendre);
|
307 |
String nouvelOrdre = String.valueOf((index + 1) + monterOuDescendre);
|
308 |
publiAPersonneSelectionnee.set("_ordre_", nouvelOrdre);
|
308 |
publiAPersonneSelectionnee.set("_ordre_", nouvelOrdre);
|
309 |
grilleAuteurs.getStore().insert(publiAPersonneSelectionnee, nouvelIndex);
|
309 |
grilleAuteurs.getStore().insert(publiAPersonneSelectionnee, nouvelIndex);
|
310 |
PublicationAPersonne papSelectionnee = new PublicationAPersonne(publiAPersonneSelectionnee, false);
|
310 |
PublicationAPersonne papSelectionnee = new PublicationAPersonne(publiAPersonneSelectionnee, false);
|
311 |
papSelectionnee.setOrdreAuteurs(nouvelOrdre);
|
311 |
papSelectionnee.setOrdreAuteurs(nouvelOrdre);
|
312 |
auteursModifies.put(papSelectionnee.getId(), papSelectionnee);
|
312 |
auteursModifies.put(papSelectionnee.getId(), papSelectionnee);
|
313 |
changeOrderMarker = false;
|
313 |
changeOrderMarker = false;
|
314 |
|
314 |
|
315 |
grilleAuteurs.getSelectionModel().select(nouvelIndex, false);
|
315 |
grilleAuteurs.getSelectionModel().select(nouvelIndex, false);
|
316 |
}
|
316 |
}
|
317 |
}
|
317 |
}
|
318 |
|
318 |
|
319 |
private boolean verifierOrdreAuteur(int nouvelIndex) {
|
319 |
private boolean verifierOrdreAuteur(int nouvelIndex) {
|
320 |
int nbrElement = grilleAuteurs.getStore().getCount();
|
320 |
int nbrElement = grilleAuteurs.getStore().getCount();
|
321 |
boolean ok = true;
|
321 |
boolean ok = true;
|
322 |
if (nouvelIndex < 0 || nouvelIndex >= nbrElement) {
|
322 |
if (nouvelIndex < 0 || nouvelIndex >= nbrElement) {
|
323 |
ok = false;
|
323 |
ok = false;
|
324 |
}
|
324 |
}
|
325 |
return ok;
|
325 |
return ok;
|
326 |
}
|
326 |
}
|
327 |
|
327 |
|
328 |
private void activerBoutonsOrdreAuteur() {
|
328 |
private void activerBoutonsOrdreAuteur() {
|
329 |
ModelData papSelectionnee = grilleAuteurs.getGrille().getSelectionModel().getSelectedItem();
|
329 |
ModelData papSelectionnee = grilleAuteurs.getGrille().getSelectionModel().getSelectedItem();
|
330 |
int index = grilleAuteurs.getStore().indexOf(papSelectionnee);
|
330 |
int index = grilleAuteurs.getStore().indexOf(papSelectionnee);
|
331 |
|
331 |
|
332 |
if (index >= 1) {
|
332 |
if (index >= 1) {
|
333 |
boutonAuteurUp.setEnabled(true);
|
333 |
boutonAuteurUp.setEnabled(true);
|
334 |
} else {
|
334 |
} else {
|
335 |
boutonAuteurUp.setEnabled(false);
|
335 |
boutonAuteurUp.setEnabled(false);
|
336 |
}
|
336 |
}
|
337 |
|
337 |
|
338 |
if ((index+1) < grilleAuteurs.getStore().getCount()) {
|
338 |
if ((index+1) < grilleAuteurs.getStore().getCount()) {
|
339 |
boutonAuteurDown.setEnabled(true);
|
339 |
boutonAuteurDown.setEnabled(true);
|
340 |
} else {
|
340 |
} else {
|
341 |
boutonAuteurDown.setEnabled(false);
|
341 |
boutonAuteurDown.setEnabled(false);
|
342 |
}
|
342 |
}
|
343 |
}
|
343 |
}
|
344 |
|
344 |
|
345 |
private Button creerBoutonAjouter() {
|
345 |
private Button creerBoutonAjouter() {
|
346 |
Button bouton = new Button(i18nC.ajouter());
|
346 |
Button bouton = new Button(i18nC.ajouter());
|
347 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
347 |
bouton.setIcon(Images.ICONES.vcardAjouter());
|
348 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
348 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
349 |
public void componentSelected(ButtonEvent ce) {
|
349 |
public void componentSelected(ButtonEvent ce) {
|
350 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
|
350 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER);
|
351 |
fenetreFormulaire.show();
|
351 |
fenetreFormulaire.show();
|
352 |
}
|
352 |
}
|
353 |
});
|
353 |
});
|
354 |
return bouton;
|
354 |
return bouton;
|
355 |
}
|
355 |
}
|
356 |
|
356 |
|
357 |
private Button creerBoutonModifier() {
|
357 |
private Button creerBoutonModifier() {
|
358 |
Button bouton = new Button(i18nC.modifier());
|
358 |
Button bouton = new Button(i18nC.modifier());
|
359 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
359 |
bouton.setIcon(Images.ICONES.vcardModifier());
|
360 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
360 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
361 |
public void componentSelected(ButtonEvent ce) {
|
361 |
public void componentSelected(ButtonEvent ce) {
|
362 |
Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
|
362 |
Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
|
363 |
|
363 |
|
364 |
if (personneSaisieSelectionnee == null) {
|
364 |
if (personneSaisieSelectionnee == null) {
|
365 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
|
365 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication());
|
366 |
} else {
|
366 |
} else {
|
367 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
|
367 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER);
|
368 |
fenetreFormulaire.show();
|
368 |
fenetreFormulaire.show();
|
369 |
}
|
369 |
}
|
370 |
}
|
370 |
}
|
371 |
});
|
371 |
});
|
372 |
return bouton;
|
372 |
return bouton;
|
373 |
}
|
373 |
}
|
374 |
|
374 |
|
375 |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
|
375 |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) {
|
376 |
String personneId = null;
|
376 |
String personneId = null;
|
377 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
377 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
378 |
Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
|
378 |
Personne personneSaisieSelectionnee = new PublicationAPersonne(grilleAuteurs.getSelectionModel().getSelectedItem(), false).getPersonne();
|
379 |
personneId = personneSaisieSelectionnee.getId();
|
379 |
personneId = personneSaisieSelectionnee.getId();
|
380 |
}
|
380 |
}
|
381 |
|
381 |
|
382 |
final FenetreForm fenetre = new FenetreForm("");
|
382 |
final FenetreForm fenetre = new FenetreForm("");
|
383 |
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
|
383 |
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId);
|
384 |
fenetre.add(formulaire);
|
384 |
fenetre.add(formulaire);
|
385 |
return fenetre;
|
385 |
return fenetre;
|
386 |
}
|
386 |
}
|
387 |
|
387 |
|
388 |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
|
388 |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) {
|
389 |
PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
|
389 |
PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this);
|
390 |
FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
|
390 |
FormPanel panneauFormulaire = formulairePersonne.getFormulaire();
|
391 |
fenetre.setHeading(panneauFormulaire.getHeading());
|
391 |
fenetre.setHeading(panneauFormulaire.getHeading());
|
392 |
panneauFormulaire.setHeaderVisible(false);
|
392 |
panneauFormulaire.setHeaderVisible(false);
|
393 |
panneauFormulaire.setTopComponent(null);
|
393 |
panneauFormulaire.setTopComponent(null);
|
394 |
|
394 |
|
395 |
// 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.
|
395 |
// 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.
|
396 |
panneauFormulaire.getBottomComponent().hide();
|
396 |
panneauFormulaire.getBottomComponent().hide();
|
397 |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
|
397 |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne);
|
398 |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
|
398 |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur);
|
399 |
fenetre.setBottomComponent(barreValidation);
|
399 |
fenetre.setBottomComponent(barreValidation);
|
400 |
|
400 |
|
401 |
return formulairePersonne;
|
401 |
return formulairePersonne;
|
402 |
}
|
402 |
}
|
403 |
|
403 |
|
404 |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
|
404 |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) {
|
405 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
405 |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() {
|
406 |
public void componentSelected(ButtonEvent ce) {
|
406 |
public void componentSelected(ButtonEvent ce) {
|
407 |
String code = ((Button) ce.getComponent()).getData("code");
|
407 |
String code = ((Button) ce.getComponent()).getData("code");
|
408 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
408 |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) {
|
409 |
if (formulaire.soumettreFormulaire()) {
|
409 |
if (formulaire.soumettreFormulaire()) {
|
410 |
fenetre.hide();
|
410 |
fenetre.hide();
|
411 |
}
|
411 |
}
|
412 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
412 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) {
|
413 |
formulaire.soumettreFormulaire();
|
413 |
formulaire.soumettreFormulaire();
|
414 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
414 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) {
|
415 |
fenetre.hide();
|
415 |
fenetre.hide();
|
416 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
|
416 |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) {
|
417 |
fenetreFormulaire.hide();
|
417 |
fenetreFormulaire.hide();
|
418 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode);
|
418 |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode);
|
419 |
fenetreFormulaire.show();
|
419 |
fenetreFormulaire.show();
|
420 |
}
|
420 |
}
|
421 |
}
|
421 |
}
|
422 |
};
|
422 |
};
|
423 |
|
423 |
|
424 |
return ecouteur;
|
424 |
return ecouteur;
|
425 |
}
|
425 |
}
|
426 |
|
426 |
|
427 |
private Button creerBoutonSupprimer() {
|
427 |
private Button creerBoutonSupprimer() {
|
428 |
Button bouton = new Button(i18nC.supprimer());
|
428 |
Button bouton = new Button(i18nC.supprimer());
|
429 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
429 |
bouton.setIcon(Images.ICONES.vcardSupprimer());
|
430 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
430 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
431 |
public void componentSelected(ButtonEvent ce) {
|
431 |
public void componentSelected(ButtonEvent ce) {
|
432 |
supprimerDansGrille();
|
432 |
supprimerDansGrille();
|
433 |
}
|
433 |
}
|
434 |
});
|
434 |
});
|
435 |
return bouton;
|
435 |
return bouton;
|
436 |
}
|
436 |
}
|
437 |
|
437 |
|
438 |
private Button creerBoutonRafraichir() {
|
438 |
private Button creerBoutonRafraichir() {
|
439 |
Button bouton = new Button(i18nC.rafraichir());
|
439 |
Button bouton = new Button(i18nC.rafraichir());
|
440 |
bouton.setIcon(Images.ICONES.rafraichir());
|
440 |
bouton.setIcon(Images.ICONES.rafraichir());
|
441 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
441 |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
442 |
public void componentSelected(ButtonEvent ce) {
|
442 |
public void componentSelected(ButtonEvent ce) {
|
443 |
actualiserGrille();
|
443 |
actualiserGrille();
|
444 |
}
|
444 |
}
|
445 |
});
|
445 |
});
|
446 |
return bouton;
|
446 |
return bouton;
|
447 |
}
|
447 |
}
|
448 |
|
448 |
|
449 |
private void actualiserGrille() {
|
449 |
private void actualiserGrille() {
|
450 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
450 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
451 |
// FIXME : c'est la merde
|
451 |
// FIXME : c'est la merde
|
452 |
grilleAuteurs.reload();
|
452 |
grilleAuteurs.reload();
|
453 |
} else {
|
453 |
} else {
|
454 |
grilleAuteurs.getStore().removeAll();
|
454 |
grilleAuteurs.getStore().removeAll();
|
455 |
layout();
|
455 |
layout();
|
456 |
}
|
456 |
}
|
457 |
}
|
457 |
}
|
458 |
|
458 |
|
459 |
private void creerComboBoxPersonnesSaisies() {
|
459 |
private void creerComboBoxPersonnesSaisies() {
|
460 |
ModelType modelTypePersonnes = new ModelType();
|
460 |
ModelType modelTypePersonnes = new ModelType();
|
461 |
modelTypePersonnes.setRoot("personnes");
|
461 |
modelTypePersonnes.setRoot("personnes");
|
462 |
modelTypePersonnes.setTotalName("nbElements");
|
462 |
modelTypePersonnes.setTotalName("nbElements");
|
463 |
modelTypePersonnes.addField("cp_fmt_nom_complet");
|
463 |
modelTypePersonnes.addField("cp_fmt_nom_complet");
|
464 |
modelTypePersonnes.addField("cp_nom");
|
464 |
modelTypePersonnes.addField("cp_nom");
|
465 |
modelTypePersonnes.addField("cp_prenom");
|
465 |
modelTypePersonnes.addField("cp_prenom");
|
466 |
modelTypePersonnes.addField("cp_id_personne");
|
466 |
modelTypePersonnes.addField("cp_id_personne");
|
467 |
modelTypePersonnes.addField("cp_code_postal");
|
467 |
modelTypePersonnes.addField("cp_code_postal");
|
468 |
modelTypePersonnes.addField("cp_ville");
|
468 |
modelTypePersonnes.addField("cp_ville");
|
469 |
modelTypePersonnes.addField("cp_truk_courriel");
|
469 |
modelTypePersonnes.addField("cp_truk_courriel");
|
470 |
|
470 |
|
471 |
String displayNamePersonnes = "cp_fmt_nom_complet";
|
471 |
String displayNamePersonnes = "cp_fmt_nom_complet";
|
472 |
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
|
472 |
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null);
|
473 |
|
473 |
|
474 |
personnesSaisiesComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
|
474 |
personnesSaisiesComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes);
|
475 |
|
475 |
|
476 |
personnesSaisiesComboBox.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
|
476 |
personnesSaisiesComboBox.getCombo().addListener(Events.Select, new Listener<BaseEvent>() {
|
477 |
public void handleEvent(BaseEvent be) {
|
477 |
public void handleEvent(BaseEvent be) {
|
478 |
if (personnesSaisiesComboBox.getValeur() instanceof ModelData) {
|
478 |
if (personnesSaisiesComboBox.getValeur() instanceof ModelData) {
|
479 |
// N'ajouter l'auteur que s'il n'est pas déjà présent dans la grille et dans les valeurs initiales
|
479 |
// N'ajouter l'auteur que s'il n'est pas déjà présent dans la grille et dans les valeurs initiales
|
480 |
Personne personneSaisieSelectionnee = new Personne(personnesSaisiesComboBox.getValeur());
|
480 |
Personne personneSaisieSelectionnee = new Personne(personnesSaisiesComboBox.getValeur());
|
481 |
Log.debug("Récupération info combo :"+personneSaisieSelectionnee.toString());
|
481 |
Log.debug("Récupération info combo :"+personneSaisieSelectionnee.toString());
|
482 |
PublicationAPersonne pap = new PublicationAPersonne(aDonnee.GARDER_PREFIXE);
|
482 |
PublicationAPersonne pap = new PublicationAPersonne(aDonnee.GARDER_PREFIXE);
|
483 |
pap.setPersonne(personneSaisieSelectionnee, aDonnee.INTEGRER_PROPRIETES);
|
483 |
pap.setPersonne(personneSaisieSelectionnee, aDonnee.INTEGRER_PROPRIETES);
|
484 |
pap.setOrdreAuteurs(String.valueOf(grilleAuteurs.getStore().getCount()+1));
|
484 |
pap.setOrdreAuteurs(String.valueOf(grilleAuteurs.getStore().getCount()+1));
|
485 |
if (modeDeCreation != Formulaire.MODE_AJOUTER) {
|
485 |
if (modeDeCreation != Formulaire.MODE_AJOUTER) {
|
486 |
pap.setPublicationLiee(publication);
|
486 |
pap.setPublicationLiee(publication);
|
487 |
pap.setIdPublication(publicationId);
|
487 |
pap.setIdPublication(publicationId);
|
488 |
}
|
488 |
}
|
489 |
pap.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
489 |
pap.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
490 |
Log.debug("Récupération info combo pap id :"+pap.getId());
|
490 |
Log.debug("Récupération info combo pap id :"+pap.getId());
|
491 |
|
491 |
|
492 |
if (ajouterDansGrille(pap)) {
|
492 |
if (ajouterDansGrille(pap)) {
|
493 |
personnesSaisiesComboBox.getCombo().setValue(null);
|
493 |
personnesSaisiesComboBox.getCombo().setValue(null);
|
494 |
}
|
494 |
}
|
495 |
}
|
495 |
}
|
496 |
}
|
496 |
}
|
497 |
});
|
497 |
});
|
498 |
}
|
498 |
}
|
499 |
|
499 |
|
500 |
private boolean ajouterDansGrille(PublicationAPersonne pap) {
|
500 |
private boolean ajouterDansGrille(PublicationAPersonne pap) {
|
501 |
return ajouterDansGrille(pap, grilleAuteurs.getStore().getCount());
|
501 |
return ajouterDansGrille(pap, grilleAuteurs.getStore().getCount());
|
502 |
}
|
502 |
}
|
503 |
|
503 |
|
504 |
private boolean ajouterDansGrille(PublicationAPersonne pap, int index) {
|
504 |
private boolean ajouterDansGrille(PublicationAPersonne pap, int index) {
|
505 |
boolean ok = false;
|
505 |
boolean ok = false;
|
506 |
if (pap != null) {
|
506 |
if (pap != null) {
|
507 |
Log.debug("Début ajout dans grille :"+pap.toString());
|
507 |
Log.debug("Début ajout dans grille :"+pap.toString());
|
508 |
if (grilleAuteurs.getStore().contains((ModelData) pap)) {
|
508 |
if (grilleAuteurs.getStore().contains((ModelData) pap)) {
|
509 |
InfoLogger.display("Information", "La personne choisie existe déjà dans la liste d'auteurs.");
|
509 |
InfoLogger.display("Information", "La personne choisie existe déjà dans la liste d'auteurs.");
|
510 |
} else {
|
510 |
} else {
|
511 |
// 1) si elle ne fait pas partie des initiaux, ajouter à la liste à ajouter
|
511 |
// 1) si elle ne fait pas partie des initiaux, ajouter à la liste à ajouter
|
512 |
if (!auteursInitialListe.containsValue(pap)) {
|
512 |
if (!auteursInitialListe.containsValue(pap)) {
|
513 |
auteursAjoutes.put(pap.getId(), pap);
|
513 |
auteursAjoutes.put(pap.getId(), pap);
|
514 |
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été ajouté à la liste des ajoutés (il ne fait pas parti de la liste initiale).");
|
514 |
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été ajouté à la liste des ajoutés (il ne fait pas parti de la liste initiale).");
|
515 |
}
|
515 |
}
|
516 |
|
516 |
|
517 |
// L'enlever de la liste à supprimer
|
517 |
// L'enlever de la liste à supprimer
|
518 |
if (auteursSupprimes.containsValue(pap)) {
|
518 |
if (auteursSupprimes.containsValue(pap)) {
|
519 |
auteursSupprimes.remove(pap);
|
519 |
auteursSupprimes.remove(pap);
|
520 |
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été retiré de la liste des supprimés.");
|
520 |
Log.debug("Ajout dans grille -> auteur '"+pap.getId()+"' a été retiré de la liste des supprimés.");
|
521 |
}
|
521 |
}
|
522 |
|
522 |
|
523 |
// 2) Ajouter a la grille
|
523 |
// 2) Ajouter a la grille
|
524 |
grilleAuteurs.getStore().insert((ModelData) pap, index);
|
524 |
grilleAuteurs.getStore().insert((ModelData) pap, index);
|
525 |
grilleAuteurs.getSelectionModel().select(index, false);
|
525 |
grilleAuteurs.getSelectionModel().select(index, false);
|
526 |
ok = true;
|
526 |
ok = true;
|
527 |
}
|
527 |
}
|
528 |
}
|
528 |
}
|
529 |
return ok;
|
529 |
return ok;
|
530 |
}
|
530 |
}
|
531 |
|
531 |
|
532 |
private void supprimerDansGrille() {
|
532 |
private void supprimerDansGrille() {
|
533 |
ModelData donneeSelectionnee = grilleAuteurs.getSelectionModel().getSelectedItem();
|
533 |
List<ModelData> listeDonneesSelectionnees = grilleAuteurs.getSelectionModel().getSelectedItems();
|
- |
|
534 |
for (ModelData donneeSelectionnee : listeDonneesSelectionnees) {
|
- |
|
535 |
supprimerAuteurDansGrille(donneeSelectionnee);
|
- |
|
536 |
}
|
- |
|
537 |
}
|
- |
|
538 |
|
- |
|
539 |
private void supprimerAuteurDansGrille(ModelData donneeSelectionnee) {
|
534 |
PublicationAPersonne personneSelectionnee = new PublicationAPersonne(donneeSelectionnee, aDonnee.GARDER_PREFIXE);
|
540 |
PublicationAPersonne personneSelectionnee = new PublicationAPersonne(donneeSelectionnee, aDonnee.GARDER_PREFIXE);
|
535 |
Log.debug("Début supprimer auteur dans grille : "+personneSelectionnee.toString());
|
541 |
Log.debug("Début supprimer auteur dans grille : "+personneSelectionnee.toString());
|
536 |
if (personneSelectionnee.getId() == null) {
|
542 |
if (personneSelectionnee.getId() == null) {
|
537 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerAuteur());
|
543 |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerAuteur());
|
538 |
} else {
|
544 |
} else {
|
539 |
// 1) Ajouter a la liste des personne à supprimer uniquement si est présente dans la liste initiale
|
545 |
// 1) Ajouter a la liste des personne à supprimer uniquement si est présente dans la liste initiale
|
540 |
if (auteursInitialListe.containsKey(personneSelectionnee.getId())) {
|
546 |
if (auteursInitialListe.containsKey(personneSelectionnee.getId())) {
|
541 |
auteursSupprimes.put(personneSelectionnee.getId(), personneSelectionnee);
|
547 |
auteursSupprimes.put(personneSelectionnee.getId(), personneSelectionnee);
|
542 |
Log.debug("Ajout Personne à supprimer : "+auteursSupprimes.toString());
|
548 |
Log.debug("Ajout Personne à supprimer : "+auteursSupprimes.toString());
|
543 |
}
|
549 |
}
|
544 |
|
550 |
|
545 |
if (auteursAjoutes.containsKey(personneSelectionnee.getId())) {
|
551 |
if (auteursAjoutes.containsKey(personneSelectionnee.getId())) {
|
546 |
auteursAjoutes.remove(personneSelectionnee.getId());
|
552 |
auteursAjoutes.remove(personneSelectionnee.getId());
|
547 |
}
|
553 |
}
|
548 |
|
554 |
|
549 |
if (auteursModifies.containsKey(personneSelectionnee.getId())) {
|
555 |
if (auteursModifies.containsKey(personneSelectionnee.getId())) {
|
550 |
auteursModifies.remove(personneSelectionnee.getId());
|
556 |
auteursModifies.remove(personneSelectionnee.getId());
|
551 |
}
|
557 |
}
|
552 |
|
558 |
|
553 |
// 2) Supprimer la personne de la liste
|
559 |
// 2) Supprimer la personne de la liste
|
554 |
Log.debug("Personne trouvée : "+grilleAuteurs.getStore().findModel(donneeSelectionnee).toString());
|
560 |
Log.debug("Personne trouvée : "+grilleAuteurs.getStore().findModel(donneeSelectionnee).toString());
|
555 |
grilleAuteurs.getStore().remove(donneeSelectionnee);
|
561 |
grilleAuteurs.getStore().remove(donneeSelectionnee);
|
556 |
formaterOrdreAuteurs();
|
562 |
formaterOrdreAuteurs();
|
557 |
}
|
563 |
}
|
558 |
}
|
564 |
}
|
559 |
|
565 |
|
560 |
private GrillePaginable<ModelData> creerGrilleAuteurs() {
|
566 |
private GrillePaginable<ModelData> creerGrilleAuteurs() {
|
561 |
// ModelType
|
567 |
// ModelType
|
562 |
ModelType modelTypePersonnesAPublication = new ModelType();
|
568 |
ModelType modelTypePersonnesAPublication = new ModelType();
|
563 |
modelTypePersonnesAPublication.setRoot("publicationsAPersonne");
|
569 |
modelTypePersonnesAPublication.setRoot("publicationsAPersonne");
|
564 |
modelTypePersonnesAPublication.setTotalName("nbElements");
|
570 |
modelTypePersonnesAPublication.setTotalName("nbElements");
|
565 |
modelTypePersonnesAPublication.addField("cpuap_id_personne");
|
571 |
modelTypePersonnesAPublication.addField("cpuap_id_personne");
|
566 |
modelTypePersonnesAPublication.addField("cpuap_id_publication");
|
572 |
modelTypePersonnesAPublication.addField("cpuap_id_publication");
|
567 |
modelTypePersonnesAPublication.addField("cpuap_id_role");
|
573 |
modelTypePersonnesAPublication.addField("cpuap_id_role");
|
568 |
modelTypePersonnesAPublication.addField("cpuap_ordre");
|
574 |
modelTypePersonnesAPublication.addField("cpuap_ordre");
|
569 |
modelTypePersonnesAPublication.addField("cp_id_personne");
|
575 |
modelTypePersonnesAPublication.addField("cp_id_personne");
|
570 |
modelTypePersonnesAPublication.addField("cp_fmt_nom_complet");
|
576 |
modelTypePersonnesAPublication.addField("cp_fmt_nom_complet");
|
571 |
modelTypePersonnesAPublication.addField("cp_nom");
|
577 |
modelTypePersonnesAPublication.addField("cp_nom");
|
572 |
modelTypePersonnesAPublication.addField("cp_prenom");
|
578 |
modelTypePersonnesAPublication.addField("cp_prenom");
|
573 |
modelTypePersonnesAPublication.addField("cp_id_personne");
|
579 |
modelTypePersonnesAPublication.addField("cp_id_personne");
|
574 |
modelTypePersonnesAPublication.addField("cp_code_postal");
|
580 |
modelTypePersonnesAPublication.addField("cp_code_postal");
|
575 |
modelTypePersonnesAPublication.addField("cp_ville");
|
581 |
modelTypePersonnesAPublication.addField("cp_ville");
|
576 |
modelTypePersonnesAPublication.addField("cp_truk_courriel");
|
582 |
modelTypePersonnesAPublication.addField("cp_truk_courriel");
|
577 |
|
583 |
|
578 |
// Proxy
|
584 |
// Proxy
|
579 |
ProxyPersonnesAPublication<ModelData> proxyPersonnesAPublication = new ProxyPersonnesAPublication<ModelData>(null, publicationId);
|
585 |
ProxyPersonnesAPublication<ModelData> proxyPersonnesAPublication = new ProxyPersonnesAPublication<ModelData>(null, publicationId);
|
580 |
|
586 |
|
581 |
// Colonnes
|
587 |
// Colonnes
|
582 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
588 |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>();
|
583 |
ColumnConfig columnOrdre = new ColumnConfig("_ordre_", i18nC.ordre(), 15);
|
589 |
ColumnConfig columnOrdre = new ColumnConfig("_ordre_", i18nC.ordre(), 15);
|
584 |
colonnes.add(columnOrdre);
|
590 |
colonnes.add(columnOrdre);
|
585 |
colonnes.add(new ColumnConfig("cp_fmt_nom_complet", i18nC.personneNomComplet(), 150));
|
591 |
colonnes.add(new ColumnConfig("cp_fmt_nom_complet", i18nC.personneNomComplet(), 150));
|
586 |
colonnes.add(new ColumnConfig("cp_code_postal", i18nC.personneCodePostal(), 150));
|
592 |
colonnes.add(new ColumnConfig("cp_code_postal", i18nC.personneCodePostal(), 150));
|
587 |
colonnes.add(new ColumnConfig("cp_ville", i18nC.personneVille(), 75));
|
593 |
colonnes.add(new ColumnConfig("cp_ville", i18nC.personneVille(), 75));
|
588 |
colonnes.add(new ColumnConfig("cp_truk_courriel", i18nC.personneCourriel(), 75));
|
594 |
colonnes.add(new ColumnConfig("cp_truk_courriel", i18nC.personneCourriel(), 75));
|
589 |
|
595 |
|
590 |
// Champs de traitement
|
596 |
// Champs de traitement
|
591 |
HashMap<String, String> virtualFields = new HashMap<String, String>();
|
597 |
HashMap<String, String> virtualFields = new HashMap<String, String>();
|
592 |
virtualFields.put("_ordre_", "cpuap_ordre");
|
598 |
virtualFields.put("_ordre_", "cpuap_ordre");
|
593 |
|
599 |
|
594 |
// Modele de selection
|
600 |
// Modele de selection
|
595 |
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
|
601 |
GridSelectionModel<ModelData> modeleDeSelection = new GridSelectionModel<ModelData>();
|
596 |
modeleDeSelection.addListener(Events.SelectionChange, new SelectionChangedListener<ModelData>() {
|
602 |
modeleDeSelection.addListener(Events.SelectionChange, new SelectionChangedListener<ModelData>() {
|
597 |
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
|
603 |
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
|
598 |
activerBoutonsOrdreAuteur();
|
604 |
activerBoutonsOrdreAuteur();
|
599 |
}
|
605 |
}
|
600 |
});
|
606 |
});
|
601 |
|
607 |
|
602 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
608 |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes);
|
603 |
|
609 |
|
604 |
// Grille
|
610 |
// Grille
|
605 |
// ATTENTION : le constructure de cette grille est à vérifier!
|
611 |
// ATTENTION : le constructure de cette grille est à vérifier!
|
606 |
final GrillePaginable<ModelData> grilleAuteurs = new GrillePaginable<ModelData>(modelTypePersonnesAPublication, virtualFields, proxyPersonnesAPublication, colonnes, modeleDeColonnes);
|
612 |
final GrillePaginable<ModelData> grilleAuteurs = new GrillePaginable<ModelData>(modelTypePersonnesAPublication, virtualFields, proxyPersonnesAPublication, colonnes, modeleDeColonnes);
|
607 |
grilleAuteurs.getGrille().setHeight("100%");
|
613 |
grilleAuteurs.getGrille().setHeight("100%");
|
608 |
grilleAuteurs.getGrille().setBorders(true);
|
614 |
grilleAuteurs.getGrille().setBorders(true);
|
609 |
grilleAuteurs.getGrille().setSelectionModel(modeleDeSelection);
|
615 |
grilleAuteurs.getGrille().setSelectionModel(modeleDeSelection);
|
610 |
grilleAuteurs.getGrille().getView().setForceFit(true);
|
616 |
grilleAuteurs.getGrille().getView().setForceFit(true);
|
611 |
grilleAuteurs.getGrille().setAutoExpandColumn("fmt_nom_complet");
|
617 |
grilleAuteurs.getGrille().setAutoExpandColumn("fmt_nom_complet");
|
612 |
grilleAuteurs.getGrille().setStripeRows(true);
|
618 |
grilleAuteurs.getGrille().setStripeRows(true);
|
613 |
grilleAuteurs.getGrille().setTrackMouseOver(true);
|
619 |
grilleAuteurs.getGrille().setTrackMouseOver(true);
|
614 |
|
620 |
|
615 |
grilleAuteurs.getStore().getLoader().addListener(Loader.Load, new Listener<LoadEvent>() {
|
621 |
grilleAuteurs.getStore().getLoader().addListener(Loader.Load, new Listener<LoadEvent>() {
|
616 |
public void handleEvent(LoadEvent be) {
|
622 |
public void handleEvent(LoadEvent be) {
|
617 |
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
|
623 |
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
|
618 |
Iterator<ModelData> itAuteurs = auteurs.iterator();
|
624 |
Iterator<ModelData> itAuteurs = auteurs.iterator();
|
619 |
while (itAuteurs.hasNext()) {
|
625 |
while (itAuteurs.hasNext()) {
|
620 |
ModelData selection = itAuteurs.next();
|
626 |
ModelData selection = itAuteurs.next();
|
621 |
PublicationAPersonne pap = new PublicationAPersonne(selection, aDonnee.GARDER_PREFIXE);
|
627 |
PublicationAPersonne pap = new PublicationAPersonne(selection, aDonnee.GARDER_PREFIXE);
|
622 |
auteursInitialListe.put(pap.getId(), pap);
|
628 |
auteursInitialListe.put(pap.getId(), pap);
|
623 |
Log.debug("PublicationAPersonne ajoutée à la liste initiale avec l'id :"+pap.getId()+pap.toString()+selection.getProperties().toString());
|
629 |
Log.debug("PublicationAPersonne ajoutée à la liste initiale avec l'id :"+pap.getId()+pap.toString()+selection.getProperties().toString());
|
624 |
}
|
630 |
}
|
625 |
Log.debug("Initialisation liste auteur :"+auteursInitialListe.size());
|
631 |
Log.debug("Initialisation liste auteur :"+auteursInitialListe.size());
|
626 |
}
|
632 |
}
|
627 |
});
|
633 |
});
|
628 |
|
634 |
|
629 |
// Rajouter des écouteurs
|
635 |
// Rajouter des écouteurs
|
630 |
grilleAuteurs.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
|
636 |
grilleAuteurs.getStore().addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
|
631 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
637 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
632 |
if (!changeOrderMarker) {
|
638 |
if (!changeOrderMarker) {
|
633 |
actualiserEtatBoutonsBarreOutils();
|
639 |
actualiserEtatBoutonsBarreOutils();
|
634 |
}
|
640 |
}
|
635 |
}
|
641 |
}
|
636 |
});
|
642 |
});
|
637 |
grilleAuteurs.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
|
643 |
grilleAuteurs.getStore().addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
|
638 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
644 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
639 |
if (!changeOrderMarker) {
|
645 |
if (!changeOrderMarker) {
|
640 |
actualiserEtatBoutonsBarreOutils();
|
646 |
actualiserEtatBoutonsBarreOutils();
|
641 |
Log.debug("Dans listener remove de grilleAuteur");
|
647 |
Log.debug("Dans listener remove de grilleAuteur");
|
642 |
}
|
648 |
}
|
643 |
}
|
649 |
}
|
644 |
});
|
650 |
});
|
645 |
grilleAuteurs.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
|
651 |
grilleAuteurs.getStore().addListener(Store.Update, new Listener<StoreEvent<ModelData>>() {
|
646 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
652 |
public void handleEvent(StoreEvent<ModelData> ce) {
|
647 |
|
653 |
|
648 |
}
|
654 |
}
|
649 |
});
|
655 |
});
|
650 |
|
656 |
|
651 |
return grilleAuteurs;
|
657 |
return grilleAuteurs;
|
652 |
}
|
658 |
}
|
653 |
|
659 |
|
654 |
private void genererTitreFormulaire() {
|
660 |
private void genererTitreFormulaire() {
|
655 |
String titre = i18nC.publicationTitreFormAjout();
|
661 |
String titre = i18nC.publicationTitreFormAjout();
|
656 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
662 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
657 |
titre = i18nC.publicationTitreFormModif();
|
663 |
titre = i18nC.publicationTitreFormModif();
|
658 |
if (publication != null) {
|
664 |
if (publication != null) {
|
659 |
titre += " - "+i18nC.id()+": "+publication.getId()+" - "+publication.getTitre();
|
665 |
titre += " - "+i18nC.id()+": "+publication.getId()+" - "+publication.getTitre();
|
660 |
}
|
666 |
}
|
661 |
}
|
667 |
}
|
662 |
panneauFormulaire.setHeading(titre);
|
668 |
panneauFormulaire.setHeading(titre);
|
663 |
}
|
669 |
}
|
664 |
|
670 |
|
665 |
|
671 |
|
666 |
private void creerZoneAuteurs() {
|
672 |
private void creerZoneAuteurs() {
|
667 |
auteursFieldset = new ContentPanel();
|
673 |
auteursFieldset = new ContentPanel();
|
668 |
auteursFieldset.setLayout(new FitLayout());
|
674 |
auteursFieldset.setLayout(new FitLayout());
|
669 |
auteursFieldset.setHeading("Auteurs");
|
675 |
auteursFieldset.setHeading("Auteurs");
|
670 |
|
676 |
|
671 |
creerChampsAuteur();
|
677 |
creerChampsAuteur();
|
672 |
}
|
678 |
}
|
673 |
|
679 |
|
674 |
private void creerChampsAuteur() {
|
680 |
private void creerChampsAuteur() {
|
675 |
auteursFieldset.removeAll();
|
681 |
auteursFieldset.removeAll();
|
676 |
barreOutils = creerBarreOutilsGrille();
|
682 |
barreOutils = creerBarreOutilsGrille();
|
677 |
auteursFieldset.setTopComponent(barreOutils);
|
683 |
auteursFieldset.setTopComponent(barreOutils);
|
678 |
grilleAuteurs = creerGrilleAuteurs();
|
684 |
grilleAuteurs = creerGrilleAuteurs();
|
679 |
auteursFieldset.add(grilleAuteurs);
|
685 |
auteursFieldset.add(grilleAuteurs);
|
680 |
auteursFieldset.layout();
|
686 |
auteursFieldset.layout();
|
681 |
}
|
687 |
}
|
682 |
|
688 |
|
683 |
private void creerZoneGeneralites() {
|
689 |
private void creerZoneGeneralites() {
|
684 |
FormLayout layout = new FormLayout();
|
690 |
FormLayout layout = new FormLayout();
|
685 |
layout.setLabelWidth(200);
|
691 |
layout.setLabelWidth(200);
|
686 |
|
692 |
|
687 |
// Fieldset Infos Générales
|
693 |
// Fieldset Infos Générales
|
688 |
generalitesFieldset = new FieldSet();
|
694 |
generalitesFieldset = new FieldSet();
|
689 |
generalitesFieldset.setHeading("Informations générales");
|
695 |
generalitesFieldset.setHeading("Informations générales");
|
690 |
generalitesFieldset.setCollapsible(true);
|
696 |
generalitesFieldset.setCollapsible(true);
|
691 |
generalitesFieldset.setLayout(layout);
|
697 |
generalitesFieldset.setLayout(layout);
|
692 |
|
698 |
|
693 |
ModelType modelTypeProjets = new ModelType();
|
699 |
ModelType modelTypeProjets = new ModelType();
|
694 |
modelTypeProjets.setRoot("projets");
|
700 |
modelTypeProjets.setRoot("projets");
|
695 |
modelTypeProjets.setTotalName("nbElements");
|
701 |
modelTypeProjets.setTotalName("nbElements");
|
696 |
modelTypeProjets.addField("cpr_nom");
|
702 |
modelTypeProjets.addField("cpr_nom");
|
697 |
modelTypeProjets.addField("cpr_id_projet");
|
703 |
modelTypeProjets.addField("cpr_id_projet");
|
698 |
|
704 |
|
699 |
String displayNameProjets = "cpr_nom";
|
705 |
String displayNameProjets = "cpr_nom";
|
700 |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(null);
|
706 |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(null);
|
701 |
|
707 |
|
702 |
projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
|
708 |
projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets);
|
703 |
projetsCombo.setWidth(200, 600);
|
709 |
projetsCombo.setWidth(200, 600);
|
704 |
projetsCombo.getCombo().setTabIndex(tabIndex++);
|
710 |
projetsCombo.getCombo().setTabIndex(tabIndex++);
|
705 |
projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp());
|
711 |
projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp());
|
706 |
projetsCombo.getCombo().setForceSelection(true);
|
712 |
projetsCombo.getCombo().setForceSelection(true);
|
707 |
projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
|
713 |
projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE);
|
708 |
projetsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
|
714 |
projetsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
|
709 |
|
715 |
|
710 |
projetsCombo.getCombo().setValidator(new Validator() {
|
716 |
projetsCombo.getCombo().setValidator(new Validator() {
|
711 |
public String validate(Field<?> field, String value) {
|
717 |
public String validate(Field<?> field, String value) {
|
712 |
String retour = null;
|
718 |
String retour = null;
|
713 |
if (field.getRawValue().equals("")) {
|
719 |
if (field.getRawValue().equals("")) {
|
714 |
field.setValue(null);
|
720 |
field.setValue(null);
|
715 |
} else if (projetsCombo.getStore().findModel("cpr_nom", field.getRawValue()) == null) {
|
721 |
} else if (projetsCombo.getStore().findModel("cpr_nom", field.getRawValue()) == null) {
|
716 |
String contenuBrut = field.getRawValue();
|
722 |
String contenuBrut = field.getRawValue();
|
717 |
field.setValue(null);
|
723 |
field.setValue(null);
|
718 |
field.setRawValue(contenuBrut);
|
724 |
field.setRawValue(contenuBrut);
|
719 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
725 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
720 |
}
|
726 |
}
|
721 |
return retour;
|
727 |
return retour;
|
722 |
}
|
728 |
}
|
723 |
});
|
729 |
});
|
724 |
generalitesFieldset.add(projetsCombo, new FormData(600, 0));
|
730 |
generalitesFieldset.add(projetsCombo, new FormData(600, 0));
|
725 |
|
731 |
|
726 |
titreChp = new TextField<String>();
|
732 |
titreChp = new TextField<String>();
|
727 |
titreChp.setName("cpu");
|
733 |
titreChp.setName("cpu");
|
728 |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
734 |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
729 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
735 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
730 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
736 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
731 |
generalitesFieldset.add(titreChp, new FormData(450, 0));
|
737 |
generalitesFieldset.add(titreChp, new FormData(450, 0));
|
732 |
|
738 |
|
733 |
collectionChp = new TextField<String>();
|
739 |
collectionChp = new TextField<String>();
|
734 |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
|
740 |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
|
735 |
generalitesFieldset.add(collectionChp, new FormData(450, 0));
|
741 |
generalitesFieldset.add(collectionChp, new FormData(450, 0));
|
736 |
|
742 |
|
737 |
uriChp = new TextField<String>();
|
743 |
uriChp = new TextField<String>();
|
738 |
uriChp.setFieldLabel("URL de la publication");
|
744 |
uriChp.setFieldLabel("URL de la publication");
|
739 |
generalitesFieldset.add(uriChp, new FormData(450, 0));
|
745 |
generalitesFieldset.add(uriChp, new FormData(450, 0));
|
740 |
}
|
746 |
}
|
741 |
|
747 |
|
742 |
private void creerZoneEdition() {
|
748 |
private void creerZoneEdition() {
|
743 |
FormLayout layout = new FormLayout();
|
749 |
FormLayout layout = new FormLayout();
|
744 |
layout.setLabelWidth(200);
|
750 |
layout.setLabelWidth(200);
|
745 |
|
751 |
|
746 |
// Fieldset Edition
|
752 |
// Fieldset Edition
|
747 |
editionFieldset = new FieldSet();
|
753 |
editionFieldset = new FieldSet();
|
748 |
editionFieldset.setHeading("Édition");
|
754 |
editionFieldset.setHeading("Édition");
|
749 |
editionFieldset.setCollapsible(true);
|
755 |
editionFieldset.setCollapsible(true);
|
750 |
editionFieldset.setLayout(layout);
|
756 |
editionFieldset.setLayout(layout);
|
751 |
|
757 |
|
752 |
/*****************************************************/
|
758 |
/*****************************************************/
|
753 |
/** Champ 'Editeur de la publication' **/
|
759 |
/** Champ 'Editeur de la publication' **/
|
754 |
/*****************************************************/
|
760 |
/*****************************************************/
|
755 |
ModelType modelTypeStructures = new ModelType();
|
761 |
ModelType modelTypeStructures = new ModelType();
|
756 |
modelTypeStructures.setRoot("structures");
|
762 |
modelTypeStructures.setRoot("structures");
|
757 |
modelTypeStructures.setTotalName("nbElements");
|
763 |
modelTypeStructures.setTotalName("nbElements");
|
758 |
modelTypeStructures.addField("cs_nom");
|
764 |
modelTypeStructures.addField("cs_nom");
|
759 |
modelTypeStructures.addField("cs_id_structure");
|
765 |
modelTypeStructures.addField("cs_id_structure");
|
760 |
|
766 |
|
761 |
String displayNameStructures = "cs_nom";
|
767 |
String displayNameStructures = "cs_nom";
|
762 |
ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(null);
|
768 |
ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(null);
|
763 |
|
769 |
|
764 |
editeurCombobox = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
|
770 |
editeurCombobox = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures);
|
765 |
editeurCombobox.setWidth(200, 600);
|
771 |
editeurCombobox.setWidth(200, 600);
|
766 |
editeurCombobox.getCombo().setTabIndex(tabIndex++);
|
772 |
editeurCombobox.getCombo().setTabIndex(tabIndex++);
|
767 |
editeurCombobox.getCombo().setEmptyText("Sélectionner un éditeur...");
|
773 |
editeurCombobox.getCombo().setEmptyText("Sélectionner un éditeur...");
|
768 |
editeurCombobox.getCombo().setFieldLabel("Éditeur de la publication");
|
774 |
editeurCombobox.getCombo().setFieldLabel("Éditeur de la publication");
|
769 |
editeurCombobox.getCombo().setEditable(true);
|
775 |
editeurCombobox.getCombo().setEditable(true);
|
770 |
editionFieldset.add(editeurCombobox, new FormData(600, 0));
|
776 |
editionFieldset.add(editeurCombobox, new FormData(600, 0));
|
771 |
|
777 |
|
772 |
/*********************************************/
|
778 |
/*********************************************/
|
773 |
/** Champ 'Date de publication' **/
|
779 |
/** Champ 'Date de publication' **/
|
774 |
/*********************************************/
|
780 |
/*********************************************/
|
775 |
datePublicationChp = new TextField<String>();
|
781 |
datePublicationChp = new TextField<String>();
|
776 |
datePublicationChp.setMaxLength(9);
|
782 |
datePublicationChp.setMaxLength(9);
|
777 |
datePublicationChp.setMinLength(4);
|
783 |
datePublicationChp.setMinLength(4);
|
778 |
datePublicationChp.setFieldLabel("Année de publication");
|
784 |
datePublicationChp.setFieldLabel("Année de publication");
|
779 |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
785 |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
780 |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
786 |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
781 |
editionFieldset.add(datePublicationChp, new FormData(80, 0));
|
787 |
editionFieldset.add(datePublicationChp, new FormData(80, 0));
|
782 |
|
788 |
|
783 |
/*********************************/
|
789 |
/*********************************/
|
784 |
/** Champ 'Tome' **/
|
790 |
/** Champ 'Tome' **/
|
785 |
/*********************************/
|
791 |
/*********************************/
|
786 |
tomeChp = new TextField<String>();
|
792 |
tomeChp = new TextField<String>();
|
787 |
tomeChp.setFieldLabel("Série de la revue ou tome");
|
793 |
tomeChp.setFieldLabel("Série de la revue ou tome");
|
788 |
editionFieldset.add(tomeChp, new FormData(75, 0));
|
794 |
editionFieldset.add(tomeChp, new FormData(75, 0));
|
789 |
|
795 |
|
790 |
/*************************************/
|
796 |
/*************************************/
|
791 |
/** Champ 'Fascicule' **/
|
797 |
/** Champ 'Fascicule' **/
|
792 |
/*************************************/
|
798 |
/*************************************/
|
793 |
fasciculeChp = new TextField<String>();
|
799 |
fasciculeChp = new TextField<String>();
|
794 |
fasciculeChp.setFieldLabel("Fascicule de la revue");
|
800 |
fasciculeChp.setFieldLabel("Fascicule de la revue");
|
795 |
editionFieldset.add(fasciculeChp, new FormData(75, 0));
|
801 |
editionFieldset.add(fasciculeChp, new FormData(75, 0));
|
796 |
|
802 |
|
797 |
/*********************************/
|
803 |
/*********************************/
|
798 |
/** Champ 'Pages' **/
|
804 |
/** Champ 'Pages' **/
|
799 |
/*********************************/
|
805 |
/*********************************/
|
800 |
pagesChp = new TextField<String>();
|
806 |
pagesChp = new TextField<String>();
|
801 |
pagesChp.setFieldLabel("Pages");
|
807 |
pagesChp.setFieldLabel("Pages");
|
802 |
pagesChp.setToolTip("Fomat : NBRE ou NBRE-NBRE. ('NBRE' correspond à une suite de chiffres arabes ou romains ou à un point d'interrogation '?' dans le cas d'une donnée inconnue)");
|
808 |
pagesChp.setToolTip("Fomat : NBRE ou NBRE-NBRE. ('NBRE' correspond à une suite de chiffres arabes ou romains ou à un point d'interrogation '?' dans le cas d'une donnée inconnue)");
|
803 |
editionFieldset.add(pagesChp, new FormData(100, 0));
|
809 |
editionFieldset.add(pagesChp, new FormData(100, 0));
|
804 |
}
|
810 |
}
|
805 |
|
811 |
|
806 |
|
812 |
|
807 |
//+----------------------------------------------------------------------------------------------------------------+
|
813 |
//+----------------------------------------------------------------------------------------------------------------+
|
808 |
// Méthodes privées
|
814 |
// Méthodes privées
|
809 |
|
815 |
|
810 |
private void miseAJourAuteursInitialListe() {
|
816 |
private void miseAJourAuteursInitialListe() {
|
811 |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
|
817 |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
|
812 |
while (clesAjoutees.hasNext()) {
|
818 |
while (clesAjoutees.hasNext()) {
|
813 |
PublicationAPersonne auteurAjoute = auteursAjoutes.get(clesAjoutees.next());
|
819 |
PublicationAPersonne auteurAjoute = auteursAjoutes.get(clesAjoutees.next());
|
814 |
auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
|
820 |
auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
|
815 |
}
|
821 |
}
|
816 |
|
822 |
|
817 |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
|
823 |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
|
818 |
while (clesSupprimees.hasNext()) {
|
824 |
while (clesSupprimees.hasNext()) {
|
819 |
PublicationAPersonne auteurSupprime = auteursSupprimes.get(clesSupprimees.next());
|
825 |
PublicationAPersonne auteurSupprime = auteursSupprimes.get(clesSupprimees.next());
|
820 |
auteursInitialListe.remove(auteurSupprime.getId());
|
826 |
auteursInitialListe.remove(auteurSupprime.getId());
|
821 |
}
|
827 |
}
|
822 |
}
|
828 |
}
|
823 |
|
829 |
|
824 |
public boolean soumettreFormulaire() {
|
830 |
public boolean soumettreFormulaire() {
|
825 |
boolean formulaireValideOk = verifierFormulaire();
|
831 |
boolean formulaireValideOk = verifierFormulaire();
|
826 |
if (formulaireValideOk) {
|
832 |
if (formulaireValideOk) {
|
827 |
soumettrePublication();
|
833 |
soumettrePublication();
|
828 |
}
|
834 |
}
|
829 |
return formulaireValideOk;
|
835 |
return formulaireValideOk;
|
830 |
}
|
836 |
}
|
831 |
|
837 |
|
832 |
private void soumettrePublication() {
|
838 |
private void soumettrePublication() {
|
833 |
Publication publicationCollectee = collecterPublication();
|
839 |
Publication publicationCollectee = collecterPublication();
|
834 |
if (publicationCollectee != null) {
|
840 |
if (publicationCollectee != null) {
|
835 |
// Pour l'enregistrement des publications, on utilise le séquenceur
|
841 |
// Pour l'enregistrement des publications, on utilise le séquenceur
|
836 |
// Il doit attendre le retour de l'enregistrement pour poursuivre
|
842 |
// Il doit attendre le retour de l'enregistrement pour poursuivre
|
837 |
sequenceur = new Sequenceur();
|
843 |
sequenceur = new Sequenceur();
|
838 |
int seqId = sequenceur.lancerRequeteSynchrone(this);
|
844 |
int seqId = sequenceur.lancerRequeteSynchrone(this);
|
839 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
845 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
840 |
mediateur.ajouterPublication(sequenceur, publicationCollectee, seqId);
|
846 |
mediateur.ajouterPublication(sequenceur, publicationCollectee, seqId);
|
841 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
847 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
842 |
mediateur.modifierPublication(sequenceur, publicationCollectee, seqId);
|
848 |
mediateur.modifierPublication(sequenceur, publicationCollectee, seqId);
|
843 |
}
|
849 |
}
|
844 |
|
850 |
|
845 |
// si l'on est en mode MODIFIER, on soumet les auteurs meme si les informations de la publication
|
851 |
// si l'on est en mode MODIFIER, on soumet les auteurs meme si les informations de la publication
|
846 |
// restent inchangées car il se peut que les auteurs aient été modifiés
|
852 |
// restent inchangées car il se peut que les auteurs aient été modifiés
|
847 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
853 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
848 |
soumettreAuteurs();
|
854 |
soumettreAuteurs();
|
849 |
}
|
855 |
}
|
850 |
}
|
856 |
}
|
851 |
|
857 |
|
852 |
private void soumettreAuteurs() {
|
858 |
private void soumettreAuteurs() {
|
853 |
//1) Auteurs ajoutés :
|
859 |
//1) Auteurs ajoutés :
|
854 |
PublicationAPersonneListe listeAuteursAAjouter = new PublicationAPersonneListe();
|
860 |
PublicationAPersonneListe listeAuteursAAjouter = new PublicationAPersonneListe();
|
855 |
Iterator<String> itAuteur = auteursAjoutes.keySet().iterator();
|
861 |
Iterator<String> itAuteur = auteursAjoutes.keySet().iterator();
|
856 |
while (itAuteur.hasNext()) {
|
862 |
while (itAuteur.hasNext()) {
|
857 |
String cle = itAuteur.next();
|
863 |
String cle = itAuteur.next();
|
858 |
PublicationAPersonne publiAPersonne = auteursAjoutes.get(cle);
|
864 |
PublicationAPersonne publiAPersonne = auteursAjoutes.get(cle);
|
859 |
Log.debug("Ajouter :"+publiAPersonne.toString());
|
865 |
Log.debug("Ajouter :"+publiAPersonne.toString());
|
860 |
publiAPersonne.setIdPublication(this.publicationId);
|
866 |
publiAPersonne.setIdPublication(this.publicationId);
|
861 |
publiAPersonne.setOrdreAuteurs(publiAPersonne.getOrdreAuteurs());
|
867 |
publiAPersonne.setOrdreAuteurs(publiAPersonne.getOrdreAuteurs());
|
862 |
listeAuteursAAjouter.put(cle, publiAPersonne);
|
868 |
listeAuteursAAjouter.put(cle, publiAPersonne);
|
863 |
}
|
869 |
}
|
864 |
|
870 |
|
865 |
// - envoyer au mediateur SSI personnes à ajouter
|
871 |
// - envoyer au mediateur SSI personnes à ajouter
|
866 |
if (listeAuteursAAjouter.size() > 0) {
|
872 |
if (listeAuteursAAjouter.size() > 0) {
|
867 |
int seqId = sequenceur.lancerRequeteSynchrone(this);
|
873 |
int seqId = sequenceur.lancerRequeteSynchrone(this);
|
868 |
mediateur.ajouterPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAAjouter, PublicationAPersonne.ROLE_AUTEUR, seqId);
|
874 |
mediateur.ajouterPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAAjouter, PublicationAPersonne.ROLE_AUTEUR, seqId);
|
869 |
}
|
875 |
}
|
870 |
|
876 |
|
871 |
//2) Auteurs supprimés :
|
877 |
//2) Auteurs supprimés :
|
872 |
PublicationAPersonneListe listeAuteursASupprimer = new PublicationAPersonneListe();
|
878 |
PublicationAPersonneListe listeAuteursASupprimer = new PublicationAPersonneListe();
|
873 |
itAuteur = auteursSupprimes.keySet().iterator();
|
879 |
itAuteur = auteursSupprimes.keySet().iterator();
|
874 |
while (itAuteur.hasNext()) {
|
880 |
while (itAuteur.hasNext()) {
|
875 |
String cle = itAuteur.next();
|
881 |
String cle = itAuteur.next();
|
876 |
PublicationAPersonne publiAPersonne = auteursSupprimes.get(cle);
|
882 |
PublicationAPersonne publiAPersonne = auteursSupprimes.get(cle);
|
877 |
Log.debug("Supprimer :"+publiAPersonne.toString());
|
883 |
Log.debug("Supprimer :"+publiAPersonne.toString());
|
878 |
listeAuteursASupprimer.put(cle, publiAPersonne);
|
884 |
listeAuteursASupprimer.put(cle, publiAPersonne);
|
879 |
}
|
885 |
}
|
880 |
|
886 |
|
881 |
// - Envoyer au médiateur SSI personnes à supprimer
|
887 |
// - Envoyer au médiateur SSI personnes à supprimer
|
882 |
if (listeAuteursASupprimer.size() > 0) {
|
888 |
if (listeAuteursASupprimer.size() > 0) {
|
883 |
// Pour une suppression des auteurs, on a pas besoin d'attendre le retour
|
889 |
// Pour une suppression des auteurs, on a pas besoin d'attendre le retour
|
884 |
Log.debug("Lancement suppression :"+listeAuteursASupprimer.size());
|
890 |
Log.debug("Lancement suppression :"+listeAuteursASupprimer.size());
|
885 |
mediateur.supprimerPublicationAPersonne(this, listeAuteursASupprimer);
|
891 |
mediateur.supprimerPublicationAPersonne(this, listeAuteursASupprimer);
|
886 |
}
|
892 |
}
|
887 |
|
893 |
|
888 |
//3) Auteurs modifiés :
|
894 |
//3) Auteurs modifiés :
|
889 |
PublicationAPersonneListe listeAuteursAModifier = new PublicationAPersonneListe();
|
895 |
PublicationAPersonneListe listeAuteursAModifier = new PublicationAPersonneListe();
|
890 |
itAuteur = auteursModifies.keySet().iterator();
|
896 |
itAuteur = auteursModifies.keySet().iterator();
|
891 |
while (itAuteur.hasNext()) {
|
897 |
while (itAuteur.hasNext()) {
|
892 |
String cle = itAuteur.next();
|
898 |
String cle = itAuteur.next();
|
893 |
PublicationAPersonne publiAPersonne = auteursModifies.get(cle);
|
899 |
PublicationAPersonne publiAPersonne = auteursModifies.get(cle);
|
894 |
Log.debug("Modifier :"+publiAPersonne.toString());
|
900 |
Log.debug("Modifier :"+publiAPersonne.toString());
|
895 |
listeAuteursAModifier.put(cle, publiAPersonne);
|
901 |
listeAuteursAModifier.put(cle, publiAPersonne);
|
896 |
}
|
902 |
}
|
897 |
|
903 |
|
898 |
// - Envoyer au médiateur SSI personnes à modifier
|
904 |
// - Envoyer au médiateur SSI personnes à modifier
|
899 |
if (listeAuteursAModifier.size() > 0) {
|
905 |
if (listeAuteursAModifier.size() > 0) {
|
900 |
int seqId = sequenceur.lancerRequeteSynchrone(this);
|
906 |
int seqId = sequenceur.lancerRequeteSynchrone(this);
|
901 |
mediateur.modifierPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAModifier, PublicationAPersonne.ROLE_AUTEUR, seqId);
|
907 |
mediateur.modifierPublicationAPersonne(sequenceur, this.publicationId, listeAuteursAModifier, PublicationAPersonne.ROLE_AUTEUR, seqId);
|
902 |
}
|
908 |
}
|
903 |
|
909 |
|
904 |
sequenceur.enfilerRafraichissement(this, new Information("auteurs_enregistres"));
|
910 |
sequenceur.enfilerRafraichissement(this, new Information("auteurs_enregistres"));
|
905 |
}
|
911 |
}
|
906 |
|
912 |
|
907 |
private void peuplerFormulaire() {
|
913 |
private void peuplerFormulaire() {
|
908 |
setValeurComboProjets();
|
914 |
setValeurComboProjets();
|
909 |
titreChp.setValue(publication.getTitre());
|
915 |
titreChp.setValue(publication.getTitre());
|
910 |
collectionChp.setValue(publication.getCollection());
|
916 |
collectionChp.setValue(publication.getCollection());
|
911 |
uriChp.setValue(publication.getURI());
|
917 |
uriChp.setValue(publication.getURI());
|
912 |
datePublicationChp.setValue(publication.getAnneeParution());
|
918 |
datePublicationChp.setValue(publication.getAnneeParution());
|
913 |
tomeChp.setValue(publication.getIndicationNvt());
|
919 |
tomeChp.setValue(publication.getIndicationNvt());
|
914 |
fasciculeChp.setValue(publication.getFascicule());
|
920 |
fasciculeChp.setValue(publication.getFascicule());
|
915 |
pagesChp.setValue(publication.getPages());
|
921 |
pagesChp.setValue(publication.getPages());
|
916 |
|
922 |
|
917 |
// Éditeur est soit une référence à une structure de la base soit une chaine
|
923 |
// Éditeur est soit une référence à une structure de la base soit une chaine
|
918 |
if (publication.getEditeur().matches("^[0-9]+$")) {
|
924 |
if (publication.getEditeur().matches("^[0-9]+$")) {
|
919 |
//editeurCombobox.getCombo().setValue(editeurCombobox.getStore().findModel("cs_id_structure", publication.getEditeur()));
|
925 |
//editeurCombobox.getCombo().setValue(editeurCombobox.getStore().findModel("cs_id_structure", publication.getEditeur()));
|
920 |
editeurCombobox.chargerValeurInitiale(publication.getEditeur(), "cs_id_structure");
|
926 |
editeurCombobox.chargerValeurInitiale(publication.getEditeur(), "cs_id_structure");
|
921 |
} else {
|
927 |
} else {
|
922 |
editeurCombobox.getCombo().setRawValue(publication.getEditeur());
|
928 |
editeurCombobox.getCombo().setRawValue(publication.getEditeur());
|
923 |
}
|
929 |
}
|
924 |
}
|
930 |
}
|
925 |
|
931 |
|
926 |
private Publication collecterPublication() {
|
932 |
private Publication collecterPublication() {
|
927 |
|
933 |
|
928 |
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
|
934 |
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
|
929 |
publicationCollectee.setIdProjet(getValeurComboProjets());
|
935 |
publicationCollectee.setIdProjet(getValeurComboProjets());
|
930 |
publicationCollectee.setAuteur(construireIntituleAuteur());
|
936 |
publicationCollectee.setAuteur(construireIntituleAuteur());
|
931 |
|
937 |
|
932 |
String titre = titreChp.getValue();
|
938 |
String titre = titreChp.getValue();
|
933 |
publicationCollectee.setTitre(titre);
|
939 |
publicationCollectee.setTitre(titre);
|
934 |
|
940 |
|
935 |
String collection = collectionChp.getValue();
|
941 |
String collection = collectionChp.getValue();
|
936 |
publicationCollectee.setCollection(collection);
|
942 |
publicationCollectee.setCollection(collection);
|
937 |
|
943 |
|
938 |
publicationCollectee.setNomComplet(construireNomComplet());
|
944 |
publicationCollectee.setNomComplet(construireNomComplet());
|
939 |
|
945 |
|
940 |
String uri = uriChp.getValue();
|
946 |
String uri = uriChp.getValue();
|
941 |
publicationCollectee.setUri(uri);
|
947 |
publicationCollectee.setUri(uri);
|
942 |
|
948 |
|
943 |
String editeur = "";
|
949 |
String editeur = "";
|
944 |
if (editeurCombobox.getValeur() != null) {
|
950 |
if (editeurCombobox.getValeur() != null) {
|
945 |
Structure structure = new Structure(editeurCombobox.getValeur());
|
951 |
Structure structure = new Structure(editeurCombobox.getValeur());
|
946 |
editeur = structure.getId();
|
952 |
editeur = structure.getId();
|
947 |
publicationCollectee.setStructureEditeur(structure);
|
953 |
publicationCollectee.setStructureEditeur(structure);
|
948 |
} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
|
954 |
} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
|
949 |
editeur = editeurCombobox.getCombo().getRawValue();
|
955 |
editeur = editeurCombobox.getCombo().getRawValue();
|
950 |
}
|
956 |
}
|
951 |
publicationCollectee.setEditeur(editeur);
|
957 |
publicationCollectee.setEditeur(editeur);
|
952 |
|
958 |
|
953 |
String anneePublication = datePublicationChp.getRawValue();
|
959 |
String anneePublication = datePublicationChp.getRawValue();
|
954 |
publicationCollectee.setAnneeParution(anneePublication);
|
960 |
publicationCollectee.setAnneeParution(anneePublication);
|
955 |
|
961 |
|
956 |
String tome = tomeChp.getValue();
|
962 |
String tome = tomeChp.getValue();
|
957 |
publicationCollectee.setIndicationNvt(tome);
|
963 |
publicationCollectee.setIndicationNvt(tome);
|
958 |
|
964 |
|
959 |
String fascicule = fasciculeChp.getValue();
|
965 |
String fascicule = fasciculeChp.getValue();
|
960 |
publicationCollectee.setFascicule(fascicule);
|
966 |
publicationCollectee.setFascicule(fascicule);
|
961 |
|
967 |
|
962 |
String pages = pagesChp.getValue();
|
968 |
String pages = pagesChp.getValue();
|
963 |
publicationCollectee.setPages(pages);
|
969 |
publicationCollectee.setPages(pages);
|
964 |
|
970 |
|
965 |
Publication publicationARetourner = null;
|
971 |
Publication publicationARetourner = null;
|
966 |
if (!publicationCollectee.comparer(publication)) {
|
972 |
if (!publicationCollectee.comparer(publication)) {
|
967 |
publicationARetourner = publication = publicationCollectee;
|
973 |
publicationARetourner = publication = publicationCollectee;
|
968 |
}
|
974 |
}
|
969 |
return publicationARetourner;
|
975 |
return publicationARetourner;
|
970 |
}
|
976 |
}
|
971 |
|
977 |
|
972 |
private String construireDate(String valeurDate) {
|
978 |
private String construireDate(String valeurDate) {
|
973 |
|
979 |
|
974 |
String dateComplete = "";
|
980 |
String dateComplete = "";
|
975 |
if (!UtilString.isEmpty(valeurDate)){
|
981 |
if (!UtilString.isEmpty(valeurDate)){
|
976 |
String jour = "00";
|
982 |
String jour = "00";
|
977 |
String mois = "00";
|
983 |
String mois = "00";
|
978 |
String annee = "0000";
|
984 |
String annee = "0000";
|
979 |
String messageErreur = null;
|
985 |
String messageErreur = null;
|
980 |
|
986 |
|
981 |
/** JJ/MM/AAAA **/
|
987 |
/** JJ/MM/AAAA **/
|
982 |
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
|
988 |
if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
|
983 |
|
989 |
|
984 |
}
|
990 |
}
|
985 |
|
991 |
|
986 |
/** MM/AAAA **/
|
992 |
/** MM/AAAA **/
|
987 |
if (valeurDate.matches("\\d{2}/\\d{4}")) {
|
993 |
if (valeurDate.matches("\\d{2}/\\d{4}")) {
|
988 |
dateComplete = valeurDate+"-00";
|
994 |
dateComplete = valeurDate+"-00";
|
989 |
}
|
995 |
}
|
990 |
|
996 |
|
991 |
/** AAAA **/
|
997 |
/** AAAA **/
|
992 |
if (valeurDate.matches("\\d{4}")) {
|
998 |
if (valeurDate.matches("\\d{4}")) {
|
993 |
dateComplete = valeurDate+"-00-00";
|
999 |
dateComplete = valeurDate+"-00-00";
|
994 |
}
|
1000 |
}
|
995 |
}
|
1001 |
}
|
996 |
|
1002 |
|
997 |
return dateComplete;
|
1003 |
return dateComplete;
|
998 |
}
|
1004 |
}
|
999 |
|
1005 |
|
1000 |
private String construireIntituleEditeur() {
|
1006 |
private String construireIntituleEditeur() {
|
1001 |
String editeur = "";
|
1007 |
String editeur = "";
|
1002 |
if (editeurCombobox.getValeur() != null) {
|
1008 |
if (editeurCombobox.getValeur() != null) {
|
1003 |
Structure structure = new Structure(editeurCombobox.getValeur());
|
1009 |
Structure structure = new Structure(editeurCombobox.getValeur());
|
1004 |
editeur = structure.getNom();
|
1010 |
editeur = structure.getNom();
|
1005 |
} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
|
1011 |
} else if (!UtilString.isEmpty(editeurCombobox.getCombo().getRawValue())) {
|
1006 |
editeur = editeurCombobox.getCombo().getRawValue();
|
1012 |
editeur = editeurCombobox.getCombo().getRawValue();
|
1007 |
}
|
1013 |
}
|
1008 |
return editeur;
|
1014 |
return editeur;
|
1009 |
}
|
1015 |
}
|
1010 |
|
1016 |
|
1011 |
private String construireIntituleAuteur() {
|
1017 |
private String construireIntituleAuteur() {
|
1012 |
String intituleAuteur = "";
|
1018 |
String intituleAuteur = "";
|
1013 |
|
1019 |
|
1014 |
// rangé par ordre désigné par le champ 'cpuap_ordre' de la table PublicationAPersonne
|
1020 |
// rangé par ordre désigné par le champ 'cpuap_ordre' de la table PublicationAPersonne
|
1015 |
grilleAuteurs.getStore().sort("_ordre_", SortDir.ASC);
|
1021 |
grilleAuteurs.getStore().sort("_ordre_", SortDir.ASC);
|
1016 |
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
|
1022 |
List<ModelData> auteurs = grilleAuteurs.getStore().getModels();
|
1017 |
Iterator<ModelData> itAuteurs = auteurs.iterator();
|
1023 |
Iterator<ModelData> itAuteurs = auteurs.iterator();
|
1018 |
|
1024 |
|
1019 |
while (itAuteurs.hasNext()) {
|
1025 |
while (itAuteurs.hasNext()) {
|
1020 |
Personne personneCourante = new PublicationAPersonne(itAuteurs.next(), false).getPersonne();
|
1026 |
Personne personneCourante = new PublicationAPersonne(itAuteurs.next(), false).getPersonne();
|
1021 |
intituleAuteur += personneCourante.getNom().toUpperCase() + " " + personneCourante.getPrenom();
|
1027 |
intituleAuteur += personneCourante.getNom().toUpperCase() + " " + personneCourante.getPrenom();
|
1022 |
if (itAuteurs.hasNext()) {
|
1028 |
if (itAuteurs.hasNext()) {
|
1023 |
intituleAuteur+=", ";
|
1029 |
intituleAuteur+=", ";
|
1024 |
}
|
1030 |
}
|
1025 |
}
|
1031 |
}
|
1026 |
return intituleAuteur;
|
1032 |
return intituleAuteur;
|
1027 |
}
|
1033 |
}
|
1028 |
|
1034 |
|
1029 |
private String construireNomComplet() {
|
1035 |
private String construireNomComplet() {
|
1030 |
// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
|
1036 |
// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
|
1031 |
String nomComplet = "";
|
1037 |
String nomComplet = "";
|
1032 |
String auteurs = construireIntituleAuteur();
|
1038 |
String auteurs = construireIntituleAuteur();
|
1033 |
String annee = datePublicationChp.getRawValue();
|
1039 |
String annee = datePublicationChp.getRawValue();
|
1034 |
String titre = titreChp.getValue();
|
1040 |
String titre = titreChp.getValue();
|
1035 |
String editeur = construireIntituleEditeur();
|
1041 |
String editeur = construireIntituleEditeur();
|
1036 |
|
1042 |
|
1037 |
nomComplet += auteurs+", "+annee+". "+titre+".";
|
1043 |
nomComplet += auteurs+", "+annee+". "+titre+".";
|
1038 |
|
1044 |
|
1039 |
if (!UtilString.isEmpty(editeur)) {
|
1045 |
if (!UtilString.isEmpty(editeur)) {
|
1040 |
nomComplet += " Éditeur "+editeur+".";
|
1046 |
nomComplet += " Éditeur "+editeur+".";
|
1041 |
}
|
1047 |
}
|
1042 |
|
1048 |
|
1043 |
if (collectionChp.getValue() != null) {
|
1049 |
if (collectionChp.getValue() != null) {
|
1044 |
String revue = collectionChp.getValue();
|
1050 |
String revue = collectionChp.getValue();
|
1045 |
nomComplet += ", "+revue;
|
1051 |
nomComplet += ", "+revue;
|
1046 |
}
|
1052 |
}
|
1047 |
|
1053 |
|
1048 |
if (fasciculeChp.getValue() != null) {
|
1054 |
if (fasciculeChp.getValue() != null) {
|
1049 |
String fascicule = fasciculeChp.getValue();
|
1055 |
String fascicule = fasciculeChp.getValue();
|
1050 |
nomComplet += ", "+fascicule;
|
1056 |
nomComplet += ", "+fascicule;
|
1051 |
}
|
1057 |
}
|
1052 |
|
1058 |
|
1053 |
if (tomeChp.getValue() != null) {
|
1059 |
if (tomeChp.getValue() != null) {
|
1054 |
String tomaison = tomeChp.getValue();
|
1060 |
String tomaison = tomeChp.getValue();
|
1055 |
nomComplet += ", "+tomaison;
|
1061 |
nomComplet += ", "+tomaison;
|
1056 |
}
|
1062 |
}
|
1057 |
|
1063 |
|
1058 |
if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
|
1064 |
if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
|
1059 |
nomComplet += ".";
|
1065 |
nomComplet += ".";
|
1060 |
}
|
1066 |
}
|
1061 |
|
1067 |
|
1062 |
if (pagesChp.getValue() != null) {
|
1068 |
if (pagesChp.getValue() != null) {
|
1063 |
String pages = pagesChp.getValue();
|
1069 |
String pages = pagesChp.getValue();
|
1064 |
nomComplet += pages+".";
|
1070 |
nomComplet += pages+".";
|
1065 |
}
|
1071 |
}
|
1066 |
|
1072 |
|
1067 |
return nomComplet;
|
1073 |
return nomComplet;
|
1068 |
}
|
1074 |
}
|
1069 |
|
1075 |
|
1070 |
public void reinitialiserFormulaire() {
|
1076 |
public void reinitialiserFormulaire() {
|
1071 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
1077 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
1072 |
mediateur.afficherFormPublication(publication.getId());
|
1078 |
mediateur.afficherFormPublication(publication.getId());
|
1073 |
} else {
|
1079 |
} else {
|
1074 |
mediateur.afficherFormPublication(null);
|
1080 |
mediateur.afficherFormPublication(null);
|
1075 |
}
|
1081 |
}
|
1076 |
}
|
1082 |
}
|
1077 |
|
1083 |
|
1078 |
//+----------------------------------------------------------------------------------------------------------------+
|
1084 |
//+----------------------------------------------------------------------------------------------------------------+
|
1079 |
// Méthodes publiques
|
1085 |
// Méthodes publiques
|
1080 |
|
1086 |
|
1081 |
public boolean verifierFormulaire() {
|
1087 |
public boolean verifierFormulaire() {
|
1082 |
boolean valide = true;
|
1088 |
boolean valide = true;
|
1083 |
ArrayList<String> messages = new ArrayList<String>();
|
1089 |
ArrayList<String> messages = new ArrayList<String>();
|
1084 |
|
1090 |
|
1085 |
// Tester si au moins un auteur est présent
|
1091 |
// Tester si au moins un auteur est présent
|
1086 |
if (grilleAuteurs.getStore().getModels().size() == 0) {
|
1092 |
if (grilleAuteurs.getStore().getModels().size() == 0) {
|
1087 |
messages.add("Veuillez saisir au moins un auteur.");
|
1093 |
messages.add("Veuillez saisir au moins un auteur.");
|
1088 |
}
|
1094 |
}
|
1089 |
|
1095 |
|
1090 |
String titre = titreChp.getValue();
|
1096 |
String titre = titreChp.getValue();
|
1091 |
if (titre == null || titre.equals("")) {
|
1097 |
if (titre == null || titre.equals("")) {
|
1092 |
messages.add("Veuillez saisir le titre de la publication !");
|
1098 |
messages.add("Veuillez saisir le titre de la publication !");
|
1093 |
}
|
1099 |
}
|
1094 |
|
1100 |
|
1095 |
String uri = uriChp.getValue();
|
1101 |
String uri = uriChp.getValue();
|
1096 |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
|
1102 |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
|
1097 |
messages.add("L'URL saisie n'est pas valide !");
|
1103 |
messages.add("L'URL saisie n'est pas valide !");
|
1098 |
}
|
1104 |
}
|
1099 |
|
1105 |
|
1100 |
String datePublication = datePublicationChp.getRawValue();
|
1106 |
String datePublication = datePublicationChp.getRawValue();
|
1101 |
if (datePublication == null || datePublication.equals("")) {
|
1107 |
if (datePublication == null || datePublication.equals("")) {
|
1102 |
messages.add("Veuillez saisir une année de parution !");
|
1108 |
messages.add("Veuillez saisir une année de parution !");
|
1103 |
} else {
|
1109 |
} else {
|
1104 |
if (!Publication.etreAnneeParutionValide(datePublication)) {
|
1110 |
if (!Publication.etreAnneeParutionValide(datePublication)) {
|
1105 |
messages.add("Le format de l'année saisie est incorrect ! Formats acceptés : AAAA ou AAAA-AAAA");
|
1111 |
messages.add("Le format de l'année saisie est incorrect ! Formats acceptés : AAAA ou AAAA-AAAA");
|
1106 |
}
|
1112 |
}
|
1107 |
}
|
1113 |
}
|
1108 |
|
1114 |
|
1109 |
String pages = pagesChp.getValue();
|
1115 |
String pages = pagesChp.getValue();
|
1110 |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
|
1116 |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
|
1111 |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
|
1117 |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
|
1112 |
messages.add("Le format des pages est incorrect !");
|
1118 |
messages.add("Le format des pages est incorrect !");
|
1113 |
}
|
1119 |
}
|
1114 |
|
1120 |
|
1115 |
if (messages.size() != 0) {
|
1121 |
if (messages.size() != 0) {
|
1116 |
String[] tableauDeMessages = {};
|
1122 |
String[] tableauDeMessages = {};
|
1117 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
1123 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
1118 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
|
1124 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
|
1119 |
valide = false;
|
1125 |
valide = false;
|
1120 |
}
|
1126 |
}
|
1121 |
return valide;
|
1127 |
return valide;
|
1122 |
}
|
1128 |
}
|
1123 |
|
1129 |
|
1124 |
|
1130 |
|
1125 |
//+----------------------------------------------------------------------------------------------------------------+
|
1131 |
//+----------------------------------------------------------------------------------------------------------------+
|
1126 |
// Accesseurs
|
1132 |
// Accesseurs
|
1127 |
|
1133 |
|
1128 |
private String getValeurComboProjets() {
|
1134 |
private String getValeurComboProjets() {
|
1129 |
String valeur = "";
|
1135 |
String valeur = "";
|
1130 |
if (projetsCombo.getValeur() != null) {
|
1136 |
if (projetsCombo.getValeur() != null) {
|
1131 |
Projet projet = new Projet(projetsCombo.getValeur());
|
1137 |
Projet projet = new Projet(projetsCombo.getValeur());
|
1132 |
valeur = projet.getId();
|
1138 |
valeur = projet.getId();
|
1133 |
}
|
1139 |
}
|
1134 |
return valeur;
|
1140 |
return valeur;
|
1135 |
}
|
1141 |
}
|
1136 |
private void setValeurComboProjets() {
|
1142 |
private void setValeurComboProjets() {
|
1137 |
if (mode.equals(Formulaire.MODE_MODIFIER) && publication != null) {
|
1143 |
if (mode.equals(Formulaire.MODE_MODIFIER) && publication != null) {
|
1138 |
if (projetsCombo.getCombo().getStore() != null
|
1144 |
if (projetsCombo.getCombo().getStore() != null
|
1139 |
&& publication != null
|
1145 |
&& publication != null
|
1140 |
&& publication.getIdProjet() != null
|
1146 |
&& publication.getIdProjet() != null
|
1141 |
&& !UtilString.isEmpty(publication.getIdProjet())) {
|
1147 |
&& !UtilString.isEmpty(publication.getIdProjet())) {
|
1142 |
projetsCombo.chargerValeurInitiale(publication.getIdProjet(), "cpr_id_projet");
|
1148 |
projetsCombo.chargerValeurInitiale(publication.getIdProjet(), "cpr_id_projet");
|
1143 |
}
|
1149 |
}
|
1144 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
1150 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
1145 |
projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", mediateur.getProjetId()));
|
1151 |
projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", mediateur.getProjetId()));
|
1146 |
} else {
|
1152 |
} else {
|
1147 |
projetsCombo.getCombo().setValue(null);
|
1153 |
projetsCombo.getCombo().setValue(null);
|
1148 |
}
|
1154 |
}
|
1149 |
}
|
1155 |
}
|
1150 |
|
1156 |
|
1151 |
//+----------------------------------------------------------------------------------------------------------------+
|
1157 |
//+----------------------------------------------------------------------------------------------------------------+
|
1152 |
// Rafraichir
|
1158 |
// Rafraichir
|
1153 |
|
1159 |
|
1154 |
public void rafraichir(Object nouvellesDonnees) {
|
1160 |
public void rafraichir(Object nouvellesDonnees) {
|
1155 |
if (nouvellesDonnees instanceof Publication) {
|
1161 |
if (nouvellesDonnees instanceof Publication) {
|
1156 |
publication = (Publication) nouvellesDonnees;
|
1162 |
publication = (Publication) nouvellesDonnees;
|
1157 |
} else if (nouvellesDonnees instanceof Information) {
|
1163 |
} else if (nouvellesDonnees instanceof Information) {
|
1158 |
rafraichirInformation((Information) nouvellesDonnees);
|
1164 |
rafraichirInformation((Information) nouvellesDonnees);
|
1159 |
} else {
|
1165 |
} else {
|
1160 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
1166 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
1161 |
}
|
1167 |
}
|
1162 |
}
|
1168 |
}
|
1163 |
|
1169 |
|
1164 |
private void rafraichirInformation(Information info) {
|
1170 |
private void rafraichirInformation(Information info) {
|
1165 |
|
1171 |
|
1166 |
String type = info.getType();
|
1172 |
String type = info.getType();
|
1167 |
if (type.equals("auteurs_enregistres")) {
|
1173 |
if (type.equals("auteurs_enregistres")) {
|
1168 |
miseAJourAuteursInitialListe();
|
1174 |
miseAJourAuteursInitialListe();
|
1169 |
initialiserAuteurs();
|
1175 |
initialiserAuteurs();
|
1170 |
repandreRafraichissement();
|
1176 |
repandreRafraichissement();
|
1171 |
controlerFermeture();
|
1177 |
controlerFermeture();
|
1172 |
} else if (type.equals("chargement_modifier_ok")) {
|
1178 |
} else if (type.equals("chargement_modifier_ok")) {
|
1173 |
Debug.log("Chargement 1");
|
1179 |
Debug.log("Chargement 1");
|
1174 |
peuplerFormulaire();
|
1180 |
peuplerFormulaire();
|
1175 |
genererTitreFormulaire();
|
1181 |
genererTitreFormulaire();
|
1176 |
}
|
1182 |
}
|
1177 |
|
1183 |
|
1178 |
if (type.equals("personne_ajoutee")) {
|
1184 |
if (type.equals("personne_ajoutee")) {
|
1179 |
if (info.getDonnee(0) != null) {
|
1185 |
if (info.getDonnee(0) != null) {
|
1180 |
Personne personne = (Personne) info.getDonnee(0);
|
1186 |
Personne personne = (Personne) info.getDonnee(0);
|
1181 |
PublicationAPersonne pap = new PublicationAPersonne();
|
1187 |
PublicationAPersonne pap = new PublicationAPersonne();
|
1182 |
pap.setPersonne(personne);
|
1188 |
pap.setPersonne(personne);
|
1183 |
if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
|
1189 |
if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
|
1184 |
ajouterDansGrille(pap);
|
1190 |
ajouterDansGrille(pap);
|
1185 |
}
|
1191 |
}
|
1186 |
} else if (type.equals("personne_modifiee")) {
|
1192 |
} else if (type.equals("personne_modifiee")) {
|
1187 |
if (info.getDonnee(0) != null) {
|
1193 |
if (info.getDonnee(0) != null) {
|
1188 |
|
1194 |
|
1189 |
// créer la nouvelle entrée
|
1195 |
// créer la nouvelle entrée
|
1190 |
Personne personne = (Personne) info.getDonnee(0);
|
1196 |
Personne personne = (Personne) info.getDonnee(0);
|
1191 |
PublicationAPersonne pap = new PublicationAPersonne();
|
1197 |
PublicationAPersonne pap = new PublicationAPersonne();
|
1192 |
pap.setPersonne(personne);
|
1198 |
pap.setPersonne(personne);
|
1193 |
if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
|
1199 |
if (modeDeCreation != Formulaire.MODE_AJOUTER) pap.setPublicationLiee(publication);
|
1194 |
|
1200 |
|
1195 |
// supprimer l'entrée précédente
|
1201 |
// supprimer l'entrée précédente
|
1196 |
PublicationAPersonne personneDansGrille = new PublicationAPersonne(grilleAuteurs.getStore().findModel("cp_id_personne", personne.getId()), false);
|
1202 |
PublicationAPersonne personneDansGrille = new PublicationAPersonne(grilleAuteurs.getStore().findModel("cp_id_personne", personne.getId()), false);
|
1197 |
int index = grilleAuteurs.getStore().indexOf(personneDansGrille);
|
1203 |
int index = grilleAuteurs.getStore().indexOf(personneDansGrille);
|
1198 |
grilleAuteurs.getStore().remove(personneDansGrille);
|
1204 |
grilleAuteurs.getStore().remove(personneDansGrille);
|
1199 |
|
1205 |
|
1200 |
// ajouter la nouvelle entrée dans la grille
|
1206 |
// ajouter la nouvelle entrée dans la grille
|
1201 |
ajouterDansGrille(pap, index);
|
1207 |
ajouterDansGrille(pap, index);
|
1202 |
}
|
1208 |
}
|
1203 |
} else if (info.getType().equals("modif_publication")) {
|
1209 |
} else if (info.getType().equals("modif_publication")) {
|
1204 |
InfoLogger.display("Modification d'une publication", info.toString());
|
1210 |
InfoLogger.display("Modification d'une publication", info.toString());
|
1205 |
soumettreAuteurs();
|
1211 |
soumettreAuteurs();
|
1206 |
} else if (info.getType().equals("ajout_publication")) {
|
1212 |
} else if (info.getType().equals("ajout_publication")) {
|
1207 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String && ((String) info.getDonnee(0)).matches("[0-9]+")) {
|
1213 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String && ((String) info.getDonnee(0)).matches("[0-9]+")) {
|
1208 |
String idPublication = (String) info.getDonnee(0);
|
1214 |
String idPublication = (String) info.getDonnee(0);
|
1209 |
this.publicationId = idPublication;
|
1215 |
this.publicationId = idPublication;
|
1210 |
this.publication.setId(idPublication);
|
1216 |
this.publication.setId(idPublication);
|
1211 |
soumettreAuteurs();
|
1217 |
soumettreAuteurs();
|
1212 |
InfoLogger.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
|
1218 |
InfoLogger.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
|
1213 |
} else {
|
1219 |
} else {
|
1214 |
InfoLogger.display("Ajout d'une publication", info.toString());
|
1220 |
InfoLogger.display("Ajout d'une publication", info.toString());
|
1215 |
}
|
1221 |
}
|
1216 |
} else if (info.getType().equals("suppression_publication_a_personne")) {
|
1222 |
} else if (info.getType().equals("suppression_publication_a_personne")) {
|
1217 |
InfoLogger.display("Suppression d'auteur", info.getMessages().toString());
|
1223 |
InfoLogger.display("Suppression d'auteur", info.getMessages().toString());
|
1218 |
}
|
1224 |
}
|
1219 |
}
|
1225 |
}
|
1220 |
|
1226 |
|
1221 |
private void repandreRafraichissement() {
|
1227 |
private void repandreRafraichissement() {
|
1222 |
if (vueExterneARafraichirApresValidation != null) {
|
1228 |
if (vueExterneARafraichirApresValidation != null) {
|
1223 |
String type = "publication_modifiee";
|
1229 |
String type = "publication_modifiee";
|
1224 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
1230 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
1225 |
type = "publication_ajoutee";
|
1231 |
type = "publication_ajoutee";
|
1226 |
}
|
1232 |
}
|
1227 |
Information info = new Information(type);
|
1233 |
Information info = new Information(type);
|
1228 |
info.setDonnee(0, publication);
|
1234 |
info.setDonnee(0, publication);
|
1229 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
1235 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
1230 |
}
|
1236 |
}
|
1231 |
}
|
1237 |
}
|
1232 |
|
- |
|
1233 |
}
|
1238 |
}
|
1234 |
|
1239 |
|