New file |
0,0 → 1,488 |
package org.tela_botanica.client.vues.structure; |
|
import java.util.ArrayList; |
import java.util.Date; |
import java.util.Iterator; |
import java.util.LinkedList; |
import java.util.List; |
|
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable; |
import org.tela_botanica.client.composants.GrillePaginable; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.composants.pagination.ProxyCollectionAPersonne; |
import org.tela_botanica.client.composants.pagination.ProxyPersonnes; |
import org.tela_botanica.client.composants.pagination.ProxyStructureAPersonne; |
import org.tela_botanica.client.composants.pagination.ProxyValeur; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.InterneValeur; |
import org.tela_botanica.client.modeles.InterneValeurListe; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureAPersonne; |
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe; |
import org.tela_botanica.client.modeles.structure.StructureConservation; |
import org.tela_botanica.client.modeles.structure.StructureValorisation; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilArray; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.structure.StructureFormPersonne.EtatPersonnelStructure; |
|
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.data.ModelData; |
import com.extjs.gxt.ui.client.data.ModelType; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.EventType; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.store.Record; |
import com.extjs.gxt.ui.client.store.Store; |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.Component; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Html; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.form.CheckBox; |
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.DateField; |
import com.extjs.gxt.ui.client.widget.form.Field; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.HiddenField; |
import com.extjs.gxt.ui.client.widget.form.LabelField; |
import com.extjs.gxt.ui.client.widget.form.NumberField; |
import com.extjs.gxt.ui.client.widget.form.Radio; |
import com.extjs.gxt.ui.client.widget.form.RadioGroup; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
import com.extjs.gxt.ui.client.widget.form.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; |
import com.extjs.gxt.ui.client.widget.grid.EditorGrid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig; |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer; |
import com.extjs.gxt.ui.client.widget.layout.ColumnData; |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.i18n.client.NumberFormat; |
import com.google.gwt.user.client.Window; |
|
public class StructureForm extends Formulaire implements Rafraichissable { |
|
private TabPanel onglets = null; |
private StructureFormIdentification identificationOnglet = null; |
private StructureFormPersonne personnelOnglet = null; |
private StructureFormConservation conservationOnglet = null; |
private StructureFormValorisation valorisationOnglet = null; |
|
// Onglet IDENTIFICATION |
public Structure identification = null; |
|
// Onglet PERSONNEL |
// Vide suite à refactoring |
|
// Onglet CONSERVATION |
public StructureConservation conservation = null; |
|
// Onglet VALORISATION |
public StructureValorisation valorisation = null; |
|
private Sequenceur sequenceur; |
|
public Structure structure = null; |
|
public Rafraichissable vueExterneARafraichirApresValidation = null; |
|
public StructureForm(Mediateur mediateurCourrant, String modeDeCreation, Sequenceur sequenceur) { |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.STRUCTURE); |
this.sequenceur = sequenceur; |
|
// Ajout du titre |
panneauFormulaire.setHeadingHtml(i18nC.titreAjoutFormStructurePanneau()); |
// Création des onglets |
onglets = creerOnglets(); |
|
// Ajout des onglets au formulaire général |
panneauFormulaire.add(onglets); |
} |
|
protected TabPanel creerOnglets() { |
TabPanel ongletsStructure = 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) |
ongletsStructure.setHeight("100%"); |
|
// Onlget formulaire IDENTIFICATION |
ongletsStructure.add(creerOngletIdentification()); |
|
// Onlget formulaire PERSONNEL |
ongletsStructure.add(creerOngletPersonnel()); |
|
// Onlget formulaire CONSERVATION |
ongletsStructure.add(creerOngletConservation()); |
|
// Onlget formulaire VALORISATION |
ongletsStructure.add(creerOngletValorisation()); |
|
// Sélection de l'onglet par défaut |
//ongletsStructure(personnelOnglet); |
|
return ongletsStructure; |
} |
|
private void repandreRafraichissement() { |
if (vueExterneARafraichirApresValidation != null) { |
String type = "structure_modifiee"; |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
type = "structure_ajoutee"; |
} |
Information info = new Information(type); |
info.setDonnee(0, structure); |
vueExterneARafraichirApresValidation.rafraichir(info); |
} |
} |
|
public boolean soumettreFormulaire() { |
|
// Vérification de la validité des champs du formulaire |
boolean fomulaireValide = verifierFormulaire(); |
|
Structure identification = collecterStructureIdentification(); |
|
if(identification != null) { |
structure = identification; |
} else { |
structure = this.identification; |
} |
|
|
structure.setConservation(this.conservation); |
structure.setValorisation(this.valorisation); |
|
if (fomulaireValide) { |
// Collecte des données du formulaire |
StructureConservation conservation = collecterStructureConservation(); |
StructureValorisation valorisation = collecterStructureValorisation(); |
|
if(conservation != null) { |
structure.setConservation(conservation); |
} |
|
if(valorisation != null) { |
structure.setValorisation(valorisation); |
} |
|
EtatPersonnelStructure etatPersonnel = personnelOnglet.collecter(); |
|
structure.setPersonnel(etatPersonnel.personnel); |
structure.setConservation(conservation); |
structure.setValorisation(valorisation); |
|
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(MODE_MODIFIER)) { |
|
// Modification des informations sur la Structure |
if (structure == null && conservation == null && valorisation == null) { |
//InfoLogger.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
mediateur.modifierStructure(this, structure.getId(), structure, conservation, valorisation); |
} |
|
if (etatPersonnel.personnelModifie.size() == 0 && etatPersonnel.personnelAjoute.size() == 0 && etatPersonnel.personnelSupprime.size() == 0) { |
//InfoLogger.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
if (etatPersonnel.personnelModifie.size() != 0) { |
personnelOnglet.incrementerDecompteRafraichissementPersonnel(); |
mediateur.modifierStructureAPersonne(this, etatPersonnel.personnelModifie); |
} |
// Ajout des relations StructureAPersonne |
if (etatPersonnel.personnelAjoute.size() != 0) { |
personnelOnglet.incrementerDecompteRafraichissementPersonnel(); |
mediateur.ajouterStructureAPersonne(this, structure.getId(), etatPersonnel.personnelAjoute); |
} |
// Suppression des relations StructureAPersonne |
if (etatPersonnel.personnelSupprime.size() != 0) { |
personnelOnglet.incrementerDecompteRafraichissementPersonnel(); |
mediateur.supprimerStructureAPersonne(this, etatPersonnel.personnelSupprime); |
} |
} |
} |
} |
|
return fomulaireValide; |
} |
|
public boolean verifierFormulaire() { |
ArrayList<String> messages = new ArrayList<String>(); |
messages.addAll(verifierOnglets()); |
|
// Affichage des messages d'alerte |
if (messages.size() != 0) { |
String[] a = {}; |
a = messages.toArray(a); |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(a, "\n\n"), null); |
return false; |
} |
|
return true; |
} |
|
private ArrayList<String> verifierOnglets() { |
ArrayList<String> messages = new ArrayList<String>(); |
messages.addAll(identificationOnglet.verifier()); |
messages.addAll(personnelOnglet.verifier()); |
return messages; |
} |
|
private StructureValorisation collecterStructureValorisation() { |
return valorisationOnglet.collecter(); |
} |
|
private void peuplerStructureValorisation() { |
valorisationOnglet.peupler(); |
} |
|
private StructureConservation collecterStructureConservation() { |
return conservationOnglet.collecter(); |
} |
|
private void peuplerStructureConservation() { |
conservationOnglet.peupler(); |
} |
|
private Structure collecterStructureIdentification() { |
Structure structureARetourner = identificationOnglet.collecter(); |
return structureARetourner; |
} |
|
private TabItem creerOngletValorisation() { |
valorisationOnglet = new StructureFormValorisation(mediateur, this, sequenceur); |
return valorisationOnglet; |
} |
|
private TabItem creerOngletConservation() { |
conservationOnglet = new StructureFormConservation(mediateur, this, sequenceur); |
return conservationOnglet; |
} |
|
private EtatPersonnelStructure collecterStructurePersonnel() { |
return personnelOnglet.collecter(); |
} |
|
private void peuplerStructurePersonnel(StructureAPersonneListe personnel) { |
personnelOnglet.peupler(personnel); |
} |
|
private TabItem creerOngletPersonnel() { |
personnelOnglet = new StructureFormPersonne(this, mediateur); |
return personnelOnglet; |
} |
|
private TabItem creerOngletIdentification() { |
identificationOnglet = new StructureFormIdentification(this); |
return identificationOnglet; |
} |
|
public void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) { |
String[] valeurs = donnees.split(";;"); |
for (int i = 0; i < valeurs.length; i++) { |
if (valeurs[i].startsWith("AUTRE##")) { |
champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", "")); |
} else { |
//TODO : check : List<CheckBox> cases = groupeCac.getAll(); |
List<Field<?>> cases = groupeCac.getAll(); |
for (int j = 0; j < cases.size(); j++) { |
if (cases.get(j).getId().equals("val-"+valeurs[i])) { |
((CheckBox) cases.get(j)).setValue(true); |
} |
} |
} |
} |
} |
|
public void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) { |
//List<Radio> boutons = groupeBr.getAll(); |
List<Field<?>> boutons = groupeBr.getAll(); |
String id = valeur+"_"+groupeBr.getName().replace("_grp", ""); |
for (int i = 0; i < boutons.size(); i++) { |
if (boutons.get(i).getId().equals(id)) { |
((Radio) boutons.get(i)).setValue(true); |
} |
} |
} |
|
public String creerChaineDenormalisee(List<CheckBox> liste) { |
String identifiants = ""; |
if (liste != null) { |
int taille = liste.size(); |
for (int i = 0; i < taille; i++) { |
CheckBox cac = liste.get(i); |
if (cac.isEnabled()) { |
identifiants = identifiants.concat(";;"+cac.getData("id")); |
} |
} |
identifiants.replaceFirst("^;;", ""); |
} |
return identifiants; |
} |
|
public void afficherChampSupplementaire(Radio radioBtn) { |
valorisationOnglet.afficherChampSupplementaire(radioBtn) ; |
conservationOnglet.afficherChampSupplementaires(radioBtn); |
} |
|
public void rafraichir(Object nouvellesDonnees) { |
try { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
if(!info.getType().equals("selection_structure") && !info.getType().equals("selection_structure")) { |
repandreRafraichissement(); |
} |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} catch (Exception e) { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e); |
} |
|
controlerFermeture(); |
} |
|
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
|
if (info.getType().equals("modif_structure")) { |
InfoLogger.display("Modification d'une institution", info.toString()); |
Structure structureMaj = (Structure)(info.getDonnee(0)); |
if(structureMaj != null) { |
// TRUE uniquement si la modification a retourné un objet JSON pour mise à jour |
// (contenant les coordonnées générées, cf r1673) |
structure.setLatitude(structureMaj.getLatitude()); |
structure.setLongitude(structureMaj.getLongitude()); |
} |
|
controlerFermeture(); |
} else if (info.getType().equals("ajout_structure")) { |
if (info.getDonnee(0) != null && ( info.getDonnee(0) instanceof String || info.getDonnee(0) instanceof Object) ) { |
this.mode = MODE_MODIFIER; |
String structureId; |
|
if(info.getDonnee(0) instanceof String) { |
structureId = (String) info.getDonnee(0); |
} |
else { |
// le backend renvoie un objet si longitude et latitude ont |
// été générés |
Structure structureMaj = (Structure)(info.getDonnee(0)); |
// structureMaj == null ? erreur horriblement impensable |
structure.setLatitude(structureMaj.getLatitude()); |
structure.setLongitude(structureMaj.getLongitude()); |
structureId = structureMaj.getId(); |
} |
|
structure.setId(structureId); |
identification = structure; |
identificationOnglet.rafraichir(info); |
personnelOnglet.rafraichir(info); |
conservationOnglet.rafraichir(info); |
valorisationOnglet.rafraichir(info); |
InfoLogger.display("Ajout d'une Institution", "L'intitution '"+structureId+"' a bien été ajoutée"); |
} else { |
InfoLogger.display("Ajout d'une Institution", info.toString()); |
} |
} else if (info.getType().equals("modif_structure_a_personne")) { |
InfoLogger.display("Modification du Personnel", info.toString()); |
personnelOnglet.rafraichir(info); |
} else if (info.getType().equals("suppression_structure_a_personne")) { |
InfoLogger.display("Suppression du Personnel", info.toString()); |
personnelOnglet.rafraichir(info); |
} else if (info.getType().equals("ajout_structure_a_personne")) { |
InfoLogger.display("Ajout du Personnel", info.toString()); |
personnelOnglet.rafraichir(info); |
} else if (info.getType().equals("selection_structure")) { |
InfoLogger.display("Modification d'une institution", info.toString()); |
String titre = i18nC.titreModifFormStructurePanneau(); |
if (info.getDonnee(0) != null) { |
identification = (Structure)info.getDonnee(0); |
identificationOnglet.rafraichir(info); |
// Composition du titre |
titre += " - ID : "+identification.getId(); |
} |
if (info.getDonnee(1) != null) { |
conservation = (StructureConservation)info.getDonnee(1); |
conservationOnglet.rafraichir(info); |
} |
if (info.getDonnee(2) != null) { |
valorisation = (StructureValorisation)info.getDonnee(2); |
valorisationOnglet.rafraichir(info); |
} |
} else if (info.getType().equals("liste_structure_a_personne")) { |
personnelOnglet.rafraichir(info); |
} |
} |
|
public void rafraichirValeurListe(ValeurListe listeValeurs) { |
List<Valeur> liste = listeValeurs.toList(); |
|
// Test pour savoir si la liste contient des éléments |
if (liste.size() > 0) { |
identificationOnglet.rafraichir(listeValeurs); |
personnelOnglet.rafraichir(listeValeurs); |
conservationOnglet.rafraichir(listeValeurs); |
valorisationOnglet.rafraichir(listeValeurs); |
//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null); |
} else { |
GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null); |
} |
} |
|
public String getIdIdentification() { |
return identification.getId(); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureForm.java:r1136-1368 |
Merged /trunk/src/org/tela_botanica/client/vues/structure/StructureForm.java:r11-934,1209-1382 |
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/vues/structure/StructureForm.java:r1383-1511 |