5,9 → 5,7 |
import java.util.Iterator; |
import java.util.List; |
|
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.composants.pagination.ProxyPersonnes; |
18,13 → 16,17 |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.personne.Personne; |
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.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.FenetreForm; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireBarreValidation; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import org.tela_botanica.client.vues.personne.PersonneForm; |
|
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.data.ModelData; |
41,9 → 43,12 |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.Field; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.NumberField; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
56,6 → 61,7 |
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.FitData; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FormLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
62,6 → 68,7 |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.i18n.client.NumberFormat; |
import com.google.gwt.user.client.Window; |
|
public class StructureFormPersonne extends FormulaireOnglet implements Rafraichissable { |
|
88,6 → 95,8 |
private Formulaire formulaireCourant = null; |
private int decompteRafraichissementPersonnel; |
|
private FenetreForm fenetreFormulaire = null; |
|
private Sequenceur sequenceur = null; |
|
final class EtatPersonnelStructure { |
216,38 → 225,18 |
configs.add(column); |
|
column = new ColumnConfig("prenom", "Prénom", 100); |
TextField<String> prenomChp = new TextField<String>(); |
prenomChp.setAllowBlank(false); |
prenomChp.getMessages().setBlankText("Ce champ est obligatoire."); |
prenomChp.setAutoValidate(true); |
prenomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
prenomChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire()); |
column.setEditor(new CellEditor(prenomChp)); |
configs.add(column); |
|
column = new ColumnConfig("nom", "Nom", 100); |
TextField<String> nomChp = new TextField<String>(); |
nomChp.setAllowBlank(false); |
nomChp.getMessages().setBlankText("Ce champ est obligatoire."); |
nomChp.setAutoValidate(true); |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
nomChp.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire()); |
column.setEditor(new CellEditor(nomChp)); |
configs.add(column); |
|
column = new ColumnConfig("tel_fix", "Téléphone fixe", 100); |
TextField<String> telChp = new TextField<String>(); |
column.setEditor(new CellEditor(telChp)); |
column = new ColumnConfig("tel_fix", "Téléphone", 100); |
configs.add(column); |
|
column = new ColumnConfig("tel_fax", "Fax", 100); |
TextField<String> faxChp = new TextField<String>(); |
column.setEditor(new CellEditor(faxChp)); |
configs.add(column); |
|
column = new ColumnConfig("courriel", "Courriel principal", 200); |
TextField<String> emailChp = new TextField<String>(); |
column.setEditor(new CellEditor(emailChp)); |
configs.add(column); |
|
magazinLiStatut = new ListStore<Valeur>(); |
290,9 → 279,7 |
column.setEditor(new CellEditor(tpsWChp)); |
configs.add(column); |
|
column = new ColumnConfig("specialite", "Spécialité principale", 150); |
TextField<String> speChp = new TextField<String>(); |
column.setEditor(new CellEditor(speChp)); |
column = new ColumnConfig("specialite", "Spécialité botanique principale", 150); |
configs.add(column); |
|
CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60); |
300,19 → 287,54 |
|
ToolBar toolBar = new ToolBar(); |
|
Button ajouterPersonnelBtn = new Button("Ajouter"); |
ajouterPersonnelBtn.setIcon(Images.ICONES.vcardAjouter()); |
ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
} |
|
personneExistanteMagazin = new ListStore<Personne>(); |
personneExistanteMagazin.add(new ArrayList<Personne>()); |
|
ModelType modelTypePersonnes = new ModelType(); |
modelTypePersonnes.setRoot("personnes"); |
modelTypePersonnes.setTotalName("nbElements"); |
modelTypePersonnes.addField("cp_fmt_nom_complet"); |
modelTypePersonnes.addField("cp_nom"); |
modelTypePersonnes.addField("cp_prenom"); |
modelTypePersonnes.addField("cp_truk_courriel"); |
modelTypePersonnes.addField("cp_truk_telephone"); |
modelTypePersonnes.addField("cp_ce_truk_specialite"); |
modelTypePersonnes.addField("cp_id_personne"); |
|
String displayNamePersonnes = "cp_fmt_nom_complet"; |
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null); |
|
personneExistanteCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes); |
personneExistanteCombo.getCombo().setEmptyText("Rechercher et sélectionner une personne existante dans la base"); |
|
// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar |
//> CHECK |
toolBar.add(personneExistanteCombo); |
|
personneExistanteCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
if (personneExistanteCombo.getValeur() instanceof ModelData) { |
Personne personneExistante = new Personne(personneExistanteCombo.getValeur()); |
StructureAPersonne membreDuPersonnel = new StructureAPersonne(personneExistante, "", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
personneExistanteCombo.getCombo().setValue(null); |
} |
} |
}); |
toolBar.add(ajouterPersonnelBtn); |
|
toolBar.add(new Text(" ou ")); |
|
Button ajouterPersonnelBtn = creerBoutonAjouter(); |
toolBar.add(ajouterPersonnelBtn); |
|
toolBar.add(new SeparatorToolItem()); |
|
Button modifierPersonnelBtn = creerBoutonModifier(); |
toolBar.add(modifierPersonnelBtn); |
|
toolBar.add(new SeparatorToolItem()); |
|
supprimerPersonnelBtn = new Button("Supprimer"); |
supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer()); |
supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
352,50 → 374,13 |
|
toolBar.add(new SeparatorToolItem()); |
|
personneExistanteMagazin = new ListStore<Personne>(); |
personneExistanteMagazin.add(new ArrayList<Personne>()); |
|
ModelType modelTypePersonnes = new ModelType(); |
modelTypePersonnes.setRoot("personnes"); |
modelTypePersonnes.setTotalName("nbElements"); |
modelTypePersonnes.addField("cp_fmt_nom_complet"); |
modelTypePersonnes.addField("cp_nom"); |
modelTypePersonnes.addField("cp_prenom"); |
modelTypePersonnes.addField("cp_truk_courriel"); |
modelTypePersonnes.addField("cp_truk_telephone"); |
modelTypePersonnes.addField("cp_ce_truk_specialite"); |
modelTypePersonnes.addField("cp_id_personne"); |
|
String displayNamePersonnes = "cp_fmt_nom_complet"; |
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(null); |
|
personneExistanteCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes); |
|
// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar |
//> CHECK |
toolBar.add(personneExistanteCombo); |
|
Button ajouterPersonneExistanteBtn = new Button("Ajouter à la grille"); |
ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
|
Personne personneExistante = new Personne(personneExistanteCombo.getValeur()); |
|
if (personneExistante != null) { |
StructureAPersonne membreDuPersonnel = new StructureAPersonne(personneExistante, "", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
} |
} |
}); |
toolBar.add(ajouterPersonneExistanteBtn); |
|
cp.setTopComponent(toolBar); |
|
ColumnModel cm = new ColumnModel(configs); |
|
grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm); |
grillePersonnel.setHeight("100%"); |
//grillePersonnel.setHeight("100%"); |
grillePersonnel.setAutoHeight(true); |
grillePersonnel.setBorders(true); |
grillePersonnel.setSelectionModel(sm); |
grillePersonnel.addPlugin(checkColumn); |
419,8 → 404,87 |
|
cp.add(grillePersonnel); |
this.add(cp); |
|
this.setAutoHeight(true); |
} |
|
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
} |
|
private Button creerBoutonModifier() { |
Button bouton = new Button(i18nC.modifier()); |
bouton.setIcon(Images.ICONES.vcardModifier()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
String IdpersonneSaisieSelectionnee = (grillePersonnel.getSelectionModel().getSelectedItem()).getIdPersonne(); |
|
if (IdpersonneSaisieSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
|
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String personneId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
personneId = (grillePersonnel.getSelectionModel().getSelectedItem()).getIdPersonne(); |
} |
|
final FenetreForm fenetre = new FenetreForm(""); |
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId); |
fenetre.add(formulaire); |
return fenetre; |
} |
|
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, final String personneId) { |
PersonneForm formulairePersonne = new PersonneForm(mediateur, personneId, this); |
FormPanel panneauFormulaire = formulairePersonne.getFormulaire(); |
fenetre.setHeadingHtml(panneauFormulaire.getHeadingHtml()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
|
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre. |
panneauFormulaire.getBottomComponent().hide(); |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulairePersonne); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
|
return formulairePersonne; |
} |
|
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} |
} |
}; |
|
return ecouteur; |
} |
|
public Collection<? extends String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
// Vérification du Personnel |
476,6 → 540,25 |
layout(); |
InfoLogger.display("Chargement du Personnel", "ok"); |
} |
} else if (info.getType().equals("personne_modifiee")) { |
if (info.getDonnee(0) != null) { |
Personne personne = (Personne) info.getDonnee(0); |
StructureAPersonne personneDansGrille = grillePersonnel.getStore().findModel("id_personne", personne.getId()); |
StructureAPersonne personneDansGrilleModif = new StructureAPersonne(personne, personneDansGrille.getFonction(), personneDansGrille.getIdRole(), personneDansGrille.getIdEtat()); |
int index = grillePersonnel.getStore().indexOf(personneDansGrille); |
grillePersonnel.getStore().remove(personneDansGrille); |
grillePersonnel.getStore().insert(personneDansGrilleModif, index); |
personnelModifie.put(personne.getId()+"", personneDansGrilleModif); |
} |
} else if (info.getType().equals("personne_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Personne personne = (Personne) info.getDonnee(0); |
StructureAPersonne structAPersonne = new StructureAPersonne(personne,"",StructureAPersonne.ROLE_EQUIPE, ""); |
Structure structure = ((StructureForm) formulaire).identification; |
structAPersonne.setIdStructure(structure.getId()); |
personnelAjoute.put(personne.getId(), structAPersonne); |
ajouterMembreAGrillePersonnel(structAPersonne); |
} |
} |
} |
|
578,7 → 661,7 |
personne.setDeces(Personne.ETRE_VIVANT); |
|
// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié) |
if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) { // Une personne ajoutée |
if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) { // Une personne ajoutée |
personnelAjoute.put(""+i, personne); |
} else {// Une personne modifiée |
personnelModifie.put(personne.getId(), personne); |