1,8 → 1,10 |
package org.tela_botanica.client.vues; |
|
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.Iterator; |
import java.util.List; |
import java.util.Map; |
|
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
28,6 → 30,7 |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.Style.SelectionMode; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.EditorEvent; |
38,6 → 41,7 |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.event.ToolBarEvent; |
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.widget.Component; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
45,6 → 49,7 |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.VerticalPanel; |
import com.extjs.gxt.ui.client.widget.WidgetComponent; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.form.CheckBox; |
69,6 → 74,8 |
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.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; |
134,11 → 141,13 |
private ComboBox<Valeur> comboPays; |
|
// Onglet PERSONNEL |
private StructureAPersonneListe personnel; |
private StructureAPersonneListe personnel; |
private StructureAPersonneListe personnelAjoute = null; |
private StructureAPersonneListe personnelModifie = null; |
private StructureAPersonneListe personnelSupprime = null; |
private NumberField nbreTotalPersonneStructureChp = null; |
private EditorGrid<StructureAPersonne> grillePersonnel = null; |
private ListStore<StructureAPersonne> personnelGrilleMagazin = null; |
private LabelField nbreTotalPersonnelChp = null; |
|
// Onglet CONSERVATION |
private StructureConservation conservation = null; |
207,6 → 216,7 |
private TextField<String> publicationChp; |
private ContentPanel materielConservationCp; |
|
|
public FormStructureVue() { |
//+-----------------------------------------------------------------------------------------------------------+ |
// Initialisation de variables |
287,13 → 297,28 |
Structure structure = collecterStructureIdentification(); |
StructureConservation conservation = collecterStructureConservation(); |
StructureValorisation valorisation = collecterStructureValorisation(); |
// JAMAIS DE COMPARAISONS DE STRING AVEC == !!!!!! ON UTILISE equals ou compareTo |
collecterStructurePersonnel(); |
|
if (mode.equals("AJOUT")) { |
// Ajout des informations sur la Structure |
//mediateur.ajouterStructure(this, structure); |
// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée |
// Voir la méthode rafraichir(). |
} else if (mode.equals("MODIF")) { |
// Modification des informations sur la Structure |
mediateur.modifierStructure(this, structure, conservation, valorisation); |
// Modification des relations StructureAPersonne |
GWT.log("Personnel modifié :"+personnelModifie.size(), null); |
mediateur.modifierStructureAPersonne(this, personnelModifie); |
// Ajout des relations StructureAPersonne |
GWT.log("Personnel ajouté :"+personnelAjoute.size(), null); |
mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute); |
// Suppression des relations StructureAPersonne |
GWT.log("Personnel supprimé :"+personnelSupprime.size(), null); |
mediateur.supprimerStructureAPersonne(this, personnelSupprime); |
// Nous rechargeons la liste |
mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE); |
} |
GWT.log("Info Structure envoyées :\n"+conservation.toString(), null); |
} |
|
private StructureValorisation collecterStructureValorisation() { |
600,6 → 625,8 |
structure.setCourriel(emailChp.getValue()); |
structure.setUrl(Structure.URL_SITE, urlChp.getValue()); |
|
structure.setNbrePersonne(nbreTotalPersonneStructureChp.getValue().intValue()); |
|
return structure; |
} |
} |
646,6 → 673,8 |
emailChp.setValue(identification.getCourriel()); |
urlChp.setValue(identification.getUrl("WEB")); |
|
nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne()); |
|
identificationOnglet.layout(); |
} |
} |
855,17 → 884,89 |
return conservationOnglet; |
} |
|
private void collecterStructurePersonnel() { |
if (personnelOnglet.getData("acces").equals(true)) { |
int nbrePersonne = personnelGrilleMagazin.getCount(); |
for (int i = 0; i < nbrePersonne; i++) { |
StructureAPersonne personne = personnelGrilleMagazin.getAt(i); |
|
// Seules les lignes ajoutées ou modifiées sont prises en compte. |
if (personnelGrilleMagazin.getModifiedRecords().contains(personnelGrilleMagazin.getRecord(personne)) == true) { |
// Gestion de la fonction |
String fonction = personne.get("fonction"); |
if (fonction != null && !fonction.equals("")) { |
Valeur valeurRecherche = comboLiFonction.getStore().findModel("nom", fonction); |
if (valeurRecherche != null) { |
personne.setFonction(valeurRecherche.getId()); |
} else { |
personne.setFonction("AUTRE", fonction); |
} |
} |
|
// Gestion de la notion de "contact" |
personne.setContact(false); |
if (personne.get("contact").equals(true)) { |
personne.setContact(true); |
} |
|
// Gestion du statut |
String statut = personne.get("statut"); |
if (statut != null && !statut.equals("")) { |
Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut); |
if (valeurRecherche != null) { |
personne.setStatut(valeurRecherche.getId()); |
} else { |
personne.setStatut("AUTRE", statut); |
} |
} |
|
// Gestion du temps de travail |
if (personne.get("travail") != null && !personne.get("travail").equals(0)) { |
personne.setBotaTravailHebdoTps(personne.get("travail").toString()); |
} |
|
// Gestion du téléphone |
String telephone = personne.get("telephone"); |
if (telephone != null && !telephone.equals("")) { |
personne.setTelephone(telephone); |
} |
|
// Gestion du fax |
String fax = personne.get("fax"); |
if (fax != null && !fax.equals("")) { |
personne.setFax(fax); |
} |
|
// Gestion du courriel |
String courriel = personne.get("courriel"); |
if (courriel != null && !courriel.equals("")) { |
personne.setCourriel(courriel); |
} |
|
// Gestion de la sépcialité |
String specialite = personne.get("specialite"); |
if (specialite != null && !specialite.equals("")) { |
personne.setSpecialite(specialite); |
} |
|
// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié) |
if (personne.getIdPersonne().equals("")) {// Une personne ajoutée |
personnelAjoute.put(""+i, personne); |
} else {// Une personne modifiée |
personnelModifie.put(personne.getId(), personne); |
} |
} |
} |
} |
} |
|
private void peuplerStructurePersonnel() { |
if (identification != null) { |
// NBRE PERSONNE |
nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne()); |
} |
|
if (personnel != null) { |
ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>(); |
for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) { |
String index = it.next(); |
|
// Gestion de la fonction |
if (magazinLiFonction != null && ((String) personnel.get(index).getFonction()).matches("^[0-9]+$")) { |
GWT.log(personnel.get(index).getFonction(), null); |
personnel.get(index).set("fonction", magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()).getNom()); |
872,10 → 973,27 |
} else { |
personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", "")); |
} |
|
// Gestion de la notion de "contact" |
personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false)); |
|
// Gestion du statut |
if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) { |
GWT.log(personnel.get(index).getStatut(), null); |
personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom()); |
} else { |
personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", "")); |
} |
|
// Gestion du temps de travail |
String tps = personnel.get(index).getBotaTravailHebdoTps(); |
personnel.get(index).set("travail", (tps.matches("^[0-9]+$") ? Integer.parseInt(tps) : 0)); |
|
personnes.add(personnel.get(index)); |
} |
personnelGrilleMagazin.removeAll(); |
personnelGrilleMagazin.add(personnes); |
|
personnelOnglet.layout(); |
// Nous vidons la variable personnel une fois qu'elle a remplie la grille |
personnel = null; |
884,51 → 1002,48 |
|
private TabItem creerOngletPersonnel() { |
personnelOnglet = new TabItem(); |
|
personnelOnglet.setText("Personnel"); |
personnelOnglet.setScrollMode(Scroll.AUTO); |
personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT, null)); |
personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT, 0)); |
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) { |
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... |
personnelOnglet.setData("acces", true); |
|
// Création des objets de la grille |
personnelModifie = new StructureAPersonneListe(); |
personnelAjoute = new StructureAPersonneListe(); |
personnelSupprime = new StructureAPersonneListe(); |
|
// Peuplement du formulaire |
peuplerStructurePersonnel(); |
} |
|
}); |
|
nbreTotalPersonneStructureChp = new NumberField(); |
nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution"); |
nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#")); |
nbreTotalPersonneStructureChp.setToolTip("Ce champ doit contenir un nombre"); |
personnelOnglet.add(nbreTotalPersonneStructureChp); |
|
personnelOnglet.add(this.creerGrillePersonnel()); |
|
nbreTotalPersonnelChp = new LabelField(); |
nbreTotalPersonnelChp.setFieldLabel("Nombre de personne travaillant sur les collections"); |
nbreTotalPersonnelChp.setLabelSeparator(":"); |
nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount()); |
personnelOnglet.add(nbreTotalPersonnelChp); |
|
return personnelOnglet; |
} |
|
private ContentPanel creerGrillePersonnel() { |
ContentPanel cp = new ContentPanel(); |
cp.setHeading("Personnes travaillant sur les collections"); |
cp.setIconStyle("icone-table"); |
//cp.setScrollMode(Scroll.AUTO); |
cp.setLayout(new FitLayout()); |
cp.setWidth(1250); |
cp.setHeight("100%"); |
cp.setFrame(true); |
|
List<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>(); |
personnes.add(new StructureAPersonne(Valeur.FONCTION_DIRECTEUR)); |
personnes.add(new StructureAPersonne(Valeur.FONCTION_CONSERVATEUR)); |
personnes.add(new StructureAPersonne(Valeur.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE)); |
personnes.add(new StructureAPersonne(Valeur.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE)); |
|
personnelGrilleMagazin = new ListStore<StructureAPersonne>(); |
personnelGrilleMagazin = new ListStore<StructureAPersonne>(); |
personnelGrilleMagazin.add(personnes); |
|
|
RowNumberer r = new RowNumberer(); |
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); |
|
CheckBoxSelectionModel<StructureAPersonne> sm = new CheckBoxSelectionModel<StructureAPersonne>(); |
configs.add(sm.getColumn()); |
GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>(); |
configs.add(r); |
|
ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150); |
modele.obtenirListeValeurs(((Configuration) Registry.get(RegistreId.CONFIG)).getListeId("fonction")); |
945,16 → 1060,16 |
@Override |
public Object preProcessValue(Object valeur) { |
if (valeur == null) { |
//GWT.log("pre null :"+this.getValue()+"-"+this.row, null); |
GWT.log("pre null :"+this.getValue()+"-"+this.row, null); |
return null; |
} |
//GWT.log("pre : "+valeur.toString(), null); |
GWT.log("pre : "+valeur.toString(), null); |
Object retour = null; |
if (((String) valeur).matches("^[0-9]+$")) { |
Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) valeur); |
if (valeurRecherche != null) { |
retour = valeurRecherche; |
//GWT.log("pre - retour valeur par chiffre : \n"+retour.toString(), null); |
GWT.log("pre - retour valeur par chiffre : \n"+retour.toString(), null); |
} else { |
this.getField().setRawValue((String) valeur); |
retour = null; |
964,7 → 1079,7 |
retour = new Valeur("", (String) valeur, "", ""); |
} else { |
retour = comboLiFonction.getStore().findModel("nom", (String) valeur); |
//GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null); |
GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null); |
} |
|
return retour; |
974,10 → 1089,10 |
public Object postProcessValue(Object valeur) { |
if (valeur == null) { |
// Si la combobox n'a pas été utilisé, nous renvoyons la valeur brute saisie par l'utilisateur |
//GWT.log("post raw : \n"+this.getField().getRawValue(), null); |
GWT.log("post raw : \n"+this.getField().getRawValue(), null); |
String retour = this.getField().getRawValue(); |
if (retour.matches("^[0-9]+$")) { |
//GWT.log("ici", null); |
GWT.log("ici", null); |
Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) retour); |
if (valeurRecherche != null) { |
retour = valeurRecherche.getNom(); |
985,12 → 1100,13 |
} |
return retour; |
} else { |
//GWT.log("post : \n"+valeur.toString(), null); |
GWT.log("post : \n"+valeur.toString(), null); |
String nom = ""; |
if (valeur instanceof Valeur) { |
nom = (((Valeur) valeur).getNom()); |
//GWT.log("la "+nom, null); |
GWT.log("la "+nom, null); |
} |
|
return nom; |
} |
} |
1085,14 → 1201,6 |
CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60); |
configs.add(checkColumn); |
|
|
cp.setHeading("Personnes travaillant sur les collections"); |
cp.setIconStyle("icone-table"); |
cp.setScrollMode(Scroll.AUTO); |
cp.setLayout(new FitLayout()); |
cp.setSize(1250, 200); |
cp.setFrame(true); |
|
ToolBar toolBar = new ToolBar(); |
|
TextToolItem ajouterPersonnelBtn = new TextToolItem("Ajouter", "icone-vcard-ajouter"); |
1099,14 → 1207,13 |
ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() { |
@Override |
public void componentSelected(ToolBarEvent ce) { |
StructureAPersonne personne = new StructureAPersonne(); |
StructureAPersonne personne = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE); |
grillePersonnel.stopEditing(); |
int numNouveau = grillePersonnel.getData("nouveau"); |
grillePersonnel.setData("nouveau", ++numNouveau); |
personnelGrilleMagazin.insert(personne, 0); |
grillePersonnel.startEditing(0, 0); |
// Mise à jour du nombre de personnel travaillant sur les collections |
nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount()); |
|
// Activation du bouton supprimer si la grille contient un élément |
if (grillePersonnel.getStore().getCount() > 0) { |
ce.component.enable(); |
1119,13 → 1226,21 |
supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() { |
@Override |
public void componentSelected(ToolBarEvent ce) { |
grillePersonnel.getStore().remove(grillePersonnel.getStore().getAt(0)); |
// Mise à jour du nombre de personnel travaillant sur les collections |
nbreTotalPersonnelChp.setValue(""+grillePersonnel.getStore().getCount()); |
// Désactivation du bouton supprimer si la grille contient plus d'élément |
if (grillePersonnel.getStore().getCount() == 0) { |
ce.item.disable(); |
} |
StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem(); |
if (personne != null) { |
// Ajout de la personne supprimée à la liste |
if (personne.getIdPersonne() != null) { |
personnelSupprime.put(personne.getId(), personne); |
} |
|
// Suppression de l'enregistrement de la grille |
grillePersonnel.getStore().remove(personne); |
|
// Désactivation du bouton supprimer si la grille contient plus d'élément |
if (grillePersonnel.getStore().getCount() == 0) { |
ce.item.disable(); |
} |
} |
} |
}); |
toolBar.add(supprimerPersonnelBtn); |
1137,29 → 1252,27 |
grillePersonnel.setData("nouveau", 0); |
grillePersonnel.setBorders(true); |
grillePersonnel.setSelectionModel(sm); |
grillePersonnel.addPlugin(sm); |
grillePersonnel.addPlugin(checkColumn); |
grillePersonnel.addPlugin(r); |
grillePersonnel.getView().setForceFit(true); |
grillePersonnel.setAutoExpandColumn("specialite"); |
grillePersonnel.setStripeRows(true); |
grillePersonnel.setTrackMouseOver(true); |
grillePersonnel.addListener(Events.ValidateEdit, new Listener<GridEvent>() { |
grillePersonnel.addListener(Events.Change, new Listener<GridEvent>() { |
|
public void handleEvent(GridEvent ge) { |
|
GWT.log(ge.property+" : "+ge.value, null); |
List<StructureAPersonne> personnes = personnelGrilleMagazin.getModels(); |
StructureAPersonneListe personnelModifie = new StructureAPersonneListe(); |
for (int i = 0; i < personnes.size(); i++) { |
personnelModifie.put(""+i, personnes.get(i)); |
} |
personnel = personnelModifie; |
// CommitChanges évite que la grille perde la valeur des combobox éditables |
personnelGrilleMagazin.commitChanges(); |
} |
|
}); |
|
|
cp.add(grillePersonnel); |
|
return cp; |
} |
personnelOnglet.add(cp); |
|
return personnelOnglet; |
} |
|
private TabItem creerOngletIdentification() { |
//+-----------------------------------------------------------------------------------------------------------+ |
1335,6 → 1448,13 |
dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa»."); |
fieldSetIdentite.add(dateFondationChp); |
|
nbreTotalPersonneStructureChp = new NumberField(); |
nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution"); |
nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#")); |
nbreTotalPersonneStructureChp.setToolTip("Ce champ doit contenir un nombre"); |
fieldSetIdentite.add(nbreTotalPersonneStructureChp); |
|
|
identificationOnglet.add(fieldSetIdentite); |
|
//+-----------------------------------------------------------------------------------------------------------+ |
1685,7 → 1805,19 |
if (info.getType().equals("modif_structure")) { |
Info.display("Modification d'une institution", info.toString()); |
} else if (info.getType().equals("ajout_structure")) { |
Info.display("Ajout d'une Institution", info.toString()); |
if (info.toString().matches("^[0-9]+$")) { |
Info.display("Ajout d'une Institution", "L'intitution a bien été ajoutée"); |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel |
mediateur.ajouterStructureAPersonne(this, info.toString(), personnelAjoute); |
} else { |
Info.display("Ajout d'une Institution", info.toString()); |
} |
} else if (info.getType().equals("modif_structure_a_personne")) { |
Info.display("Modification du Personnel", info.toString()); |
} else if (info.getType().equals("suppression_structure_a_personne")) { |
Info.display("Suppression du Personnel", info.toString()); |
} else if (info.getType().equals("ajout_structure_a_personne")) { |
Info.display("Ajout du Personnel", info.toString()); |
} else if (info.getType().equals("selection_structure")) { |
Info.display("Modification d'une institution", info.toString()); |
mode = "MODIF"; |
1721,8 → 1853,12 |
//GWT.log(personnel.toString(), null); |
if (onglets.getSelectedItem().equals(personnelOnglet)) { |
peuplerStructurePersonnel(); |
Info.display("Peuplement", "ok"); |
} |
} |
if (info.getDonnee(1) != null) { |
Info.display("Debug", info.getDonnee(1).toString()); |
} |
} |
} else if (nouvelleDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvelleDonnees; |