30,7 → 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.data.BaseModelData; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.GridEvent; |
import com.extjs.gxt.ui.client.event.KeyListener; |
88,10 → 88,12 |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.i18n.client.NumberFormat; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.ListBox; |
|
public class FormStructureVue extends LayoutContainer implements Rafraichissable { |
|
private static final String MODE_AJOUTER = "AJOUT"; |
private static final String MODE_MODIFIER = "MODIF"; |
|
private Constantes i18nC = null; |
private Mediateur mediateur = null; |
private Modele modele = null ; |
116,8 → 118,8 |
private ComboBox<Valeur> comboLstpu = null; |
private ListStore<Valeur> magazinLiStatut = null; |
private ComboBox<Valeur> comboLiStatut = null; |
private ListStore<Valeur> magazinLiFonction = null; |
private ComboBox<Valeur> comboLiFonction = null; |
private ListStore<Valeur> fonctionsMagazin = null; |
private ComboBox<Valeur> fonctionsCombo = null; |
private ComboBox<InterneValeur> comboAcronyme = null; |
private TextField<String> ihChp = null; |
private TextField<String> mnhnChp = null; |
213,9 → 215,10 |
private ListStore<Personne> personneExistanteMagazin; |
private ComboBox<Personne> personneExistanteCombo; |
private TextToolItem supprimerPersonnelBtn; |
private ListBox projetChp; |
private ListStore<Projet> projetsMagazin; |
private ComboBox<Projet> projetsCombo; |
private CellEditor fonctionEditor; |
private List<Valeur> fonctionsListe; |
|
|
public FormStructureVue() { |
329,7 → 332,7 |
private Boolean verifierFormulaire() { |
ArrayList<String> messages = new ArrayList<String>(); |
|
// Vérification des infos sur la structure |
// Vérification des infos sur le nom de la structure |
if ( (identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue() == null) || |
(identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue().equals("")) || |
(identificationOnglet.getData("acces").equals(false) && identification.getNom().equals(""))) { |
336,6 → 339,13 |
messages.add("Veuillez indiquez un nom à l'institution."); |
} |
|
// Vérification des infos sur le projet de la structure |
if ( (identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue() == null) || |
(identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue().equals("")) || |
(identificationOnglet.getData("acces").equals(false) && identification.getIdProjet().equals(""))) { |
messages.add("Veuillez sélectionner un projet pour l'institution."); |
} |
|
// Vérification du Personnel |
if (personnelOnglet.getData("acces").equals(true)) { |
String personnelNumero = ""; |
680,16 → 690,16 |
} |
|
private void peuplerStructureIdentification() { |
if (mode.equals("AJOUT")) { |
if (mode.equals(MODE_AJOUTER)) { |
// Indique que l'ongleta pu être modifié pour la méthode collecter... |
identificationOnglet.setData("acces", true); |
// Indication du projet sélectionné par défaut |
String projetCourantId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getProjetId(); |
if (!projetCourantId.equals("0")) { |
if (projetCourantId != null && !projetCourantId.equals("0")) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", projetCourantId)); |
} |
} |
if (mode.equals("MODIF") && identification != null && identificationOnglet.getData("acces").equals(false)) { |
if (mode.equals(MODE_MODIFIER) && identification != null && identificationOnglet.getData("acces").equals(false)) { |
idStructureChp.setValue(identification.getId()); |
nomStructureChp.setValue(identification.getNom()); |
if (!identification.getIdProjet().equals("0")) { |
960,7 → 970,7 |
// Gestion de la fonction |
String fonction = personne.get("fonction"); |
if (fonction != null && !fonction.equals("")) { |
Valeur valeurRecherche = comboLiFonction.getStore().findModel("nom", fonction); |
Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction); |
if (valeurRecherche != null) { |
personne.setFonction(valeurRecherche.getId()); |
} else { |
1028,16 → 1038,16 |
} |
|
private void peuplerStructurePersonnel() { |
if (personnel != null) { |
if (mode.equals(MODE_MODIFIER) && 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()).startsWith("AUTRE##")) { |
if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) { |
GWT.log(personnel.get(index).getFonction(), null); |
if (magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()) != null) { |
personnel.get(index).set("fonction", magazinLiFonction.findModel("id_valeur", personnel.get(index).getFonction()).getNom()); |
if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) { |
personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom()); |
} |
} else { |
personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", "")); |
1095,12 → 1105,7 |
cp.setHeight("100%"); |
cp.setFrame(true); |
|
List<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>(); |
personnes.add(new StructureAPersonne(StructureAPersonne.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE)); |
personnes.add(new StructureAPersonne(StructureAPersonne.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE)); |
|
personnelGrilleMagazin = new ListStore<StructureAPersonne>(); |
personnelGrilleMagazin.add(personnes); |
personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() { |
|
public void handleEvent(StoreEvent<StructureAPersonne> ce) { |
1121,39 → 1126,32 |
|
ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150); |
modele.obtenirListeValeurs(this, ((Configuration) Registry.get(RegistreId.CONFIG)).getListeId("fonction")); |
magazinLiFonction = new ListStore<Valeur>(); |
magazinLiFonction.add(new ArrayList<Valeur>()); |
fonctionsMagazin = new ListStore<Valeur>(); |
|
comboLiFonction = new ComboBox<Valeur>(); |
comboLiFonction.setTriggerAction(TriggerAction.ALL); |
comboLiFonction.setEditable(true); |
comboLiFonction.setDisplayField("nom"); |
comboLiFonction.setStore(magazinLiFonction); |
fonctionsCombo = new ComboBox<Valeur>(); |
fonctionsCombo.setTriggerAction(TriggerAction.ALL); |
fonctionsCombo.setEditable(true); |
fonctionsCombo.setDisplayField("nom"); |
fonctionsCombo.setStore(fonctionsMagazin); |
|
CellEditor fonctionEditor = new CellEditor(comboLiFonction) { |
fonctionEditor = new CellEditor(fonctionsCombo) { |
@Override |
public Object preProcessValue(Object valeur) { |
if (valeur == null) { |
//GWT.log("pre null :"+this.getValue()+"-"+this.row, null); |
return 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); |
Valeur retour = null; |
|
if (valeur != null) { |
String chaineTransmise = (String) valeur; |
GWT.log("ici:"+fonctionsMagazin.getCount(), null); |
if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) { |
fonctionsMagazin.add(fonctionsListe); |
} |
if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) { |
retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise); |
} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) { |
retour = fonctionsMagazin.findModel("nom", chaineTransmise); |
} else { |
this.getField().setRawValue((String) valeur); |
retour = null; |
retour = new Valeur("", chaineTransmise, "", ""); |
} |
} else if (valeur instanceof String) { |
this.getField().setRawValue((String) valeur); |
retour = new Valeur("", (String) valeur, "", ""); |
} else { |
retour = comboLiFonction.getStore().findModel("nom", (String) valeur); |
//GWT.log("pre - retour valeur par chaine : \n"+retour.toString(), null); |
} |
|
return retour; |
1161,28 → 1159,29 |
|
@Override |
public Object postProcessValue(Object valeur) { |
String retour = ""; |
Valeur fonctionTrouvee = null; |
GWT.log("ICI ", null); |
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); |
String retour = this.getField().getRawValue(); |
if (retour.matches("^[0-9]+$")) { |
//GWT.log("ici", null); |
Valeur valeurRecherche = comboLiFonction.getStore().findModel("id_valeur", (String) retour); |
if (valeurRecherche != null) { |
retour = valeurRecherche.getNom(); |
} |
GWT.log(this.getField().getRawValue(), null); |
String valeurBrute = this.getField().getRawValue(); |
if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) { |
fonctionsMagazin.add(fonctionsListe); |
} |
return retour; |
} else { |
//GWT.log("post : \n"+valeur.toString(), null); |
String nom = ""; |
if (valeur instanceof Valeur) { |
nom = (((Valeur) valeur).getNom()); |
//GWT.log("la "+nom, null); |
if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) { |
fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute); |
} else { |
retour = valeurBrute; |
} |
|
return nom; |
} else if (valeur instanceof Valeur) { |
fonctionTrouvee = (Valeur) valeur; |
} |
|
if (fonctionTrouvee != null) { |
retour = fonctionTrouvee.getNom(); |
} |
|
return retour; |
} |
}; |
column.setEditor(fonctionEditor); |
1275,13 → 1274,8 |
ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ToolBarEvent>() { |
@Override |
public void componentSelected(ToolBarEvent ce) { |
StructureAPersonne personne = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE); |
personne.set("etat", "A"); |
grillePersonnel.stopEditing(); |
int numNouveau = grillePersonnel.getData("nouveau"); |
grillePersonnel.setData("nouveau", ++numNouveau); |
personnelGrilleMagazin.insert(personne, 0); |
grillePersonnel.startEditing(0, 0); |
StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
} |
}); |
toolBar.add(ajouterPersonnelBtn); |
1353,31 → 1347,18 |
public void componentSelected(ToolBarEvent ce) { |
Personne personneExistante = personneExistanteCombo.getValue(); |
|
StructureAPersonne personne = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE); |
personne.setIdPersonne(personneExistante.getId()); |
|
grillePersonnel.stopEditing(); |
|
// Ajout au magazin de la grille |
int numNouveau = grillePersonnel.getData("nouveau"); |
grillePersonnel.setData("nouveau", ++numNouveau); |
personnelGrilleMagazin.insert(personne, 0); |
|
// Nous modifions l'enregistrement pour que le modèle soit pris en compte lors de la collecte. |
Record record = personnelGrilleMagazin.getRecord(personnelGrilleMagazin.getAt(0)); |
record.beginEdit(); |
record.set("nom", personneExistante.getNom()); |
record.set("prenom", personneExistante.getPrenom()); |
record.set("telephone", personneExistante.selectionnerTelephone(Personne.TELEPHONE_FIXE)); |
record.set("fax", personneExistante.selectionnerFax(1)); |
record.set("courriel", personneExistante.selectionnerCourriel(1)); |
record.set("specialite", personneExistante.afficherSpecialite()); |
record.set("etat", "A"); |
record.endEdit(); |
grillePersonnel.startEditing(0, 0); |
|
//GWT.log("Ajout : "+personnelGrilleMagazin.getModifiedRecords()., null); |
GWT.log("ici : "+personnelGrilleMagazin.getModifiedRecords().contains(record), null); |
if (personneExistante != null) { |
StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
membreDuPersonnel.setIdPersonne(personneExistante.getId()); |
membreDuPersonnel.setNom(personneExistante.getNom()); |
membreDuPersonnel.setPrenom(personneExistante.getPrenom()); |
membreDuPersonnel.setTelephone(personneExistante.getTelephone()); |
membreDuPersonnel.setFax(personneExistante.getFax()); |
membreDuPersonnel.setCourriel(personneExistante.getCourriel()); |
membreDuPersonnel.setSpecialite(personneExistante.getSpecialite()); |
|
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
} |
} |
}); |
toolBar.add(ajouterPersonneExistanteBtn); |
1387,7 → 1368,6 |
ColumnModel cm = new ColumnModel(configs); |
|
grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm); |
grillePersonnel.setData("nouveau", 0); |
grillePersonnel.setBorders(true); |
grillePersonnel.setSelectionModel(sm); |
grillePersonnel.addPlugin(checkColumn); |
1405,9 → 1385,9 |
|
}); |
|
cp.add(grillePersonnel); |
cp.add(grillePersonnel); |
personnelOnglet.add(cp); |
|
|
return personnelOnglet; |
} |
|
1418,6 → 1398,7 |
identificationOnglet.setId("identification"); |
identificationOnglet.setText("Identification"); |
identificationOnglet.setLayout(new FormLayout()); |
identificationOnglet.setScrollMode(Scroll.AUTO); |
identificationOnglet.setData("acces", false); |
identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
1875,6 → 1856,9 |
((Component) composants.get(i)).show(); |
} else { |
((Component) composants.get(i)).hide(); |
|
|
|
} |
} |
// Si on a à faire à un ContentPanel, on l'actualise pour déclencher l'affichage |
1911,6 → 1895,23 |
* @return |
*/ |
private void creerChoixMultipleCac(ContentPanel cp, CheckBoxGroup cacGroupe, ValeurListe listeValeurs, Field<String> autreChp) { |
cp.addListener(Events.Hide, new Listener<BaseEvent>() { |
|
public void handleEvent(BaseEvent be) { |
ContentPanel cp = (ContentPanel) be.source; |
List<Component> composants = cp.getItems(); |
for (Iterator<Component> it = composants.iterator(); it.hasNext();) { |
Object composant = it.next(); |
if (composant instanceof CheckBoxGroup) { |
GWT.log("Classe : groupedecac", null); |
CheckBoxGroup caseACocherGroupe = (CheckBoxGroup) composant; |
caseACocherGroupe.reset(); |
|
} |
} |
} |
|
}); |
cacGroupe.setAutoWidth(true); |
cacGroupe.setData("liste_id", listeValeurs.getId()); |
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) { |
2052,9 → 2053,13 |
comboLiStatut.setStore(magazinLiStatut); |
} |
if (listeValeurs.getId().equals(config.getListeId("fonction"))) { |
magazinLiFonction.removeAll(); |
magazinLiFonction.add(liste); |
comboLiFonction.setStore(magazinLiFonction); |
// FIXME : le store ne contient pas tout le temps les données, chose étrange. |
// On stocke donc les données dans une variables de la classe pour recharger le store si besoin. |
fonctionsListe = liste; |
fonctionsMagazin.removeAll(); |
fonctionsMagazin.add(liste); |
fonctionsCombo.setStore(fonctionsMagazin); |
rafraichirPersonnel(); |
} |
if (listeValeurs.getId().equals(config.getListeId("pays"))) { |
magazinPays.removeAll(); |
2149,10 → 2154,69 |
} |
|
private void rafraichirPersonnel() { |
mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE); |
if (mode.equals(MODE_MODIFIER)) { |
initialiserGrillePersonnelEnModifcation(); |
} else if (mode.equals(MODE_AJOUTER)) { |
initialiserGrillePersonnelEnAjout(); |
} |
} |
|
private void rafraichirPersonneExistante(String nom) { |
mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%"); |
} |
|
private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) { |
grillePersonnel.stopEditing(); |
personnelGrilleMagazin.insert(new StructureAPersonne(), 0); |
|
// Nous modifions l'enregistrement pour que le modèle soit pris en compte lors de la collecte. |
Record record = personnelGrilleMagazin.getRecord(personnelGrilleMagazin.getAt(0)); |
record.beginEdit(); |
if (!personnel.getFonction().equals("")) { |
Object fonction = fonctionEditor.preProcessValue(personnel.getFonction()); |
if (fonction != null && fonction instanceof Valeur) { |
record.set("fonction", ((Valeur)fonction).getNom()); |
} |
} |
if (!personnel.getPrenom().equals("")) { |
record.set("prenom", personnel.getPrenom()); |
} |
if (!personnel.getNom().equals("")) { |
record.set("nom", personnel.getNom()); |
} |
if (!personnel.getTelephone().equals("")) { |
record.set("telephone", personnel.selectionnerTelephone(Personne.TELEPHONE_FIXE)); |
} |
if (!personnel.getFax().equals("")) { |
record.set("fax", personnel.selectionnerFax(1)); |
} |
if (!personnel.getCourriel().equals("")) { |
record.set("courriel", personnel.selectionnerCourriel(1)); |
} |
if (!personnel.getStatut().equals("")) { |
record.set("statut", personnel.getStatut()); |
} |
String tempsDeTravail = personnel.getBotaTravailHebdoTps(); |
record.set("travail", (tempsDeTravail.matches("^[0-9]+$") ? Integer.parseInt(tempsDeTravail) : 0)); |
if (!personnel.getSpecialite().equals("")) { |
record.set("specialite", personnel.afficherSpecialite()); |
} |
record.set("contact", (personnel.getContact().equals("1") ? true : false)); |
record.set("etat", personnel.get("etat")); |
record.endEdit(); |
|
grillePersonnel.startEditing(0, 0); |
} |
|
private void initialiserGrillePersonnelEnAjout() { |
personnelGrilleMagazin.removeAll(); |
StructureAPersonne conservateurDesCollections = new StructureAPersonne(StructureAPersonne.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(conservateurDesCollections); |
StructureAPersonne directeurDuPersonnel = new StructureAPersonne(StructureAPersonne.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(directeurDuPersonnel); |
} |
|
private void initialiserGrillePersonnelEnModifcation() { |
mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE); |
} |
} |