/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java |
---|
New file |
0,0 → 1,336 |
package org.tela_botanica.client.vues.collection; |
import java.util.HashMap; |
import java.util.Iterator; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.composants.ConteneurMultiChamps; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilDate; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.form.DateField; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData; |
public class CollectionFormContenu extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "contenu"; |
private Collection collection = null; |
private CollectionBotanique collectionBotanique = null; |
private Collection collectionCollectee = null; |
private CollectionBotanique collectionBotaniqueCollectee = null; |
private ChampCaseACocher natureChp = null; |
private TextArea specialiteChp = null; |
private ChampComboBoxListeValeurs dateDebutCombo = null; |
private ChampComboBoxListeValeurs dateFinCombo = null; |
private DateField dateDebutChp = null; |
private DateField dateFinChp = null; |
private TextArea annotationClassementChp = null; |
private ChampComboBoxListeValeurs etatClassementCombo = null; |
private ChampComboBoxListeValeurs precisionDateCombo = null; |
private ChampComboBoxListeValeurs precisionLocaliteCombo = null; |
private TextArea etiquetteAnnotationChp = null; |
private ChampComboBoxListeValeurs integreCollectionCombo = null; |
private ChampComboBoxListeValeurs infoIntegreCollectionCombo = null; |
private ChampSliderPourcentage auteurTitrePourcentChp; |
private ChampSliderPourcentage famillePourcentChp; |
private ChampSliderPourcentage genrePourcentChp; |
private ChampSliderPourcentage spPourcentChp; |
private ChampSliderPourcentage auteurSpPourcentChp; |
private ChampSliderPourcentage localitePourcentChp; |
private ChampSliderPourcentage datePourcentChp; |
public CollectionFormContenu(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionContenu()); |
creerFieldsetNature(); |
// TODO : réaliser un champ couverture géographique détaillé |
creerFieldsetPeriode(); |
creerFieldsetClassement(); |
creerFieldsetEtiquette(); |
creerFieldsetIntegration(); |
} |
private void creerFieldsetNature() { |
FieldSet natureFieldSet = new FieldSet(); |
natureFieldSet.setHeading(i18nC.collectionNatureTitre()); |
natureFieldSet.setCollapsible(true); |
natureFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
natureChp = new ChampCaseACocher(i18nC.natureVegetaleContenu(), "natureVegetale", false); |
natureFieldSet.add(natureChp); |
specialiteChp = new TextArea(); |
specialiteChp.setFieldLabel(i18nC.specialiteCollection()); |
specialiteChp.setToolTip(i18nC.specialiteCollectionInfo()); |
natureFieldSet.add(specialiteChp, new FormData(550, 0)); |
add(natureFieldSet); |
} |
private void creerFieldsetPeriode() { |
FieldSet periodeFieldSet = new FieldSet(); |
periodeFieldSet.setHeading(i18nC.collectionConstitutionTitre()); |
periodeFieldSet.setCollapsible(true); |
periodeFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
ConteneurMultiChamps dateDebutConteneur = new ConteneurMultiChamps(i18nC.dateDebutCollection()); |
dateDebutChp = new DateField(); |
dateDebutChp.getPropertyEditor().setFormat(UtilDate.formatDateFr); |
dateDebutChp.getPropertyEditor().setParseStrict(false); |
dateDebutChp.setFormatValue(true); |
dateDebutConteneur.ajouterChamp(dateDebutChp, new HBoxLayoutData(new Margins(0, 20, 0, 0))); |
dateDebutCombo = new ChampComboBoxListeValeurs(null, "dateDebut"); |
dateDebutCombo.setTrie("id_valeur"); |
dateDebutConteneur.ajouterChamp(dateDebutCombo); |
periodeFieldSet.add(dateDebutConteneur); |
ConteneurMultiChamps dateFinConteneur = new ConteneurMultiChamps(i18nC.dateFinCollection()); |
dateFinChp = new DateField(); |
dateFinChp.getPropertyEditor().setFormat(UtilDate.formatDateFr); |
dateFinChp.getPropertyEditor().setParseStrict(false); |
dateFinChp.setFormatValue(true); |
dateFinConteneur.ajouterChamp(dateFinChp, new HBoxLayoutData(new Margins(0, 20, 0, 0))); |
dateFinCombo = new ChampComboBoxListeValeurs(null, "dateFin"); |
dateFinCombo.setTrie("id_valeur"); |
dateFinConteneur.ajouterChamp(dateFinCombo); |
periodeFieldSet.add(dateFinConteneur); |
Text infoDate = new Text(i18nC.dateApproximativeInfo()); |
periodeFieldSet.add(infoDate); |
add(periodeFieldSet); |
} |
private void creerFieldsetClassement() { |
FieldSet classementFieldSet = new FieldSet(); |
classementFieldSet.setHeading(i18nC.collectionClassementTitre()); |
classementFieldSet.setCollapsible(true); |
classementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
etatClassementCombo = new ChampComboBoxListeValeurs(i18nC.etatClassementCollection(), "etatClassement", tabIndex++); |
classementFieldSet.add(etatClassementCombo); |
annotationClassementChp = new TextArea(); |
annotationClassementChp.setFieldLabel(i18nC.annotationClassementCollection()); |
classementFieldSet.add(annotationClassementChp, new FormData(550, 0)); |
Text infoClassement = new Text(i18nC.annotationClassementCollectionInfo()); |
classementFieldSet.add(infoClassement); |
add(classementFieldSet); |
} |
private void creerFieldsetEtiquette() { |
FieldSet etiquetteFieldSet = new FieldSet(); |
etiquetteFieldSet.setHeading(i18nC.collectionEtiquetteTitre()); |
etiquetteFieldSet.setCollapsible(true); |
etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
Text renseignementPoucentLabel = new Text(i18nC.renseignementEtiquetteCollection()); |
renseignementPoucentLabel.setTagName("label"); |
renseignementPoucentLabel.setStyleName("x-form-item-label"); |
etiquetteFieldSet.add(renseignementPoucentLabel); |
auteurTitrePourcentChp = new ChampSliderPourcentage(i18nC.auteurTitrePourcentCollection()); |
etiquetteFieldSet.add(auteurTitrePourcentChp, new FormData(200, 0)); |
famillePourcentChp = new ChampSliderPourcentage(i18nC.famillePourcentCollection()); |
etiquetteFieldSet.add(famillePourcentChp, new FormData(200, 0)); |
genrePourcentChp = new ChampSliderPourcentage(i18nC.genrePourcentCollection()); |
etiquetteFieldSet.add(genrePourcentChp, new FormData(200, 0)); |
spPourcentChp = new ChampSliderPourcentage(i18nC.spPourcentCollection()); |
etiquetteFieldSet.add(spPourcentChp, new FormData(200, 0)); |
auteurSpPourcentChp = new ChampSliderPourcentage(i18nC.auteurSpPourcentCollection()); |
etiquetteFieldSet.add(auteurSpPourcentChp, new FormData(200, 0)); |
localitePourcentChp = new ChampSliderPourcentage(i18nC.localitePourcentCollection()); |
etiquetteFieldSet.add(localitePourcentChp, new FormData(200, 0)); |
datePourcentChp = new ChampSliderPourcentage(i18nC.datePourcentCollection()); |
etiquetteFieldSet.add(datePourcentChp, new FormData(200, 0)); |
precisionLocaliteCombo = new ChampComboBoxListeValeurs(i18nC.precisionLocaliteCollection(), "onep", tabIndex++); |
etiquetteFieldSet.add(precisionLocaliteCombo); |
precisionDateCombo = new ChampComboBoxListeValeurs(i18nC.precisionDateCollection(), "onep", tabIndex++); |
etiquetteFieldSet.add(precisionDateCombo); |
etiquetteAnnotationChp = new TextArea(); |
etiquetteAnnotationChp.setFieldLabel(i18nC.etiquetteAnnotationCollection()); |
etiquetteAnnotationChp.setToolTip(i18nC.etiquetteAnnotationCollectionInfo()); |
etiquetteFieldSet.add(etiquetteAnnotationChp, new FormData(550, 0)); |
add(etiquetteFieldSet); |
} |
private String collecterEtiquetteRenseignement() { |
String renseignement = ""; |
renseignement += creerTypeValeur("AT", auteurTitrePourcentChp.getValeur()); |
renseignement += creerTypeValeur("F", famillePourcentChp.getValeur()); |
renseignement += creerTypeValeur("G", genrePourcentChp.getValeur()); |
renseignement += creerTypeValeur("SP", spPourcentChp.getValeur()); |
renseignement += creerTypeValeur("ASP", auteurSpPourcentChp.getValeur()); |
renseignement += creerTypeValeur("L", localitePourcentChp.getValeur()); |
renseignement += creerTypeValeur("D", datePourcentChp.getValeur()); |
renseignement = renseignement.replaceFirst(aDonnee.SEPARATEUR_VALEURS+"$", ""); |
return renseignement; |
} |
private String creerTypeValeur(String type, String valeur) { |
String retour = ""; |
if (!UtilString.isEmpty(valeur)) { |
retour = type+aDonnee.SEPARATEUR_TYPE_VALEUR+valeur+aDonnee.SEPARATEUR_VALEURS; |
} |
return retour; |
} |
private void peuplerEtiquetteRenseignement(String valeurTruk) { |
HashMap<String,String> infos = parserEtiquetteRenseignement(valeurTruk); |
if (infos != null) { |
Iterator<String> it = infos.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.equals("AT")) { |
auteurTitrePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("F")) { |
famillePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("G")) { |
genrePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("SP")) { |
spPourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("ASP")) { |
auteurSpPourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("L")) { |
localitePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("D")) { |
datePourcentChp.peupler(infos.get(cle)); |
} |
} |
} |
} |
public static HashMap<String,String> parserEtiquetteRenseignement(String valeurTruk) { |
HashMap<String,String> infos = null; |
if (!UtilString.isEmpty(valeurTruk)) { |
infos = new HashMap<String,String>(); |
String[] pourcentages = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS)); |
for (int i = 0; i < pourcentages.length; i++) { |
String[] pourcentageIdValeur = pourcentages[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
String id = pourcentageIdValeur[0]; |
String valeur = pourcentageIdValeur[1]; |
infos.put(id, valeur); |
} |
} |
return infos; |
} |
private void creerFieldsetIntegration() { |
FieldSet integrationFieldSet = new FieldSet(); |
integrationFieldSet.setHeading(i18nC.collectionIntegreeTitre()); |
integrationFieldSet.setCollapsible(true); |
integrationFieldSet.setLayout(Formulaire.creerFormLayout(350, alignementLabelDefaut)); |
integreCollectionCombo = new ChampComboBoxListeValeurs(i18nC.integreCollection(), "onpi", tabIndex++); |
integrationFieldSet.add(integreCollectionCombo); |
infoIntegreCollectionCombo = new ChampComboBoxListeValeurs(i18nC.infoIntegreCollection(), "onp", tabIndex++); |
integrationFieldSet.add(infoIntegreCollectionCombo); |
Text infoIntegration = new Text(i18nC.infoIntegrationCollection()); |
integrationFieldSet.add(infoIntegration); |
add(integrationFieldSet); |
} |
public void peupler() { |
initialiserCollection(); |
if (collectionBotanique != null) { |
natureChp.peupler(collectionBotanique.getNature()); |
specialiteChp.setValue(collectionBotanique.getSpecialite()); |
dateDebutChp.setValue(UtilString.formaterEnDate(collectionBotanique.getRecolteDateDebut())); |
dateDebutCombo.peupler(collectionBotanique.getRecolteDateDebutType()); |
dateFinChp.setValue(UtilString.formaterEnDate(collectionBotanique.getRecolteDateFin())); |
dateFinCombo.peupler(collectionBotanique.getRecolteDateFinType()); |
etatClassementCombo.peupler(collectionBotanique.getClassementEtat()); |
annotationClassementChp.setValue(collectionBotanique.getClassementAnnotation()); |
peuplerEtiquetteRenseignement(collectionBotanique.getEtiquetteRenseignement()); |
precisionLocaliteCombo.peupler(collectionBotanique.getPrecisionLocalite()); |
precisionDateCombo.peupler(collectionBotanique.getPrecisionDate()); |
etiquetteAnnotationChp.setValue(collectionBotanique.getAnnotationsDiverses()); |
integreCollectionCombo.peupler(collectionBotanique.getCollectionIntegre()); |
infoIntegreCollectionCombo.peupler(collectionBotanique.getCollectionIntegreInfo()); |
} |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionBotaniqueCollectee.setNature(natureChp.getValeur()); |
collectionBotaniqueCollectee.setSpecialite(specialiteChp.getValue()); |
collectionBotaniqueCollectee.setRecolteDateDebut(UtilDate.formaterEnString(dateDebutChp.getValue())); |
collectionBotaniqueCollectee.setRecolteDateDebutType(dateDebutCombo.getValeur()); |
collectionBotaniqueCollectee.setRecolteDateFin(UtilDate.formaterEnString(dateFinChp.getValue())); |
collectionBotaniqueCollectee.setRecolteDateFinType(dateFinCombo.getValeur()); |
collectionBotaniqueCollectee.setClassementEtat(etatClassementCombo.getValeur()); |
collectionBotaniqueCollectee.setClassementAnnotation(annotationClassementChp.getValue()); |
collectionBotaniqueCollectee.setEtiquetteRenseignement(collecterEtiquetteRenseignement()); |
collectionBotaniqueCollectee.setPrecisionLocalite(precisionLocaliteCombo.getValeur()); |
collectionBotaniqueCollectee.setPrecisionDate(precisionDateCombo.getValeur()); |
collectionBotaniqueCollectee.setAnnotationsDiverses(etiquetteAnnotationChp.getValue()); |
collectionBotaniqueCollectee.setCollectionIntegre(integreCollectionCombo.getValeur()); |
collectionBotaniqueCollectee.setCollectionIntegreInfo(infoIntegreCollectionCombo.getValeur()); |
} |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
if (collection != null) { |
collectionBotanique = collection.getBotanique(); |
} |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
if (collectionCollectee != null) { |
collectionBotaniqueCollectee = collectionCollectee.getBotanique(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionVue.java |
---|
New file |
0,0 → 1,62 |
package org.tela_botanica.client.vues.collection; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
public class CollectionVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private CollectionListeVue listeCollectionPanneau = null; |
private CollectionDetailVue detailCollectionPanneau = null; |
private Sequenceur sequenceur = new Sequenceur(); |
public CollectionVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
listeCollectionPanneau = new CollectionListeVue(mediateur); |
add(listeCollectionPanneau, new BorderLayoutData(LayoutRegion.CENTER)); |
detailCollectionPanneau = new CollectionDetailVue(mediateur, sequenceur); |
BorderLayoutData dispositionSud = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
dispositionSud.setSplit(true); |
dispositionSud.setMargins(new Margins(5, 0, 0, 0)); |
add(detailCollectionPanneau, dispositionSud); |
} |
public void rafraichir(Object nouvellesDonnees) { |
// Nous passons l'objet aux méthodes rafraichir des panneaux composant le panneau principal Structure |
if (nouvellesDonnees instanceof Collection) { |
detailCollectionPanneau.rafraichir(nouvellesDonnees); |
} else if (nouvellesDonnees instanceof CollectionListe) { |
listeCollectionPanneau.rafraichir(nouvellesDonnees); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("liste_collection_a_personne") |
|| info.getType().equals("liste_collection_a_publication") |
|| info.getType().equals("liste_collection_a_commentaire")) { |
detailCollectionPanneau.rafraichir(nouvellesDonnees); |
} else if (info.getType().equals("suppression_collection")) { |
listeCollectionPanneau.rafraichir(nouvellesDonnees); |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionVue.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java |
---|
New file |
0,0 → 1,202 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.i18n.Constantes; |
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.Utilisateur; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
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.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class CollectionListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Grid<Collection> grille = null; |
private ListStore<Collection> store = null; |
private Button modifier; |
private Button supprimer; |
private Button ajouter; |
private BarrePaginationVue pagination = null; |
public CollectionListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
setLayout(new FitLayout()); |
setHeading(i18nC.collectionListeTitre()); |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicAjouterCollection(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicModifierCollection(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
clicSupprimerCollection(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("nom", i18nC.personneNom(), 300)); |
colonnes.add(new ColumnConfig("_structure_nom_", i18nC.structure(), 200)); |
colonnes.add(new ColumnConfig("_structure_ville_", i18nC.ville(), 150)); |
colonnes.get(1).setHidden(true); |
ColumnModel modeleDeColonne = new ColumnModel(colonnes); |
GridSelectionModel<Collection> modeleDeSelection = new GridSelectionModel<Collection>(); |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Collection>() { |
public void selectionChanged(SelectionChangedEvent<Collection> event) { |
Collection collectionSelectionnee = (Collection) event.getSelectedItem(); |
clicListe(collectionSelectionnee); |
} |
}); |
store = new ListStore<Collection>(); |
store.sort("nom", SortDir.ASC); |
grille = new Grid<Collection>(store, modeleDeColonne); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("nom"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new CollectionListe(), mediateur); |
setBottomComponent(pagination); |
} |
private void clicListe(Collection collection) { |
if (collection != null && store.getCount() > 0) { |
mediateur.clicListeCollection(collection); |
} |
} |
private void clicSupprimerCollection(List<Collection> collectionsASupprimer) { |
if (store.getCount() > 0) { |
mediateur.clicSupprimerCollection(this, collectionsASupprimer); |
} |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin == 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof CollectionListe) { |
CollectionListe collections = (CollectionListe) nouvellesDonnees; |
pagination.setlistePaginable(collections); |
int[] pt = collections.getPageTable(); |
pagination.rafraichir(collections.getPageTable()); |
if (collections != null) { |
List<Collection> liste = collections.toList(); |
store.removeAll(); |
store.add(liste); |
mediateur.actualiserPanneauCentral(); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getType().equals("suppression_collection")) { |
// Affichage d'un message d'information |
InfoLogger.display(i18nC.suppressionCollection(), info.toString().replaceAll("\n", "<br />")); |
supprimerCollectionsSelectionnees(); |
gererEtatActivationBouton(); |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
layout(); |
} |
private void supprimerCollectionsSelectionnees() { |
List<Collection> collectionsSelectionnees = grille.getSelectionModel().getSelectedItems(); |
Iterator<Collection> it = collectionsSelectionnees.iterator(); |
while (it.hasNext()) { |
grille.getStore().remove(it.next()); |
} |
layout(true); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java |
---|
New file |
0,0 → 1,472 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampComboBoxRechercheTempsReelPaginable; |
import org.tela_botanica.client.composants.ChampMultiValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable; |
import org.tela_botanica.client.composants.ConteneurMultiChamps; |
import org.tela_botanica.client.composants.pagination.ProxyCollections; |
import org.tela_botanica.client.composants.pagination.ProxyProjets; |
import org.tela_botanica.client.composants.pagination.ProxyStructures; |
import org.tela_botanica.client.composants.pagination.ProxyValeur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.data.ModelData; |
import com.extjs.gxt.ui.client.data.ModelType; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.Text; |
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.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.HiddenField; |
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; |
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.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData; |
import com.google.gwt.i18n.client.NumberFormat; |
public class CollectionFormGeneral extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "general"; |
private Collection collection = null; |
private Collection collectionCollectee = null; |
private HiddenField<String> idCollectionChp = null; |
private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null; |
private ChampComboBoxRechercheTempsReelPaginable structuresCombo = null; |
private ChampComboBoxRechercheTempsReelPaginable collectionsCombo = null; |
private ChampCaseACocher periodeConstitutionChp = null; |
private ChampComboBoxListeValeurs groupementPrincipeCombo = null; |
private ChampMultiValeurs lieuCouvertureChp = null; |
private ChampComboBoxListeValeurs specimenTypeCombo = null; |
private ChampComboBoxListeValeurs precisionTypeNbreCombo = null; |
private NumberField nbreTypeChp = null; |
private ChampComboBoxListeValeurs classementSpecimenTypeCombo = null; |
private ChampComboBoxListeValeurs typeDepotCombo = null; |
private TextField<String> coteChp = null; |
private ChampMultiValeurs idAlternatifsChp = null; |
private ChampMultiValeurs nomsAlternatifsChp = null; |
private ChampMultiValeurs codesAlternatifsChp = null; |
private TextArea descriptionSpecialisteChp = null; |
private TextArea descriptionChp = null; |
private TextArea historiqueChp = null; |
private ChampMultiValeurs urlsChp = null; |
private ChampComboBoxListeValeurs butRealisationCombo = null; |
private Sequenceur sequenceur = new Sequenceur(); |
public CollectionFormGeneral(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionGeneral()); |
creerChampsCache(); |
creerFieldsetLiaison(); |
creerFieldsetAdministratif(); |
creerFieldsetDescription(); |
creerFieldsetCouverture(); |
creerFieldsetType(); |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
} |
private void creerChampsCache() { |
// Champs cachés |
idCollectionChp = new HiddenField<String>(); |
this.add(idCollectionChp); |
} |
private void creerFieldsetLiaison() { |
FieldSet liaisonFieldSet = new FieldSet(); |
liaisonFieldSet.setHeading(i18nC.liaisonTitreCollection()); |
liaisonFieldSet.setCollapsible(true); |
liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
/*********************************/ |
/** Champ Projets **/ |
/*********************************/ |
ModelType modelTypeProjets = new ModelType(); |
modelTypeProjets.setRoot("projets"); |
modelTypeProjets.setTotalName("nbElements"); |
modelTypeProjets.addField("cpr_nom"); |
modelTypeProjets.addField("cpr_id_projet"); |
String displayNameProjets = "cpr_nom"; |
ProxyProjets<ModelData> proxyProjets = new ProxyProjets<ModelData>(sequenceur); |
projetsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyProjets, modelTypeProjets, displayNameProjets); |
projetsCombo.setWidth(250, 600); |
projetsCombo.getCombo().setTabIndex(tabIndex++); |
projetsCombo.getCombo().setFieldLabel(i18nC.projetChamp()); |
projetsCombo.getCombo().setForceSelection(true); |
projetsCombo.getCombo().addStyleName(ComposantClass.OBLIGATOIRE); |
projetsCombo.getCombo().addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire()); |
projetsCombo.getCombo().setValidator(new Validator() { |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (projetsCombo.getStore().findModel("cpr_nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
liaisonFieldSet.add(projetsCombo, new FormData(600, 0)); |
/*************************************/ |
/** Champ Structures **/ |
/*************************************/ |
ModelType modelTypeStructures = new ModelType(); |
modelTypeStructures.setRoot("structures"); |
modelTypeStructures.setTotalName("nbElements"); |
modelTypeStructures.addField("cs_nom"); |
modelTypeStructures.addField("cs_id_structure"); |
String displayNameStructures = "cs_nom"; |
ProxyStructures<ModelData> proxyStructures = new ProxyStructures<ModelData>(sequenceur); |
structuresCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyStructures, modelTypeStructures, displayNameStructures); |
structuresCombo.setWidth(250, 600); |
structuresCombo.getCombo().setTabIndex(tabIndex++); |
structuresCombo.getCombo().setFieldLabel(i18nC.lienStructureCollection()); |
structuresCombo.getCombo().setForceSelection(true); |
structuresCombo.getCombo().setValidator(new Validator() { |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (structuresCombo.getStore().findModel("cs_nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
liaisonFieldSet.add(structuresCombo, new FormData(600, 0)); |
/*************************************/ |
/** Champ Collections **/ |
/*************************************/ |
ModelType modelTypeCollections = new ModelType(); |
modelTypeCollections.setRoot("collections"); |
modelTypeCollections.setTotalName("nbElements"); |
modelTypeCollections.addField("cc_nom"); |
modelTypeCollections.addField("cc_id_collection"); |
modelTypeCollections.addField("cc_ce_mere"); |
String displayNameCollections = "cc_nom"; |
ProxyCollections<ModelData> proxyCollections = new ProxyCollections<ModelData>(sequenceur); |
collectionsCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyCollections, modelTypeCollections, displayNameCollections); |
collectionsCombo.setWidth(250, 600); |
collectionsCombo.getCombo().setTabIndex(tabIndex++); |
collectionsCombo.getCombo().setFieldLabel(i18nC.lienMereCollection()); |
collectionsCombo.getCombo().setForceSelection(true); |
collectionsCombo.getCombo().setValidator(new Validator() { |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (collectionsCombo.getStore().findModel("cc_nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
liaisonFieldSet.add(collectionsCombo, new FormData(600, 0)); |
this.add(liaisonFieldSet); |
} |
private void creerFieldsetAdministratif() { |
// Fieldset ADMINISTRATIF |
FieldSet administratifFieldSet = new FieldSet(); |
administratifFieldSet.setHeading(i18nC.collectionGeneralTitre()); |
administratifFieldSet.setCollapsible(true); |
administratifFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
typeDepotCombo = new ChampComboBoxListeValeurs(i18nC.typeDepot(), "typeDepot", tabIndex++); |
administratifFieldSet.add(typeDepotCombo); |
coteChp = new TextField<String>(); |
coteChp.setTabIndex(tabIndex++); |
coteChp.setFieldLabel(i18nC.cote()); |
administratifFieldSet.add(coteChp, new FormData(450, 0)); |
idAlternatifsChp = new ChampMultiValeurs(i18nC.idAlternatifCollection()); |
administratifFieldSet.add(idAlternatifsChp); |
nomsAlternatifsChp = new ChampMultiValeurs(i18nC.intituleAlternatifCollection()); |
administratifFieldSet.add(nomsAlternatifsChp); |
codesAlternatifsChp = new ChampMultiValeurs(i18nC.codeAlternatifCollection()); |
administratifFieldSet.add(codesAlternatifsChp); |
this.add(administratifFieldSet); |
} |
private void creerFieldsetDescription() { |
// Fieldset DESCRIPTION |
FieldSet descriptionFieldSet = new FieldSet(); |
descriptionFieldSet.setHeading(i18nC.collectionDescriptionTitre()); |
descriptionFieldSet.setCollapsible(true); |
descriptionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
descriptionChp = new TextArea(); |
descriptionChp.setFieldLabel(i18nC.description()); |
descriptionFieldSet.add(descriptionChp, new FormData(550, 0)); |
descriptionSpecialisteChp = new TextArea(); |
descriptionSpecialisteChp.setFieldLabel(i18nC.descriptionSpecialiste()); |
descriptionFieldSet.add(descriptionSpecialisteChp, new FormData(550, 0)); |
historiqueChp = new TextArea(); |
historiqueChp.setFieldLabel(i18nC.historique()); |
descriptionFieldSet.add(historiqueChp, new FormData(550, 0)); |
urlsChp = new ChampMultiValeurs(i18nC.urlsCollection()); |
descriptionFieldSet.add(urlsChp); |
this.add(descriptionFieldSet); |
} |
private void creerFieldsetCouverture() { |
FieldSet couvertureFieldSet = new FieldSet(); |
couvertureFieldSet.setHeading("Couvertures"); |
couvertureFieldSet.setCollapsible(true); |
couvertureFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
periodeConstitutionChp = new ChampCaseACocher(i18nC.periodeConstitution(), "siecleNaturaliste", false); |
couvertureFieldSet.add(periodeConstitutionChp); |
groupementPrincipeCombo = new ChampComboBoxListeValeurs(i18nC.groupementPrincipeCollection(), "groupementPrincipe", tabIndex++); |
groupementPrincipeCombo.setToolTip(i18nC.groupementPrincipeCollectionInfo()); |
couvertureFieldSet.add(groupementPrincipeCombo); |
butRealisationCombo = new ChampComboBoxListeValeurs(i18nC.butCollection(), "realisationBut", tabIndex++); |
couvertureFieldSet.add(butRealisationCombo); |
lieuCouvertureChp = new ChampMultiValeurs(i18nC.lieuCouvertureCollection()); |
couvertureFieldSet.add(lieuCouvertureChp); |
this.add(couvertureFieldSet); |
} |
private void creerFieldsetType() { |
FieldSet typeFieldSet = new FieldSet(); |
typeFieldSet.setHeading("Spécimens «types»"); |
typeFieldSet.setCollapsible(true); |
typeFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
specimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.specimenTypeCollection(), "onpi", tabIndex++); |
typeFieldSet.add(specimenTypeCombo); |
ConteneurMultiChamps nbreTypeConteneur = new ConteneurMultiChamps(i18nC.nbreSpecimenTypeCollection()); |
nbreTypeChp = new NumberField(); |
nbreTypeChp.setFormat(NumberFormat.getFormat("#")); |
nbreTypeConteneur.ajouterChamp(nbreTypeChp, new HBoxLayoutData(new Margins(0, 20, 0, 0))); |
precisionTypeNbreCombo = new ChampComboBoxListeValeurs(null, "ea"); |
precisionTypeNbreCombo.setTrie("id_valeur"); |
precisionTypeNbreCombo.setEmptyText(i18nC.precisionNbreSpecimenTypeCollectionChpVide()); |
nbreTypeConteneur.ajouterChamp(precisionTypeNbreCombo); |
typeFieldSet.add(nbreTypeConteneur); |
classementSpecimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.classementSpecimenTypeCollection(), "typeClassement", tabIndex++); |
typeFieldSet.add(classementSpecimenTypeCombo); |
Text infoType = new Text(i18nC.specimenTypeCollectionInfo()); |
typeFieldSet.add(infoType); |
this.add(typeFieldSet); |
} |
public void peupler() { |
initialiserCollection(); |
if (collection != null) { |
idCollectionChp.setValue(collection.getId()); |
setValeurComboProjets(); |
setValeurComboStructures(); |
setValeurComboCollections(); |
typeDepotCombo.peupler(collection.getTypeDepot()); |
coteChp.setValue(collection.getCote()); |
idAlternatifsChp.peupler(collection.getIdAlternatif()); |
nomsAlternatifsChp.peupler(collection.getNomAlternatif()); |
codesAlternatifsChp.peupler(collection.getCode()); |
descriptionChp.setValue(collection.getDescription()); |
descriptionSpecialisteChp.setValue(collection.getDescriptionSpecialiste()); |
historiqueChp.setValue(collection.getHistorique()); |
urlsChp.peupler(collection.getUrls()); |
periodeConstitutionChp.peupler(collection.getPeriodeConstitution()); |
groupementPrincipeCombo.peupler(collection.getGroupementPrincipe()); |
butRealisationCombo.peupler(collection.getGroupementBut()); |
lieuCouvertureChp.peupler(collection.getCouvertureLieu()); |
specimenTypeCombo.peupler(collection.getSpecimenType()); |
nbreTypeChp.setValue((collection.getSpecimenTypeNbre().equals("") ? 0 : Integer.parseInt(collection.getSpecimenTypeNbre()))); |
precisionTypeNbreCombo.peupler(collection.getSpecimenTypeNbrePrecision()); |
classementSpecimenTypeCombo.peupler(collection.getSpecimenTypeClassement()); |
} |
} |
public ArrayList<String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
if (projetsCombo.getCombo().getValue() == null || !projetsCombo.getCombo().isValid()) { |
messages.add(i18nM.selectionObligatoire(i18nC.articleUn()+" "+i18nC.projetSingulier(), i18nC.articleLa()+" "+i18nC.collectionSingulier())); |
} |
return messages; |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionCollectee.setId(idCollectionChp.getValue()); |
collectionCollectee.setIdProjet(getValeurComboProjets()); |
collectionCollectee.setIdStructure(getValeurComboStructures()); |
collectionCollectee.setCollectionMereId(getValeurComboCollections()); |
collectionCollectee.setTypeDepot(typeDepotCombo.getValeur()); |
collectionCollectee.setCote(coteChp.getValue()); |
collectionCollectee.setIdAlternatif(idAlternatifsChp.getValeurs()); |
collectionCollectee.setNomAlternatif(nomsAlternatifsChp.getValeurs()); |
collectionCollectee.setCode(codesAlternatifsChp.getValeurs()); |
collectionCollectee.setDescription(descriptionChp.getValue()); |
collectionCollectee.setDescriptionSpecialiste(descriptionSpecialisteChp.getValue()); |
collectionCollectee.setHistorique(historiqueChp.getValue()); |
collectionCollectee.setUrls(urlsChp.getValeurs()); |
collectionCollectee.setPeriodeConstitution(periodeConstitutionChp.getValeur()); |
collectionCollectee.setGroupementPrincipe(groupementPrincipeCombo.getValeur()); |
collectionCollectee.setGroupementBut(butRealisationCombo.getValeur()); |
collectionCollectee.setCouvertureLieu(lieuCouvertureChp.getValeurs()); |
collectionCollectee.setSpecimenType(specimenTypeCombo.getValeur()); |
if (nbreTypeChp.getValue() != null) { |
collectionCollectee.setSpecimenTypeNbre(nbreTypeChp.getValue().toString()); |
} |
collectionCollectee.setSpecimenTypeNbrePrecision(precisionTypeNbreCombo.getValeur()); |
collectionCollectee.setSpecimenTypeClassement(classementSpecimenTypeCombo.getValeur()); |
} |
} |
private String getValeurComboProjets() { |
String valeur = ""; |
if (projetsCombo.getCombo().getValue() != null) { |
Projet projet = new Projet(projetsCombo.getValeur()); |
valeur = projet.getId(); |
} |
return valeur; |
} |
private void setValeurComboProjets() { |
if (projetsCombo.getStore() != null && collection != null) { |
projetsCombo.getCombo().setValue(projetsCombo.getStore().findModel("cpr_id_projet", collection.getIdProjet())); |
} |
} |
private String getValeurComboStructures() { |
String valeur = ""; |
if (structuresCombo.getCombo().getValue() != null) { |
Structure structure = new Structure(structuresCombo.getValeur()); |
valeur = structure.getId(); |
} |
return valeur; |
} |
private void setValeurComboStructures() { |
if (structuresCombo.getStore() != null && collection != null) { |
structuresCombo.getCombo().setValue(structuresCombo.getStore().findModel("cs_id_structure", collection.getIdStructure())); |
} |
} |
private String getValeurComboCollections() { |
String valeur = ""; |
if (collectionsCombo.getCombo().getValue() != null) { |
Collection collection = new Collection(collectionsCombo.getValeur()); |
valeur = collection.getId(); |
} |
return valeur; |
} |
private void setValeurComboCollections() { |
if (collectionsCombo.getCombo().getStore() != null && collection != null) { |
collectionsCombo.getCombo().setValue(collectionsCombo.getStore().findModel("cc_ce_mere", collection.getCollectionMereId())); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("typeDepot"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeDepotCombo); |
} else { |
Debug.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!"); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java |
---|
New file |
0,0 → 1,1122 |
package org.tela_botanica.client.vues.collection; |
import java.util.HashMap; |
import java.util.Iterator; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaire; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe; |
import org.tela_botanica.client.modeles.collection.CollectionAPublication; |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.modeles.collection.UniteBase; |
import org.tela_botanica.client.modeles.collection.UniteRangement; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilNombre; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.DetailVue; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.util.Format; |
import com.extjs.gxt.ui.client.util.Params; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Html; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
public class CollectionDetailVue extends DetailVue implements Rafraichissable { |
private Collection collection = null; |
private boolean collectionChargementOk = false; |
private boolean personnesLieesChargementOk = false; |
private boolean publicationsLieesChargementOk = false; |
private boolean commentairesLieesChargementOk = false; |
private Structure structure = null; |
private String enteteTpl = null; |
private String generalTpl = null; |
private String personneTpl = null; |
private String tableauPersonnesLieesTpl = null; |
private String lignePersonneLieeTpl = null; |
private String publicationTpl = null; |
private String tableauPublicationsLieesTpl = null; |
private String lignePublicationLieeTpl = null; |
private String descriptionTpl = null; |
private String contenuTpl = null; |
private String inventaireTpl = null; |
private String commentaireTpl = null; |
private String tableauCommentairesLieesTpl = null; |
private String ligneCommentaireLieeTpl = null; |
private ContentPanel panneauPrincipal = null; |
private Html entete = null; |
private TabPanel onglets = null; |
private TabItem generalOnglet = null; |
private TabItem personneOnglet = null; |
private TabItem publicationOnglet = null; |
private TabItem descriptionOnglet = null; |
private TabItem contenuOnglet = null; |
private TabItem inventaireOnglet = null; |
private TabItem commentaireOnglet = null; |
private String tableauUniteRangementTpl; |
private String ligneUniteRangementTpl; |
private String tableauUniteBaseTpl; |
private String ligneUniteBaseTpl; |
private Sequenceur sequenceur; |
public CollectionDetailVue(Mediateur mediateurCourant, Sequenceur sequenceur) { |
super(mediateurCourant); |
this.sequenceur = sequenceur; |
initialiserTousLesTpl(); |
chargerOntologie(); |
panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(false); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
panneauPrincipal.setTopComponent(entete); |
onglets = new TabPanel(); |
onglets.setId(ComposantId.ZONE_DETAIL_CORPS); |
onglets.setBodyBorder(false); |
generalOnglet = new TabItem(i18nC.structureInfoGeneral()); |
generalOnglet.setLayout(new AnchorLayout()); |
generalOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(generalOnglet); |
personneOnglet = new TabItem(i18nC.collectionPersonne()); |
personneOnglet.setLayout(new AnchorLayout()); |
personneOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(personneOnglet); |
publicationOnglet = new TabItem(i18nC.collectionPublication()); |
publicationOnglet.setLayout(new AnchorLayout()); |
publicationOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(publicationOnglet); |
descriptionOnglet = new TabItem(i18nC.collectionDescription()); |
descriptionOnglet.setLayout(new AnchorLayout()); |
descriptionOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(descriptionOnglet); |
contenuOnglet = new TabItem(i18nC.collectionContenu()); |
contenuOnglet.setLayout(new AnchorLayout()); |
contenuOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(contenuOnglet); |
inventaireOnglet = new TabItem(i18nC.collectionInventaire()); |
inventaireOnglet.setLayout(new AnchorLayout()); |
inventaireOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(inventaireOnglet); |
commentaireOnglet = new TabItem(i18nC.collectionCommentaire()); |
commentaireOnglet.setLayout(new AnchorLayout()); |
commentaireOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(commentaireOnglet); |
panneauPrincipal.add(onglets); |
add(panneauPrincipal); |
} |
private void initialiserTousLesTpl() { |
initialiserEnteteHtmlTpl(); |
initialiserGeneralTpl(); |
initialiserPersonneTpl(); |
initialiserTableauPersonnesLieesTpl(); |
initialiserLignePersonneLieeTpl(); |
initialiserPublicationTpl(); |
initialiserTableauPublicationsLieesTpl(); |
initialiserLignePublicationLieeTpl(); |
initialiserContenuTpl(); |
initialiserDescriptionTpl(); |
initialiserTableauUniteRangementTpl(); |
initialiserLigneUniteRangementTpl(); |
initialiserTableauUniteBaseTpl(); |
initialiserLigneUniteBaseTpl(); |
initialiserInventaireTpl(); |
initialiserCommentaireTpl(); |
initialiserTableauCommentairesLieesTpl(); |
initialiserLigneCommentaireLieeTpl(); |
} |
private void initialiserEnteteHtmlTpl() { |
enteteTpl = |
"<div id='{css_id}'>"+ |
" <h1>{nom}</h1>"+ |
" <h2>{structure}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" + |
"</div>"; |
} |
private void initialiserGeneralTpl() { |
generalTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_identification}</h2>"+ |
" <span class='{css_label}'>{i18n_nom_alternatif} :</span> {nom_alternatif}<br />"+ |
" <span class='{css_label}'>{i18n_mere} :</span> {mere}<br />"+ |
" <span class='{css_label}'>{i18n_type_ncd} :</span> {type_ncd}<br />"+ |
" <span class='{css_label}'>{i18n_type_depot} :</span> {type_depot}<br />"+ |
" <span class='{css_label}'>{i18n_id_alternatif} :</span> {id_alternatif}<br />"+ |
" <span class='{css_label}'>{i18n_code} :</span> {code}<br />"+ |
" <span class='{css_label}'>{i18n_cote} :</span> {cote}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_general_collection_titre}</h2>"+ |
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+ |
" <span class='{css_label}'>{i18n_description_specialiste} :</span> {description_specialiste}<br />"+ |
" <span class='{css_label}'>{i18n_historique} :</span> {historique}<br />"+ |
" <span class='{css_label}'>{i18n_web} :</span> {web}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_couverture_collection_titre}</h2>"+ |
" <span class='{css_label}'>{i18n_groupement_principe} :</span> {groupement_principe}<br />"+ |
" <span class='{css_label}'>{i18n_groupement_but} :</span> {groupement_but}<br />"+ |
" <span class='{css_label}'>{i18n_couverture_geo} :</span> {couverture_geo}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_specimen_type_titre}</h2>"+ |
" <span class='{css_label}'>{i18n_specimen_type_presence} :</span> {specimen_type_presence}<br />"+ |
" <span class='{css_label}'>{i18n_specimen_type_nombre} :</span> {specimen_type_nombre}<br />"+ |
" <span class='{css_label}'>{i18n_specimen_type_classement} :</span> {specimen_type_classement}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
"</div>"; |
} |
private void initialiserPersonneTpl() { |
personneTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_personne}</h2>"+ |
" {tableau_personnes_liees}"+ |
"</div>"; |
} |
private void initialiserTableauPersonnesLieesTpl() { |
tableauPersonnesLieesTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_relation}</th>" + |
" <th>{i18n_nom_complet}</th>" + |
" <th>{i18n_nom}</th>" + |
" <th>{i18n_prenom}</th>" + |
" <th>{i18n_naissance_date}</th>" + |
" <th>{i18n_naissance_lieu}</th>" + |
" <th>{i18n_etre_decede}</th>" + |
" <th>{i18n_deces_date}</th>" + |
" <th>{i18n_deces_lieu}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLignePersonneLieeTpl() { |
lignePersonneLieeTpl = |
"<tr>"+ |
" <td>{relation}</td>"+ |
" <td>{nom_complet}</td>"+ |
" <td>{nom}</td>"+ |
" <td>{prenom}</td>"+ |
" <td>{naissance_date}</td>"+ |
" <td>{naissance_lieu}</td>"+ |
" <td>{etre_decede}</td>"+ |
" <td>{deces_date}</td>"+ |
" <td>{deces_lieu}</td>"+ |
"</tr>"; |
} |
private void initialiserPublicationTpl() { |
publicationTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_publication}</h2>"+ |
" {tableau_publications_liees}"+ |
"</div>"; |
} |
private void initialiserTableauPublicationsLieesTpl() { |
tableauPublicationsLieesTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_auteur}</th>" + |
" <th>{i18n_titre}</th>" + |
" <th>{i18n_revue}</th>" + |
" <th>{i18n_editeur}</th>" + |
" <th>{i18n_annee}</th>" + |
" <th>{i18n_nvt}</th>" + |
" <th>{i18n_fascicule}</th>" + |
" <th>{i18n_page}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLignePublicationLieeTpl() { |
lignePublicationLieeTpl = |
"<tr>"+ |
" <td>{auteur}</td>"+ |
" <td>{titre}</td>"+ |
" <td>{revue}</td>"+ |
" <td>{editeur}</td>"+ |
" <td>{annee}</td>"+ |
" <td>{nvt}</td>"+ |
" <td>{fascicule}</td>"+ |
" <td>{page}</td>"+ |
"</tr>"; |
} |
private void initialiserDescriptionTpl() { |
descriptionTpl = |
"<div class='{css_corps}'>"+ |
" <div>"+ |
" <h2>{i18n_titre_description}</h2>"+ |
" <span class='{css_label}'>{i18n_type_botanique} :</span> {type_botanique}<br />"+ |
" <span class='{css_label}'>{i18n_nbre_echantillon} :</span> {nbre_echantillon}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_unite_rangement}</h2>"+ |
" <span class='{css_label}'>{i18n_etat_unite_rangement} :</span> {etat_unite_rangement}<br />"+ |
" {tableau_unite_rangement}"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_unite_base}</h2>"+ |
" {tableau_unite_base}"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_conservation}</h2>"+ |
" <span class='{css_label}'>{i18n_type_papier} :</span> {type_papier}<br />"+ |
" <span class='{css_label}'>{i18n_conservation_methode} :</span> {conservation_methode}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_etiquette}</h2>"+ |
" <span class='{css_label}'>{i18n_specimen_fixation_pourcent} :</span> {specimen_fixation_pourcent}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_fixation_pourcent} :</span> {etiquette_fixation_pourcent}<br />"+ |
" <span class='{css_label}'>{i18n_specimen_fixation_methode} :</span> {specimen_fixation_methode}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_fixation_methode_support} :</span> {etiquette_fixation_methode_support}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_fixation_methode_specimen} :</span> {etiquette_fixation_methode_specimen}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_type_ecriture} :</span> {etiquette_type_ecriture}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_traitement}</h2>"+ |
" <span class='{css_label}'>{i18n_traitement} :</span> {traitement}<br />"+ |
" <span class='{css_label}'>{i18n_traitement_poison} :</span> {traitement_poison}<br />"+ |
" <span class='{css_label}'>{i18n_traitement_insecte} :</span> {traitement_insecte}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_etat_degradation}</h2>"+ |
" <span class='{css_label}'>{i18n_etat_general} :</span> {etat_general}<br />"+ |
" <span class='{css_label}'>{i18n_degradation_specimen} :</span> {degradation_specimen}<br />"+ |
" <span class='{css_label}'>{i18n_degradation_presentation} :</span> {degradation_presentation}<br />"+ |
" <span class='{css_label}'>{i18n_determination} :</span> {determination}<br />"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserTableauUniteRangementTpl() { |
tableauUniteRangementTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_type}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" <th>{i18n_format}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLigneUniteRangementTpl() { |
ligneUniteRangementTpl = |
"<tr>"+ |
" <td>{type}</td>"+ |
" <td>{nombre}</td>"+ |
" <td>{precision}</td>"+ |
" <td>{format}</td>"+ |
"</tr>"; |
} |
private void initialiserTableauUniteBaseTpl() { |
tableauUniteBaseTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th colspan='4'>{i18n_unite_base}</th>" + |
" <th colspan='2'>{i18n_part}</th>" + |
" <th colspan='2'>{i18n_sp}</th>" + |
" </tr>"+ |
" <tr>" + |
" <th>{i18n_type}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" <th>{i18n_format}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLigneUniteBaseTpl() { |
ligneUniteBaseTpl = |
"<tr>"+ |
" <td>{type}</td>"+ |
" <td>{nombre}</td>"+ |
" <td>{precision}</td>"+ |
" <td>{format}</td>"+ |
" <td>{part_nombre}</td>"+ |
" <td>{part_precision}</td>"+ |
" <td>{sp_nombre}</td>"+ |
" <td>{sp_precision}</td>"+ |
"</tr>"; |
} |
private void initialiserContenuTpl() { |
contenuTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_nature}</h2>"+ |
" <span class='{css_label}'>{i18n_nature} :</span> {nature}<br />"+ |
" <span class='{css_label}'>{i18n_specialite} :</span> {specialite}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_constitution}</h2>"+ |
" <span class='{css_label}'>{i18n_periode} :</span> {periode}<br />"+ |
" <span class='{css_label}'>{i18n_date_debut} :</span> {date_debut}<br />"+ |
" <span class='{css_label}'>{i18n_date_fin} :</span> {date_fin}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_classement}</h2>"+ |
" <span class='{css_label}'>{i18n_classement_etat} :</span> {classement_etat}<br />"+ |
" <span class='{css_label}'>{i18n_classement} :</span> {classement}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_etiquette}</h2>"+ |
" <span class='{css_label}'>{i18n_etiquette_renseignement} :</span> {etiquette_renseignement}<br />"+ |
" <span class='{css_label}'>{i18n_precision_localite} :</span> {precision_localite}<br />"+ |
" <span class='{css_label}'>{i18n_precision_date} :</span> {precision_date}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_annotation} :</span> {etiquette_annotation}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_integree}</h2>"+ |
" <span class='{css_label}'>{i18n_collection_integration} :</span> {collection_integration}<br />"+ |
" <span class='{css_label}'>{i18n_collection_integration_info} :</span> {collection_integration_info}<br />"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserInventaireTpl() { |
inventaireTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_inventaire}</h2>"+ |
" <span class='{css_label}'>{i18n_existence} :</span> {existence}<br />"+ |
" <span class='{css_label}'>{i18n_participation_auteur} :</span> {participation_auteur}<br />"+ |
" <span class='{css_label}'>{i18n_forme} :</span> {forme}<br />"+ |
" <span class='{css_label}'>{i18n_info} :</span> {info}<br />"+ |
" <span class='{css_label}'>{i18n_digital} :</span> {digital}<br />"+ |
" <span class='{css_label}'>{i18n_digital_pourcent} :</span> {digital_pourcent}<br />"+ |
" <span class='{css_label}'>{i18n_etat} :</span> {etat}<br />"+ |
//DELETEME : " <span class='{css_label}'>{i18n_type_donnee} :</span> {type_donnee}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
"</div>"; |
} |
private void initialiserCommentaireTpl() { |
commentaireTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_commentaire}</h2>"+ |
" {tableau_commentaires_liees}"+ |
"</div>"; |
} |
private void initialiserTableauCommentairesLieesTpl() { |
tableauCommentairesLieesTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_type}</th>" + |
" <th>{i18n_titre}</th>" + |
" <th>{i18n_ponderation}</th>" + |
" <th>{i18n_public}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLigneCommentaireLieeTpl() { |
ligneCommentaireLieeTpl = |
"<tr>"+ |
" <td>{type}</td>"+ |
" <td>{titre}</td>"+ |
" <td>{ponderation}</td>"+ |
" <td>{public}</td>"+ |
"</tr>"+ |
"<tr>"+ |
" <td colspan='4'>{texte}</td>"+ |
"</tr>"; |
} |
private void chargerOntologie() { |
String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot", "groupementPrincipe", |
"realisationBut", "onpi", "ea", "typeClassement", "relationPersonneCollection", "ion", |
"typeUniteRangement", "etat", "typeUniteBase", "typePapier", "methodeRangement", "methodeFixation", |
"methodeFixationSurSpecimen", "typeEcriture", "poisonTraitement", "insecteTraitement", "specimenDegradation", |
"niveauImportance", "supportDegradation", "niveauDetermination", "natureVegetale", "siecleNaturaliste", |
"dateDebut", "dateFin", "etat", "onep", "onp", "inventaireForme", "inventaireLogiciel", "inventaireEtat", |
"etatClassement", "typeCommentaireCollection"}; |
lancerChargementListesValeurs(listesCodes, sequenceur); |
sequenceur.enfilerRafraichissement(this, new Information("ontologie_chargee")); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Collection) { |
collection = (Collection) nouvellesDonnees; |
collectionChargementOk = true; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
projets = (ProjetListe) nouvellesDonnees; |
projetsChargementOk = true; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees; |
receptionerListeValeurs(listeValeursReceptionnee); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("liste_collection_a_personne")) { |
lierCollectionAPersonne((CollectionAPersonneListe) info.getDonnee(0)); |
} else if (info.getType().equals("liste_collection_a_publication")) { |
lierCollectionAPublication((CollectionAPublicationListe) info.getDonnee(0)); |
} else if (info.getType().equals("liste_collection_a_commentaire")) { |
lierCollectionACommentaire((CollectionACommentaireListe) info.getDonnee(0)); |
} else if (info.getType().equals("ontologie_chargee")) { |
ontologieChargementOk = true; |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
if (avoirDonneesChargees()) { |
afficherDetail(); |
} |
} |
protected void lierCollectionAPersonne(CollectionAPersonneListe personnes) { |
collection.setPersonnesLiees(personnes); |
personnesLieesChargementOk = true; |
} |
protected void lierCollectionAPublication(CollectionAPublicationListe publications) { |
collection.setPublicationsLiees(publications); |
publicationsLieesChargementOk = true; |
} |
protected void lierCollectionACommentaire(CollectionACommentaireListe commentaires) { |
collection.setCommentairesLiees(commentaires); |
commentairesLieesChargementOk = true; |
} |
private boolean avoirDonneesChargees() { |
boolean ok = false; |
if (projetsChargementOk && collectionChargementOk && ontologieChargementOk && personnesLieesChargementOk && publicationsLieesChargementOk && commentairesLieesChargementOk) { |
ok = true; |
} |
return ok; |
} |
private void afficherDetail() { |
if (collection != null) { |
afficherEntete(); |
afficherIdentification(); |
afficherPersonne(); |
afficherPublication(); |
afficherDescription(); |
afficherContenu(); |
afficherInventaire(); |
afficherCommentaire(); |
} |
layout(); |
} |
private void afficherEntete() { |
Params enteteParams = new Params(); |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE); |
enteteParams.set("css_meta", ComposantClass.META); |
enteteParams.set("i18n_id", i18nC.id()); |
enteteParams.set("nom", collection.getNom()); |
enteteParams.set("structure", collection.getStructureNom()); |
enteteParams.set("id", collection.getId()); |
enteteParams.set("guid", collection.getGuid()); |
enteteParams.set("projet", construireTxtProjet(collection.getIdProjet())); |
String eHtml = Format.substitute(enteteTpl, enteteParams); |
entete.getElement().setInnerHTML(eHtml); |
} |
private void afficherIdentification() { |
Params generalParams = new Params(); |
generalParams.set("i18n_titre_identification", i18nC.titreAdministratif()); |
generalParams.set("i18n_nom_alternatif", i18nC.intituleAlternatifCollection()); |
generalParams.set("i18n_mere", i18nC.collectionMere()); |
generalParams.set("i18n_type_ncd", i18nC.typeCollectionNcd()); |
generalParams.set("i18n_type_depot", i18nC.typeDepot()); |
generalParams.set("i18n_id_alternatif", i18nC.idAlternatifCollection()); |
generalParams.set("i18n_code", i18nC.codeAlternatifCollection()); |
generalParams.set("i18n_cote", i18nC.cote()); |
generalParams.set("i18n_general_collection_titre", i18nC.collectionGeneralTitre()); |
generalParams.set("i18n_description", i18nC.description()); |
generalParams.set("i18n_description_specialiste", i18nC.descriptionSpecialiste()); |
generalParams.set("i18n_historique", i18nC.historique()); |
generalParams.set("i18n_web", i18nC.siteWeb()); |
generalParams.set("i18n_couverture_collection_titre", i18nC.collectionCouvertureTitre()); |
generalParams.set("i18n_groupement_principe", i18nC.groupementPrincipe()); |
generalParams.set("i18n_groupement_but", i18nC.groupementBut()); |
generalParams.set("i18n_couverture_geo", i18nC.couvertureGeo()); |
generalParams.set("i18n_specimen_type_titre", i18nC.collectionSpecimenTypeTitre()); |
generalParams.set("i18n_specimen_type_presence", i18nC.specimenTypeCollectionDetail()); |
generalParams.set("i18n_specimen_type_nombre", i18nC.nbreSpecimenTypeCollectionDetail()); |
generalParams.set("i18n_specimen_type_classement", i18nC.classementSpecimenTypeCollectionDetail()); |
String nomAlternatif = construireTxtTruck(collection.getNomAlternatif()); |
String typeNcd = construireTxtListeOntologie(collection.getTypeNcd()); |
String typeDepot = construireTxtListeOntologie(collection.getTypeDepot()); |
String idAlternatif = construireTxtTruck(collection.getIdAlternatif()); |
String code = construireTxtTruck(collection.getCode()); |
String urls = construireTxtTruck(collection.getUrls(), false); |
String groupementBut = construireTxtListeOntologie(collection.getGroupementBut()); |
String groupementPrincipe = construireTxtListeOntologie(collection.getGroupementPrincipe()); |
String couvertureGeo = construireTxtTruck(collection.getCouvertureLieu()); |
String specimenTypePresence = construireTxtListeOntologie(collection.getSpecimenType()); |
String specimenTypeNombrePrecision = construireTxtListeOntologie(collection.getSpecimenTypeNbrePrecision()); |
String specimenTypeNombre = ""; |
if (!collection.getSpecimenTypeNbre().equals("0") && !collection.getSpecimenTypeNbre().equals("")) { |
specimenTypeNombre = collection.getSpecimenTypeNbre()+" ("+specimenTypeNombrePrecision+")"; |
} |
String specimenTypeClassement = construireTxtListeOntologie(collection.getSpecimenTypeClassement()); |
generalParams.set("nom_alternatif", nomAlternatif); |
generalParams.set("mere", collection.getCollectionMereNom()); |
generalParams.set("type_ncd", typeNcd); |
generalParams.set("type_depot", typeDepot); |
generalParams.set("id_alternatif", idAlternatif); |
generalParams.set("code", code); |
generalParams.set("cote", collection.getCote()); |
generalParams.set("description", collection.getDescription()); |
generalParams.set("description_specialiste", collection.getDescriptionSpecialiste()); |
generalParams.set("historique", collection.getHistorique()); |
generalParams.set("web", urls); |
generalParams.set("groupement_principe", groupementPrincipe); |
generalParams.set("groupement_but", groupementBut); |
generalParams.set("couverture_geo", couvertureGeo); |
generalParams.set("specimen_type_presence", specimenTypePresence); |
generalParams.set("specimen_type_nombre", specimenTypeNombre); |
generalParams.set("specimen_type_classement", specimenTypeClassement); |
afficherOnglet(generalTpl, generalParams, generalOnglet); |
} |
private void afficherPersonne() { |
String tableauPersonneHtml = ""; |
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) { |
tableauPersonneHtml = construireTableauPersonnesLiees(); |
} |
Params personneParams = new Params(); |
personneParams.set("i18n_titre_personne", i18nC.collectionPersonneTitre()); |
personneParams.set("tableau_personnes_liees", tableauPersonneHtml); |
afficherOnglet(personneTpl, personneParams, personneOnglet); |
} |
private String construireTableauPersonnesLiees() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_relation", i18nC.typeRelationPersonneCollection()); |
contenuParams.set("i18n_nom_complet", i18nC.personneNomComplet()); |
contenuParams.set("i18n_prenom", i18nC.personnePrenom()); |
contenuParams.set("i18n_nom", i18nC.personneNom()); |
contenuParams.set("i18n_naissance_date", i18nC.personneDateNaissance()); |
contenuParams.set("i18n_naissance_lieu", i18nC.personneLieuNaissance()); |
contenuParams.set("i18n_etre_decede", i18nC.personneDeces()); |
contenuParams.set("i18n_deces_date", i18nC.personneDateDeces()); |
contenuParams.set("i18n_deces_lieu", i18nC.personneLieuDeces()); |
String lignesPersonnel = ""; |
if (collection.getPersonnesLiees() != null) { |
Iterator<String> it = collection.getPersonnesLiees().keySet().iterator(); |
while (it.hasNext()) { |
CollectionAPersonne relationCollectionAPersonne = collection.getPersonnesLiees().get(it.next()); |
Personne personne = relationCollectionAPersonne.getPersonne(); |
String relation = construireTxtListeOntologie(relationCollectionAPersonne.getIdRole()); |
String etreDecede = construireTxtListeOntologie(personne.getDeces()); |
Params ligneParams = new Params(); |
ligneParams.set("relation", relation); |
ligneParams.set("nom_complet", personne.getNomComplet()); |
ligneParams.set("nom", personne.getNom()); |
ligneParams.set("prenom", personne.getPrenom()); |
ligneParams.set("naissance_date", personne.getNaissanceDate()); |
ligneParams.set("naissance_lieu", personne.getNaissanceLieu()); |
ligneParams.set("etre_decede", etreDecede); |
ligneParams.set("deces_date", personne.getDecesDate()); |
ligneParams.set("deces_lieu", personne.getDecesLieu()); |
lignesPersonnel += Format.substitute(lignePersonneLieeTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesPersonnel)) { |
contenuParams.set("lignes", lignesPersonnel); |
cHtml = Format.substitute(tableauPersonnesLieesTpl, contenuParams); |
} |
return cHtml; |
} |
private void afficherPublication() { |
Params publicationParams = new Params(); |
publicationParams.set("i18n_titre_publication", i18nC.collectionPublicationTitre()); |
String tableauPublicationHtml = ""; |
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) { |
tableauPublicationHtml = construireTableauPublicationsLiees(); |
} |
publicationParams.set("tableau_publications_liees", tableauPublicationHtml); |
afficherOnglet(publicationTpl, publicationParams, publicationOnglet); |
} |
private String construireTableauPublicationsLiees() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_auteur", i18nC.publicationAuteurs()); |
contenuParams.set("i18n_titre", i18nC.publicationTitre()); |
contenuParams.set("i18n_revue", i18nC.publicationRevueCollection()); |
contenuParams.set("i18n_editeur", i18nC.publicationEditeur()); |
contenuParams.set("i18n_annee", i18nC.publicationDateParution()); |
contenuParams.set("i18n_nvt", i18nC.publicationNvt()); |
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule()); |
contenuParams.set("i18n_page", i18nC.publicationPage()); |
String lignesPublication = ""; |
if (collection.getPublicationsLiees() != null) { |
Iterator<String> it = collection.getPublicationsLiees().keySet().iterator(); |
while (it.hasNext()) { |
CollectionAPublication relationCollectionAPublication = collection.getPublicationsLiees().get(it.next()); |
Publication publication = relationCollectionAPublication.getPublication(); |
Params ligneParams = new Params(); |
ligneParams.set("auteur", publication.getAuteur()); |
ligneParams.set("titre", publication.getTitre()); |
ligneParams.set("revue", publication.getCollection()); |
ligneParams.set("editeur", publication.getEditeur()); |
ligneParams.set("annee", publication.getAnneeParution()); |
ligneParams.set("nvt", publication.getIndicationNvt()); |
ligneParams.set("fascicule", publication.getFascicule()); |
ligneParams.set("page", publication.getPages()); |
lignesPublication += Format.substitute(lignePublicationLieeTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesPublication)) { |
contenuParams.set("lignes", lignesPublication); |
cHtml = Format.substitute(tableauPublicationsLieesTpl, contenuParams); |
} |
return cHtml; |
} |
private void afficherDescription() { |
Params descriptionParams = new Params(); |
descriptionParams.set("i18n_titre_description", i18nC.collectionDescriptionTitre()); |
descriptionParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique()); |
descriptionParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon()); |
descriptionParams.set("i18n_titre_unite_rangement", i18nC.collectionUniteRangementTitre()); |
descriptionParams.set("i18n_etat_unite_rangement", i18nC.collectionUniteRangementEtatGeneralDetail()); |
descriptionParams.set("i18n_titre_unite_base", i18nC.collectionUniteBaseTitre()); |
descriptionParams.set("i18n_titre_conservation", i18nC.collectionTitreConservation()); |
descriptionParams.set("i18n_type_papier", i18nC.typePapierConservationDetail()); |
descriptionParams.set("i18n_conservation_methode", i18nC.methodeConservationDetail()); |
descriptionParams.set("i18n_titre_etiquette", i18nC.collectionTitreEtiquette()); |
descriptionParams.set("i18n_specimen_fixation_pourcent", i18nC.specimenFixationPourcent()); |
descriptionParams.set("i18n_etiquette_fixation_pourcent", i18nC.etiquetteFixationPourcent()); |
descriptionParams.set("i18n_specimen_fixation_methode", i18nC.specimenMethodeFixationDetail()); |
descriptionParams.set("i18n_etiquette_fixation_methode_support", i18nC.etiquetteMethodeFixationSurSupportDetail()); |
descriptionParams.set("i18n_etiquette_fixation_methode_specimen", i18nC.etiquetteMethodeFixationSurSpecimenDetail()); |
descriptionParams.set("i18n_etiquette_type_ecriture", i18nC.typeEcritureDetail()); |
descriptionParams.set("i18n_titre_traitement", i18nC.collectionTitreTraitement()); |
descriptionParams.set("i18n_traitement", i18nC.collectionTraitementDetail()); |
descriptionParams.set("i18n_traitement_poison", i18nC.collectionTraitementPoisonDetail()); |
descriptionParams.set("i18n_traitement_insecte", i18nC.collectionTraitementInsecteDetail()); |
descriptionParams.set("i18n_titre_etat_degradation", i18nC.collectionTitreEtatEtDegradation()); |
descriptionParams.set("i18n_etat_general", i18nC.collectionEtatGeneralDetail()); |
descriptionParams.set("i18n_degradation_specimen", i18nC.degradationSpecimenDetail()); |
descriptionParams.set("i18n_degradation_presentation", i18nC.degradationPresentationDetail()); |
descriptionParams.set("i18n_determination", i18nC.collectionDeterminationDetail()); |
String typeBota = construireTxtListeOntologie(collection.getBotanique().getType()); |
descriptionParams.set("type_botanique", typeBota); |
descriptionParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
String etatUniteRangement = construireTxtListeOntologie(collectionBotanique.getUniteRangementEtat()); |
String tableauUniteRangementHtml = construireTableauUniteRangement(); |
String tableauUniteBaseHtml = construireTableauUniteBase(); |
descriptionParams.set("tableau_unite_rangement", tableauUniteRangementHtml); |
descriptionParams.set("etat_unite_rangement", etatUniteRangement); |
descriptionParams.set("tableau_unite_base", tableauUniteBaseHtml); |
String typePapier = construireTxtListeOntologie(collectionBotanique.getConservationPapierType()); |
String conservationMethode = construireTxtListeOntologie(collectionBotanique.getConservationMethode()); |
descriptionParams.set("type_papier", typePapier); |
descriptionParams.set("conservation_methode", conservationMethode); |
String specimenFixationMethode = construireTxtListeOntologie(collectionBotanique.getSpecimenFixationMethode()); |
String etiquetteFixationMethodeSupport = construireTxtListeOntologie(collectionBotanique.getEtiquetteFixationSupport()); |
String etiquetteFixationMethodeSpecimen = construireTxtListeOntologie(collectionBotanique.getEtiquetteFixationSpecimen()); |
String etiquetteTypeEcriture = construireTxtListeOntologie(collectionBotanique.getEtiquetteEcriture()); |
descriptionParams.set("specimen_fixation_pourcent", collectionBotanique.getSpecimenFixationPourcent()); |
descriptionParams.set("etiquette_fixation_pourcent", collectionBotanique.getEtiquetteFixationPourcent()); |
descriptionParams.set("specimen_fixation_methode", specimenFixationMethode); |
descriptionParams.set("etiquette_fixation_methode_support", etiquetteFixationMethodeSupport); |
descriptionParams.set("etiquette_fixation_methode_specimen", etiquetteFixationMethodeSpecimen); |
descriptionParams.set("etiquette_type_ecriture", etiquetteTypeEcriture); |
String traitement = construireTxtListeOntologie(collectionBotanique.getTraitement()); |
String traitementPoison = construireTxtListeOntologie(collectionBotanique.getTraitementPoison()); |
String traitementInsecte = construireTxtListeOntologie(collectionBotanique.getTraitementInsecte()); |
descriptionParams.set("traitement", traitement); |
descriptionParams.set("traitement_poison", traitementPoison); |
descriptionParams.set("traitement_insecte", traitementInsecte); |
String etatGeneral = construireTxtListeOntologie(collectionBotanique.getEtatGeneral()); |
boolean valeurEstOntologie = false; |
boolean typeEstOntologie = true; |
boolean donneeEstOntologie = true; |
String degradationSpecimen = construireTxtListeOntologie(collectionBotanique.getDegradationSpecimen(), valeurEstOntologie, typeEstOntologie, donneeEstOntologie); |
String degradationPresentation = construireTxtListeOntologie(collectionBotanique.getDegradationPresentation(), valeurEstOntologie, typeEstOntologie, donneeEstOntologie); |
String determination = construireTxtListeOntologie(collectionBotanique.getDetermination()); |
descriptionParams.set("etat_general", etatGeneral); |
descriptionParams.set("degradation_specimen", degradationSpecimen); |
descriptionParams.set("degradation_presentation", degradationPresentation); |
descriptionParams.set("determination", determination); |
afficherOnglet(descriptionTpl, descriptionParams, descriptionOnglet); |
} |
private String construireTableauUniteRangement() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_type", i18nC.collectionUniteType()); |
contenuParams.set("i18n_nombre", i18nC.collectionUniteNbre()); |
contenuParams.set("i18n_precision", i18nC.collectionUnitePrecision()); |
contenuParams.set("i18n_format", i18nC.collectionUniteFormat()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
HashMap<String,UniteRangement> unites = CollectionFormDescription.parserValeurUniteRangement(collectionBotanique.getUniteRangement()); |
String lignesUnite = ""; |
Iterator<String> it = unites.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
UniteRangement unite = unites.get(cle); |
if (unite.getNombre() != 0) { |
Params ligneParams = new Params(); |
if (unite.getTypeAutre()) { |
ligneParams.set("type", unite.getType()); |
} else { |
ligneParams.set("type", construireTxtListeOntologie(unite.getId())); |
} |
ligneParams.set("nombre", UtilNombre.formaterEnEntier(unite.getNombre())); |
ligneParams.set("precision", unite.getPrecision()); |
ligneParams.set("format", unite.getFormat()); |
lignesUnite += Format.substitute(ligneUniteRangementTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesUnite)) { |
contenuParams.set("lignes", lignesUnite); |
cHtml = Format.substitute(tableauUniteRangementTpl, contenuParams); |
} |
return cHtml; |
} |
private String construireTableauUniteBase() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_unite_base", i18nC.collectionUniteBase()); |
contenuParams.set("i18n_part", i18nC.collectionUniteBasePart()); |
contenuParams.set("i18n_sp", i18nC.collectionUniteBaseSp()); |
contenuParams.set("i18n_type", i18nC.collectionUniteType()); |
contenuParams.set("i18n_nombre", i18nC.collectionUniteNbre()); |
contenuParams.set("i18n_precision", i18nC.collectionUnitePrecision()); |
contenuParams.set("i18n_format", i18nC.collectionUniteFormat()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
HashMap<String,UniteBase> unites = CollectionFormDescription.parserValeurUniteBase(collectionBotanique.getUniteBase()); |
String lignesUnite = ""; |
Iterator<String> it = unites.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
UniteBase unite = unites.get(cle); |
if (unite.getNombre() != 0 || unite.getNombrePart() != 0 || unite.getNombreSp() != 0) { |
Params ligneParams = new Params(); |
if (unite.getTypeAutre()) { |
ligneParams.set("type", unite.getType()); |
} else { |
ligneParams.set("type", construireTxtListeOntologie(unite.getId())); |
} |
ligneParams.set("nombre", UtilNombre.formaterEnEntier(unite.getNombre())); |
ligneParams.set("precision", unite.getPrecision()); |
ligneParams.set("format", unite.getFormat()); |
ligneParams.set("part_nombre", UtilNombre.formaterEnEntier(unite.getNombrePart())); |
ligneParams.set("part_precision", unite.getPrecisionPart()); |
ligneParams.set("sp_nombre", UtilNombre.formaterEnEntier(unite.getNombreSp())); |
ligneParams.set("sp_precision", unite.getPrecisionSp()); |
lignesUnite += Format.substitute(ligneUniteBaseTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesUnite)) { |
contenuParams.set("lignes", lignesUnite); |
cHtml = Format.substitute(tableauUniteBaseTpl, contenuParams); |
} |
return cHtml; |
} |
private void afficherContenu() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_titre_nature", i18nC.collectionNatureTitre()); |
contenuParams.set("i18n_nature", i18nC.natureVegetaleContenuDetail()); |
contenuParams.set("i18n_specialite", i18nC.specialiteCollectionDetail()); |
contenuParams.set("i18n_titre_constitution", i18nC.collectionConstitutionTitre()); |
contenuParams.set("i18n_periode", i18nC.periodeConstitutionDetail()); |
contenuParams.set("i18n_date_debut", i18nC.dateDebutCollectionDetail()); |
contenuParams.set("i18n_date_fin", i18nC.dateFinCollectionDetail()); |
contenuParams.set("i18n_titre_classement", i18nC.collectionClassementTitre()); |
contenuParams.set("i18n_classement_etat", i18nC.etatClassementCollectionDetail()); |
contenuParams.set("i18n_classement", i18nC.annotationClassementCollectionDetail()); |
contenuParams.set("i18n_titre_etiquette", i18nC.collectionEtiquetteTitre()); |
contenuParams.set("i18n_etiquette_renseignement", i18nC.etiquetteRenseignementDetail()); |
contenuParams.set("i18n_precision_localite", i18nC.precisionLocaliteDetail()); |
contenuParams.set("i18n_precision_date", i18nC.precisionDateDetail()); |
contenuParams.set("i18n_etiquette_annotation", i18nC.etiquetteAnnotationDetail()); |
contenuParams.set("i18n_titre_integree", i18nC.collectionIntegreeTitre()); |
contenuParams.set("i18n_collection_integration", i18nC.integreCollectionDetail()); |
contenuParams.set("i18n_collection_integration_info", i18nC.infoIntegreCollectionDetail()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
String nature = construireTxtListeOntologie(collectionBotanique.getNature()); |
contenuParams.set("nature", nature); |
contenuParams.set("specialite", collectionBotanique.getSpecialite()); |
String periode = construireTxtListeOntologie(collection.getPeriodeConstitution()); |
String dateDebut = collectionBotanique.getRecolteDateDebut(); |
String dateDebutPrecision = construireTxtListeOntologie(collectionBotanique.getRecolteDateDebutType()); |
String dateDebutRecolte = (UtilString.isEmpty(dateDebut)) ? "" : dateDebut+" ("+dateDebutPrecision+")"; |
String dateFin = collectionBotanique.getRecolteDateFin(); |
String dateFinPrecision = construireTxtListeOntologie(collectionBotanique.getRecolteDateFinType()); |
String dateFinRecolte = (UtilString.isEmpty(dateFin)) ? "" : dateFin+" ("+dateFinPrecision+")"; |
contenuParams.set("periode", periode); |
contenuParams.set("date_debut", dateDebutRecolte); |
contenuParams.set("date_fin", dateFinRecolte); |
String classementEtat = construireTxtListeOntologie(collectionBotanique.getClassementEtat()); |
contenuParams.set("classement_etat", classementEtat); |
contenuParams.set("classement", collectionBotanique.getClassementAnnotation()); |
String etiquetteRenseignements = ""; |
HashMap<String,String> infos = CollectionFormContenu.parserEtiquetteRenseignement(collectionBotanique.getEtiquetteRenseignement()); |
if (infos != null) { |
Iterator<String> it = infos.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.equals("AT")) { |
etiquetteRenseignements += i18nC.etiquetteAuteurCollection(); |
} else if (cle.equals("F")) { |
etiquetteRenseignements += i18nC.etiquetteFamille(); |
} else if (cle.equals("G")) { |
etiquetteRenseignements += i18nC.etiquetteGenre(); |
} else if (cle.equals("SP")) { |
etiquetteRenseignements += i18nC.etiquetteSp(); |
} else if (cle.equals("ASP")) { |
etiquetteRenseignements += i18nC.etiquetteAuteurSp(); |
} else if (cle.equals("L")) { |
etiquetteRenseignements += i18nC.etiquetteLocalite(); |
} else if (cle.equals("D")) { |
etiquetteRenseignements += i18nC.etiquetteDateRecolte(); |
} else { |
etiquetteRenseignements += i18nC.inconnue(); |
} |
if (it.hasNext()) etiquetteRenseignements += ": "+infos.get(cle)+"%, "; |
else etiquetteRenseignements += ": "+infos.get(cle)+"%."; |
} |
} |
String precisionLocalite = construireTxtListeOntologie(collectionBotanique.getPrecisionLocalite()); |
String precisionDate = construireTxtListeOntologie(collectionBotanique.getPrecisionDate()); |
contenuParams.set("etiquette_renseignement", etiquetteRenseignements); |
contenuParams.set("precision_localite", precisionLocalite); |
contenuParams.set("precision_date", precisionDate); |
contenuParams.set("etiquette_annotation", collectionBotanique.getAnnotationsDiverses()); |
String collectionIntegration = construireTxtListeOntologie(collectionBotanique.getCollectionIntegre()); |
String collectionIntegrationInfo = construireTxtListeOntologie(collectionBotanique.getCollectionIntegreInfo()); |
contenuParams.set("collection_integration", collectionIntegration); |
contenuParams.set("collection_integration_info", collectionIntegrationInfo); |
afficherOnglet(contenuTpl, contenuParams, contenuOnglet); |
} |
private void afficherInventaire() { |
Params inventaireParams = new Params(); |
inventaireParams.set("i18n_titre_inventaire", i18nC.collectionInventaireTitre()); |
inventaireParams.set("i18n_existence", i18nC.existenceInventaireCollectionDetail()); |
inventaireParams.set("i18n_participation_auteur", i18nC.auteurInventaireCollectionDetail()); |
inventaireParams.set("i18n_forme", i18nC.formeInventaireCollectionDetail()); |
inventaireParams.set("i18n_info", i18nC.infoInventaireCollectionDetail()); |
inventaireParams.set("i18n_digital", i18nC.digitalInventaireCollectionDetail()); |
inventaireParams.set("i18n_digital_pourcent", i18nC.pourcentDigitalInventaireCollectionDetail()); |
inventaireParams.set("i18n_etat", i18nC.etatInventaireCollectionDetail()); |
//DELETEME inventaireParams.set("i18n_type_donnee", i18nC.typeDonneeInventaireCollectionDetail()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
String existence = construireTxtListeOntologie(collectionBotanique.getInventaire()); |
String participationAuteur = construireTxtListeOntologie(collectionBotanique.getInventaireAuteur()); |
String forme = construireTxtListeOntologie(collectionBotanique.getInventaireForme()); |
String digital = construireTxtListeOntologie(collectionBotanique.getInventaireDigital()); |
String digitalPourcent = collectionBotanique.getInventaireDigitalPourcent()+"%"; |
String etat = construireTxtListeOntologie(collectionBotanique.getInventaireEtat()); |
inventaireParams.set("existence", existence); |
inventaireParams.set("participation_auteur", participationAuteur); |
inventaireParams.set("forme", forme); |
inventaireParams.set("info", collectionBotanique.getInventaireInfo()); |
inventaireParams.set("digital", digital); |
inventaireParams.set("digital_pourcent", digitalPourcent); |
inventaireParams.set("etat", etat); |
//DELETEME inventaireParams.set("type_donnee", collectionBotanique.getInventaireDonneesTypes()); |
afficherOnglet(inventaireTpl, inventaireParams, inventaireOnglet); |
} |
private void afficherCommentaire() { |
String tableauCommentaireHtml = ""; |
if (collection.getCommentairesLiees() != null && collection.getCommentairesLiees().size() > 0) { |
tableauCommentaireHtml = construireTableauCommentairesLiees(); |
} |
Params personneParams = new Params(); |
personneParams.set("i18n_titre_commentaire", i18nC.collectionCommentaireTitre()); |
personneParams.set("tableau_commentaires_liees", tableauCommentaireHtml); |
afficherOnglet(commentaireTpl, personneParams, commentaireOnglet); |
} |
private String construireTableauCommentairesLiees() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_type", i18nC.commentaireType()); |
contenuParams.set("i18n_titre", i18nC.commentaireTitre()); |
contenuParams.set("i18n_texte", i18nC.commentaireTexte()); |
contenuParams.set("i18n_ponderation", i18nC.commentairePonderation()); |
contenuParams.set("i18n_public", i18nC.commentairePublic()); |
String lignesCommentaire = ""; |
if (collection.getCommentairesLiees() != null) { |
Iterator<String> it = collection.getCommentairesLiees().keySet().iterator(); |
while (it.hasNext()) { |
CollectionACommentaire relationCollectionACommentaire = collection.getCommentairesLiees().get(it.next()); |
Commentaire commentaire = relationCollectionACommentaire.getCommentaire(); |
String type = construireTxtListeOntologie(relationCollectionACommentaire.getType()); |
String acces = (commentaire.etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee()); |
Params ligneParams = new Params(); |
ligneParams.set("type", type); |
ligneParams.set("titre", commentaire.getTitre()); |
ligneParams.set("texte", commentaire.getTexte()); |
ligneParams.set("ponderation", commentaire.getPonderation()+"/100"); |
ligneParams.set("public", acces); |
lignesCommentaire += Format.substitute(ligneCommentaireLieeTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesCommentaire)) { |
contenuParams.set("lignes", lignesCommentaire); |
cHtml = Format.substitute(tableauCommentairesLieesTpl, contenuParams); |
} |
return cHtml; |
} |
protected String getNomStructure() { |
String nomStructure = ""; |
if (structure != null) { |
nomStructure = structure.getNom(); |
} else { |
nomStructure = collection.getIdStructure(); |
} |
return nomStructure; |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionForm.java |
---|
New file |
0,0 → 1,411 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
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.InfoLogger; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
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.StructureForm; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.widget.Info; |
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.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.google.gwt.core.client.GWT; |
public class CollectionForm extends Formulaire implements Rafraichissable { |
protected Collection collection = null; |
protected Collection collectionCollectee = null; |
private ChampComboBoxListeValeurs typesCollectionCombo = null; |
private TabPanel onglets = null; |
private CollectionFormGeneral generalOnglet = null; |
private CollectionFormPersonne personneOnglet = null; |
private CollectionFormPublication publicationOnglet = null; |
private CollectionFormDescription descriptionOnglet = null; |
private CollectionFormContenu contenuOnglet = null; |
private CollectionFormInventaire inventaireOnglet = null; |
private CollectionFormCommentaire commentaireOnglet = null; |
private TextField<String> nomChp = null; |
private Sequenceur sequenceur = new Sequenceur(); |
public CollectionForm(Mediateur mediateurCourrant, String collectionId) { |
initialiserCollectionForm(mediateurCourrant, collectionId); |
} |
private void initialiserCollectionForm(Mediateur mediateurCourrant, String collectionId) { |
collection = new Collection(); |
collection.setId(collectionId); |
String modeDeCreation = (UtilString.isEmpty(collection.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION); |
genererTitreFormulaire(); |
creerOnglets(); |
creerFieldsetPrincipal(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateurCourrant.selectionnerCollection(this, collectionId, null, sequenceur); |
mediateurCourrant.selectionnerCollectionAPersonne(this, collectionId, null, sequenceur); |
mediateurCourrant.selectionnerCollectionAPublication(this, collectionId, sequenceur); |
mediateurCourrant.selectionnerCollectionACommentaire(this, collectionId, sequenceur); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.collectionTitreFormAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.collectionTitreFormModif(); |
if (collection != null) { |
titre += " - "+i18nC.id()+": "+collection.getId(); |
} |
} |
panneauFormulaire.setHeading(titre); |
} |
private void creerFieldsetPrincipal() { |
FieldSet principalFieldSet = new FieldSet(); |
principalFieldSet.setHeading("Info"); |
principalFieldSet.setCollapsible(true); |
principalFieldSet.setLayout(Formulaire.creerFormLayout(150, LabelAlign.LEFT)); |
nomChp = new TextField<String>(); |
nomChp.setTabIndex(tabIndex++); |
nomChp.setFieldLabel(i18nC.nomCollection()); |
nomChp.setAllowBlank(false); |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
nomChp.getMessages().setBlankText(i18nC.champObligatoire()); |
principalFieldSet.add(nomChp, new FormData(450, 0)); |
Listener<BaseEvent> ecouteurTypeCollection = new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
Valeur valeur = typesCollectionCombo.getValue(); |
// Gestion des onglets en fonction du type de collection |
mediateur.activerChargement(""); |
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) { |
activerOngletsHerbier(); |
} else { |
activerOngletsDefaut(); |
} |
mediateur.desactiverChargement(); |
} |
}; |
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++); |
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER); |
typesCollectionCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
typesCollectionCombo.addListener(Events.Change, ecouteurTypeCollection); |
typesCollectionCombo.addListener(Events.Select, ecouteurTypeCollection); |
typesCollectionCombo.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0)); |
typesCollectionCombo.fireEvent(Events.Select); |
panneauFormulaire.setTopComponent(principalFieldSet); |
} |
private void activerOngletsDefaut() { |
if (onglets.findItem(CollectionFormGeneral.ID, false) == null) { |
onglets.add(generalOnglet); |
} |
if (onglets.findItem(CollectionFormPersonne.ID, false) == null) { |
onglets.add(personneOnglet); |
} |
if (onglets.findItem(CollectionFormPublication.ID, false) != null) { |
onglets.remove(publicationOnglet); |
} |
if (onglets.findItem(CollectionFormDescription.ID, false) != null) { |
onglets.remove(descriptionOnglet); |
} |
if (onglets.findItem(CollectionFormContenu.ID, false) != null) { |
onglets.remove(contenuOnglet); |
} |
if (onglets.findItem(CollectionFormInventaire.ID, false) != null) { |
onglets.remove(inventaireOnglet); |
} |
if (onglets.findItem(CollectionFormCommentaire.ID, false) != null) { |
onglets.remove(commentaireOnglet); |
} |
panneauFormulaire.layout(); |
} |
private void activerOngletsHerbier() { |
if (onglets.findItem(CollectionFormGeneral.ID, false) == null) { |
onglets.add(generalOnglet); |
} |
if (onglets.findItem(CollectionFormPersonne.ID, false) == null) { |
onglets.add(personneOnglet); |
} |
if (onglets.findItem(CollectionFormPublication.ID, false) == null) { |
onglets.add(publicationOnglet); |
} |
if (onglets.findItem(CollectionFormDescription.ID, false) == null) { |
onglets.add(descriptionOnglet); |
} |
if (onglets.findItem(CollectionFormContenu.ID, false) == null) { |
onglets.add(contenuOnglet); |
} |
if (onglets.findItem(CollectionFormInventaire.ID, false) == null) { |
onglets.add(inventaireOnglet); |
} |
if (onglets.findItem(CollectionFormCommentaire.ID, false) == null) { |
onglets.add(commentaireOnglet); |
} |
panneauFormulaire.layout(); |
} |
private 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%"); |
// Onlget formulaire GENERAL |
onglets.add(creerOngletGeneral()); |
// Onlget formulaire AUTEUR |
onglets.add(creerOngletPersonne()); |
// Onlget formulaire PUBLICATION |
onglets.add(creerOngletPublication()); |
// Onlget formulaire DESCRIPTION |
onglets.add(creerOngletDescription()); |
// Onlget formulaire CONTENU |
onglets.add(creerOngletContenu()); |
// Onlget formulaire INVENTAIRE |
onglets.add(creerOngletInventaire()); |
// Onlget formulaire COMMENTAIRE |
onglets.add(creerOngletCommentaire()); |
// Sélection de l'onglet par défaut |
onglets.setSelection(generalOnglet); |
panneauFormulaire.add(onglets); |
} |
private TabItem creerOngletGeneral() { |
generalOnglet = new CollectionFormGeneral(this); |
return generalOnglet; |
} |
private TabItem creerOngletPersonne() { |
personneOnglet = new CollectionFormPersonne(this); |
return personneOnglet; |
} |
private TabItem creerOngletPublication() { |
publicationOnglet = new CollectionFormPublication(this); |
return publicationOnglet; |
} |
private TabItem creerOngletDescription() { |
descriptionOnglet = new CollectionFormDescription(this); |
return descriptionOnglet; |
} |
private TabItem creerOngletContenu() { |
contenuOnglet = new CollectionFormContenu(this); |
return contenuOnglet; |
} |
private TabItem creerOngletInventaire() { |
inventaireOnglet = new CollectionFormInventaire(this); |
return inventaireOnglet; |
} |
private TabItem creerOngletCommentaire() { |
commentaireOnglet = new CollectionFormCommentaire(this); |
return commentaireOnglet; |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
controlerFermeture(); |
} |
private void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
Debug.log("MESSAGES:\n"+info.getMessages().toString()); |
} |
String infoType = info.getType(); |
if (infoType.equals("modif_collection")) { |
InfoLogger.display("Modification d'une collection", info.toString()); |
} else if (infoType.equals("selection_collection")) { |
InfoLogger.display("Modification d'une collection", info.toString()); |
if (info.getDonnee(0) != null) { |
collection = (Collection) info.getDonnee(0); |
} |
peupler(); |
genererTitreFormulaire(); |
} else if (infoType.equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
InfoLogger.display("Ajout d'une collection", "La collection '"+collectionId+"' a bien été ajoutée"); |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées |
personneOnglet.rafraichir(info); |
publicationOnglet.rafraichir(info); |
commentaireOnglet.rafraichir(info); |
} else { |
InfoLogger.display("Ajout d'une collection", info.toString()); |
} |
} else if (infoType.equals("liste_collection_a_personne")) { |
personneOnglet.rafraichir(info); |
} else if (infoType.equals("liste_collection_a_publication")) { |
publicationOnglet.rafraichir(info); |
} else if (infoType.equals("liste_collection_a_commentaire")) { |
commentaireOnglet.rafraichir(info); |
} |
} |
private void peupler() { |
if (collection != null) { |
nomChp.setValue(collection.getNom()); |
typesCollectionCombo.peupler(collection.getTypeNcd()); |
peuplerOnglets(); |
} |
} |
private void peuplerOnglets() { |
generalOnglet.peupler(); |
descriptionOnglet.peupler(); |
contenuOnglet.peupler(); |
inventaireOnglet.peupler(); |
commentaireOnglet.peupler(); |
} |
public boolean soumettreFormulaire() { |
// Vérification de la validité des champs du formulaire |
boolean formulaireValide = verifierFormulaire(); |
if (formulaireValide) { |
// Collecte des données du formulaire |
Collection collectionAEnregistrer = collecterCollection(); |
if (mode.equals(MODE_AJOUTER)) { |
mediateur.ajouterCollection(this, collectionAEnregistrer); |
} else if (mode.equals(MODE_MODIFIER)) { |
if (collectionAEnregistrer == null) { |
InfoLogger.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
this.controlerFermeture(); |
} else { |
mediateur.modifierCollection(this, collectionAEnregistrer); |
} |
} |
soumettreOnglets(); |
} |
return formulaireValide; |
} |
private void soumettreOnglets() { |
personneOnglet.soumettre(); |
publicationOnglet.soumettre(); |
commentaireOnglet.soumettre(); |
} |
public void reinitialiserFormulaire() { |
if (mode.equals(StructureForm.MODE_MODIFIER)) { |
mediateur.afficherFormCollection(collection.getId()); |
} else { |
mediateur.afficherFormCollection(null); |
} |
} |
private Collection collecterCollection() { |
collectionCollectee = (Collection) collection.cloner(new Collection()); |
this.collecter(); |
collecterOnglets(); |
Collection collectionARetourner = null; |
if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) { |
collectionARetourner = collection = collectionCollectee; |
} |
return collectionARetourner; |
} |
private void collecter() { |
collectionCollectee.setNom(nomChp.getValue()); |
collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId()); |
} |
private void collecterOnglets() { |
generalOnglet.collecter(); |
personneOnglet.collecter(); |
publicationOnglet.collecter(); |
descriptionOnglet.collecter(); |
contenuOnglet.collecter(); |
inventaireOnglet.collecter(); |
commentaireOnglet.collecter(); |
} |
public boolean verifierFormulaire() { |
ArrayList<String> messages = new ArrayList<String>(); |
// Vérification des infos sur le nom de la collection |
if (nomChp.getValue() == null |
|| nomChp.getValue().equals("") |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) { |
messages.add("Veuillez donner un nom à la collection."); |
} |
// Vérification des infos sur le type de collection |
if (typesCollectionCombo.getValue() == null |
|| typesCollectionCombo.getValue().equals("") |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) { |
messages.add("Veuillez sélectionner un type pour la collection."); |
} |
messages.addAll(verifierOnglets()); |
// Affichage des messages d'alerte |
if (messages.size() != 0) { |
String[] tableauDesMessages = {}; |
tableauDesMessages = messages.toArray(tableauDesMessages); |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null); |
return false; |
} |
return true; |
} |
private ArrayList<String> verifierOnglets() { |
ArrayList<String> messages = new ArrayList<String>(); |
messages.addAll(generalOnglet.verifier()); |
messages.addAll(personneOnglet.verifier()); |
return messages; |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionForm.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java |
---|
New file |
0,0 → 1,615 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxMultiSelect; |
import org.tela_botanica.client.composants.InfoLogger; |
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.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaire; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.commentaire.CommentaireListe; |
import org.tela_botanica.client.synchronisation.Sequenceur; |
import org.tela_botanica.client.util.Debug; |
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.commentaire.CommentaireForm; |
import com.extjs.gxt.ui.client.Style.SortDir; |
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.Events; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.store.Store; |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
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.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
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.FitLayout; |
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; |
public class CollectionFormCommentaire extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "commentaire"; |
private Collection collection = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<CollectionACommentaire> grille; |
private ChampComboBoxMultiSelect<Valeur> typeCombo = null; |
private CollectionACommentaireListe commentairesAjoutes = null; |
private CollectionACommentaireListe commentairesModifies = null; |
private CollectionACommentaireListe commentairesSupprimes = null; |
private ComboBox<Commentaire> commentairesSaisisComboBox = null; |
private Button commentairesBoutonSupprimer = null; |
private Button commentairesBoutonModifier = null; |
private static boolean chargementTypesOk = false; |
private static boolean chargementCommentairesOk = false; |
private FenetreForm fenetreFormulaire = null; |
private Sequenceur sequenceur; |
public CollectionFormCommentaire(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionCommentaire()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection", null); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des commentaires |
initialiserGestionCommentaires(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
collection = ((CollectionForm) formulaire).collection; |
} |
private void initialiserGestionCommentaires() { |
idGenere = 1; |
commentairesAjoutes = new CollectionACommentaireListe(); |
commentairesModifies = new CollectionACommentaireListe(); |
commentairesSupprimes = new CollectionACommentaireListe(); |
} |
private void initialiserChargement() { |
chargementCommentairesOk = false; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionCommentaireTitre()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterPersonneBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterPersonneBouton); |
barreOutils.add(new Text(" ou ")); |
commentairesSaisisComboBox = creerComboBoxCommentairesSaisies(); |
barreOutils.add(commentairesSaisisComboBox); |
barreOutils.add(new SeparatorToolItem()); |
commentairesBoutonModifier = creerBoutonModifier(); |
barreOutils.add(commentairesBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
commentairesBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(commentairesBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirPersonneBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirPersonneBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(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>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionACommentaire commentaireSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (commentaireSaisiSelectionne == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulaireCommentaire(String mode) { |
String commentaireId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
CollectionACommentaire commentaierSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
commentaireId = commentaierSaisieSelectionnee.getIdCommentaire(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final CommentaireForm formulaire = creerFormulaireCommentaire(fenetre, commentaireId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private CommentaireForm creerFormulaireCommentaire(final FenetreForm fenetre, String commentaireId) { |
CommentaireForm formulaire = new CommentaireForm(mediateur, commentaireId, this); |
FormPanel panneauFormulaire = formulaire.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
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 = creerEcouteurValidationFormulaireCommentaire(fenetre, formulaire); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulaire; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulaireCommentaire(final FenetreForm fenetre, final CommentaireForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
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(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
CollectionACommentaire commentaireSaisiSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (commentaireSaisiSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire()); |
} else { |
supprimerDansGrille(commentaireSaisiSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private ComboBox<Commentaire> creerComboBoxCommentairesSaisies() { |
ListStore<Commentaire> commentairesSaisiesStore = new ListStore<Commentaire>(); |
commentairesSaisiesStore.add(new ArrayList<Commentaire>()); |
ComboBox<Commentaire> comboBox = new ComboBox<Commentaire>(); |
comboBox.setWidth(200); |
comboBox.setEmptyText(i18nC.chercherCommentaireSaisi()); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setEditable(true); |
comboBox.setDisplayField("titre"); |
comboBox.setStore(commentairesSaisiesStore); |
comboBox.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (commentairesSaisisComboBox.getRawValue() != null && commentairesSaisisComboBox.getRawValue().length() > 0) { |
if (!ce.isNavKeyPress()) { |
obtenirCommentairesSaisis(commentairesSaisisComboBox.getRawValue()); |
} |
} |
} |
}); |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
if (commentairesSaisisComboBox.getValue() instanceof Commentaire) { |
Commentaire commentaireSaisiSelectionnee = commentairesSaisisComboBox.getValue(); |
ajouterDansGrille(commentaireSaisiSelectionnee); |
commentairesSaisisComboBox.setValue(null); |
} |
} |
}); |
return comboBox; |
} |
private void ajouterDansGrille(Commentaire commentaire) { |
ajouterDansGrille(commentaire, null, 0); |
} |
private void ajouterDansGrille(Commentaire commentaire, String type, int index) { |
if (commentaire != null) { |
CollectionACommentaire relationCollectionACommentaire = new CollectionACommentaire(); |
relationCollectionACommentaire.setCommentaire(commentaire); |
relationCollectionACommentaire.setIdCommentaire(commentaire.getId()); |
if (type != null) { |
relationCollectionACommentaire.set("_type_", type); |
} |
// Gestion de l'id de la collection |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
relationCollectionACommentaire.setIdCollection(collection.getId()); |
} |
relationCollectionACommentaire.set("_etat_", aDonnee.ETAT_AJOUTE); |
corrigerChampsGrille(relationCollectionACommentaire); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(relationCollectionACommentaire, index); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} |
} |
private void supprimerDansGrille(CollectionACommentaire relationCollectionACommentaire) { |
if (relationCollectionACommentaire != null) { |
// Ajout de la personne supprimée à la liste |
if ((relationCollectionACommentaire.get("_etat_").equals("") || !relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& relationCollectionACommentaire.getId() != null |
&& !relationCollectionACommentaire.getId().equals("")) { |
commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(relationCollectionACommentaire); |
} |
} |
private EditorGrid<CollectionACommentaire> creerGrille() { |
ListStore<CollectionACommentaire> storeGrille = new ListStore<CollectionACommentaire>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionACommentaire>>() { |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionACommentaire>>() { |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionACommentaire>>() { |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) { |
if (ce.getRecord().isModified("_type_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE); |
} |
} |
}); |
RowNumberer pluginLigneNumero = new RowNumberer(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(pluginLigneNumero); |
colonnes.add(creerColonneType()); |
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150)); |
colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75)); |
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35)); |
colonnes.add(creerColonneAcces()); |
GridSelectionModel<CollectionACommentaire> modeleDeSelection = new GridSelectionModel<CollectionACommentaire>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
EditorGrid<CollectionACommentaire> grille = new EditorGrid<CollectionACommentaire>(storeGrille, modeleDeColonnes); |
grille.setHeight("100%"); |
grille.setBorders(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addPlugin(pluginLigneNumero); |
grille.getView().setForceFit(true); |
grille.setAutoExpandColumn("_titre_"); |
grille.setStripeRows(true); |
grille.setTrackMouseOver(true); |
return grille; |
} |
private ColumnConfig creerColonneType() { |
typeCombo = new ChampComboBoxMultiSelect<Valeur>(); |
typeCombo.setDisplayField("nom"); |
typeCombo.setValueField("id_valeur"); |
typeCombo.setStore(new ListStore<Valeur>()); |
typeCombo.setEditable(false); |
typeCombo.setForceSelection(true); |
CellEditor typeEditeur = new CellEditor(typeCombo) { |
@SuppressWarnings("unchecked") |
@Override |
public Object preProcessValue(Object valeur) { |
Valeur retour = new Valeur(); |
if (valeur != null ) { |
if (valeur instanceof String) { |
((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (getField().getRawValue() != null ) { |
retour = getField().getRawValue(); |
} |
return retour; |
} |
}; |
GridCellRenderer<CollectionACommentaire> typeRendu = new GridCellRenderer<CollectionACommentaire>() { |
public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) { |
String type = model.get("_type_"); |
if (typeCombo.getStore() != null && type != null && (type.matches("[0-9]+") || type.contains(aDonnee.SEPARATEUR_VALEURS))) { |
type = typeCombo.formaterIdentifiantsEnTexte(type); |
model.set("_type_", type); |
} |
return type; |
} |
}; |
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100); |
typeColonne.setEditor(typeEditeur); |
typeColonne.setRenderer(typeRendu); |
return typeColonne; |
} |
private ColumnConfig creerColonneAcces() { |
GridCellRenderer<CollectionACommentaire> accesRendu = new GridCellRenderer<CollectionACommentaire>() { |
public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) { |
String acces = (model.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee()); |
model.set("_public_", acces); |
return acces; |
} |
}; |
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30); |
accesColonne.setRenderer(accesRendu); |
return accesColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
commentairesBoutonSupprimer.enable(); |
commentairesBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
commentairesBoutonSupprimer.disable(); |
commentairesBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else if (nouvellesDonnees instanceof CommentaireListe) { |
CommentaireListe listeCommentaires = (CommentaireListe) nouvellesDonnees; |
rafraichirCommentairesListe(listeCommentaires); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (chargementTypesOk && chargementCommentairesOk) { |
peupler(); |
initialiserChargement(); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) { |
List<Valeur> liste = listeValeurs.toList(); |
if (liste.size() > 0) { |
ListStore<Valeur> store = typeCombo.getStore(); |
store.removeAll(); |
store.add(liste); |
store.sort("nom", SortDir.ASC); |
typeCombo.setStore(store); |
} |
chargementTypesOk = true; |
} else { |
GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null); |
} |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (info.getType().equals("liste_collection_a_commentaire")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0)); |
chargementCommentairesOk = true; |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées |
// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées |
mediateur.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes); |
} |
} else if (type.equals("commentaire_modifiee")) { |
if (info.getDonnee(0) != null) { |
Commentaire commentaire = (Commentaire) info.getDonnee(0); |
CollectionACommentaire commentaireDansGrille = grille.getStore().findModel("id_commentaire", commentaire.getId()); |
int index = grille.getStore().indexOf(commentaireDansGrille); |
grille.getStore().remove(commentaireDansGrille); |
String typeCommentaire = (String) commentaireDansGrille.get("_type_"); |
ajouterDansGrille(commentaire, typeCommentaire, index); |
} |
} else if (type.equals("commentaire_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Commentaire commentaire = (Commentaire) info.getDonnee(0); |
ajouterDansGrille(commentaire); |
} |
} else if (info.getType().equals("modif_collection_a_commentaire")) { |
InfoLogger.display("Modification des notes liées à la collection", info.toString()); |
initialiserGestionCommentaires(); |
} else if (info.getType().equals("suppression_collection_a_commentaire")) { |
InfoLogger.display("Suppression des notes liées à la collection", info.toString()); |
initialiserGestionCommentaires(); |
} else if (info.getType().equals("ajout_collection_a_commentaire")) { |
InfoLogger.display("Ajout des notes liées à la collection", info.toString()); |
initialiserGestionCommentaires(); |
} |
} |
private void rafraichirCommentairesListe(CommentaireListe listeCommentaires) { |
commentairesSaisisComboBox.getStore().removeAll(); |
commentairesSaisisComboBox.getStore().add(listeCommentaires.toList()); |
commentairesSaisisComboBox.expand(); |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(collection.getCommentairesLiees().toList()); |
grille.recalculate(); |
layout(); |
InfoLogger.display(i18nC.chargementCommentaire(), i18nC.ok()); |
} |
public void collecter() { |
if (etreAccede()) { |
int nbreCommentaire = grille.getStore().getCount(); |
for (int i = 0; i < nbreCommentaire; i++) { |
CollectionACommentaire relationCollectionACommentaire = grille.getStore().getAt(i); |
if (relationCollectionACommentaire.get("_etat_") != null) { |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type |
commentairesModifies.put("id"+idGenere++, relationCollectionACommentaire); |
} |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type |
commentairesAjoutes.put("id"+idGenere++, relationCollectionACommentaire); |
} |
// Initialisation de la grille |
relationCollectionACommentaire.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) { |
String type = relationCollectionACommentaire.get("_type_"); |
relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type)); |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) { |
InfoLogger.display("Modification des notes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes); |
mediateur.modifierCollectionACommentaire(this, commentairesModifies); |
mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes); |
} |
} |
} |
private void obtenirCommentairesSaisis(String titre) { |
mediateur.selectionnerCommentaireParTitre(this, titre+"%", null); |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCollectionACommentaire(this, collection.getId(), null); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java |
---|
New file |
0,0 → 1,937 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.InterneValeur; |
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.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.modeles.collection.UniteBase; |
import org.tela_botanica.client.modeles.collection.UniteRangement; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilNombre; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.Style.Scroll; |
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.Events; |
import com.extjs.gxt.ui.client.event.FieldEvent; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.MessageBoxEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
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.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
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.AggregationRowConfig; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
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.SummaryType; |
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.layout.FormLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.i18n.client.NumberFormat; |
public class CollectionFormDescription extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "description"; |
private Collection collection = null; |
private CollectionBotanique collectionBotanique = null; |
private Collection collectionCollectee = null; |
private CollectionBotanique collectionBotaniqueCollectee = null; |
private static ListStore<InterneValeur> precisionStore = null; |
private ChampComboBoxListeValeurs typesCollectionBotaCombo = null; |
private NumberField nbreEchantillonChp = null; |
private EditorGrid<UniteRangement> uniteRangementGrille = null; |
private ChampComboBoxListeValeurs etatUniteRangementCombo = null; |
private EditorGrid<UniteBase> uniteBaseGrille = null; |
private ChampCaseACocher typePapierConservationChp = null; |
private ChampCaseACocher methodeConservationChp = null; |
private ChampSliderPourcentage specimenFixationPourcentChp = null; |
private ChampSliderPourcentage etiquetteFixationPourcentChp = null; |
private ChampCaseACocher specimentMethodeFixationChp = null; |
private ChampCaseACocher etiquetteMethodeFixationSurSupportChp = null; |
private ChampCaseACocher etiquetteMethodeFixationSurSpecimenChp = null; |
private ChampCaseACocher typeEcritureChp = null; |
private ChampComboBoxListeValeurs traitementCombo = null; |
private ChampCaseACocher poisonTraitementChp = null; |
private ChampCaseACocher insecteTraitementChp = null; |
private ChampComboBoxListeValeurs etatGeneralCombo = null; |
private ChampComboBoxListeValeurs determinationCombo = null; |
private ChampMultiValeursMultiTypes specimenDegradationChp = null; |
private ChampMultiValeursMultiTypes presentationDegradationChp = null; |
private Text labelPresentationDegradationChp = null; |
public CollectionFormDescription(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionDescription()); |
FormLayout formulaireLayout = (FormLayout) this.getLayout(); |
formulaireLayout.setLabelAlign(LabelAlign.LEFT); |
formulaireLayout.setLabelWidth(300); |
creerFieldsetPrecision(); |
creerStorePrecision(); |
creerUniteRangement(); |
creerUniteBase(); |
creerFieldsetConservation(); |
creerFieldsetEtiquette(); |
creerFieldsetTraitement(); |
creerFieldsetEtat(); |
layout(); |
} |
private void creerFieldsetPrecision() { |
FieldSet precisionFieldSet = new FieldSet(); |
precisionFieldSet.setHeading(i18nC.collectionTitrePrecision()); |
precisionFieldSet.setCollapsible(true); |
precisionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
typesCollectionBotaCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionBotanique(), "typeCollectionBota"); |
typesCollectionBotaCombo.setTabIndex(tabIndex++); |
precisionFieldSet.add(typesCollectionBotaCombo, new FormData(250, 0)); |
nbreEchantillonChp = new NumberField(); |
nbreEchantillonChp.setFieldLabel(i18nC.nbreEchantillon()); |
nbreEchantillonChp.setToolTip(i18nC.nbreEchantillonInfo()); |
nbreEchantillonChp.setFormat(NumberFormat.getFormat("#")); |
precisionFieldSet.add(nbreEchantillonChp); |
this.add(precisionFieldSet); |
} |
private static void creerStorePrecision() { |
if (precisionStore == null) { |
precisionStore = new ListStore<InterneValeur>(); |
precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, Mediateur.i18nC.precisionApproximatif())); |
precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, Mediateur.i18nC.precisionExact())); |
} |
} |
private static String getPrecisionNom(String precisionAbr) { |
String precision = ""; |
if (!precisionAbr.equals("NULL")) { |
creerStorePrecision(); |
InterneValeur precisionValeur = precisionStore.findModel("abr", precisionAbr); |
if (precisionValeur != null && !precisionValeur.getNom().equals("NULL")) { |
precision = precisionValeur.getNom(); |
} |
} |
return precision; |
} |
private static String getPrecisionAbr(String precisionNom) { |
String precision = ""; |
if (!precisionNom.equals("NULL")) { |
creerStorePrecision(); |
InterneValeur precisionValeur = precisionStore.findModel("nom", precisionNom); |
if (precisionValeur != null) { |
precision = precisionValeur.getAbr(); |
} |
} |
return precision; |
} |
private ComboBox<InterneValeur> getChampPrecision() { |
ComboBox<InterneValeur> precisionCombo = new ComboBox<InterneValeur>(); |
precisionCombo.setForceSelection(true); |
precisionCombo.setTriggerAction(TriggerAction.ALL); |
precisionCombo.setDisplayField("nom"); |
precisionCombo.setStore(precisionStore); |
precisionCombo.setEditable(false); |
return precisionCombo; |
} |
private void creerUniteRangement() { |
ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteRangementTitre()); |
uniteRangementGrille = creerGrilleUniteRangement(); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteRangement", null); |
panneauGrille.add(uniteRangementGrille); |
ToolBar barreOutils = creerBarreOutilsGrilleUniteRangement(); |
panneauGrille.setTopComponent(barreOutils); |
add(panneauGrille); |
} |
private ContentPanel creerPanneauContenantGrille(String titre) { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(titre); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
panneau.setScrollMode(Scroll.AUTO); |
panneau.setCollapsible(true); |
panneau.setStyleAttribute("margin", "5px 0"); |
return panneau; |
} |
private EditorGrid<UniteRangement> creerGrilleUniteRangement() { |
ListStore<UniteRangement> storeGrille = new ListStore<UniteRangement>(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150)); |
NumberField champNombre = new NumberField(); |
champNombre.setFormat(NumberFormat.getFormat("#")); |
ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50); |
nombreColonne.setEditor(new CellEditor(champNombre)); |
nombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(nombreColonne); |
CellEditor editeurPrecision = new CellEditor(getChampPrecision()) { |
@Override |
public Object preProcessValue(Object valeur) { |
InterneValeur retour = null; |
if (valeur != null ) { |
if (precisionStore.findModel("nom", valeur.toString()) != null) { |
retour = precisionStore.findModel("nom", valeur.toString()); |
} else if (precisionStore.findModel("abr", valeur.toString()) != null) { |
retour = precisionStore.findModel("abr", valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof InterneValeur) { |
InterneValeur valeurInterne = (InterneValeur) valeur; |
retour = valeurInterne.getNom(); |
} |
} |
return retour; |
} |
}; |
ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50); |
precisionColonne.setEditor(editeurPrecision); |
colonnes.add(precisionColonne); |
TextField<String> formatChp = new TextField<String>(); |
ColumnConfig formatColonne = new ColumnConfig("format", i18nC.collectionUniteFormat(), 100); |
formatColonne.setEditor(new CellEditor(formatChp)); |
colonnes.add(formatColonne); |
GridSelectionModel<UniteRangement> modeleDeSelection = new GridSelectionModel<UniteRangement>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>(); |
total.setHtml("type", i18nC.total()); |
total.setSummaryType("nombre", SummaryType.SUM); |
total.setSummaryFormat("nombre", NumberFormat.getFormat("#")); |
modeleDeColonnes.addAggregationRow(total); |
EditorGrid<UniteRangement> grilleUniteRangement = new EditorGrid<UniteRangement>(storeGrille, modeleDeColonnes); |
grilleUniteRangement.setHeight(300); |
grilleUniteRangement.setBorders(true); |
grilleUniteRangement.setSelectionModel(modeleDeSelection); |
grilleUniteRangement.getView().setForceFit(true); |
grilleUniteRangement.getView().setAutoFill(true); |
grilleUniteRangement.setAutoExpandColumn("type"); |
grilleUniteRangement.setStripeRows(true); |
grilleUniteRangement.setTrackMouseOver(true); |
return grilleUniteRangement; |
} |
private String collecterGrilleUniteRangement() { |
String truk = ""; |
int nbreUnite = uniteRangementGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteRangement unite = uniteRangementGrille.getStore().getAt(i); |
if (unite.getTypeAutre()) { |
truk += unite.getType(); |
} else { |
truk += unite.getId(); |
} |
truk += aDonnee.SEPARATEUR_TYPE_VALEUR; |
truk += UtilNombre.formaterEnEntier(unite.getNombre())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecision())+aDonnee.SEPARATEUR_DONNEES; |
truk += unite.getFormat(); |
truk += (i == (nbreUnite - 1)) ? "" : aDonnee.SEPARATEUR_VALEURS; |
if (truk.matches("^"+aDonnee.SEPARATEUR_DONNEES)) { |
truk = truk.replaceFirst("^"+aDonnee.SEPARATEUR_DONNEES, ""); |
} |
if (truk.matches("^"+aDonnee.SEPARATEUR_TYPE_VALEUR)) { |
truk = truk.replaceFirst("^"+aDonnee.SEPARATEUR_TYPE_VALEUR, ""); |
} |
} |
return truk; |
} |
private void peuplerGrilleUniteRangement(String valeurTruk) { |
if (!UtilString.isEmpty(valeurTruk)) { |
HashMap<String,UniteRangement> unitesEnregistrees = parserValeurUniteRangement(valeurTruk); |
ArrayList<UniteRangement> listeUniteMaj = new ArrayList<UniteRangement>(); |
int nbreUnite = uniteRangementGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteRangement uniteDansGrille = uniteRangementGrille.getStore().getAt(i); |
UniteRangement uniteEnregistree = unitesEnregistrees.get(uniteDansGrille.getId()); |
if (uniteEnregistree != null) { |
uniteEnregistree.setType(uniteDansGrille.getType()); |
listeUniteMaj.add(uniteEnregistree); |
} else { |
listeUniteMaj.add(uniteDansGrille); |
} |
} |
Iterator<String> it = unitesEnregistrees.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.matches(aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR)) { |
UniteRangement uniteAutreEnregistree = unitesEnregistrees.get(cle); |
listeUniteMaj.add(uniteAutreEnregistree); |
} |
} |
uniteRangementGrille.getStore().removeAll(); |
uniteRangementGrille.getStore().add(listeUniteMaj); |
layout(); |
} |
} |
public static HashMap<String,UniteRangement> parserValeurUniteRangement(String valeurTruk) { |
HashMap<String,UniteRangement> unitesEnregistrees = new HashMap<String,UniteRangement>(); |
if (!UtilString.isEmpty(valeurTruk)) { |
String[] unites = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS)); |
for (int i = 0; i < unites.length; i++) { |
String[] uniteTypeIdDonnees = unites[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
String uniteChaineDonnees = uniteTypeIdDonnees[1]; |
String[] uniteDonnees = uniteChaineDonnees.split(Pattern.quote(aDonnee.SEPARATEUR_DONNEES)); |
UniteRangement uniteRangement = new UniteRangement(); |
if (uniteDonnees.length > 0) { |
uniteRangement.setNombre(UtilString.formaterEnEntier(uniteDonnees[0])); |
} |
if (uniteDonnees.length > 1) { |
uniteRangement.setPrecision(getPrecisionNom(uniteDonnees[1])); |
} |
if (uniteDonnees.length > 2) { |
uniteRangement.setFormat(uniteDonnees[2]); |
} |
if (uniteTypeIdDonnees[0].matches("[0-9]+")) { |
uniteRangement.setId(uniteTypeIdDonnees[0]); |
uniteRangement.setTypeAutre(false); |
unitesEnregistrees.put(uniteTypeIdDonnees[0], uniteRangement); |
} else { |
uniteRangement.setType(uniteTypeIdDonnees[0]); |
uniteRangement.setTypeAutre(true); |
String id = aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR+uniteTypeIdDonnees[0]+"-"+i; |
uniteRangement.setId(id); |
unitesEnregistrees.put(aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR, uniteRangement); |
} |
} |
} |
return unitesEnregistrees; |
} |
private ToolBar creerBarreOutilsGrilleUniteRangement() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouterUniteRangement(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new SeparatorToolItem()); |
Button supprimerBouton = creerBoutonSupprimerUniteRangement(); |
barreOutils.add(supprimerBouton); |
barreOutils.add(new SeparatorToolItem()); |
barreOutils.add(new Text(i18nC.collectionUniteRangementEtatGeneralLabel())); |
etatUniteRangementCombo = new ChampComboBoxListeValeurs("", "etat"); |
etatUniteRangementCombo.setEmptyText(i18nC.collectionUniteRangementEtatGeneral()); |
etatUniteRangementCombo.setToolTip(i18nC.collectionUniteRangementEtatGeneralInfo()); |
etatUniteRangementCombo.setTrie("id_valeur"); |
etatUniteRangementCombo.setWidth(300); |
barreOutils.add(etatUniteRangementCombo); |
return barreOutils; |
} |
private Button creerBoutonAjouterUniteRangement() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.ajouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteRangementSaisirType()); |
box.addCallback(new Listener<MessageBoxEvent>() { |
public void handleEvent(MessageBoxEvent be) { |
if (!UtilString.isEmpty(be.getValue()) && !be.getValue().matches("[0-9]+")) { |
final UniteRangement unite = new UniteRangement(); |
unite.setType(be.getValue()); |
unite.setTypeAutre(true); |
uniteRangementGrille.getStore().add(unite); |
} else { |
InfoLogger.display("Information", "Vous ne pouvez pas saisir de valeur vide ou numérique"); |
} |
} |
}); |
} |
}); |
return bouton; |
} |
private Button creerBoutonSupprimerUniteRangement() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.supprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
UniteRangement uniteRangementSelectionnee = uniteRangementGrille.getSelectionModel().getSelectedItem(); |
if (uniteRangementSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteRangement())); |
} else if (uniteRangementSelectionnee.getTypeAutre() == false) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteRangementAjoute()); |
} else { |
uniteRangementGrille.getStore().remove(uniteRangementSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private void creerUniteBase() { |
ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteBaseTitre()); |
uniteBaseGrille = creerGrilleUniteBase(); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteBase", null); |
panneauGrille.add(uniteBaseGrille); |
ToolBar barreOutils = creerBarreOutilsGrilleUniteBase(); |
panneauGrille.setTopComponent(barreOutils); |
add(panneauGrille); |
} |
private EditorGrid<UniteBase> creerGrilleUniteBase() { |
ListStore<UniteBase> storeGrille = new ListStore<UniteBase>(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150)); |
NumberField champNombre = new NumberField(); |
champNombre.setFormat(NumberFormat.getFormat("#")); |
CellEditor editeurNombre = new CellEditor(champNombre); |
ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50); |
nombreColonne.setEditor(editeurNombre); |
nombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(nombreColonne); |
CellEditor editeurPrecision = new CellEditor(getChampPrecision()) { |
@Override |
public Object preProcessValue(Object valeur) { |
InterneValeur retour = null; |
if (valeur != null ) { |
if (precisionStore.findModel("nom", valeur.toString()) != null) { |
retour = precisionStore.findModel("nom", valeur.toString()); |
} else if (precisionStore.findModel("abr", valeur.toString()) != null) { |
retour = precisionStore.findModel("abr", valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof InterneValeur) { |
InterneValeur valeurInterne = (InterneValeur) valeur; |
retour = valeurInterne.getNom(); |
} |
} |
return retour; |
} |
}; |
ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50); |
precisionColonne.setEditor(editeurPrecision); |
colonnes.add(precisionColonne); |
TextField<String> formatChp = new TextField<String>(); |
ColumnConfig formatColonne = new ColumnConfig("format", i18nC.collectionUniteFormat(), 100); |
formatColonne.setEditor(new CellEditor(formatChp)); |
colonnes.add(formatColonne); |
ColumnConfig partNombreColonne = new ColumnConfig("nombre_part", i18nC.collectionUniteNbre(), 50); |
partNombreColonne.setEditor(editeurNombre); |
partNombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(partNombreColonne); |
ColumnConfig partPrecisionColonne = new ColumnConfig("precision_part", i18nC.collectionUnitePrecision(), 50); |
partPrecisionColonne.setEditor(editeurPrecision); |
colonnes.add(partPrecisionColonne); |
ColumnConfig spNombreColonne = new ColumnConfig("nombre_sp", i18nC.collectionUniteNbre(), 50); |
spNombreColonne.setEditor(editeurNombre); |
spNombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(spNombreColonne); |
ColumnConfig spPrecisionColonne = new ColumnConfig("precision_sp", i18nC.collectionUnitePrecision(), 50); |
spPrecisionColonne.setEditor(editeurPrecision); |
colonnes.add(spPrecisionColonne); |
GridSelectionModel<UniteBase> modeleDeSelection = new GridSelectionModel<UniteBase>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.addHeaderGroup(0, 0, new HeaderGroupConfig(i18nC.collectionUniteBase(), 1, 4)); |
modeleDeColonnes.addHeaderGroup(0, 4, new HeaderGroupConfig(i18nC.collectionUniteBasePart(), 1, 2)); |
modeleDeColonnes.addHeaderGroup(0, 6, new HeaderGroupConfig(i18nC.collectionUniteBaseSp(), 1, 2)); |
AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>(); |
total.setHtml("type", "TOTAL"); |
total.setSummaryType("nombre", SummaryType.SUM); |
total.setSummaryFormat("nombre", NumberFormat.getFormat("#")); |
total.setSummaryType("nombre_part", SummaryType.SUM); |
total.setSummaryFormat("nombre_part", NumberFormat.getFormat("#")); |
total.setSummaryType("nombre_sp", SummaryType.SUM); |
total.setSummaryFormat("nombre_sp", NumberFormat.getFormat("#")); |
modeleDeColonnes.addAggregationRow(total); |
EditorGrid<UniteBase> grilleUniteBase = new EditorGrid<UniteBase>(storeGrille, modeleDeColonnes); |
grilleUniteBase.setHeight(200); |
grilleUniteBase.setBorders(true); |
grilleUniteBase.setSelectionModel(modeleDeSelection); |
grilleUniteBase.getView().setForceFit(true); |
grilleUniteBase.getView().setAutoFill(true); |
grilleUniteBase.setAutoExpandColumn("type"); |
grilleUniteBase.setStripeRows(true); |
grilleUniteBase.setTrackMouseOver(true); |
return grilleUniteBase; |
} |
private String collecterGrilleUniteBase() { |
String truk = ""; |
int nbreUnite = uniteBaseGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteBase unite = uniteBaseGrille.getStore().getAt(i); |
if (unite.getTypeAutre()) { |
truk += unite.getType(); |
} else { |
truk += unite.getId(); |
} |
truk += aDonnee.SEPARATEUR_TYPE_VALEUR; |
truk += UtilNombre.formaterEnEntier(unite.getNombre())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecision())+aDonnee.SEPARATEUR_DONNEES; |
truk += unite.getFormat()+aDonnee.SEPARATEUR_DONNEES; |
truk += UtilNombre.formaterEnEntier(unite.getNombrePart())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecisionPart())+aDonnee.SEPARATEUR_DONNEES; |
truk += UtilNombre.formaterEnEntier(unite.getNombreSp())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecisionSp()); |
truk += (i == (nbreUnite - 1)) ? "" : aDonnee.SEPARATEUR_VALEURS; |
} |
return truk; |
} |
private void peuplerGrilleUniteBase(String valeurTruk) { |
if (!UtilString.isEmpty(valeurTruk)) { |
HashMap<String,UniteBase> unitesEnregistrees = parserValeurUniteBase(valeurTruk); |
ArrayList<UniteBase> listeUniteMaj = new ArrayList<UniteBase>(); |
int nbreUnite = uniteBaseGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteBase uniteDansGrille = uniteBaseGrille.getStore().getAt(i); |
UniteBase uniteEnregistree = unitesEnregistrees.get(uniteDansGrille.getId()); |
if (uniteEnregistree != null) { |
uniteEnregistree.setType(uniteDansGrille.getType()); |
listeUniteMaj.add(uniteEnregistree); |
} else { |
listeUniteMaj.add(uniteDansGrille); |
} |
} |
Iterator<String> it = unitesEnregistrees.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.matches(aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR)) { |
UniteBase uniteAutreEnregistree = unitesEnregistrees.get(cle); |
listeUniteMaj.add(uniteAutreEnregistree); |
} |
} |
uniteBaseGrille.getStore().removeAll(); |
uniteBaseGrille.getStore().add(listeUniteMaj); |
layout(); |
} |
} |
public static HashMap<String,UniteBase> parserValeurUniteBase(String valeurTruk) { |
HashMap<String,UniteBase> unitesEnregistrees = new HashMap<String,UniteBase>(); |
if (!UtilString.isEmpty(valeurTruk)) { |
String[] unites = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS)); |
for (int i = 0; i < unites.length; i++) { |
String[] uniteTypeIdDonnees = unites[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
String uniteChaineDonnees = uniteTypeIdDonnees[1]; |
String[] uniteDonnees = uniteChaineDonnees.split(Pattern.quote(aDonnee.SEPARATEUR_DONNEES)); |
UniteBase uniteBase = new UniteBase(); |
if (uniteDonnees.length > 0) { |
uniteBase.setNombre(UtilString.formaterEnEntier(uniteDonnees[0])); |
} |
if (uniteDonnees.length > 1) { |
uniteBase.setPrecision(getPrecisionNom(uniteDonnees[1])); |
} |
if (uniteDonnees.length > 2) { |
uniteBase.setFormat(uniteDonnees[2]); |
} |
if (uniteDonnees.length > 3) { |
uniteBase.setNombrePart(UtilString.formaterEnEntier(uniteDonnees[3])); |
} |
if (uniteDonnees.length > 4) { |
uniteBase.setPrecisionPart(getPrecisionNom(uniteDonnees[4])); |
} |
if (uniteDonnees.length > 5) { |
uniteBase.setNombreSp(UtilString.formaterEnEntier(uniteDonnees[5])); |
} |
if (uniteDonnees.length > 6) { |
uniteBase.setPrecisionSp(getPrecisionNom(uniteDonnees[6])); |
} |
if (uniteTypeIdDonnees[0].matches("[0-9]+")) { |
uniteBase.setId(uniteTypeIdDonnees[0]); |
uniteBase.setTypeAutre(false); |
unitesEnregistrees.put(uniteTypeIdDonnees[0], uniteBase); |
} else { |
uniteBase.setType(uniteTypeIdDonnees[0]); |
uniteBase.setTypeAutre(true); |
String id = aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR+uniteTypeIdDonnees[0]+"-"+i; |
uniteBase.setId(id); |
unitesEnregistrees.put(aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR, uniteBase); |
} |
} |
} |
return unitesEnregistrees; |
} |
private ToolBar creerBarreOutilsGrilleUniteBase() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouterUniteBase(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new SeparatorToolItem()); |
Button supprimerBouton = creerBoutonSupprimerUniteBase(); |
barreOutils.add(supprimerBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouterUniteBase() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.ajouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteBaseSaisirType()); |
box.addCallback(new Listener<MessageBoxEvent>() { |
public void handleEvent(MessageBoxEvent be) { |
if (!UtilString.isEmpty(be.getValue()) && !be.getValue().matches("[0-9]+")) { |
final UniteBase unite = new UniteBase(); |
unite.setType(be.getValue()); |
unite.setTypeAutre(true); |
uniteBaseGrille.getStore().add(unite); |
} else { |
InfoLogger.display("Information", "Vous ne pouvez pas saisir de valeur vide ou numérique"); |
} |
} |
}); |
} |
}); |
return bouton; |
} |
private Button creerBoutonSupprimerUniteBase() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.supprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
UniteBase uniteBaseSelectionnee = uniteBaseGrille.getSelectionModel().getSelectedItem(); |
if (uniteBaseSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteBase())); |
} else if (uniteBaseSelectionnee.getTypeAutre() == false) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteBaseAjoute()); |
} else { |
uniteBaseGrille.getStore().remove(uniteBaseSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private void creerFieldsetConservation() { |
FieldSet conservationFieldSet = new FieldSet(); |
conservationFieldSet.setHeading(i18nC.collectionTitreConservation()); |
conservationFieldSet.setCollapsible(true); |
conservationFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
typePapierConservationChp = new ChampCaseACocher(i18nC.typePapierConservation(), "typePapier", true); |
conservationFieldSet.add(typePapierConservationChp); |
methodeConservationChp = new ChampCaseACocher(i18nC.methodeConservation(), "methodeRangement", true); |
conservationFieldSet.add(methodeConservationChp); |
this.add(conservationFieldSet); |
} |
private void creerFieldsetEtiquette() { |
FieldSet etiquetteFieldSet = new FieldSet(); |
etiquetteFieldSet.setHeading(i18nC.collectionTitreEtiquette()); |
etiquetteFieldSet.setCollapsible(true); |
etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
Text fixationPoucentLabel = new Text(i18nC.fixationPourcent()); |
etiquetteFieldSet.add(fixationPoucentLabel); |
specimenFixationPourcentChp = new ChampSliderPourcentage(i18nC.specimenFixationPourcent()); |
etiquetteFieldSet.add(specimenFixationPourcentChp, new FormData(200, 0)); |
etiquetteFixationPourcentChp = new ChampSliderPourcentage(i18nC.etiquetteFixationPourcent()); |
etiquetteFieldSet.add(etiquetteFixationPourcentChp, new FormData(200, 0)); |
specimentMethodeFixationChp = new ChampCaseACocher(i18nC.specimenMethodeFixation(), "methodeFixation", true); |
etiquetteFieldSet.add(specimentMethodeFixationChp); |
etiquetteMethodeFixationSurSupportChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSupport(), "methodeFixation", true); |
etiquetteFieldSet.add(etiquetteMethodeFixationSurSupportChp); |
etiquetteMethodeFixationSurSpecimenChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSpecimen(), "methodeFixationSurSpecimen", true); |
etiquetteFieldSet.add(etiquetteMethodeFixationSurSpecimenChp); |
typeEcritureChp = new ChampCaseACocher(i18nC.typeEcriture(), "typeEcriture", false); |
etiquetteFieldSet.add(typeEcritureChp); |
this.add(etiquetteFieldSet); |
} |
private void creerFieldsetTraitement() { |
FieldSet traitementFieldSet = new FieldSet(); |
traitementFieldSet.setHeading(i18nC.collectionTitreTraitement()); |
traitementFieldSet.setCollapsible(true); |
traitementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
traitementCombo = new ChampComboBoxListeValeurs(i18nC.collectionTraitement(), "onpi"); |
traitementCombo.setTrie("id_valeur"); |
traitementFieldSet.add(traitementCombo, new FormData(300, 0)); |
poisonTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementPoison(), "poisonTraitement", true); |
traitementFieldSet.add(poisonTraitementChp); |
insecteTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementInsecte(), "insecteTraitement", true); |
traitementFieldSet.add(insecteTraitementChp); |
this.add(traitementFieldSet); |
} |
private void creerFieldsetEtat() { |
FieldSet etatFieldSet = new FieldSet(); |
etatFieldSet.setHeading(i18nC.collectionTitreEtatEtDegradation()); |
etatFieldSet.setCollapsible(true); |
etatFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
etatGeneralCombo = new ChampComboBoxListeValeurs(i18nC.collectionEtatGeneral(), "etat"); |
etatGeneralCombo.setToolTip(i18nC.collectionEtatGeneralInfo()); |
etatGeneralCombo.setTrie("id_valeur"); |
etatFieldSet.add(etatGeneralCombo, new FormData(300, 0)); |
specimenDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationSpecimen(), 150, true); |
specimenDegradationChp.initialiserType("specimenDegradation"); |
specimenDegradationChp.initialiserCombobox("niveauImportance"); |
etatFieldSet.add(specimenDegradationChp); |
labelPresentationDegradationChp = new Text(); |
labelPresentationDegradationChp.setWidth("95%"); |
labelPresentationDegradationChp.setVisible(false); |
presentationDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationPresentation(), 150, 200, true); |
presentationDegradationChp.initialiserType("supportDegradation"); |
presentationDegradationChp.initialiserCombobox("niveauImportance"); |
presentationDegradationChp.getTypes().addListener(Events.Select, |
new Listener<FieldEvent>() { |
public void handleEvent(FieldEvent be) { |
if (((Valeur)(be.getField().getValue())).get("id_valeur").equals("2310")) { |
labelPresentationDegradationChp.setText(i18nC.degradationPresentationLabel()); |
labelPresentationDegradationChp.setVisible(true); |
} |
else { |
labelPresentationDegradationChp.setText(""); |
labelPresentationDegradationChp.setVisible(false); |
} |
} |
}); |
etatFieldSet.add(presentationDegradationChp); |
etatFieldSet.add(labelPresentationDegradationChp); |
determinationCombo = new ChampComboBoxListeValeurs(i18nC.collectionDetermination(), "niveauDetermination"); |
determinationCombo.setTrie("id_valeur"); |
etatFieldSet.add(determinationCombo, new FormData(450, 0)); |
this.add(etatFieldSet); |
} |
public void peupler() { |
initialiserCollection(); |
if (collectionBotanique != null) { |
typesCollectionBotaCombo.peupler(collectionBotanique.getType()); |
if (!UtilString.isEmpty(collectionBotanique.getNbreEchantillon())) { |
nbreEchantillonChp.setValue(Integer.parseInt(collectionBotanique.getNbreEchantillon())); |
} |
peuplerGrilleUniteRangement(collectionBotanique.getUniteRangement()); |
etatUniteRangementCombo.peupler(collectionBotanique.getUniteRangementEtat()); |
peuplerGrilleUniteBase(collectionBotanique.getUniteBase()); |
typePapierConservationChp.peupler(collectionBotanique.getConservationPapierType()); |
methodeConservationChp.peupler(collectionBotanique.getConservationMethode()); |
specimenFixationPourcentChp.peupler(collectionBotanique.getSpecimenFixationPourcent()); |
etiquetteFixationPourcentChp.peupler(collectionBotanique.getEtiquetteFixationPourcent()); |
specimentMethodeFixationChp.peupler(collectionBotanique.getSpecimenFixationMethode()); |
etiquetteMethodeFixationSurSupportChp.peupler(collectionBotanique.getEtiquetteFixationSupport()); |
etiquetteMethodeFixationSurSpecimenChp.peupler(collectionBotanique.getEtiquetteFixationSpecimen()); |
typeEcritureChp.peupler(collectionBotanique.getEtiquetteEcriture()); |
traitementCombo.peupler(collectionBotanique.getTraitement()); |
poisonTraitementChp.peupler(collectionBotanique.getTraitementPoison()); |
insecteTraitementChp.peupler(collectionBotanique.getTraitementInsecte()); |
etatGeneralCombo.peupler(collectionBotanique.getEtatGeneral()); |
specimenDegradationChp.peupler(collectionBotanique.getDegradationSpecimen()); |
presentationDegradationChp.peupler(collectionBotanique.getDegradationPresentation()); |
determinationCombo.peupler(collectionBotanique.getDetermination()); |
} |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionBotaniqueCollectee.setType(typesCollectionBotaCombo.getValeur()); |
if (nbreEchantillonChp.getValue() != null) { |
collectionBotaniqueCollectee.setNbreEchantillon(Integer.toString(nbreEchantillonChp.getValue().intValue())); |
} |
collectionBotaniqueCollectee.setUniteRangement(collecterGrilleUniteRangement()); |
collectionBotaniqueCollectee.setUniteRangementEtat(etatUniteRangementCombo.getValeur()); |
collectionBotaniqueCollectee.setUniteBase(collecterGrilleUniteBase()); |
collectionBotaniqueCollectee.setConservationPapierType(typePapierConservationChp.getValeur()); |
collectionBotaniqueCollectee.setConservationMethode(methodeConservationChp.getValeur()); |
collectionBotaniqueCollectee.setSpecimenFixationPourcent(specimenFixationPourcentChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteFixationPourcent(etiquetteFixationPourcentChp.getValeur()); |
collectionBotaniqueCollectee.setSpecimenFixationMethode(specimentMethodeFixationChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteFixationSupport(etiquetteMethodeFixationSurSupportChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteFixationSpecimen(etiquetteMethodeFixationSurSpecimenChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteEcriture(typeEcritureChp.getValeur()); |
collectionBotaniqueCollectee.setTraitement(traitementCombo.getValeur()); |
collectionBotaniqueCollectee.setTraitementPoison(poisonTraitementChp.getValeur()); |
collectionBotaniqueCollectee.setTraitementInsecte(insecteTraitementChp.getValeur()); |
collectionBotaniqueCollectee.setEtatGeneral(etatGeneralCombo.getValeur()); |
collectionBotaniqueCollectee.setDegradationSpecimen(specimenDegradationChp.getValeurs()); |
collectionBotaniqueCollectee.setDegradationPresentation(presentationDegradationChp.getValeurs()); |
collectionBotaniqueCollectee.setDetermination(determinationCombo.getValeur()); |
} |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
if (collection != null) { |
collectionBotanique = collection.getBotanique(); |
} |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
if (collectionCollectee != null) { |
collectionBotaniqueCollectee = collectionCollectee.getBotanique(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("typeUniteRangement"))) { |
Iterator<String> it = listeValeurs.keySet().iterator(); |
while (it.hasNext()) { |
Valeur valeur = listeValeurs.get(it.next()); |
UniteRangement unite = new UniteRangement(); |
unite.setId(valeur.getId()); |
unite.setType(valeur.getNom()); |
unite.setTypeAutre(false); |
uniteRangementGrille.getStore().add(unite); |
} |
} else if (listeValeurs.getId().equals(config.getListeId("typeUniteBase"))) { |
Iterator<String> it = listeValeurs.keySet().iterator(); |
while (it.hasNext()) { |
Valeur valeur = listeValeurs.get(it.next()); |
UniteBase unite = new UniteBase(); |
unite.setId(valeur.getId()); |
unite.setType(valeur.getNom()); |
unite.setTypeAutre(false); |
uniteBaseGrille.getStore().add(unite); |
} |
} else { |
Debug.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!"); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java |
---|
New file |
0,0 → 1,110 |
package org.tela_botanica.client.vues.collection; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
public class CollectionFormInventaire extends FormulaireOnglet { |
public static final String ID = "inventaire"; |
private Collection collection = null; |
private CollectionBotanique collectionBotanique = null; |
private Collection collectionCollectee = null; |
private CollectionBotanique collectionBotaniqueCollectee = null; |
private ChampComboBoxListeValeurs existenceInventaireCombo = null; |
private ChampComboBoxListeValeurs auteurInventaireCombo = null; |
private ChampComboBoxListeValeurs formeInventaireCombo = null; |
private TextArea infoInventaireChp = null; |
private ChampCaseACocher digitalInventaireChp = null; |
private ChampSliderPourcentage pourcentDigitalInventaireChp = null; |
private ChampComboBoxListeValeurs etatInventaireCombo = null; |
public CollectionFormInventaire(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionInventaire()); |
int tabIndex = formulaireCourrant.tabIndex; |
existenceInventaireCombo = new ChampComboBoxListeValeurs(i18nC.existenceInventaireCollection(), "onpi", tabIndex++); |
existenceInventaireCombo.setTrie("id_valeur"); |
add(existenceInventaireCombo, new FormData(300, 0)); |
auteurInventaireCombo = new ChampComboBoxListeValeurs(i18nC.auteurInventaireCollection(), "onpi", tabIndex++); |
auteurInventaireCombo.setTrie("id_valeur"); |
auteurInventaireCombo.setTabIndex(tabIndex++); |
add(auteurInventaireCombo, new FormData(300, 0)); |
formeInventaireCombo = new ChampComboBoxListeValeurs(i18nC.formeInventaireCollection(), "inventaireForme", tabIndex++); |
formeInventaireCombo.setTabIndex(tabIndex++); |
add(formeInventaireCombo, new FormData(300, 0)); |
infoInventaireChp = new TextArea(); |
infoInventaireChp.setTabIndex(tabIndex++); |
infoInventaireChp.setFieldLabel(i18nC.infoInventaireCollection()); |
add(infoInventaireChp, new FormData(550, 0)); |
digitalInventaireChp = new ChampCaseACocher(i18nC.digitalInventaireCollection(), "inventaireLogiciel", true); |
add(digitalInventaireChp); |
pourcentDigitalInventaireChp = new ChampSliderPourcentage(i18nC.pourcentDigitalInventaireCollection()); |
pourcentDigitalInventaireChp.setTabIndex(tabIndex++); |
add(pourcentDigitalInventaireChp, new FormData(200, 0)); |
etatInventaireCombo = new ChampComboBoxListeValeurs(i18nC.etatInventaireCollection(), "inventaireEtat", tabIndex++); |
etatInventaireCombo.setTabIndex(tabIndex++); |
add(etatInventaireCombo, new FormData(300, 0)); |
} |
public void peupler() { |
initialiserCollection(); |
if (collectionBotanique != null) { |
existenceInventaireCombo.peupler(collectionBotanique.getInventaire()); |
auteurInventaireCombo.peupler(collectionBotanique.getInventaireAuteur()); |
formeInventaireCombo.peupler(collectionBotanique.getInventaireForme()); |
infoInventaireChp.setValue(collectionBotanique.getInventaireInfo()); |
digitalInventaireChp.peupler(collectionBotanique.getInventaireDigital()); |
pourcentDigitalInventaireChp.peupler(collectionBotanique.getInventaireDigitalPourcent()); |
etatInventaireCombo.peupler(collectionBotanique.getInventaireEtat()); |
} |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionBotaniqueCollectee.setInventaire(existenceInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireAuteur(auteurInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireForme(formeInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireInfo(infoInventaireChp.getValue()); |
collectionBotaniqueCollectee.setInventaireDigital(digitalInventaireChp.getValeur()); |
collectionBotaniqueCollectee.setInventaireDigitalPourcent(pourcentDigitalInventaireChp.getValeur()); |
collectionBotaniqueCollectee.setInventaireEtat(etatInventaireCombo.getValeur()); |
} |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
if (collection != null) { |
collectionBotanique = collection.getBotanique(); |
} |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
if (collectionCollectee != null) { |
collectionBotaniqueCollectee = collectionCollectee.getBotanique(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java |
---|
New file |
0,0 → 1,679 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
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.ChampComboBoxRechercheTempsReelPaginable; |
import org.tela_botanica.client.composants.InfoLogger; |
import org.tela_botanica.client.composants.pagination.ProxyPersonnes; |
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.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe; |
import org.tela_botanica.client.modeles.collection.UniteBase; |
import org.tela_botanica.client.modeles.collection.UniteRangement; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.structure.StructureAPersonne; |
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; |
import com.extjs.gxt.ui.client.data.ModelType; |
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.Events; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
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.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
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.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
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.AnchorLayout; |
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; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.dom.client.Element; |
import com.google.gwt.event.dom.client.KeyCodes; |
public class CollectionFormPersonne extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "personne"; |
private Collection collection = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<CollectionAPersonne> grille; |
private ComboBox<Valeur> typeRelationCombo = null; |
private CollectionAPersonneListe personnesAjoutees = null; |
private CollectionAPersonneListe personnesSupprimees = null; |
private ChampComboBoxRechercheTempsReelPaginable personnesSaisisComboBox = null; |
private ChampComboBoxRechercheTempsReelPaginable recherchePersonnesCombo = null; |
private Button personnesBoutonSupprimer = null; |
private Button personnesBoutonModifier = null; |
private ListStore<Valeur> listeIon = null; |
private FenetreForm fenetreFormulaire = null; |
private Sequenceur sequenceur = new Sequenceur(); |
public CollectionFormPersonne(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setLayout(new FitLayout()); |
setScrollMode(Scroll.AUTO); |
setId(ID); |
setText(Mediateur.i18nC.collectionPersonne()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
mediateur.obtenirListeValeurEtRafraichir(this, "ion", null); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonneCollection", null); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
idGenere = 1; |
personnesAjoutees = new CollectionAPersonneListe(); |
personnesSupprimees = new CollectionAPersonneListe(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
collection = ((CollectionForm) formulaire).collection; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionPersonneTitre()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
panneau.setScrollMode(Scroll.AUTO); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterPersonneBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterPersonneBouton); |
barreOutils.add(new Text(" ou ")); |
personnesSaisisComboBox = creerComboBoxPersonnesSaisies(); |
barreOutils.add(personnesSaisisComboBox); |
barreOutils.add(new SeparatorToolItem()); |
personnesBoutonModifier = creerBoutonModifier(); |
barreOutils.add(personnesBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
personnesBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(personnesBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirPersonneBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirPersonneBouton); |
return barreOutils; |
} |
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) { |
CollectionAPersonne personneSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (personneSaisiSelectionne == 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)) { |
CollectionAPersonne personneSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
personneId = personneSaisieSelectionnee.getIdPersonne(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, String personneId) { |
PersonneForm formulaire = new PersonneForm(mediateur, personneId, this); |
FormPanel panneauFormulaire = formulaire.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
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, formulaire); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulaire; |
} |
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(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
CollectionAPersonne personneSaisiSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (personneSaisiSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne()); |
} else { |
supprimerDansGrille(personneSaisiSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private ChampComboBoxRechercheTempsReelPaginable creerComboBoxPersonnesSaisies() { |
ModelType modelTypePersonnes = new ModelType(); |
modelTypePersonnes.setRoot("personnes"); |
modelTypePersonnes.setTotalName("nbElements"); |
modelTypePersonnes.addField("cp_fmt_nom_complet"); |
modelTypePersonnes.addField("cp_id_personne"); |
modelTypePersonnes.addField("cp_nom"); |
modelTypePersonnes.addField("cp_prenom"); |
modelTypePersonnes.addField("cp_code_postal"); |
modelTypePersonnes.addField("cp_naissance_date"); |
modelTypePersonnes.addField("cp_naissance_lieu"); |
modelTypePersonnes.addField("cp_ce_deces"); |
modelTypePersonnes.addField("cp_deces_date"); |
modelTypePersonnes.addField("cp_deces_lieu"); |
String displayNamePersonnes = "cp_fmt_nom_complet"; |
ProxyPersonnes<ModelData> proxyPersonnes = new ProxyPersonnes<ModelData>(sequenceur); |
recherchePersonnesCombo = new ChampComboBoxRechercheTempsReelPaginable(proxyPersonnes, modelTypePersonnes, displayNamePersonnes); |
recherchePersonnesCombo.getCombo().setForceSelection(true); |
recherchePersonnesCombo.getCombo().setValidator(new Validator() { |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (recherchePersonnesCombo.getStore().findModel("cp_fmt_nom_complet", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
recherchePersonnesCombo.getCombo().addListener(Events.Select, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
if (personnesSaisisComboBox.getValeur() instanceof ModelData) { |
Personne personneSaisiSelectionnee = new Personne(personnesSaisisComboBox.getValeur()); |
ajouterDansGrille(personneSaisiSelectionnee); |
personnesSaisisComboBox.getCombo().setValue(null); |
} |
} |
}); |
return recherchePersonnesCombo; |
} |
private void ajouterDansGrille(Personne personne) { |
ajouterDansGrille(personne, null, 0); |
} |
private void ajouterDansGrille(Personne personne, String relation, int index) { |
if (personne != null) { |
CollectionAPersonne relationCollectionPersonne = new CollectionAPersonne(); |
relationCollectionPersonne.setPersonne(personne); |
relationCollectionPersonne.setIdPersonne(personne.getId()); |
if (relation != null) { |
relationCollectionPersonne.set("_role_", relation); |
} |
// Gestion de l'id de la collection |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
relationCollectionPersonne.setIdCollection(collection.getId()); |
} |
relationCollectionPersonne.set("_etat_", aDonnee.ETAT_AJOUTE); |
corrigerChampsGrille(relationCollectionPersonne); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(relationCollectionPersonne, index); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} |
} |
private void supprimerDansGrille(CollectionAPersonne relationCollectionPersonne) { |
if (relationCollectionPersonne != null) { |
// Ajout de la personne supprimée à la liste |
if ((relationCollectionPersonne.get("_etat_").equals("") || !relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& relationCollectionPersonne.getId() != null |
&& !relationCollectionPersonne.getId().equals("")) { |
personnesSupprimees.put("id"+idGenere++, relationCollectionPersonne); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(relationCollectionPersonne); |
} |
} |
private EditorGrid<CollectionAPersonne> creerGrille() { |
ListStore<CollectionAPersonne> storeGrille = new ListStore<CollectionAPersonne>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionAPersonne>>() { |
public void handleEvent(StoreEvent<CollectionAPersonne> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionAPersonne>>() { |
public void handleEvent(StoreEvent<CollectionAPersonne> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionAPersonne>>() { |
public void handleEvent(StoreEvent<CollectionAPersonne> ce) { |
if (ce.getRecord().isModified("_role_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE); |
} |
} |
}); |
RowNumberer pluginLigneNumero = new RowNumberer(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(pluginLigneNumero); |
colonnes.add(creerColonneRole()); |
colonnes.add(new ColumnConfig("fmt_nom_complet", i18nC.personneNomComplet(), 150)); |
colonnes.add(new ColumnConfig("nom", i18nC.personneNom(), 75)); |
colonnes.add(new ColumnConfig("prenom", i18nC.personnePrenom(), 75)); |
colonnes.add(new ColumnConfig("naissance_date", i18nC.date(), 75)); |
colonnes.add(new ColumnConfig("naissance_lieu", i18nC.lieu(), 100)); |
colonnes.add(creerColonneDeces()); |
colonnes.add(new ColumnConfig("deces_date", i18nC.date(), 75)); |
colonnes.add(new ColumnConfig("deces_lieu", i18nC.lieu(), 100)); |
GridSelectionModel<CollectionAPersonne> modeleDeSelection = new GridSelectionModel<CollectionAPersonne>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.addHeaderGroup(0, 1, new HeaderGroupConfig(i18nC.personneIdentite(), 1, 4)); |
modeleDeColonnes.addHeaderGroup(0, 5, new HeaderGroupConfig(i18nC.personneNaissance(), 1, 2)); |
modeleDeColonnes.addHeaderGroup(0, 7, new HeaderGroupConfig(i18nC.personneDeces(), 1, 3)); |
EditorGrid<CollectionAPersonne> grillePersonne = new EditorGrid<CollectionAPersonne>(storeGrille, modeleDeColonnes); |
grillePersonne.setHeight("100%"); |
grillePersonne.setBorders(true); |
grillePersonne.setSelectionModel(modeleDeSelection); |
grillePersonne.addPlugin(pluginLigneNumero); |
grillePersonne.getView().setForceFit(true); |
grillePersonne.setAutoExpandColumn("fmt_nom_complet"); |
grillePersonne.setStripeRows(true); |
grillePersonne.setTrackMouseOver(true); |
return grillePersonne; |
} |
private ColumnConfig creerColonneRole() { |
typeRelationCombo = new ComboBox<Valeur>(); |
typeRelationCombo.setForceSelection(true); |
typeRelationCombo.setTriggerAction(TriggerAction.ALL); |
typeRelationCombo.setDisplayField("nom"); |
typeRelationCombo.setStore(new ListStore<Valeur>()); |
typeRelationCombo.setEditable(false); |
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire()); |
CellEditor editeurRelation = new CellEditor(typeRelationCombo) { |
public Object preProcessValue(Object valeur) { |
Valeur retour = null; |
if (valeur != null ) { |
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()); |
} |
} |
return retour; |
} |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof Valeur) { |
Valeur valeurOntologie = (Valeur) valeur; |
retour = valeurOntologie.getNom(); |
} |
} |
return retour; |
} |
}; |
GridCellRenderer<CollectionAPersonne> relationRendu = new GridCellRenderer<CollectionAPersonne>() { |
public String render(CollectionAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPersonne> store, Grid<CollectionAPersonne> grille) { |
// Gestion du texte afficher dans la cellule |
String role = modele.get("_role_"); |
if (typeRelationCombo.getStore() != null && role.matches("[0-9]+")) { |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getNom(); |
} |
modele.set("_role_", role); |
return role; |
} |
}; |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonneCollection(), 75); |
typeRelationColonne.setEditor(editeurRelation); |
typeRelationColonne.setRenderer(relationRendu); |
return typeRelationColonne; |
} |
public ColumnConfig creerColonneDeces() { |
GridCellRenderer<CollectionAPersonne> decesRendu = new GridCellRenderer<CollectionAPersonne>() { |
public String render(CollectionAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPersonne> store, Grid<CollectionAPersonne> grid) { |
String deces = modele.getPersonne().getDeces(); |
if (listeIon != null && modele.getPersonne().getDeces().matches("[0-9]+")) { |
deces = listeIon.findModel("id_valeur", modele.getPersonne().getDeces()).getNom(); |
} |
modele.set("_deces_", deces); |
return deces; |
} |
}; |
ColumnConfig decesColonne = new ColumnConfig("_deces_", Mediateur.i18nC.personneDecedeeInterogation(), 50); |
decesColonne.setRenderer(decesRendu); |
return decesColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
personnesBoutonSupprimer.enable(); |
personnesBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
personnesBoutonSupprimer.disable(); |
personnesBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("ion"))) { |
listeIon = new ListStore<Valeur>(); |
listeIon.add(listeValeurs.toList()); |
} else if (listeValeurs.getId().equals(config.getListeId("relationPersonneCollection"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo); |
} else { |
GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null); |
} |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (info.getType().equals("liste_collection_a_personne")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
collection.setPersonnesLiees((CollectionAPersonneListe) info.getDonnee(0)); |
peupler(); |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées |
// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées |
mediateur.ajouterCollectionAPersonne(this, collectionId, personnesAjoutees); |
} |
} else if (type.equals("personne_modifiee")) { |
if (info.getDonnee(0) != null) { |
Personne personne = (Personne) info.getDonnee(0); |
CollectionAPersonne personneDansGrille = grille.getStore().findModel("id_personne", personne.getId()); |
int index = grille.getStore().indexOf(personneDansGrille); |
grille.getStore().remove(personneDansGrille); |
String role = (String) personneDansGrille.get("_role_"); |
ajouterDansGrille(personne, role, index); |
} |
} else if (type.equals("personne_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Personne personne = (Personne) info.getDonnee(0); |
ajouterDansGrille(personne); |
} |
} else if (info.getType().equals("modif_collection_a_personne")) { |
InfoLogger.display("Modification des personnes liées à la collection", info.toString()); |
} else if (info.getType().equals("suppression_collection_a_personne")) { |
InfoLogger.display("Suppression des personnes liées à la collection", info.toString()); |
} else if (info.getType().equals("ajout_collection_a_personne")) { |
InfoLogger.display("Ajout des personnes liées à la collection", info.toString()); |
} |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(collection.getPersonnesLiees().toList()); |
layout(); |
InfoLogger.display(i18nC.chargementPersonne(), i18nC.ok()); |
} |
public ArrayList<String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
String personneNumero = ""; |
int nbrePersonne = grille.getStore().getCount(); |
if (nbrePersonne > 0) { |
for (int i = 0; i < nbrePersonne; i++) { |
CollectionAPersonne personne = grille.getStore().getAt(i); |
if (personne.get("_role_").equals("")) { |
personneNumero += (i != 0 ? ", " : "")+(i+1); |
} |
} |
if (!personneNumero.equals("")) { |
messages.add("Veuillez indiquez le type de relation existant entre la collection et les personnes numéros : "+personneNumero); |
} |
} |
return messages; |
} |
public void collecter() { |
if (etreAccede()) { |
int nbrePersonne = grille.getStore().getCount(); |
for (int i = 0; i < nbrePersonne; i++) { |
CollectionAPersonne relationCollectionPersonne = grille.getStore().getAt(i); |
if (relationCollectionPersonne.get("_etat_") != null) { |
if (relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role |
personnesSupprimees.put("id"+idGenere++, relationCollectionPersonne); |
CollectionAPersonne relationAAjouter = (CollectionAPersonne) relationCollectionPersonne.cloner(new CollectionAPersonne()); |
corrigerChampsGrille(relationAAjouter);// Nous modifions l'id_role |
personnesAjoutees.put("id"+idGenere++, relationAAjouter); |
} |
if (relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
corrigerChampsGrille(relationCollectionPersonne);// Nous modifions l'id_role |
personnesAjoutees.put("id"+idGenere++, relationCollectionPersonne); |
} |
// Initialisation de la grille |
relationCollectionPersonne.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
private void corrigerChampsGrille(CollectionAPersonne relationCollectionPersonne) { |
String role = relationCollectionPersonne.get("_role_"); |
String champModele = "nom"; |
if (role.matches("[0-9]+")) { |
champModele = "id_valeur"; |
} |
if (typeRelationCombo.getStore().findModel(champModele, role) != null) { |
String idRole = typeRelationCombo.getStore().findModel(champModele, role).getId(); |
relationCollectionPersonne.setIdRole(idRole); |
} |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (personnesAjoutees.size() == 0 && personnesSupprimees.size() == 0) { |
InfoLogger.display("Modification des personnes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
// Ajout des relations CollectionAPersonne |
if (personnesAjoutees.size() != 0) { |
mediateur.ajouterCollectionAPersonne(this, collection.getId(), personnesAjoutees); |
} |
// Suppression des relations StructureAPersonne |
if (personnesSupprimees.size() != 0) { |
mediateur.supprimerCollectionAPersonne(this, personnesSupprimees); |
} |
} |
} |
} |
private void obtenirPersonnesSaisis(String nom) { |
mediateur.selectionnerPersonneParNomComplet(this, null, "%"+nom+"%", null); |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCollectionAPersonne(this, collection.getId(), null, null); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java |
---|
New file |
0,0 → 1,539 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.InfoLogger; |
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.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionAPublication; |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.util.Debug; |
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.publication.PublicationForm; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.core.XTemplate; |
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.Events; |
import com.extjs.gxt.ui.client.event.KeyListener; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.store.Store; |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
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.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.RowExpander; |
import com.extjs.gxt.ui.client.widget.grid.RowNumberer; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout; |
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; |
public class CollectionFormPublication extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "publication"; |
private Collection collection = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<CollectionAPublication> grille; |
private CollectionAPublicationListe publicationsAjoutees = null; |
private CollectionAPublicationListe publicationsSupprimees = null; |
private ComboBox<Publication> publicationsSaisiesComboBox = null; |
private Button publicationsBoutonSupprimer = null; |
private Button publicationsBoutonModifier = null; |
private FenetreForm fenetreFormulaire = null; |
public CollectionFormPublication(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionPublication()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
setLayout(new FitLayout()); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.add(grille); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
idGenere = 1; |
publicationsAjoutees = new CollectionAPublicationListe(); |
publicationsSupprimees = new CollectionAPublicationListe(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
collection = ((CollectionForm) formulaire).collection; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionPublicationTitre()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new Text(" ou ")); |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis(); |
barreOutils.add(publicationsSaisiesComboBox); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonModifier = creerBoutonModifier(); |
barreOutils.add(publicationsBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(publicationsBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirBouton); |
return barreOutils; |
} |
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) { |
CollectionAPublication publicationSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String publicationId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
CollectionAPublication publicationSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
publicationId = publicationSaisiSelectionne.getIdPublication(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) { |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this); |
FormPanel panneauFormulaire = formulairePublication.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
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 = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulairePublication; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm 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(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
CollectionAPublication publicationSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
InfoLogger.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
supprimerDansGrille(publicationSaisieSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCollectionAPublication(this, collection.getId(), null); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
private ComboBox<Publication> creerComboBoxPublicationsSaisis() { |
ListStore<Publication> publicationsSaisiesStore = new ListStore<Publication>(); |
ComboBox<Publication> comboBox = new ComboBox<Publication>(); |
comboBox.setWidth(400); |
comboBox.setEmptyText(i18nC.chercherPublicationSaisi()); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setEditable(true); |
comboBox.setDisplayField("fmt_nom_complet"); |
comboBox.setStore(publicationsSaisiesStore); |
comboBox.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (publicationsSaisiesComboBox.getRawValue() != null && publicationsSaisiesComboBox.getRawValue().length() > 0) { |
if (!ce.isNavKeyPress()) { |
obtenirPublicationsSaisies(publicationsSaisiesComboBox.getRawValue()); |
} |
} |
} |
}); |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
if (publicationsSaisiesComboBox.getValue() instanceof Publication) { |
Publication publicationSaisieSelectionne = publicationsSaisiesComboBox.getValue(); |
ajouterDansGrille(publicationSaisieSelectionne); |
publicationsSaisiesComboBox.setValue(null); |
} |
} |
}); |
return comboBox; |
} |
private void ajouterDansGrille(Publication publication) { |
ajouterDansGrille(publication, 0); |
} |
private void ajouterDansGrille(Publication publication, int index) { |
if (publication != null) { |
CollectionAPublication publicationLiee = new CollectionAPublication(); |
publicationLiee.setPublication(publication); |
publicationLiee.setIdPublication(publication.getId()); |
// Gestion de l'id de la collection |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
publicationLiee.setIdCollection(collection.getId()); |
} |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(publicationLiee, 0); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} |
} |
private void supprimerDansGrille(CollectionAPublication publicationLiee) { |
if (publicationLiee != null) { |
// Ajout de la personne supprimée à la liste |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& publicationLiee.getId() != null |
&& !publicationLiee.getId().equals("")) { |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(publicationLiee); |
} |
} |
private EditorGrid<CollectionAPublication> creerGrille() { |
ListStore<CollectionAPublication> storeGrille = new ListStore<CollectionAPublication>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionAPublication>>() { |
public void handleEvent(StoreEvent<CollectionAPublication> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionAPublication>>() { |
public void handleEvent(StoreEvent<CollectionAPublication> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
RowNumberer numeroPlugin = new RowNumberer(); |
numeroPlugin.setHeader("#"); |
XTemplate infoTpl = XTemplate.create("<p>"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {fmt_auteur}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {titre}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {collection}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+ |
"</p>"); |
RowExpander expansionPlugin = new RowExpander(); |
expansionPlugin.setTemplate(infoTpl); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(expansionPlugin); |
colonnes.add(numeroPlugin); |
colonnes.add(new ColumnConfig("fmt_auteur", i18nC.publicationAuteurs(), 150)); |
colonnes.add(new ColumnConfig("titre", i18nC.publicationTitre(), 150)); |
colonnes.add(new ColumnConfig("collection", i18nC.publicationRevueCollection(), 75)); |
colonnes.add(creerColonneEditeur()); |
colonnes.add(creerColonneAnneePublication()); |
colonnes.add(new ColumnConfig("indication_nvt", i18nC.publicationNvt(), 75)); |
colonnes.add(new ColumnConfig("fascicule", i18nC.publicationFascicule(), 75)); |
colonnes.add(new ColumnConfig("truk_pages", i18nC.publicationPage(), 50)); |
GridSelectionModel<CollectionAPublication> modeleDeSelection = new GridSelectionModel<CollectionAPublication>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info"); |
EditorGrid<CollectionAPublication> grillePublications = new EditorGrid<CollectionAPublication>(storeGrille, modeleDeColonnes); |
//grillePublications.setHeight("100%"); |
grillePublications.setBorders(true); |
grillePublications.setSelectionModel(modeleDeSelection); |
grillePublications.addPlugin(expansionPlugin); |
grillePublications.addPlugin(numeroPlugin); |
grillePublications.getView().setForceFit(true); |
grillePublications.setAutoExpandColumn("titre"); |
grillePublications.setStripeRows(true); |
grillePublications.setTrackMouseOver(true); |
return grillePublications; |
} |
private ColumnConfig creerColonneEditeur() { |
GridCellRenderer<CollectionAPublication> editeurRendu = new GridCellRenderer<CollectionAPublication>() { |
public String render(CollectionAPublication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPublication> store, Grid<CollectionAPublication> grid) { |
String editeur = model.getPublication().getNomEditeur(); |
model.set("_editeur_", editeur); |
return editeur; |
} |
}; |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135); |
editeurColonne.setRenderer(editeurRendu); |
return editeurColonne; |
} |
private ColumnConfig creerColonneAnneePublication() { |
GridCellRenderer<CollectionAPublication> datePublicationRendu = new GridCellRenderer<CollectionAPublication>() { |
public String render(CollectionAPublication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPublication> store, Grid<CollectionAPublication> grid) { |
String annee = model.getPublication().getAnneeParution(); |
model.set("_annee_", annee); |
return annee; |
} |
}; |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75); |
datePublicationColonne.setRenderer(datePublicationRendu); |
return datePublicationColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
publicationsBoutonSupprimer.enable(); |
publicationsBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
publicationsBoutonSupprimer.disable(); |
publicationsBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else if (nouvellesDonnees instanceof PublicationListe) { |
PublicationListe listePublications = (PublicationListe) nouvellesDonnees; |
rafraichirPublicationListe(listePublications); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
private void rafraichirPublicationListe(PublicationListe listePublications) { |
publicationsSaisiesComboBox.getStore().removeAll(); |
publicationsSaisiesComboBox.getStore().add(listePublications.toList()); |
publicationsSaisiesComboBox.expand(); |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (type.equals("liste_collection_a_publication")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
collection.setPublicationsLiees((CollectionAPublicationListe) info.getDonnee(0)); |
peupler(); |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les publications liées |
// En mode AJOUT, il ne peut que y avoir des publications liées ajoutées |
mediateur.ajouterCollectionAPublication(this, collectionId, publicationsAjoutees); |
} |
} else if (type.equals("publication_modifiee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
CollectionAPublication publicationDansGrille = grille.getStore().findModel("id_publication", publication.getId()); |
int index = grille.getStore().indexOf(publicationDansGrille); |
grille.getStore().remove(publicationDansGrille); |
ajouterDansGrille(publication, index); |
} |
} else if (type.equals("publication_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
ajouterDansGrille(publication); |
} |
} else if (type.equals("suppression_collection_a_publication")) { |
InfoLogger.display("Suppression des publications liées à la collection", info.toString()); |
} else if (type.equals("ajout_collection_a_publication")) { |
InfoLogger.display("Ajout des publications liées à la collection", info.toString()); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null); |
} |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(collection.getPublicationsLiees().toList()); |
layout(); |
InfoLogger.display(i18nC.chargementPublication(), i18nC.ok()); |
} |
public void collecter() { |
if (etreAccede()) { |
int nbrePublication = grille.getStore().getCount(); |
for (int i = 0; i < nbrePublication; i++) { |
CollectionAPublication publicationLiee = grille.getStore().getAt(i); |
if (publicationLiee.get("_etat_") != null) { |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
CollectionAPublication relationAAjouter = (CollectionAPublication) publicationLiee.cloner(new CollectionAPublication()); |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter); |
} |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
publicationsAjoutees.put("id"+idGenere++, publicationLiee); |
} |
// Initialisation de la grille |
publicationLiee.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) { |
InfoLogger.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
// Ajout des relations CollectionAPublication |
if (publicationsAjoutees.size() != 0) { |
mediateur.ajouterCollectionAPublication(this, collection.getId(), publicationsAjoutees); |
} |
// Suppression des relations CollectionAPublication |
if (publicationsSupprimees.size() != 0) { |
mediateur.supprimerCollectionAPublication(this, publicationsSupprimees); |
} |
} |
} |
} |
private void obtenirPublicationsSaisies(String nom) { |
mediateur.selectionnerPublicationParNomComplet(this, null, "%"+nom+"%"); |
} |
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java:r1136-1368 |
/branches/v1.1-aramon/src/org/tela_botanica/client/vues/collection/. |
---|
New file |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection:r1136-1291 |