91,21 → 91,11 |
import com.google.gwt.i18n.client.NumberFormat; |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
|
public class StructureForm extends LayoutContainer implements Rafraichissable { |
public class StructureForm extends Formulaire implements Rafraichissable { |
|
public static final String MODE_AJOUTER = "AJOUT"; |
public static final String MODE_MODIFIER = "MODIF"; |
|
private Constantes i18nC = null; |
private Mediateur mediateur = null; |
|
private String mode = null; |
private static Boolean clicBoutonvalidation = false; |
private static int decompteRafraichissementPersonnel = 0; |
private int tabIndex = 100; |
private FormPanel structureFormPanneau = null; |
private TabPanel onglets = null; |
|
|
private TabItem identificationOnglet = null; |
private TabItem personnelOnglet = null; |
private TabItem conservationOnglet = null; |
222,41 → 212,15 |
private ComboBox<Projet> projetsCombo = null; |
private CellEditor fonctionEditor = null; |
private List<Valeur> fonctionsListe = null; |
private ButtonBar barreOutilsValidation = null; |
|
|
public StructureForm(Mediateur mediateurCourrant, String modeDeCreation) { |
//+-----------------------------------------------------------------------------------------------------------+ |
// Initialisation de variables |
mode = modeDeCreation; |
mediateur = mediateurCourrant; |
i18nC = Mediateur.i18nC; |
|
// Iniatilisation du layoutContainer |
setLayout(new FitLayout()); |
setBorders(false); |
|
// Création du panneau du FORMULAIRE GÉNÉRAL |
structureFormPanneau = new FormPanel(); |
structureFormPanneau.setBodyBorder(false); |
structureFormPanneau.setFrame(true); |
structureFormPanneau.setIcon(Images.ICONES.formAjouter()); |
structureFormPanneau.setCollapsible(false); |
structureFormPanneau.setHeading(i18nC.titreAjoutFormStructurePanneau()); |
structureFormPanneau.setButtonAlign(HorizontalAlignment.CENTER); |
structureFormPanneau.setLayout(new FitLayout()); |
|
// Création des onglets |
super(mediateurCourrant, modeDeCreation); |
creerOnglets(); |
|
// Ajout des boutons au panneau formulaire |
creerBarreOutilsValidation(); |
|
// Ajout du panneau Formulaire à la disposition générale |
add(structureFormPanneau); |
add(panneauFormulaire); |
} |
|
private void creerOnglets() { |
protected void creerOnglets() { |
onglets = new TabPanel(); |
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) |
onglets.setHeight("100%"); |
277,38 → 241,21 |
//onglets.setSelection(personnelOnglet); |
|
// Ajout des onglets au formulaire général |
structureFormPanneau.add(onglets); |
panneauFormulaire.add(onglets); |
} |
|
private void creerBarreOutilsValidation() { |
barreOutilsValidation = new ButtonBar(); |
barreOutilsValidation.setAlignment(HorizontalAlignment.LEFT); |
|
barreOutilsValidation.add(creerBouton(i18nC.reinitialiser(), Images.ICONES.reinitialiser(), "RE")); |
|
barreOutilsValidation.add(new FillToolItem()); |
|
barreOutilsValidation.add(creerBouton(i18nC.appliquer(), Images.ICONES.appliquer(), "AP")); |
|
barreOutilsValidation.add(creerBouton(i18nC.annuler(), Images.ICONES.annuler(), "AN")); |
|
barreOutilsValidation.add(creerBouton(i18nC.valider(), Images.ICONES.valider(), "VA")); |
|
structureFormPanneau.setBottomComponent(barreOutilsValidation); |
} |
|
private Button creerBouton(String nom, AbstractImagePrototype icone, final String code) { |
SelectionListener<ButtonEvent> sl = new SelectionListener<ButtonEvent>() { |
protected SelectionListener<ButtonEvent> creerEcouteurBoutonFormulaire(final String code) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
if (code.equals("VA")) { |
if (code.equals(Formulaire.CODE_BOUTON_VALIDER)) { |
soumettreFormulaire(); |
clicBoutonvalidation = true; |
} else if (code.equals("AP")) { |
} else if (code.equals(Formulaire.CODE_BOUTON_APPLIQUER)) { |
soumettreFormulaire(); |
} else if (code.equals("AN")) { |
} else if (code.equals(Formulaire.CODE_BOUTON_ANNULER)) { |
mediateur.clicMenu(MenuApplicationId.STRUCTURE); |
} else if (code.equals("RE")) { |
} else if (code.equals(Formulaire.CODE_BOUTON_REINITIALISER)) { |
if (mode.equals(StructureForm.MODE_MODIFIER)) { |
mediateur.afficherFormStructure(identification.getId()); |
} else { |
318,11 → 265,7 |
} |
}; |
|
Button bouton = new Button(nom); |
bouton.setIcon(icone); |
bouton.addSelectionListener(sl); |
|
return bouton; |
return ecouteur; |
} |
|
private void soumettreFormulaire() { |
334,12 → 277,12 |
StructureValorisation valorisation = collecterStructureValorisation(); |
collecterStructurePersonnel(); |
|
if (mode.equals("AJOUT")) { |
if (mode.equals(MODE_AJOUTER)) { |
// Ajout des informations sur la Structure |
mediateur.ajouterStructure(this, structure, conservation, valorisation); |
// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée |
// Voir la méthode rafraichir(). |
} else if (mode.equals("MODIF")) { |
} else if (mode.equals(MODE_MODIFIER)) { |
// Modification des informations sur la Structure |
if (structure == null && conservation == null && valorisation == null) { |
Info.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
486,7 → 429,6 |
//TODO : check below: |
((Radio) actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1))).setValue(true); |
|
|
// ACTION INFO |
peuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp); |
|
817,17 → 759,15 |
} |
|
private TabItem creerOngletValorisation() { |
valorisationOnglet = new TabItem(); |
valorisationOnglet.setText("Valorisation"); |
valorisationOnglet.setScrollMode(Scroll.AUTO); |
valorisationOnglet = creerOnglet("Valorisation", "valorisation"); |
valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP)); |
valorisationOnglet.setStyleAttribute("padding", "10px"); |
valorisationOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur |
valorisationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
peuplerStructureValorisation(); |
} |
}); |
valorisationOnglet.layout(); |
} |
}; |
valorisationOnglet.addListener(Events.Select, ecouteurSelection); |
|
actionMarkRGrpChp = creerChoixUniqueRadioGroupe("action_mark", "ouiNon"); |
actionMarkRGrpChp.setFieldLabel("Avez-vous réalisé des actions de valorisation de vos collections botaniques ou avez-vous été sollicités pour la valorisation de ces collections ?"); |
919,18 → 859,15 |
} |
|
private TabItem creerOngletConservation() { |
conservationOnglet = new TabItem(); |
conservationOnglet.setText("Conservation"); |
conservationOnglet.setScrollMode(Scroll.AUTO); |
conservationOnglet = creerOnglet("Conservation", "conservation"); |
conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP)); |
conservationOnglet.setStyleAttribute("padding", "10px"); |
conservationOnglet.setData("acces", false); |
conservationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
peuplerStructureConservation(); |
conservationOnglet.layout(); |
} |
}); |
}; |
conservationOnglet.addListener(Events.Select, ecouteurSelection); |
|
formationMarkRGrpChp = creerChoixUniqueRadioGroupe("formation_mark", "ouiNon"); |
formationMarkRGrpChp.setFieldLabel("Le personnel s'occupant des collections a-t-il suivi des formations en conservations ?"); |
1191,14 → 1128,10 |
personnelAjoute = new StructureAPersonneListe(); |
personnelSupprime = new StructureAPersonneListe(); |
|
personnelOnglet = new TabItem(); |
personnelOnglet.setText("Personnel"); |
personnelOnglet.setScrollMode(Scroll.AUTO); |
personnelOnglet = creerOnglet("Personnel", "personnel"); |
personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT)); |
identificationOnglet.setStyleAttribute("padding", "10px"); |
personnelOnglet.setData("acces", false); // Permet de savoir si l'onblet a été accédé par l'utilisateur |
personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... |
personnelOnglet.setData("acces", true); |
|
1507,13 → 1440,8 |
private TabItem creerOngletIdentification() { |
//+-----------------------------------------------------------------------------------------------------------+ |
// Onlget formulaire IDENTIFICATION |
identificationOnglet = new TabItem(); |
identificationOnglet.setId("identification"); |
identificationOnglet.setText("Identification"); |
identificationOnglet.setLayout(new FormLayout()); |
identificationOnglet.setStyleAttribute("padding", "10px"); |
identificationOnglet.setScrollMode(Scroll.AUTO); |
identificationOnglet.setData("acces", false); |
identificationOnglet = creerOnglet("Identification", "identification"); |
GWT.log(identificationOnglet.getItemId(), null); |
identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
peuplerStructureIdentification(); |
1539,8 → 1467,9 |
nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire."); |
fieldSetIdentite.add(nomStructureChp, new FormData(450, 0)); |
|
|
projetsMagazin = new ListStore<Projet>(); |
mediateur.selectionnerProjets(this); |
projetsMagazin = new ListStore<Projet>(); |
projetsCombo = new ComboBox<Projet>(); |
projetsCombo.setTabIndex(tabIndex++); |
projetsCombo.setFieldLabel("Projet"); |
2045,10 → 1974,10 |
cp.layout(); |
} |
|
public void rafraichir(Object nouvelleDonnees) { |
public void rafraichir(Object nouvellesDonnees) { |
try { |
if (nouvelleDonnees instanceof Information) { |
Information info = (Information) nouvelleDonnees; |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
2104,7 → 2033,7 |
} |
} |
} |
structureFormPanneau.setHeading(titre); |
panneauFormulaire.setHeading(titre); |
} else if (info.getType().equals("liste_structure_a_personne")) { |
if (info.getDonnee(0) != null) { |
personnel = (StructureAPersonneListe) info.getDonnee(0); |
2136,8 → 2065,8 |
personneExistanteCombo.expand(); |
} |
} |
} else if (nouvelleDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
|
List<Valeur> liste = listeValeurs.toList(); |
|
2241,8 → 2170,8 |
} else { |
GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null); |
} |
} else if (nouvelleDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvelleDonnees; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
|
List<Projet> liste = new ArrayList<Projet>(); |
for (Iterator<String> it = projets.keySet().iterator(); it.hasNext();) { |
2252,7 → 2181,7 |
projetsMagazin.add(liste); |
projetsCombo.setStore(projetsMagazin); |
} else { |
GWT.log("Pas de correspondance dans la méthode rafraichir() de la classe "+this.getClass(), null); |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} catch (Exception e) { |
GWT.log("rafraichir()", e); |