Subversion Repositories eFlore/Applications.coel

Compare Revisions

Ignore whitespace Rev 953 → Rev 954

/trunk/src/org/tela_botanica/client/composants/ChampCaseACocher.java
1,6 → 1,7
package org.tela_botanica.client.composants;
 
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
8,6 → 9,8
import org.tela_botanica.client.interfaces.Rafraichissable;
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.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.BaseEvent;
59,6 → 62,9
groupeCaseACocher.setFieldLabel(label);
}
public boolean avoirChampAutre() {
return avoirChampAutre;
}
public void setChampAutre(boolean avoirChamp) {
avoirChampAutre = avoirChamp;
if (avoirChampAutre) {
66,6 → 72,49
}
}
public String getValeur() {
String valeur = "";
List<CheckBox> liste = groupeCaseACocher.getValues();
if (liste != null) {
int taille = liste.size();
for (int i = 0; i < taille; i++) {
CheckBox cac = liste.get(i);
if (cac.isEnabled()) {
valeur += aDonnee.SEPARATEUR_VALEURS+cac.getData("id");
}
}
}
if (avoirChampAutre() && !UtilString.isEmpty(champAutre.getValue())) {
valeur += aDonnee.SEPARATEUR_VALEURS+champAutre.getValue();
}
if (!valeur.equals("")) {
valeur.replaceFirst("^"+aDonnee.SEPARATEUR_VALEURS, "");
}
return valeur;
}
public void peupler(String donnees) {
String[] valeurs = donnees.split(aDonnee.SEPARATEUR_VALEURS);
for (int i = 0; i < valeurs.length; i++) {
if (valeurs[i].startsWith("AUTRE##")) {
champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", ""));
} else {
//TODO : check : List<CheckBox> cases = groupeCac.getAll();
List<Field<?>> cases = groupeCaseACocher.getAll();
for (int j = 0; j < cases.size(); j++) {
if (cases.get(j).getId().equals("val-"+valeurs[i])) {
((CheckBox) cases.get(j)).setValue(true);
}
}
}
}
}
private FormLayout creerFormLayout(Integer labelWidth, LabelAlign labelAlign) {
FormLayout formLayout = new FormLayout();
if (labelWidth != null) {
81,7 → 130,7
addListener(Events.Hide, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
groupeCaseACocher.reset();
if (avoirChampAutre) {
if (avoirChampAutre()) {
champAutre.setValue("");
}
}
104,7 → 153,7
}
add(groupeCaseACocher);
if (avoirChampAutre) {
if (avoirChampAutre()) {
// FIXME : éviter le chevauchement du texte des cases à cocher avec le label "Autre" sur les petits écrans
LayoutContainer conteneur = new LayoutContainer();
conteneur.setLayout(creerFormLayout(50, LabelAlign.TOP));