Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 1763 → Rev 1764

/trunk/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java
10,12 → 10,10
import org.tela_botanica.client.composants.ChampMultiValeurs;
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.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.collection.Collection;
import org.tela_botanica.client.modeles.projet.Projet;
import org.tela_botanica.client.modeles.structure.Structure;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
47,7 → 45,6
 
private HiddenField<String> idCollectionChp = null;
private ChampComboBoxRechercheTempsReelPaginable projetsCombo = null;
private ChampComboBoxRechercheTempsReelPaginable structuresCombo = null;
private ChampComboBoxRechercheTempsReelPaginable collectionsCombo = null;
108,44 → 105,6
//+-----------------------------------------------------------------------------------------------------------+
// 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>(null);
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();
329,7 → 288,6
initialiserCollection();
if (collection != null) {
idCollectionChp.setValue(collection.getId());
setValeurComboProjets();
setValeurComboStructures();
setValeurComboCollections();
358,9 → 316,6
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;
}
369,7 → 324,6
// l'onglet collection est obligatoirement rempli lors d'un ajout
if (this.mode == Formulaire.MODE_AJOUTER || etreAccede()) {
collectionCollectee.setId(idCollectionChp.getValue());
collectionCollectee.setIdProjet(getValeurComboProjets());
collectionCollectee.setIdStructure(getValeurComboStructures());
collectionCollectee.setCollectionMereId(getValeurComboCollections());
398,25 → 352,6
}
}
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.getCombo().getStore() != null
&& collection != null
&& collection.getIdProjet() != null
&& !UtilString.isEmpty(collection.getIdProjet())) {
projetsCombo.chargerValeurInitiale(collection.getIdProjet(), "cpr_id_projet");
} else {
projetsCombo.getCombo().setValue(null);
}
}
private String getValeurComboStructures() {
String valeur = "";
if (structuresCombo.getCombo().getValue() != null) {