1,7 → 1,9 |
package org.tela_botanica.client.vues; |
|
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeurs; |
import org.tela_botanica.client.composants.ConteneurMultiChamps; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Collection; |
import org.tela_botanica.client.modeles.CollectionListe; |
13,33 → 15,50 |
import org.tela_botanica.client.modeles.ValeurListe; |
|
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.util.Padding; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
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.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.Validator; |
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.layout.ColumnData; |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout; |
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.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData; |
import com.extjs.gxt.ui.client.widget.layout.RowLayout; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout.HBoxLayoutAlign; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.i18n.client.NumberFormat; |
|
public class CollectionFormGeneral extends FormulaireOnglet implements Rafraichissable { |
|
private HiddenField<String> idCollectionChp; |
|
private ListStore<Projet> projetsStore; |
private ComboBox<Projet> projetsCombo; |
private ComboBox<Structure> structuresCombo; |
private ListStore<Structure> structuresStore; |
private ComboBox<Collection> collectionsCombo; |
private ListStore<Collection> collectionsStore; |
private ComboBox<Projet> projetsCombo = null; |
private ComboBox<Structure> structuresCombo = null; |
private ComboBox<Collection> collectionsCombo = null; |
|
private FieldSet descriptionFieldSet; |
private ListStore<Valeur> typeDepotStore; |
private ComboBox<Valeur> typeDepotCombo; |
private FieldSet descriptionFieldSet = null; |
private ComboBox<Valeur> typeDepotCombo = null; |
|
private TextArea lieuCouvertureChp; |
private TextArea lieuCouvertureChp = null; |
|
private ChampComboBoxListeValeurs specimenTypeCombo = null; |
private ChampComboBoxListeValeurs precisionTypeNbreCombo = null; |
private NumberField nbreTypeChp = null; |
|
private ChampComboBoxListeValeurs classementSpecimenTypeCombo; |
|
public CollectionFormGeneral(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
51,6 → 70,7 |
creerFieldsetAdministratif(); |
creerFieldsetDescription(); |
creerFieldsetCouverture(); |
creerFieldsetType(); |
} |
|
private void creerChampsCache() { |
65,7 → 85,6 |
liaisonFieldSet.setCollapsible(true); |
liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
|
projetsStore = new ListStore<Projet>(); |
projetsCombo = new ComboBox<Projet>(); |
projetsCombo.setTabIndex(tabIndex++); |
projetsCombo.setFieldLabel(i18nC.projetChamp()); |
77,7 → 96,7 |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (projetsStore.findModel("nom", field.getRawValue()) == null) { |
} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
87,11 → 106,10 |
} |
}); |
projetsCombo.setTriggerAction(TriggerAction.ALL); |
projetsCombo.setStore(projetsStore); |
projetsCombo.setStore(new ListStore<Projet>()); |
liaisonFieldSet.add(projetsCombo, new FormData(450, 0)); |
mediateur.selectionnerProjets(this); |
|
structuresStore = new ListStore<Structure>(); |
structuresCombo = new ComboBox<Structure>(); |
structuresCombo.setTabIndex(tabIndex++); |
structuresCombo.setFieldLabel(i18nC.lienStructureCollection()); |
103,7 → 121,7 |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (structuresStore.findModel("nom", field.getRawValue()) == null) { |
} else if (structuresCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
113,11 → 131,10 |
} |
}); |
structuresCombo.setTriggerAction(TriggerAction.ALL); |
structuresCombo.setStore(structuresStore); |
structuresCombo.setStore(new ListStore<Structure>()); |
liaisonFieldSet.add(structuresCombo, new FormData(450, 0)); |
mediateur.selectionnerStructureParProjet(this, null); |
|
collectionsStore = new ListStore<Collection>(); |
collectionsCombo = new ComboBox<Collection>(); |
collectionsCombo.setTabIndex(tabIndex++); |
collectionsCombo.setFieldLabel(i18nC.lienMereCollection()); |
129,7 → 146,7 |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (collectionsStore.findModel("nom", field.getRawValue()) == null) { |
} else if (collectionsCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
140,7 → 157,7 |
} |
}); |
collectionsCombo.setTriggerAction(TriggerAction.ALL); |
collectionsCombo.setStore(collectionsStore); |
collectionsCombo.setStore(new ListStore<Collection>()); |
liaisonFieldSet.add(collectionsCombo, new FormData(450, 0)); |
mediateur.selectionnerCollectionParProjet(this, null); |
|
154,31 → 171,8 |
administratifFieldSet.setCollapsible(true); |
administratifFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
|
typeDepotStore = new ListStore<Valeur>(); |
typeDepotCombo = new ComboBox<Valeur>(); |
typeDepotCombo.setTabIndex(tabIndex++); |
typeDepotCombo.setFieldLabel(i18nC.typeDepot()); |
typeDepotCombo.setDisplayField("nom"); |
typeDepotCombo.setForceSelection(true); |
typeDepotCombo.setValidator(new Validator() { |
@Override |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (typeDepotStore.findModel("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; |
} |
}); |
typeDepotCombo.setTriggerAction(TriggerAction.ALL); |
typeDepotCombo.setStore(typeDepotStore); |
administratifFieldSet.add(typeDepotCombo, new FormData(250, 0)); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeDepot"); |
typeDepotCombo = new ChampComboBoxListeValeurs(i18nC.typeDepot(), "typeDepot", tabIndex++); |
administratifFieldSet.add(typeDepotCombo); |
|
ChampMultiValeurs nomsAlternatifsChp = new ChampMultiValeurs(i18nC.intituleAlternatifCollection()); |
administratifFieldSet.add(nomsAlternatifsChp); |
227,6 → 221,37 |
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 rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |