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 |