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.Iterator;
|
4 |
import java.util.Iterator;
|
5 |
import java.util.List;
|
5 |
import java.util.List;
|
6 |
|
6 |
|
7 |
import org.tela_botanica.client.ComposantClass;
|
7 |
import org.tela_botanica.client.ComposantClass;
|
8 |
import org.tela_botanica.client.Mediateur;
|
8 |
import org.tela_botanica.client.Mediateur;
|
9 |
import org.tela_botanica.client.images.Images;
|
9 |
import org.tela_botanica.client.images.Images;
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
10 |
import org.tela_botanica.client.interfaces.Rafraichissable;
|
11 |
import org.tela_botanica.client.modeles.Information;
|
11 |
import org.tela_botanica.client.modeles.Information;
|
12 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
12 |
import org.tela_botanica.client.modeles.MenuApplicationId;
|
13 |
import org.tela_botanica.client.modeles.personne.Personne;
|
13 |
import org.tela_botanica.client.modeles.personne.Personne;
|
14 |
import org.tela_botanica.client.modeles.personne.PersonneListe;
|
14 |
import org.tela_botanica.client.modeles.personne.PersonneListe;
|
15 |
import org.tela_botanica.client.modeles.projet.Projet;
|
15 |
import org.tela_botanica.client.modeles.projet.Projet;
|
16 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
16 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
17 |
import org.tela_botanica.client.modeles.publication.Publication;
|
17 |
import org.tela_botanica.client.modeles.publication.Publication;
|
18 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
18 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
|
19 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
19 |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
|
20 |
import org.tela_botanica.client.modeles.structure.Structure;
|
20 |
import org.tela_botanica.client.modeles.structure.Structure;
|
21 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
21 |
import org.tela_botanica.client.modeles.structure.StructureListe;
|
22 |
import org.tela_botanica.client.util.Debug;
|
22 |
import org.tela_botanica.client.util.Debug;
|
23 |
import org.tela_botanica.client.util.Pattern;
|
23 |
import org.tela_botanica.client.util.Pattern;
|
24 |
import org.tela_botanica.client.util.UtilArray;
|
24 |
import org.tela_botanica.client.util.UtilArray;
|
25 |
import org.tela_botanica.client.util.UtilString;
|
25 |
import org.tela_botanica.client.util.UtilString;
|
26 |
import org.tela_botanica.client.vues.Formulaire;
|
26 |
import org.tela_botanica.client.vues.Formulaire;
|
27 |
|
27 |
|
28 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
28 |
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
29 |
import com.extjs.gxt.ui.client.event.Events;
|
29 |
import com.extjs.gxt.ui.client.event.Events;
|
30 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
30 |
import com.extjs.gxt.ui.client.event.SelectionListener;
|
31 |
import com.extjs.gxt.ui.client.store.ListStore;
|
31 |
import com.extjs.gxt.ui.client.store.ListStore;
|
32 |
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
32 |
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
|
33 |
import com.extjs.gxt.ui.client.widget.Info;
|
33 |
import com.extjs.gxt.ui.client.widget.Info;
|
34 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
34 |
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
35 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
35 |
import com.extjs.gxt.ui.client.widget.MessageBox;
|
36 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
36 |
import com.extjs.gxt.ui.client.widget.button.Button;
|
37 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
37 |
import com.extjs.gxt.ui.client.widget.form.ComboBox;
|
38 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
38 |
import com.extjs.gxt.ui.client.widget.form.Field;
|
39 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
39 |
import com.extjs.gxt.ui.client.widget.form.FieldSet;
|
40 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
40 |
import com.extjs.gxt.ui.client.widget.form.TextField;
|
41 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
41 |
import com.extjs.gxt.ui.client.widget.form.Validator;
|
42 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
42 |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
43 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
43 |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
44 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
44 |
import com.extjs.gxt.ui.client.widget.layout.FormData;
|
45 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
45 |
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
46 |
import com.google.gwt.core.client.GWT;
|
46 |
import com.google.gwt.core.client.GWT;
|
47 |
|
47 |
|
48 |
|
48 |
|
49 |
public class PublicationForm extends Formulaire implements Rafraichissable {
|
49 |
public class PublicationForm extends Formulaire implements Rafraichissable {
|
50 |
|
50 |
|
51 |
private Publication publication;
|
51 |
private Publication publication;
|
52 |
private PersonneListe auteursInitialListe = null;
|
52 |
private PersonneListe auteursInitialListe = null;
|
53 |
private static boolean publicationAPersonneListeChargementOk = false;
|
53 |
private static boolean publicationAPersonneListeChargementOk = false;
|
54 |
private PublicationAPersonneListe auteursAjoutes = null;
|
54 |
private PublicationAPersonneListe auteursAjoutes = null;
|
55 |
private PublicationAPersonneListe auteursSupprimes = null;
|
55 |
private PublicationAPersonneListe auteursSupprimes = null;
|
56 |
|
56 |
|
57 |
private FieldSet auteursFieldset = null;
|
57 |
private FieldSet auteursFieldset = null;
|
58 |
private ComboBox<Projet> projetsCombo = null;
|
58 |
private ComboBox<Projet> projetsCombo = null;
|
59 |
private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
|
59 |
private ArrayList<ComboBox<Personne>> auteurComboboxListe = null;
|
60 |
private LayoutContainer conteneurChamps;
|
60 |
private LayoutContainer conteneurChamps;
|
61 |
private ListStore<Personne> auteursStorePartage = null;
|
61 |
private ListStore<Personne> auteursStorePartage = null;
|
62 |
private static boolean auteurStorePartageChargementOk = false;
|
62 |
private static boolean auteurStorePartageChargementOk = false;
|
63 |
|
63 |
|
64 |
private FieldSet generalitesFieldset = null;
|
64 |
private FieldSet generalitesFieldset = null;
|
65 |
private TextField<String> titreChp = null;
|
65 |
private TextField<String> titreChp = null;
|
66 |
private TextField<String> collectionChp = null;
|
66 |
private TextField<String> collectionChp = null;
|
67 |
private TextField<String> uriChp = null;
|
67 |
private TextField<String> uriChp = null;
|
68 |
|
68 |
|
69 |
private FieldSet editionFieldset = null;
|
69 |
private FieldSet editionFieldset = null;
|
70 |
private ComboBox<Structure> editeurCombobox = null;
|
70 |
private ComboBox<Structure> editeurCombobox = null;
|
71 |
private static boolean editeursOk = false;
|
71 |
private static boolean editeursOk = false;
|
72 |
private TextField<String> datePublicationChp = null;
|
72 |
private TextField<String> datePublicationChp = null;
|
73 |
private TextField<String> tomeChp = null;
|
73 |
private TextField<String> tomeChp = null;
|
74 |
private TextField<String> fasciculeChp = null;
|
74 |
private TextField<String> fasciculeChp = null;
|
75 |
private TextField<String> pagesChp = null;
|
75 |
private TextField<String> pagesChp = null;
|
76 |
|
76 |
|
77 |
boolean auteursAffiches = false;
|
77 |
boolean auteursAffiches = false;
|
78 |
private static boolean formulaireValideOk = false;
|
78 |
private static boolean formulaireValideOk = false;
|
79 |
private static boolean publicationValideOk = false;
|
79 |
private static boolean publicationValideOk = false;
|
80 |
private static boolean auteursValideOk = false;
|
80 |
private static boolean auteursValideOk = false;
|
81 |
private static boolean publicationOk = false;
|
81 |
private static boolean publicationOk = false;
|
82 |
private static boolean attenteAjoutAuteursOk = true;
|
82 |
private static boolean attenteAjoutAuteursOk = true;
|
83 |
private static boolean attenteSuppressionAuteursOk = true;
|
83 |
private static boolean attenteSuppressionAuteursOk = true;
|
84 |
|
84 |
|
85 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
85 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
86 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
86 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
87 |
}
|
87 |
}
|
88 |
|
88 |
|
89 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
|
89 |
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) {
|
90 |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
|
90 |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
|
91 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
91 |
initialiserPublicationForm(mediateurCourrant, publicationId);
|
92 |
}
|
92 |
}
|
93 |
|
93 |
|
94 |
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
94 |
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) {
|
95 |
auteursInitialListe = new PersonneListe();
|
95 |
auteursInitialListe = new PersonneListe();
|
96 |
initialiserValidation();
|
96 |
initialiserValidation();
|
97 |
initialiserAffichageAuteurs();
|
97 |
initialiserAffichageAuteurs();
|
98 |
|
98 |
|
99 |
publication = new Publication();
|
99 |
publication = new Publication();
|
100 |
publication.setId(publicationId);
|
100 |
publication.setId(publicationId);
|
101 |
|
101 |
|
102 |
String modeDeCreation = (UtilString.isEmpty(publication.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
102 |
String modeDeCreation = (UtilString.isEmpty(publication.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
|
103 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
|
103 |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION);
|
104 |
|
104 |
|
105 |
panneauFormulaire.setLayout(new FlowLayout());
|
105 |
panneauFormulaire.setLayout(new FlowLayout());
|
106 |
genererTitreFormulaire();
|
106 |
genererTitreFormulaire();
|
107 |
|
107 |
|
108 |
creerZoneAuteurs();
|
108 |
creerZoneAuteurs();
|
109 |
panneauFormulaire.add(auteursFieldset);
|
109 |
panneauFormulaire.add(auteursFieldset);
|
110 |
|
110 |
|
111 |
creerZoneGeneralites();
|
111 |
creerZoneGeneralites();
|
112 |
panneauFormulaire.add(generalitesFieldset);
|
112 |
panneauFormulaire.add(generalitesFieldset);
|
113 |
|
113 |
|
114 |
creerZoneEdition();
|
114 |
creerZoneEdition();
|
115 |
panneauFormulaire.add(editionFieldset);
|
115 |
panneauFormulaire.add(editionFieldset);
|
116 |
|
116 |
|
117 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
117 |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
|
118 |
mediateurCourrant.selectionnerPublication(this, publicationId);
|
118 |
mediateurCourrant.selectionnerPublication(this, publicationId);
|
119 |
mediateurCourrant.selectionnerPublicationAPersonne(this, publicationId, null, PublicationAPersonne.ROLE_AUTEUR);
|
119 |
mediateurCourrant.selectionnerPublicationAPersonne(this, publicationId, null, PublicationAPersonne.ROLE_AUTEUR);
|
120 |
}
|
120 |
}
|
121 |
}
|
121 |
}
|
122 |
|
122 |
|
123 |
private void genererTitreFormulaire() {
|
123 |
private void genererTitreFormulaire() {
|
124 |
String titre = i18nC.publicationTitreFormAjout();
|
124 |
String titre = i18nC.publicationTitreFormAjout();
|
125 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
125 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
126 |
titre = i18nC.publicationTitreFormModif();
|
126 |
titre = i18nC.publicationTitreFormModif();
|
127 |
if (publication != null) {
|
127 |
if (publication != null) {
|
128 |
titre += " - "+i18nC.id()+": "+publication.getId();
|
128 |
titre += " - "+i18nC.id()+": "+publication.getId();
|
129 |
}
|
129 |
}
|
130 |
}
|
130 |
}
|
131 |
panneauFormulaire.setHeading(titre);
|
131 |
panneauFormulaire.setHeading(titre);
|
132 |
}
|
132 |
}
|
133 |
|
133 |
|
134 |
private void creerZoneAuteurs() {
|
134 |
private void creerZoneAuteurs() {
|
135 |
FormLayout layout = new FormLayout();
|
135 |
FormLayout layout = new FormLayout();
|
136 |
layout.setLabelWidth(200);
|
136 |
layout.setLabelWidth(200);
|
137 |
|
137 |
|
138 |
// Fieldset Auteur
|
138 |
// Fieldset Auteur
|
139 |
auteursFieldset = new FieldSet();
|
139 |
auteursFieldset = new FieldSet();
|
140 |
auteursFieldset.setHeading(i18nC.publicationAuteursTitre());
|
140 |
auteursFieldset.setHeading(i18nC.publicationAuteursTitre());
|
141 |
auteursFieldset.setCollapsible(true);
|
141 |
auteursFieldset.setCollapsible(true);
|
142 |
auteursFieldset.setLayout(layout);
|
142 |
auteursFieldset.setLayout(layout);
|
143 |
|
143 |
|
144 |
Debug.log("Dans creerZoneAuteurs");
|
144 |
Debug.log("Dans creerZoneAuteurs");
|
145 |
auteurComboboxListe = new ArrayList<ComboBox<Personne>>(0);
|
145 |
auteurComboboxListe = new ArrayList<ComboBox<Personne>>(0);
|
146 |
auteursStorePartage = new ListStore<Personne>();
|
146 |
auteursStorePartage = new ListStore<Personne>();
|
147 |
mediateur.clicObtenirListeAuteurs(this);
|
147 |
mediateur.clicObtenirListeAuteurs(this);
|
148 |
|
148 |
|
149 |
creerChampsAuteur();
|
149 |
creerChampsAuteur();
|
150 |
}
|
150 |
}
|
151 |
|
151 |
|
152 |
private void creerChampsAuteur() {
|
152 |
private void creerChampsAuteur() {
|
153 |
auteursFieldset.removeAll();
|
153 |
auteursFieldset.removeAll();
|
154 |
conteneurChamps = new LayoutContainer();
|
154 |
conteneurChamps = new LayoutContainer();
|
155 |
|
155 |
|
156 |
Button ajouterAuteurBouton = new Button(i18nC.publicationAuteurBoutonAjouter());
|
156 |
Button ajouterAuteurBouton = new Button(i18nC.publicationAuteurBoutonAjouter());
|
157 |
ajouterAuteurBouton.setIcon(Images.ICONES.ajouter());
|
157 |
ajouterAuteurBouton.setIcon(Images.ICONES.ajouter());
|
158 |
ajouterAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
158 |
ajouterAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
159 |
@Override
|
159 |
@Override
|
160 |
public void componentSelected(ButtonEvent be) {
|
160 |
public void componentSelected(ButtonEvent be) {
|
161 |
creerChampAuteurEtBoutonSupprimer(null);
|
161 |
creerChampAuteurEtBoutonSupprimer(null);
|
162 |
}
|
162 |
}
|
163 |
});
|
163 |
});
|
164 |
|
164 |
|
165 |
auteursFieldset.add(conteneurChamps);
|
165 |
auteursFieldset.add(conteneurChamps);
|
166 |
auteursFieldset.add(ajouterAuteurBouton);
|
166 |
auteursFieldset.add(ajouterAuteurBouton);
|
167 |
auteursFieldset.layout();
|
167 |
auteursFieldset.layout();
|
168 |
}
|
168 |
}
|
169 |
|
169 |
|
170 |
public void creerChampAuteurEtBoutonSupprimer(Personne auteur) {
|
170 |
public void creerChampAuteurEtBoutonSupprimer(Personne auteur) {
|
171 |
final HorizontalPanel panneauHorizontal = new HorizontalPanel();
|
171 |
final HorizontalPanel panneauHorizontal = new HorizontalPanel();
|
172 |
|
172 |
|
173 |
LayoutContainer panneauChampTxt = new LayoutContainer();
|
173 |
LayoutContainer panneauChampTxt = new LayoutContainer();
|
174 |
panneauChampTxt.setLayout(new FormLayout());
|
174 |
panneauChampTxt.setLayout(new FormLayout());
|
175 |
|
175 |
|
176 |
final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis();
|
176 |
final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis();
|
177 |
if (auteur != null) {
|
177 |
if (auteur != null) {
|
178 |
auteursSaisisComboBox.setValue(auteur);
|
178 |
auteursSaisisComboBox.setValue(auteur);
|
179 |
auteursSaisisComboBox.validate();
|
179 |
auteursSaisisComboBox.validate();
|
180 |
}
|
180 |
}
|
181 |
auteurComboboxListe.add(auteursSaisisComboBox);
|
181 |
auteurComboboxListe.add(auteursSaisisComboBox);
|
182 |
auteursSaisisComboBox.setFieldLabel(i18nC.publicationAuteurSingulier()+" "+auteurComboboxListe.size());
|
182 |
auteursSaisisComboBox.setFieldLabel(i18nC.publicationAuteurSingulier()+" "+auteurComboboxListe.size());
|
183 |
panneauChampTxt.add(auteursSaisisComboBox, new FormData(300, 0));
|
183 |
panneauChampTxt.add(auteursSaisisComboBox, new FormData(300, 0));
|
184 |
panneauHorizontal.add(panneauChampTxt);
|
184 |
panneauHorizontal.add(panneauChampTxt);
|
185 |
|
185 |
|
186 |
Button supprimerAuteurBouton = new Button();
|
186 |
Button supprimerAuteurBouton = new Button();
|
187 |
supprimerAuteurBouton.setIcon(Images.ICONES.supprimer());
|
187 |
supprimerAuteurBouton.setIcon(Images.ICONES.supprimer());
|
188 |
supprimerAuteurBouton.setToolTip(i18nC.supprimer());
|
188 |
supprimerAuteurBouton.setToolTip(i18nC.supprimer());
|
189 |
supprimerAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
189 |
supprimerAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
190 |
@Override
|
190 |
@Override
|
191 |
public void componentSelected(ButtonEvent be) {
|
191 |
public void componentSelected(ButtonEvent be) {
|
192 |
auteurComboboxListe.remove(auteursSaisisComboBox);
|
192 |
auteurComboboxListe.remove(auteursSaisisComboBox);
|
193 |
conteneurChamps.remove(panneauHorizontal);
|
193 |
conteneurChamps.remove(panneauHorizontal);
|
194 |
|
194 |
|
195 |
int numeroAuteurs = 1;
|
195 |
int numeroAuteurs = 1;
|
196 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
196 |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) {
|
197 |
it.next().setFieldLabel(i18nC.publicationAuteurSingulier()+" "+numeroAuteurs);
|
197 |
it.next().setFieldLabel(i18nC.publicationAuteurSingulier()+" "+numeroAuteurs);
|
198 |
numeroAuteurs++;
|
198 |
numeroAuteurs++;
|
199 |
}
|
199 |
}
|
200 |
|
200 |
|
201 |
auteursFieldset.layout();
|
201 |
auteursFieldset.layout();
|
202 |
}
|
202 |
}
|
203 |
});
|
203 |
});
|
204 |
panneauHorizontal.add(supprimerAuteurBouton);
|
204 |
panneauHorizontal.add(supprimerAuteurBouton);
|
205 |
|
205 |
|
206 |
conteneurChamps.add(panneauHorizontal);
|
206 |
conteneurChamps.add(panneauHorizontal);
|
207 |
auteursFieldset.layout();
|
207 |
auteursFieldset.layout();
|
208 |
}
|
208 |
}
|
209 |
|
209 |
|
210 |
private ComboBox<Personne> creerComboBoxAuteursSaisis() {
|
210 |
private ComboBox<Personne> creerComboBoxAuteursSaisis() {
|
211 |
ListStore<Personne> auteursStore = new ListStore<Personne>();
|
211 |
ListStore<Personne> auteursStore = new ListStore<Personne>();
|
212 |
auteursStore.add(auteursStorePartage.getModels());
|
212 |
auteursStore.add(auteursStorePartage.getModels());
|
213 |
|
213 |
|
214 |
ComboBox<Personne> comboBox = new ComboBox<Personne>();
|
214 |
ComboBox<Personne> comboBox = new ComboBox<Personne>();
|
215 |
comboBox.setEmptyText(i18nC.chercherPersonneSaisi());
|
215 |
comboBox.setEmptyText(i18nC.chercherPersonneSaisi());
|
216 |
comboBox.setEditable(true);
|
216 |
comboBox.setEditable(true);
|
217 |
comboBox.setAllowBlank(false);
|
217 |
comboBox.setAllowBlank(false);
|
218 |
comboBox.setForceSelection(true);
|
218 |
comboBox.setForceSelection(true);
|
219 |
comboBox.setDisplayField("fmt_nom_complet");
|
219 |
comboBox.setDisplayField("fmt_nom_complet");
|
220 |
comboBox.setTriggerAction(TriggerAction.ALL);
|
220 |
comboBox.setTriggerAction(TriggerAction.ALL);
|
221 |
comboBox.setStore(auteursStore);
|
221 |
comboBox.setStore(auteursStore);
|
222 |
comboBox.setMessageTarget("tooltip");
|
222 |
comboBox.setMessageTarget("tooltip");
|
223 |
comboBox.addStyleName(ComposantClass.OBLIGATOIRE);
|
223 |
comboBox.addStyleName(ComposantClass.OBLIGATOIRE);
|
224 |
comboBox.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
224 |
comboBox.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
225 |
|
225 |
|
226 |
return comboBox;
|
226 |
return comboBox;
|
227 |
}
|
227 |
}
|
228 |
|
228 |
|
229 |
private void creerZoneGeneralites() {
|
229 |
private void creerZoneGeneralites() {
|
230 |
FormLayout layout = new FormLayout();
|
230 |
FormLayout layout = new FormLayout();
|
231 |
layout.setLabelWidth(200);
|
231 |
layout.setLabelWidth(200);
|
232 |
|
232 |
|
233 |
// Fieldset Infos Générales
|
233 |
// Fieldset Infos Générales
|
234 |
generalitesFieldset = new FieldSet();
|
234 |
generalitesFieldset = new FieldSet();
|
235 |
generalitesFieldset.setHeading("Informations générales");
|
235 |
generalitesFieldset.setHeading("Informations générales");
|
236 |
generalitesFieldset.setCollapsible(true);
|
236 |
generalitesFieldset.setCollapsible(true);
|
237 |
generalitesFieldset.setLayout(layout);
|
237 |
generalitesFieldset.setLayout(layout);
|
238 |
|
238 |
|
239 |
projetsCombo = new ComboBox<Projet>();
|
239 |
projetsCombo = new ComboBox<Projet>();
|
240 |
projetsCombo.setTabIndex(tabIndex++);
|
240 |
projetsCombo.setTabIndex(tabIndex++);
|
241 |
projetsCombo.setFieldLabel(i18nC.projetChamp());
|
241 |
projetsCombo.setFieldLabel(i18nC.projetChamp());
|
242 |
projetsCombo.setDisplayField("nom");
|
242 |
projetsCombo.setDisplayField("nom");
|
243 |
projetsCombo.setForceSelection(true);
|
243 |
projetsCombo.setForceSelection(true);
|
244 |
projetsCombo.setValidator(new Validator() {
|
244 |
projetsCombo.setValidator(new Validator() {
|
245 |
@Override
|
245 |
@Override
|
246 |
public String validate(Field<?> field, String value) {
|
246 |
public String validate(Field<?> field, String value) {
|
247 |
String retour = null;
|
247 |
String retour = null;
|
248 |
if (field.getRawValue().equals("")) {
|
248 |
if (field.getRawValue().equals("")) {
|
249 |
field.setValue(null);
|
249 |
field.setValue(null);
|
250 |
} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) {
|
250 |
} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) {
|
251 |
String contenuBrut = field.getRawValue();
|
251 |
String contenuBrut = field.getRawValue();
|
252 |
field.setValue(null);
|
252 |
field.setValue(null);
|
253 |
field.setRawValue(contenuBrut);
|
253 |
field.setRawValue(contenuBrut);
|
254 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
254 |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide";
|
255 |
}
|
255 |
}
|
256 |
return retour;
|
256 |
return retour;
|
257 |
}
|
257 |
}
|
258 |
});
|
258 |
});
|
259 |
projetsCombo.setTriggerAction(TriggerAction.ALL);
|
259 |
projetsCombo.setTriggerAction(TriggerAction.ALL);
|
260 |
projetsCombo.setStore(new ListStore<Projet>());
|
260 |
projetsCombo.setStore(new ListStore<Projet>());
|
261 |
projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE);
|
261 |
projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE);
|
262 |
projetsCombo.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
|
262 |
projetsCombo.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire());
|
263 |
generalitesFieldset.add(projetsCombo, new FormData(450, 0));
|
263 |
generalitesFieldset.add(projetsCombo, new FormData(450, 0));
|
264 |
mediateur.selectionnerProjet(this, null);
|
264 |
mediateur.selectionnerProjet(this, null);
|
265 |
|
265 |
|
266 |
titreChp = new TextField<String>();
|
266 |
titreChp = new TextField<String>();
|
267 |
titreChp.setName("cpu");
|
267 |
titreChp.setName("cpu");
|
268 |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
268 |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage");
|
269 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
269 |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
270 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
270 |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
271 |
generalitesFieldset.add(titreChp, new FormData(450, 0));
|
271 |
generalitesFieldset.add(titreChp, new FormData(450, 0));
|
272 |
|
272 |
|
273 |
collectionChp = new TextField<String>();
|
273 |
collectionChp = new TextField<String>();
|
274 |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
|
274 |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection");
|
275 |
generalitesFieldset.add(collectionChp, new FormData(450, 0));
|
275 |
generalitesFieldset.add(collectionChp, new FormData(450, 0));
|
276 |
|
276 |
|
277 |
uriChp = new TextField<String>();
|
277 |
uriChp = new TextField<String>();
|
278 |
uriChp.setFieldLabel("URL de la publication");
|
278 |
uriChp.setFieldLabel("URL de la publication");
|
279 |
generalitesFieldset.add(uriChp, new FormData(450, 0));
|
279 |
generalitesFieldset.add(uriChp, new FormData(450, 0));
|
280 |
}
|
280 |
}
|
281 |
|
281 |
|
282 |
private void creerZoneEdition() {
|
282 |
private void creerZoneEdition() {
|
283 |
FormLayout layout = new FormLayout();
|
283 |
FormLayout layout = new FormLayout();
|
284 |
layout.setLabelWidth(200);
|
284 |
layout.setLabelWidth(200);
|
285 |
|
285 |
|
286 |
// Fieldset Edition
|
286 |
// Fieldset Edition
|
287 |
editionFieldset = new FieldSet();
|
287 |
editionFieldset = new FieldSet();
|
288 |
editionFieldset.setHeading("Édition");
|
288 |
editionFieldset.setHeading("Édition");
|
289 |
editionFieldset.setCollapsible(true);
|
289 |
editionFieldset.setCollapsible(true);
|
290 |
editionFieldset.setLayout(layout);
|
290 |
editionFieldset.setLayout(layout);
|
291 |
|
291 |
|
292 |
ListStore<Structure> editeurStore = new ListStore<Structure>();
|
292 |
ListStore<Structure> editeurStore = new ListStore<Structure>();
|
293 |
editeurCombobox = new ComboBox<Structure>();
|
293 |
editeurCombobox = new ComboBox<Structure>();
|
294 |
editeurCombobox.setEmptyText("Sélectionner un éditeur...");
|
294 |
editeurCombobox.setEmptyText("Sélectionner un éditeur...");
|
295 |
editeurCombobox.setFieldLabel("Éditeur de la publication");
|
295 |
editeurCombobox.setFieldLabel("Éditeur de la publication");
|
296 |
editeurCombobox.setDisplayField("nom");
|
296 |
editeurCombobox.setDisplayField("nom");
|
297 |
editeurCombobox.setStore(editeurStore);
|
297 |
editeurCombobox.setStore(editeurStore);
|
298 |
editeurCombobox.setEditable(true);
|
298 |
editeurCombobox.setEditable(true);
|
299 |
editeurCombobox.setTriggerAction(TriggerAction.ALL);
|
299 |
editeurCombobox.setTriggerAction(TriggerAction.ALL);
|
300 |
editionFieldset.add(editeurCombobox, new FormData(450, 0));
|
300 |
editionFieldset.add(editeurCombobox, new FormData(450, 0));
|
301 |
mediateur.clicObtenirListeEditeurs(this);
|
301 |
mediateur.clicObtenirListeEditeurs(this);
|
302 |
|
302 |
|
303 |
datePublicationChp = new TextField<String>();
|
303 |
datePublicationChp = new TextField<String>();
|
304 |
datePublicationChp.setMaxLength(4);
|
304 |
datePublicationChp.setMaxLength(4);
|
305 |
datePublicationChp.setMinLength(4);
|
305 |
datePublicationChp.setMinLength(4);
|
306 |
datePublicationChp.setFieldLabel("Année de publication");
|
306 |
datePublicationChp.setFieldLabel("Année de publication");
|
307 |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
307 |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE);
|
308 |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
308 |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire());
|
309 |
editionFieldset.add(datePublicationChp, new FormData(40, 0));
|
309 |
editionFieldset.add(datePublicationChp, new FormData(40, 0));
|
310 |
|
310 |
|
311 |
tomeChp = new TextField<String>();
|
311 |
tomeChp = new TextField<String>();
|
312 |
tomeChp.setFieldLabel("Série de la revue ou tome");
|
312 |
tomeChp.setFieldLabel("Série de la revue ou tome");
|
313 |
editionFieldset.add(tomeChp, new FormData(75, 0));
|
313 |
editionFieldset.add(tomeChp, new FormData(75, 0));
|
314 |
|
314 |
|
315 |
fasciculeChp = new TextField<String>();
|
315 |
fasciculeChp = new TextField<String>();
|
316 |
fasciculeChp.setFieldLabel("Fascicule de la revue");
|
316 |
fasciculeChp.setFieldLabel("Fascicule de la revue");
|
317 |
editionFieldset.add(fasciculeChp, new FormData(75, 0));
|
317 |
editionFieldset.add(fasciculeChp, new FormData(75, 0));
|
318 |
|
318 |
|
319 |
pagesChp = new TextField<String>();
|
319 |
pagesChp = new TextField<String>();
|
320 |
pagesChp.setFieldLabel("Pages");
|
320 |
pagesChp.setFieldLabel("Pages");
|
321 |
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)");
|
321 |
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)");
|
322 |
editionFieldset.add(pagesChp, new FormData(100, 0));
|
322 |
editionFieldset.add(pagesChp, new FormData(100, 0));
|
323 |
}
|
323 |
}
|
324 |
|
324 |
|
325 |
public void rafraichir(Object nouvellesDonnees) {
|
325 |
public void rafraichir(Object nouvellesDonnees) {
|
326 |
if (nouvellesDonnees instanceof Publication) {
|
326 |
if (nouvellesDonnees instanceof Publication) {
|
327 |
// Si on a reçu les details d'une publication
|
327 |
// Si on a reçu les details d'une publication
|
328 |
rafraichirPublication((Publication) nouvellesDonnees);
|
328 |
rafraichirPublication((Publication) nouvellesDonnees);
|
329 |
} else if (nouvellesDonnees instanceof StructureListe) {
|
329 |
} else if (nouvellesDonnees instanceof StructureListe) {
|
330 |
// Si on a reçu une liste des editeurs
|
330 |
// Si on a reçu une liste des editeurs
|
331 |
rafraichirListeEditeurs((StructureListe) nouvellesDonnees);
|
331 |
rafraichirListeEditeurs((StructureListe) nouvellesDonnees);
|
332 |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
|
332 |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) {
|
333 |
rafraichirListeAuteurs((PublicationAPersonneListe) nouvellesDonnees);
|
333 |
rafraichirListeAuteurs((PublicationAPersonneListe) nouvellesDonnees);
|
334 |
} else if (nouvellesDonnees instanceof Information) {
|
334 |
} else if (nouvellesDonnees instanceof Information) {
|
335 |
rafraichirInformation((Information) nouvellesDonnees);
|
335 |
rafraichirInformation((Information) nouvellesDonnees);
|
336 |
} else if (nouvellesDonnees instanceof ProjetListe) {
|
336 |
} else if (nouvellesDonnees instanceof ProjetListe) {
|
337 |
ProjetListe projets = (ProjetListe) nouvellesDonnees;
|
337 |
ProjetListe projets = (ProjetListe) nouvellesDonnees;
|
338 |
Formulaire.rafraichirComboBox(projets, projetsCombo);
|
338 |
Formulaire.rafraichirComboBox(projets, projetsCombo);
|
339 |
setValeurComboProjets();
|
339 |
setValeurComboProjets();
|
340 |
} else {
|
340 |
} else {
|
341 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
341 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
342 |
}
|
342 |
}
|
343 |
|
343 |
|
344 |
synchronisation();
|
344 |
synchronisation();
|
345 |
}
|
345 |
}
|
346 |
|
346 |
|
347 |
private void synchronisation() {
|
347 |
private void synchronisation() {
|
348 |
// Respecter l'ordre et faire attention à la réinitialisation des jetons
|
348 |
// Respecter l'ordre et faire attention à la réinitialisation des jetons
|
349 |
// 1. gestion des auteurs (Modif ou Ajout)
|
349 |
// 1. gestion des auteurs (Modif ou Ajout)
|
350 |
// 2. peupler le formulaire (Modif)
|
350 |
// 2. peupler le formulaire (Modif)
|
351 |
// 3. initialisation de la gestion des auteurs ajoutés/supprimés (Modif)
|
351 |
// 3. initialisation de la gestion des auteurs ajoutés/supprimés (Modif)
|
352 |
// 4. valider le formulaire (Modif ou Ajout)
|
352 |
// 4. valider le formulaire (Modif ou Ajout)
|
353 |
|
353 |
|
354 |
if (etrePretAAfficherAuteurs()) {
|
354 |
if (etrePretAAfficherAuteurs()) {
|
355 |
afficherAuteurs();
|
355 |
afficherAuteurs();
|
356 |
initialiserAffichageAuteurs();
|
356 |
initialiserAffichageAuteurs();
|
357 |
}
|
357 |
}
|
358 |
|
358 |
|
359 |
if (etrePretAPeupler()) {
|
359 |
if (etrePretAPeupler()) {
|
360 |
Debug.log("Entrain de peupler");
|
360 |
Debug.log("Entrain de peupler");
|
361 |
peuplerFormulaire();
|
361 |
peuplerFormulaire();
|
362 |
genererTitreFormulaire();
|
362 |
genererTitreFormulaire();
|
363 |
initialiserPeupler();
|
363 |
initialiserPeupler();
|
364 |
}
|
364 |
}
|
365 |
|
365 |
|
366 |
if (avoirAuteursMiseAJourCorrectement()) {
|
366 |
if (avoirAuteursMiseAJourCorrectement()) {
|
367 |
Debug.log("Mise à jour liste auteur");
|
367 |
Debug.log("Mise à jour liste auteur");
|
368 |
miseAJourAuteursInitialListe();
|
368 |
miseAJourAuteursInitialListe();
|
369 |
initialiserAuteurs();
|
369 |
initialiserAuteurs();
|
370 |
auteursValideOk = true;
|
370 |
auteursValideOk = true;
|
371 |
}
|
371 |
}
|
372 |
|
372 |
|
373 |
if (etreValide()) {
|
373 |
if (etreValide()) {
|
374 |
initialiserValidation();
|
374 |
initialiserValidation();
|
375 |
repandreRafraichissement();
|
375 |
repandreRafraichissement();
|
376 |
controlerFermetureApresRafraichissement();
|
376 |
controlerFermetureApresRafraichissement();
|
377 |
}
|
377 |
}
|
378 |
}
|
378 |
}
|
379 |
|
379 |
|
380 |
private void miseAJourAuteursInitialListe() {
|
380 |
private void miseAJourAuteursInitialListe() {
|
381 |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
|
381 |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator();
|
382 |
while (clesAjoutees.hasNext()) {
|
382 |
while (clesAjoutees.hasNext()) {
|
383 |
Personne auteurAjoute = auteursAjoutes.get(clesAjoutees.next()).getPersonne();
|
383 |
Personne auteurAjoute = auteursAjoutes.get(clesAjoutees.next()).getPersonne();
|
384 |
auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
|
384 |
auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute);
|
385 |
}
|
385 |
}
|
386 |
|
386 |
|
387 |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
|
387 |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator();
|
388 |
while (clesSupprimees.hasNext()) {
|
388 |
while (clesSupprimees.hasNext()) {
|
389 |
Personne auteurSupprime = auteursSupprimes.get(clesSupprimees.next()).getPersonne();
|
389 |
Personne auteurSupprime = auteursSupprimes.get(clesSupprimees.next()).getPersonne();
|
390 |
auteursInitialListe.remove(auteurSupprime.getId());
|
390 |
auteursInitialListe.remove(auteurSupprime.getId());
|
391 |
}
|
391 |
}
|
392 |
}
|
392 |
}
|
393 |
|
393 |
|
394 |
private void rafraichirPublication(Publication publi) {
|
394 |
private void rafraichirPublication(Publication publi) {
|
395 |
publicationOk = true;
|
395 |
publicationOk = true;
|
396 |
publication = publi;
|
396 |
publication = publi;
|
397 |
}
|
397 |
}
|
398 |
|
398 |
|
399 |
private void rafraichirListeEditeurs(StructureListe editeurs) {
|
399 |
private void rafraichirListeEditeurs(StructureListe editeurs) {
|
400 |
editeursOk = true;
|
400 |
editeursOk = true;
|
401 |
editeurCombobox.getStore().removeAll();
|
401 |
editeurCombobox.getStore().removeAll();
|
402 |
editeurCombobox.getStore().add((List<Structure>) editeurs.toList());
|
402 |
editeurCombobox.getStore().add((List<Structure>) editeurs.toList());
|
403 |
}
|
403 |
}
|
404 |
|
404 |
|
405 |
private void rafraichirListeAuteurs(PublicationAPersonneListe auteurs) {
|
405 |
private void rafraichirListeAuteurs(PublicationAPersonneListe auteurs) {
|
406 |
Iterator<String> it = auteurs.keySet().iterator();
|
406 |
Iterator<String> it = auteurs.keySet().iterator();
|
407 |
while (it.hasNext()) {
|
407 |
while (it.hasNext()) {
|
408 |
Personne auteur = auteurs.get(it.next()).getPersonne();
|
408 |
Personne auteur = auteurs.get(it.next()).getPersonne();
|
409 |
auteursInitialListe.put(auteur.getId(), auteur);
|
409 |
auteursInitialListe.put(auteur.getId(), auteur);
|
410 |
}
|
410 |
}
|
411 |
Debug.log("Réception liste des auteurs : "+auteurs.size());
|
411 |
Debug.log("Réception liste des auteurs : "+auteurs.size());
|
412 |
publicationAPersonneListeChargementOk = true;
|
412 |
publicationAPersonneListeChargementOk = true;
|
413 |
}
|
413 |
}
|
414 |
|
414 |
|
415 |
private void rafraichirInformation(Information info) {
|
415 |
private void rafraichirInformation(Information info) {
|
416 |
String type = info.getType();
|
416 |
String type = info.getType();
|
417 |
if (type.equals("ajout_publication") || type.equals("modif_publication")) {
|
417 |
if (type.equals("ajout_publication") || type.equals("modif_publication")) {
|
418 |
publicationValideOk = true;
|
418 |
publicationValideOk = true;
|
419 |
if (vueExterneARafraichirApresValidation != null) {
|
- |
|
420 |
publication.setId((String) info.getDonnee(0));
|
- |
|
421 |
}
|
- |
|
422 |
|
- |
|
423 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
419 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
- |
|
420 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
- |
|
421 |
String publicationId = (String) info.getDonnee(0);
|
- |
|
422 |
if (publicationId.matches("[0-9]+")) {
|
- |
|
423 |
publication.setId(publicationId);
|
- |
|
424 |
}
|
- |
|
425 |
}
|
424 |
attenteAjoutAuteursOk = true;
|
426 |
attenteAjoutAuteursOk = true;
|
425 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
427 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
426 |
}
|
428 |
}
|
427 |
}
|
429 |
}
|
428 |
|
430 |
|
429 |
if (info.getType().equals("liste_personne")) {
|
431 |
if (info.getType().equals("liste_personne")) {
|
430 |
PersonneListe listePersonneAuteur = (PersonneListe) info.getDonnee(0);
|
432 |
PersonneListe listePersonneAuteur = (PersonneListe) info.getDonnee(0);
|
431 |
|
433 |
|
432 |
List<Personne> liste = listePersonneAuteur.toList();
|
434 |
List<Personne> liste = listePersonneAuteur.toList();
|
433 |
auteursStorePartage.removeAll();
|
435 |
auteursStorePartage.removeAll();
|
434 |
auteursStorePartage.add(liste);
|
436 |
auteursStorePartage.add(liste);
|
435 |
Debug.log("Reception nouvelle liste auteurs");
|
437 |
Debug.log("Reception nouvelle liste auteurs");
|
436 |
auteurStorePartageChargementOk = true;
|
438 |
auteurStorePartageChargementOk = true;
|
437 |
} else if (info.getType().equals("ajout_publication_a_personne")) {
|
439 |
} else if (info.getType().equals("ajout_publication_a_personne")) {
|
438 |
attenteAjoutAuteursOk = false;
|
440 |
attenteAjoutAuteursOk = false;
|
439 |
GWT.log("attenteAjoutAuteursOk", null);
|
441 |
Debug.log("attenteAjoutAuteursOk");
|
440 |
} else if (info.getType().equals("suppression_publication_a_personne")) {
|
442 |
} else if (info.getType().equals("suppression_publication_a_personne")) {
|
441 |
attenteSuppressionAuteursOk = false;
|
443 |
attenteSuppressionAuteursOk = false;
|
442 |
GWT.log("attenteSuppressionAuteursOk", null);
|
444 |
Debug.log("attenteSuppressionAuteursOk");
|
443 |
} else if (info.getType().equals("modif_publication")) {
|
445 |
} else if (info.getType().equals("modif_publication")) {
|
444 |
Info.display("Modification d'une publication", info.toString());
|
446 |
Info.display("Modification d'une publication", info.toString());
|
445 |
} else if (info.getType().equals("ajout_publication")) {
|
447 |
} else if (info.getType().equals("ajout_publication")) {
|
446 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) {
|
448 |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String && ((String) info.getDonnee(0)).matches("[0-9]+")) {
|
447 |
String publicationId = (String) info.getDonnee(0);
|
449 |
String publicationId = (String) info.getDonnee(0);
|
448 |
Info.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
|
450 |
Info.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée");
|
449 |
if (vueExterneARafraichirApresValidation != null) {
|
- |
|
450 |
publication.setId(publicationId);
|
- |
|
451 |
}
|
- |
|
452 |
} else {
|
451 |
} else {
|
453 |
Info.display("Ajout d'une publication", info.toString());
|
452 |
Info.display("Ajout d'une publication", info.toString());
|
454 |
}
|
453 |
}
|
455 |
}
|
454 |
}
|
456 |
}
|
455 |
}
|
457 |
|
456 |
|
458 |
private boolean avoirAuteursMiseAJourCorrectement() {
|
457 |
private boolean avoirAuteursMiseAJourCorrectement() {
|
459 |
boolean ok = false;
|
458 |
boolean ok = false;
|
460 |
if (attenteAjoutAuteursOk == false && attenteSuppressionAuteursOk == false) {
|
459 |
if (attenteAjoutAuteursOk == false && attenteSuppressionAuteursOk == false) {
|
461 |
ok = true;
|
460 |
ok = true;
|
462 |
}
|
461 |
}
|
463 |
return ok;
|
462 |
return ok;
|
464 |
}
|
463 |
}
|
465 |
|
464 |
|
466 |
private void afficherAuteurs() {
|
465 |
private void afficherAuteurs() {
|
467 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
466 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
468 |
creerChampAuteurEtBoutonSupprimer(null);
|
467 |
creerChampAuteurEtBoutonSupprimer(null);
|
469 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
468 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
470 |
Iterator<String> itap = auteursInitialListe.keySet().iterator();
|
469 |
Iterator<String> itap = auteursInitialListe.keySet().iterator();
|
471 |
while (itap.hasNext()) {
|
470 |
while (itap.hasNext()) {
|
472 |
creerChampAuteurEtBoutonSupprimer(auteursInitialListe.get(itap.next()));
|
471 |
creerChampAuteurEtBoutonSupprimer(auteursInitialListe.get(itap.next()));
|
473 |
}
|
472 |
}
|
474 |
}
|
473 |
}
|
475 |
auteursAffiches = true;
|
474 |
auteursAffiches = true;
|
476 |
}
|
475 |
}
|
477 |
|
476 |
|
478 |
private void initialiserAffichageAuteurs() {
|
477 |
private void initialiserAffichageAuteurs() {
|
479 |
auteurStorePartageChargementOk = false;
|
478 |
auteurStorePartageChargementOk = false;
|
480 |
publicationAPersonneListeChargementOk = false;
|
479 |
publicationAPersonneListeChargementOk = false;
|
481 |
}
|
480 |
}
|
482 |
|
481 |
|
483 |
private void initialiserPeupler() {
|
482 |
private void initialiserPeupler() {
|
484 |
publicationOk = false;
|
483 |
publicationOk = false;
|
485 |
editeursOk = false;
|
484 |
editeursOk = false;
|
486 |
auteursAffiches = false;
|
485 |
auteursAffiches = false;
|
487 |
}
|
486 |
}
|
488 |
|
487 |
|
489 |
private boolean etrePretAAfficherAuteurs() {
|
488 |
private boolean etrePretAAfficherAuteurs() {
|
490 |
boolean ok = false;
|
489 |
boolean ok = false;
|
491 |
if (auteurStorePartageChargementOk
|
490 |
if (auteurStorePartageChargementOk
|
492 |
&& ((mode.equals(Formulaire.MODE_MODIFIER) && publicationOk && publicationAPersonneListeChargementOk)
|
491 |
&& ((mode.equals(Formulaire.MODE_MODIFIER) && publicationOk && publicationAPersonneListeChargementOk)
|
493 |
|| (mode.equals(Formulaire.MODE_AJOUTER)))) {
|
492 |
|| (mode.equals(Formulaire.MODE_AJOUTER)))) {
|
494 |
ok = true;
|
493 |
ok = true;
|
495 |
}
|
494 |
}
|
496 |
return ok;
|
495 |
return ok;
|
497 |
}
|
496 |
}
|
498 |
|
497 |
|
499 |
private boolean etrePretAPeupler() {
|
498 |
private boolean etrePretAPeupler() {
|
500 |
boolean ok = false;
|
499 |
boolean ok = false;
|
501 |
Debug.log("Mode :"+mode.equals(Formulaire.MODE_MODIFIER)+" - PublicationOk :"+publicationOk+" - AuteursAffiches :"+auteursAffiches);
|
500 |
Debug.log("Mode :"+mode.equals(Formulaire.MODE_MODIFIER)+" - PublicationOk :"+publicationOk+" - AuteursAffiches :"+auteursAffiches);
|
502 |
if (mode.equals(Formulaire.MODE_MODIFIER) && publicationOk && auteursAffiches && editeursOk) {
|
501 |
if (mode.equals(Formulaire.MODE_MODIFIER) && publicationOk && auteursAffiches && editeursOk) {
|
503 |
ok = true;
|
502 |
ok = true;
|
504 |
}
|
503 |
}
|
505 |
return ok;
|
504 |
return ok;
|
506 |
}
|
505 |
}
|
507 |
|
506 |
|
508 |
private Boolean etreValide() {
|
507 |
private Boolean etreValide() {
|
509 |
Boolean valide = false;
|
508 |
Boolean valide = false;
|
510 |
//Debug.log("formulaire"+formulaireValideOk+" - Publication :"+publicationValideOk+" - Auteurs :"+auteursValideOk, null);
|
509 |
//Debug.log("formulaire"+formulaireValideOk+" - Publication :"+publicationValideOk+" - Auteurs :"+auteursValideOk, null);
|
511 |
if (formulaireValideOk && publicationValideOk && auteursValideOk) {
|
510 |
if (formulaireValideOk && publicationValideOk && auteursValideOk) {
|
512 |
valide = true;
|
511 |
valide = true;
|
513 |
}
|
512 |
}
|
514 |
return valide;
|
513 |
return valide;
|
515 |
}
|
514 |
}
|
516 |
|
515 |
|
517 |
private void initialiserValidation() {
|
516 |
private void initialiserValidation() {
|
518 |
formulaireValideOk = false;
|
517 |
formulaireValideOk = false;
|
519 |
publicationValideOk = false;
|
518 |
publicationValideOk = false;
|
520 |
initialiserAuteurs();
|
519 |
initialiserAuteurs();
|
521 |
auteursValideOk = false;
|
520 |
auteursValideOk = false;
|
522 |
}
|
521 |
}
|
523 |
|
522 |
|
524 |
private void initialiserAuteurs() {
|
523 |
private void initialiserAuteurs() {
|
525 |
attenteAjoutAuteursOk = true;
|
524 |
attenteAjoutAuteursOk = true;
|
526 |
auteursAjoutes = new PublicationAPersonneListe();
|
525 |
auteursAjoutes = new PublicationAPersonneListe();
|
527 |
attenteSuppressionAuteursOk = true;
|
526 |
attenteSuppressionAuteursOk = true;
|
528 |
auteursSupprimes = new PublicationAPersonneListe();
|
527 |
auteursSupprimes = new PublicationAPersonneListe();
|
529 |
}
|
528 |
}
|
530 |
|
529 |
|
531 |
private void repandreRafraichissement() {
|
530 |
private void repandreRafraichissement() {
|
532 |
if (vueExterneARafraichirApresValidation != null) {
|
531 |
if (vueExterneARafraichirApresValidation != null) {
|
533 |
String type = "publication_modifiee";
|
532 |
String type = "publication_modifiee";
|
534 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
533 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
535 |
type = "publication_ajoutee";
|
534 |
type = "publication_ajoutee";
|
536 |
}
|
535 |
}
|
537 |
Information info = new Information(type);
|
536 |
Information info = new Information(type);
|
538 |
info.setDonnee(0, publication);
|
537 |
info.setDonnee(0, publication);
|
539 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
538 |
vueExterneARafraichirApresValidation.rafraichir(info);
|
540 |
}
|
539 |
}
|
541 |
}
|
540 |
}
|
542 |
|
541 |
|
543 |
public boolean soumettreFormulaire() {
|
542 |
public boolean soumettreFormulaire() {
|
544 |
formulaireValideOk = verifierFormulaire();
|
543 |
formulaireValideOk = verifierFormulaire();
|
545 |
if (formulaireValideOk) {
|
544 |
if (formulaireValideOk) {
|
546 |
soumettrePublication();
|
545 |
soumettrePublication();
|
547 |
soumettreAuteurs();
|
546 |
soumettreAuteurs();
|
548 |
}
|
547 |
}
|
549 |
return formulaireValideOk;
|
548 |
return formulaireValideOk;
|
550 |
}
|
549 |
}
|
551 |
|
550 |
|
552 |
private void soumettrePublication() {
|
551 |
private void soumettrePublication() {
|
553 |
Publication publicationCollectee = collecterPublication();
|
552 |
Publication publicationCollectee = collecterPublication();
|
554 |
if (publicationCollectee != null) {
|
553 |
if (publicationCollectee != null) {
|
555 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
554 |
if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
556 |
mediateur.ajouterPublication(this, publicationCollectee);
|
555 |
mediateur.ajouterPublication(this, publicationCollectee);
|
557 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
556 |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
558 |
mediateur.modifierPublication(this, publicationCollectee);
|
557 |
mediateur.modifierPublication(this, publicationCollectee);
|
559 |
}
|
558 |
}
|
560 |
}
|
559 |
}
|
561 |
}
|
560 |
}
|
562 |
|
561 |
|
563 |
private void soumettreAuteurs() {
|
562 |
private void soumettreAuteurs() {
|
564 |
attenteAjoutAuteursOk = false;
|
563 |
attenteAjoutAuteursOk = false;
|
565 |
attenteSuppressionAuteursOk = false;
|
564 |
attenteSuppressionAuteursOk = false;
|
566 |
|
565 |
|
567 |
PersonneListe personnesInitiales = auteursInitialListe;
|
566 |
PersonneListe personnesInitiales = auteursInitialListe;
|
568 |
|
567 |
|
569 |
PersonneListe personnesActuelles = new PersonneListe();
|
568 |
PersonneListe personnesActuelles = new PersonneListe();
|
570 |
if (auteurComboboxListe != null) {
|
569 |
if (auteurComboboxListe != null) {
|
571 |
Iterator<ComboBox<Personne>> itcp = auteurComboboxListe.iterator();
|
570 |
Iterator<ComboBox<Personne>> itcp = auteurComboboxListe.iterator();
|
572 |
while (itcp.hasNext()) {
|
571 |
while (itcp.hasNext()) {
|
573 |
ComboBox<Personne> combobox = itcp.next();
|
572 |
ComboBox<Personne> combobox = itcp.next();
|
574 |
Personne personne = combobox.getValue();
|
573 |
Personne personne = combobox.getValue();
|
575 |
if (personne != null) {
|
574 |
if (personne != null) {
|
576 |
personnesActuelles.put(personne.getId(), personne);
|
575 |
personnesActuelles.put(personne.getId(), personne);
|
577 |
} else {
|
576 |
} else {
|
578 |
Debug.log("Etre valide :"+combobox.isValid()+" - "+combobox.getRawValue());
|
577 |
Debug.log("Etre valide :"+combobox.isValid()+" - "+combobox.getRawValue());
|
579 |
}
|
578 |
}
|
580 |
}
|
579 |
}
|
581 |
}
|
580 |
}
|
582 |
|
581 |
|
583 |
// Auteurs ajoutés
|
582 |
// Auteurs ajoutés
|
584 |
Iterator<String> clesActuelles = personnesActuelles.keySet().iterator();
|
583 |
Iterator<String> clesActuelles = personnesActuelles.keySet().iterator();
|
585 |
while (clesActuelles.hasNext()) {
|
584 |
while (clesActuelles.hasNext()) {
|
586 |
String idActuel = clesActuelles.next();
|
585 |
String idActuel = clesActuelles.next();
|
587 |
if (personnesInitiales.size() == 0 || personnesInitiales.get(idActuel) == null) {
|
586 |
if (personnesInitiales.size() == 0 || personnesInitiales.get(idActuel) == null) {
|
588 |
Personne personne = personnesActuelles.get(idActuel);
|
587 |
Personne personne = personnesActuelles.get(idActuel);
|
589 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
588 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
590 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
589 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
591 |
publicationAAuteur.setIdPublication(publication.getId());
|
590 |
publicationAAuteur.setIdPublication(publication.getId());
|
592 |
}
|
591 |
}
|
593 |
publicationAAuteur.setPersonne(personne);
|
592 |
publicationAAuteur.setPersonne(personne);
|
594 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
593 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
595 |
auteursAjoutes.put(publicationAAuteur.getId(), publicationAAuteur);
|
594 |
auteursAjoutes.put(publicationAAuteur.getId(), publicationAAuteur);
|
596 |
attenteAjoutAuteursOk = true;
|
595 |
attenteAjoutAuteursOk = true;
|
597 |
}
|
596 |
}
|
598 |
}
|
597 |
}
|
599 |
|
598 |
|
600 |
// Auteurs supprimés
|
599 |
// Auteurs supprimés
|
601 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
600 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
602 |
Iterator<String> clesInitiales = personnesInitiales.keySet().iterator();
|
601 |
Iterator<String> clesInitiales = personnesInitiales.keySet().iterator();
|
603 |
while (clesInitiales.hasNext()) {
|
602 |
while (clesInitiales.hasNext()) {
|
604 |
String idInitial = clesInitiales.next();
|
603 |
String idInitial = clesInitiales.next();
|
605 |
if (personnesActuelles.size() == 0 || personnesActuelles.get(idInitial) == null) {
|
604 |
if (personnesActuelles.size() == 0 || personnesActuelles.get(idInitial) == null) {
|
606 |
Personne personne = personnesInitiales.get(idInitial);
|
605 |
Personne personne = personnesInitiales.get(idInitial);
|
607 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
606 |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne();
|
608 |
publicationAAuteur.setIdPublication(publication.getId());
|
607 |
publicationAAuteur.setIdPublication(publication.getId());
|
609 |
publicationAAuteur.setPersonne(personne);
|
608 |
publicationAAuteur.setPersonne(personne);
|
610 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
609 |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR);
|
611 |
auteursSupprimes.put(publicationAAuteur.getId(), publicationAAuteur);
|
610 |
auteursSupprimes.put(publicationAAuteur.getId(), publicationAAuteur);
|
612 |
attenteSuppressionAuteursOk = true;
|
611 |
attenteSuppressionAuteursOk = true;
|
613 |
}
|
612 |
}
|
614 |
}
|
613 |
}
|
615 |
}
|
614 |
}
|
616 |
|
615 |
|
617 |
// Execution de les mise à jour pour le mode MODIFICATION
|
616 |
// Execution de les mise à jour pour le mode MODIFICATION
|
618 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
617 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
619 |
if (auteursAjoutes != null && auteursAjoutes.size() != 0) {
|
618 |
if (auteursAjoutes != null && auteursAjoutes.size() != 0) {
|
620 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
619 |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR);
|
621 |
}
|
620 |
}
|
622 |
|
621 |
|
623 |
if (auteursSupprimes != null && auteursSupprimes.size() != 0) {
|
622 |
if (auteursSupprimes != null && auteursSupprimes.size() != 0) {
|
624 |
mediateur.supprimerPublicationAPersonne(this, auteursSupprimes);
|
623 |
mediateur.supprimerPublicationAPersonne(this, auteursSupprimes);
|
625 |
}
|
624 |
}
|
626 |
}
|
625 |
}
|
627 |
Debug.log("personnesInitiales:"+personnesInitiales.size()+" - personnesActuelles :"+personnesActuelles.size()+" - auteursSupprimes :"+auteursSupprimes.size()+" - auteursAjoutes :"+auteursAjoutes.size());
|
626 |
Debug.log("personnesInitiales:"+personnesInitiales.size()+" - personnesActuelles :"+personnesActuelles.size()+" - auteursSupprimes :"+auteursSupprimes.size()+" - auteursAjoutes :"+auteursAjoutes.size());
|
628 |
}
|
627 |
}
|
629 |
|
628 |
|
630 |
public boolean verifierFormulaire() {
|
629 |
public boolean verifierFormulaire() {
|
631 |
boolean valide = true;
|
630 |
boolean valide = true;
|
632 |
ArrayList<String> messages = new ArrayList<String>();
|
631 |
ArrayList<String> messages = new ArrayList<String>();
|
633 |
|
632 |
|
634 |
boolean auteurErreur = true;
|
633 |
boolean auteurErreur = true;
|
635 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
634 |
for (int i = 0; i < auteurComboboxListe.size(); i++) {
|
636 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
635 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
637 |
auteurErreur = false;
|
636 |
auteurErreur = false;
|
638 |
break;
|
637 |
break;
|
639 |
}
|
638 |
}
|
640 |
}
|
639 |
}
|
641 |
if (auteurErreur) {
|
640 |
if (auteurErreur) {
|
642 |
messages.add("Veuillez saisir au moins un auteur !");
|
641 |
messages.add("Veuillez saisir au moins un auteur !");
|
643 |
}
|
642 |
}
|
644 |
|
643 |
|
645 |
String titre = titreChp.getValue();
|
644 |
String titre = titreChp.getValue();
|
646 |
if (titre == null || titre.equals("")) {
|
645 |
if (titre == null || titre.equals("")) {
|
647 |
messages.add("Veuillez saisir le titre de la publication !");
|
646 |
messages.add("Veuillez saisir le titre de la publication !");
|
648 |
}
|
647 |
}
|
649 |
|
648 |
|
650 |
String uri = uriChp.getValue();
|
649 |
String uri = uriChp.getValue();
|
651 |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
|
650 |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) {
|
652 |
messages.add("L'URL saisie n'est pas valide !");
|
651 |
messages.add("L'URL saisie n'est pas valide !");
|
653 |
}
|
652 |
}
|
654 |
|
653 |
|
655 |
String datePublication = datePublicationChp.getRawValue();
|
654 |
String datePublication = datePublicationChp.getRawValue();
|
656 |
if (datePublication == null || datePublication.equals("")) {
|
655 |
if (datePublication == null || datePublication.equals("")) {
|
657 |
messages.add("Veuillez saisir une année de parution !");
|
656 |
messages.add("Veuillez saisir une année de parution !");
|
658 |
} else {
|
657 |
} else {
|
659 |
if (!etreDateValide(datePublication)) {
|
658 |
if (!etreDateValide(datePublication)) {
|
660 |
messages.add("Le format de l'année saisie est incorrect !");
|
659 |
messages.add("Le format de l'année saisie est incorrect !");
|
661 |
}
|
660 |
}
|
662 |
}
|
661 |
}
|
663 |
|
662 |
|
664 |
String pages = pagesChp.getValue();
|
663 |
String pages = pagesChp.getValue();
|
665 |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
|
664 |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)";
|
666 |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
|
665 |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) {
|
667 |
messages.add("Le format des pages est incorrect !");
|
666 |
messages.add("Le format des pages est incorrect !");
|
668 |
}
|
667 |
}
|
669 |
|
668 |
|
670 |
if (messages.size() != 0) {
|
669 |
if (messages.size() != 0) {
|
671 |
String[] tableauDeMessages = {};
|
670 |
String[] tableauDeMessages = {};
|
672 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
671 |
tableauDeMessages = messages.toArray(tableauDeMessages);
|
673 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
|
672 |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null);
|
674 |
valide = false;
|
673 |
valide = false;
|
675 |
}
|
674 |
}
|
676 |
return valide;
|
675 |
return valide;
|
677 |
}
|
676 |
}
|
678 |
|
677 |
|
679 |
private void peuplerFormulaire() {
|
678 |
private void peuplerFormulaire() {
|
680 |
setValeurComboProjets();
|
679 |
setValeurComboProjets();
|
681 |
titreChp.setValue(publication.getTitre());
|
680 |
titreChp.setValue(publication.getTitre());
|
682 |
collectionChp.setValue(publication.getCollection());
|
681 |
collectionChp.setValue(publication.getCollection());
|
683 |
uriChp.setValue(publication.getURI());
|
682 |
uriChp.setValue(publication.getURI());
|
684 |
datePublicationChp.setValue(reduireDateParAnnee(publication.getDateParution()));
|
683 |
datePublicationChp.setValue(reduireDateParAnnee(publication.getDateParution()));
|
685 |
tomeChp.setValue(publication.getIndicationNvt());
|
684 |
tomeChp.setValue(publication.getIndicationNvt());
|
686 |
fasciculeChp.setValue(publication.getFascicule());
|
685 |
fasciculeChp.setValue(publication.getFascicule());
|
687 |
pagesChp.setValue(publication.getPages());
|
686 |
pagesChp.setValue(publication.getPages());
|
688 |
|
687 |
|
689 |
if (publication.getEditeur().matches("^[0-9]+$")) {
|
688 |
if (publication.getEditeur().matches("^[0-9]+$")) {
|
690 |
editeurCombobox.setValue(editeurCombobox.getStore().findModel("id_structure", publication.getEditeur()));
|
689 |
editeurCombobox.setValue(editeurCombobox.getStore().findModel("id_structure", publication.getEditeur()));
|
691 |
} else {
|
690 |
} else {
|
692 |
editeurCombobox.setRawValue(publication.getEditeur());
|
691 |
editeurCombobox.setRawValue(publication.getEditeur());
|
693 |
}
|
692 |
}
|
694 |
}
|
693 |
}
|
695 |
|
694 |
|
696 |
private Publication collecterPublication() {
|
695 |
private Publication collecterPublication() {
|
697 |
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
|
696 |
Publication publicationCollectee = (Publication) publication.cloner(new Publication());
|
698 |
|
697 |
|
699 |
publicationCollectee.setIdProjet(getValeurComboProjets());
|
698 |
publicationCollectee.setIdProjet(getValeurComboProjets());
|
700 |
|
699 |
|
701 |
publicationCollectee.setAuteur(construireIntituleAuteur());
|
700 |
publicationCollectee.setAuteur(construireIntituleAuteur());
|
702 |
|
701 |
|
703 |
String titre = titreChp.getValue();
|
702 |
String titre = titreChp.getValue();
|
704 |
publicationCollectee.setTitre(titre);
|
703 |
publicationCollectee.setTitre(titre);
|
705 |
|
704 |
|
706 |
String collection = collectionChp.getValue();
|
705 |
String collection = collectionChp.getValue();
|
707 |
publicationCollectee.setCollection(collection);
|
706 |
publicationCollectee.setCollection(collection);
|
708 |
|
707 |
|
709 |
publicationCollectee.setNomComplet(construireNomComplet());
|
708 |
publicationCollectee.setNomComplet(construireNomComplet());
|
710 |
|
709 |
|
711 |
String uri = uriChp.getValue();
|
710 |
String uri = uriChp.getValue();
|
712 |
publicationCollectee.setUri(uri);
|
711 |
publicationCollectee.setUri(uri);
|
713 |
|
712 |
|
714 |
String editeur = "";
|
713 |
String editeur = "";
|
715 |
if (editeurCombobox.getValue() != null) {
|
714 |
if (editeurCombobox.getValue() != null) {
|
716 |
editeur = editeurCombobox.getValue().getId();
|
715 |
editeur = editeurCombobox.getValue().getId();
|
717 |
publicationCollectee.setStructureEditeur(editeurCombobox.getValue());
|
716 |
publicationCollectee.setStructureEditeur(editeurCombobox.getValue());
|
718 |
} else if (editeurCombobox.getRawValue() != "") {
|
717 |
} else if (editeurCombobox.getRawValue() != "") {
|
719 |
editeur = editeurCombobox.getRawValue();
|
718 |
editeur = editeurCombobox.getRawValue();
|
720 |
}
|
719 |
}
|
721 |
publicationCollectee.setEditeur(editeur);
|
720 |
publicationCollectee.setEditeur(editeur);
|
722 |
|
721 |
|
723 |
String anneePublication = datePublicationChp.getRawValue();
|
722 |
String anneePublication = datePublicationChp.getRawValue();
|
724 |
String datePublication = anneePublication+"-00-00";
|
723 |
String datePublication = anneePublication+"-00-00";
|
725 |
publicationCollectee.setDateParution(datePublication);
|
724 |
publicationCollectee.setDateParution(datePublication);
|
726 |
|
725 |
|
727 |
String tome = tomeChp.getValue();
|
726 |
String tome = tomeChp.getValue();
|
728 |
publicationCollectee.setIndicationNvt(tome);
|
727 |
publicationCollectee.setIndicationNvt(tome);
|
729 |
|
728 |
|
730 |
String fascicule = fasciculeChp.getValue();
|
729 |
String fascicule = fasciculeChp.getValue();
|
731 |
publicationCollectee.setFascicule(fascicule);
|
730 |
publicationCollectee.setFascicule(fascicule);
|
732 |
|
731 |
|
733 |
String pages = pagesChp.getValue();
|
732 |
String pages = pagesChp.getValue();
|
734 |
publicationCollectee.setPages(pages);
|
733 |
publicationCollectee.setPages(pages);
|
735 |
|
734 |
|
736 |
Publication publicationARetourner = null;
|
735 |
Publication publicationARetourner = null;
|
737 |
if (!publicationCollectee.comparer(publication)) {
|
736 |
if (!publicationCollectee.comparer(publication)) {
|
738 |
publicationARetourner = publication = publicationCollectee;
|
737 |
publicationARetourner = publication = publicationCollectee;
|
739 |
}
|
738 |
}
|
740 |
return publicationARetourner;
|
739 |
return publicationARetourner;
|
741 |
}
|
740 |
}
|
742 |
|
741 |
|
743 |
private String construireIntituleEditeur() {
|
742 |
private String construireIntituleEditeur() {
|
744 |
String editeur = "";
|
743 |
String editeur = "";
|
745 |
if (editeurCombobox.getValue() != null) {
|
744 |
if (editeurCombobox.getValue() != null) {
|
746 |
editeur = editeurCombobox.getValue().getNom();
|
745 |
editeur = editeurCombobox.getValue().getNom();
|
747 |
} else if (editeurCombobox.getRawValue() != "") {
|
746 |
} else if (editeurCombobox.getRawValue() != "") {
|
748 |
editeur = editeurCombobox.getRawValue();
|
747 |
editeur = editeurCombobox.getRawValue();
|
749 |
}
|
748 |
}
|
750 |
return editeur;
|
749 |
return editeur;
|
751 |
}
|
750 |
}
|
752 |
|
751 |
|
753 |
private String construireIntituleAuteur() {
|
752 |
private String construireIntituleAuteur() {
|
754 |
String inituleAuteur = "";
|
753 |
String inituleAuteur = "";
|
755 |
int auteursNombre = auteurComboboxListe.size();
|
754 |
int auteursNombre = auteurComboboxListe.size();
|
756 |
for (int i = 0; i < auteursNombre; i++) {
|
755 |
for (int i = 0; i < auteursNombre; i++) {
|
757 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
756 |
if (auteurComboboxListe.get(i).getValue() != null) {
|
758 |
Personne auteur = auteurComboboxListe.get(i).getValue();
|
757 |
Personne auteur = auteurComboboxListe.get(i).getValue();
|
759 |
inituleAuteur += auteur.getNom().toUpperCase()+ " "+auteur.getPrenom();
|
758 |
inituleAuteur += auteur.getNom().toUpperCase()+ " "+auteur.getPrenom();
|
760 |
if (i != (auteursNombre - 1)) {
|
759 |
if (i != (auteursNombre - 1)) {
|
761 |
inituleAuteur += ", ";
|
760 |
inituleAuteur += ", ";
|
762 |
}
|
761 |
}
|
763 |
}
|
762 |
}
|
764 |
}
|
763 |
}
|
765 |
return inituleAuteur;
|
764 |
return inituleAuteur;
|
766 |
}
|
765 |
}
|
767 |
|
766 |
|
768 |
private String construireNomComplet() {
|
767 |
private String construireNomComplet() {
|
769 |
// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
|
768 |
// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages.
|
770 |
String nomComplet = "";
|
769 |
String nomComplet = "";
|
771 |
String auteurs = construireIntituleAuteur();
|
770 |
String auteurs = construireIntituleAuteur();
|
772 |
String annee = datePublicationChp.getRawValue();
|
771 |
String annee = datePublicationChp.getRawValue();
|
773 |
String titre = titreChp.getValue();
|
772 |
String titre = titreChp.getValue();
|
774 |
String editeur = construireIntituleEditeur();
|
773 |
String editeur = construireIntituleEditeur();
|
775 |
|
774 |
|
776 |
nomComplet += auteurs+", "+annee+". "+titre+".";
|
775 |
nomComplet += auteurs+", "+annee+". "+titre+".";
|
777 |
|
776 |
|
778 |
if (!UtilString.isEmpty(editeur)) {
|
777 |
if (!UtilString.isEmpty(editeur)) {
|
779 |
nomComplet += " Éditeur "+editeur+".";
|
778 |
nomComplet += " Éditeur "+editeur+".";
|
780 |
}
|
779 |
}
|
781 |
|
780 |
|
782 |
if (collectionChp.getValue() != null) {
|
781 |
if (collectionChp.getValue() != null) {
|
783 |
String revue = collectionChp.getValue();
|
782 |
String revue = collectionChp.getValue();
|
784 |
nomComplet += ", "+revue;
|
783 |
nomComplet += ", "+revue;
|
785 |
}
|
784 |
}
|
786 |
|
785 |
|
787 |
if (fasciculeChp.getValue() != null) {
|
786 |
if (fasciculeChp.getValue() != null) {
|
788 |
String fascicule = fasciculeChp.getValue();
|
787 |
String fascicule = fasciculeChp.getValue();
|
789 |
nomComplet += ", "+fascicule;
|
788 |
nomComplet += ", "+fascicule;
|
790 |
}
|
789 |
}
|
791 |
|
790 |
|
792 |
if (tomeChp.getValue() != null) {
|
791 |
if (tomeChp.getValue() != null) {
|
793 |
String tomaison = tomeChp.getValue();
|
792 |
String tomaison = tomeChp.getValue();
|
794 |
nomComplet += ", "+tomaison;
|
793 |
nomComplet += ", "+tomaison;
|
795 |
}
|
794 |
}
|
796 |
|
795 |
|
797 |
if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
|
796 |
if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) {
|
798 |
nomComplet += ".";
|
797 |
nomComplet += ".";
|
799 |
}
|
798 |
}
|
800 |
|
799 |
|
801 |
if (pagesChp.getValue() != null) {
|
800 |
if (pagesChp.getValue() != null) {
|
802 |
String pages = pagesChp.getValue();
|
801 |
String pages = pagesChp.getValue();
|
803 |
nomComplet += pages+".";
|
802 |
nomComplet += pages+".";
|
804 |
}
|
803 |
}
|
805 |
|
804 |
|
806 |
return nomComplet;
|
805 |
return nomComplet;
|
807 |
}
|
806 |
}
|
808 |
|
807 |
|
809 |
public void reinitialiserFormulaire() {
|
808 |
public void reinitialiserFormulaire() {
|
810 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
809 |
if (mode.equals(Formulaire.MODE_MODIFIER)) {
|
811 |
mediateur.afficherFormPublication(publication.getId());
|
810 |
mediateur.afficherFormPublication(publication.getId());
|
812 |
} else {
|
811 |
} else {
|
813 |
mediateur.afficherFormPublication(null);
|
812 |
mediateur.afficherFormPublication(null);
|
814 |
}
|
813 |
}
|
815 |
}
|
814 |
}
|
816 |
|
815 |
|
817 |
private boolean etreDateValide(String anneePublication) {
|
816 |
private boolean etreDateValide(String anneePublication) {
|
818 |
boolean valide = true;
|
817 |
boolean valide = true;
|
819 |
if (!anneePublication.matches("^[0-2][0-9]{3}$")) {
|
818 |
if (!anneePublication.matches("^[0-2][0-9]{3}$")) {
|
820 |
valide = false;
|
819 |
valide = false;
|
821 |
}
|
820 |
}
|
822 |
return valide;
|
821 |
return valide;
|
823 |
}
|
822 |
}
|
824 |
|
823 |
|
825 |
private String reduireDateParAnnee(String datePar) {
|
824 |
private String reduireDateParAnnee(String datePar) {
|
826 |
if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) {
|
825 |
if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) {
|
827 |
return datePar.split("-")[0];
|
826 |
return datePar.split("-")[0];
|
828 |
} else {
|
827 |
} else {
|
829 |
return "";
|
828 |
return "";
|
830 |
}
|
829 |
}
|
831 |
}
|
830 |
}
|
832 |
|
831 |
|
833 |
private String getValeurComboProjets() {
|
832 |
private String getValeurComboProjets() {
|
834 |
String valeur = "";
|
833 |
String valeur = "";
|
835 |
if (projetsCombo.getValue() != null) {
|
834 |
if (projetsCombo.getValue() != null) {
|
836 |
valeur = projetsCombo.getValue().getId();
|
835 |
valeur = projetsCombo.getValue().getId();
|
837 |
}
|
836 |
}
|
838 |
return valeur;
|
837 |
return valeur;
|
839 |
}
|
838 |
}
|
840 |
private void setValeurComboProjets() {
|
839 |
private void setValeurComboProjets() {
|
841 |
if (projetsCombo.getStore() != null ) {
|
840 |
if (projetsCombo.getStore() != null ) {
|
842 |
if (mode.equals(Formulaire.MODE_MODIFIER) && publication != null) {
|
841 |
if (mode.equals(Formulaire.MODE_MODIFIER) && publication != null) {
|
843 |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", publication.getIdProjet()));
|
842 |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", publication.getIdProjet()));
|
844 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
843 |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) {
|
845 |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", mediateur.getProjetId()));
|
844 |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", mediateur.getProjetId()));
|
846 |
}
|
845 |
}
|
847 |
}
|
846 |
}
|
848 |
}
|
847 |
}
|
849 |
}
|
848 |
}
|