Subversion Repositories eFlore/Applications.coel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1909 → Rev 1943

/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampComboBoxRechercheTempsReelPaginable.java
New file
0,0 → 1,211
package org.tela_botanica.client.composants;
 
import java.util.List;
 
import org.tela_botanica.client.composants.pagination.ChargeurListe;
import org.tela_botanica.client.composants.pagination.Proxy;
import org.tela_botanica.client.composants.pagination.TransformateurJSONaModelData;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.util.Debug;
 
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.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
 
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.LoadEvent;
import com.extjs.gxt.ui.client.data.Loader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
 
public class ChampComboBoxRechercheTempsReelPaginable extends LayoutContainer implements Rafraichissable {
 
//-------------//
// ATTRIBUTS //
//-------------//
private ListStore<ModelData> store = null;
private ComboBox<ModelData> combo = null;
 
private Proxy<?> proxy = null;
private TransformateurJSONaModelData<PagingLoadResult<ModelData>> reader = null;
private ChargeurListe<PagingLoadResult<ModelData>> loader = null;
private int start = 0;
private int limit = 10;
private int largeur = 370;
 
private BasePagingLoadConfig plc = null;
private ModelType modeltype = null;
private String displayName = "";
private String recherche = "";
private String champValeurInitiale = "";
private String valeurInitiale = "";
private boolean valeurInitialeAffectee = false;
//-------------//
// METHODES //
//-------------//
 
/*--------------
Constructeur
--------------*/
public ChampComboBoxRechercheTempsReelPaginable(Proxy<?> proxy, ModelType modelType, String displayName, int taillePage) {
initialiserChamp(proxy, modelType, displayName);
}
public ChampComboBoxRechercheTempsReelPaginable(Proxy<?> proxy, ModelType modelType, String displayName) {
initialiserChamp(proxy, modelType, displayName);
}
private void initialiserChamp(Proxy<?> proxy, ModelType modelType, String displayName) {
this.modeltype = modelType;
this.proxy = proxy;
this.displayName = displayName;
 
plc = new BasePagingLoadConfig();
plc.setLimit(limit);
plc.setOffset(start);
reader = new TransformateurJSONaModelData<PagingLoadResult<ModelData>>(this.modeltype, null);
loader = new ChargeurListe<PagingLoadResult<ModelData>>(this.proxy, reader, this);
loader.setLimit(plc.getLimit());
loader.setOffset(plc.getOffset());
 
loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
be.<ModelData> getConfig().set("start", be.<ModelData> getConfig().get("offset"));
}
});
 
loader.addListener(Loader.Load, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
 
}
});
loader.addListener(Loader.LoadException, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
 
}
});
combo = new ComboBox<ModelData>();
this.setWidth(largeur);
combo.setDisplayField(this.displayName);
combo.setHideTrigger(false);
combo.setPageSize(plc.getLimit());
store = new ListStore<ModelData>(loader);
combo.setStore(store);
loader.load(plc, recherche, false);
 
combo.addListener(Events.KeyUp, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent fe) {
// on vérifie que les touches enfoncées ne sont pas les flèches du clavier
if (!fe.isNavKeyPress()) {
recherche = combo.getRawValue();
plc.setLimit(limit);
plc.setOffset(start);
loader.setLimit(limit);
loader.setOffset(start);
loader.load(plc, recherche, false);
}
}
});
 
this.add(combo);
}
 
/*------------
Accesseurs
------------*/
public ComboBox<ModelData> getCombo() {
return this.combo;
}
public ModelData getValeur() {
if (combo.getSelection() != null && combo.getSelection().size() > 0) {
return combo.getSelection().get(0);
} else {
return null;
}
}
public ListStore<?> getStore() {
return combo.getStore();
}
public void setWidth(int largeur) {
this.largeur = largeur;
this.combo.setWidth(largeur);
}
public void setWidth(int tailleLabel, int largeurTotale) {
this.setWidth(largeurTotale);
this.largeur = largeurTotale;
this.combo.setWidth(largeurTotale - tailleLabel);
FormLayout fl = new FormLayout();
fl.setLabelWidth(tailleLabel);
fl.setDefaultWidth(largeurTotale - tailleLabel);
this.setLayout(fl);
 
this.layout();
}
/*-----------------------------
Gestion du contenu du champ
-----------------------------*/
public List<ModelData> collecterValeursDuChamp() {
return combo.getSelection();
}
public void peuplerChamp(List<ModelData> selection) {
combo.setSelection(selection);
}
 
public void chargerValeurInitiale(String valeurInitiale, String champ) {
this.valeurInitiale = valeurInitiale;
this.champValeurInitiale = champ;
if(combo.getStore().findModel(champValeurInitiale, valeurInitiale) == null) {
loader.load(plc, "", true);
this.getCombo().disable();
} else {
combo.setValue(combo.getStore().findModel(champValeurInitiale, valeurInitiale));
}
}
 
/*-----------------------------
Rafraichir
-----------------------------*/
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("selectionnerValeurCombo")) {
if (combo.getStore().findModel(champValeurInitiale, valeurInitiale) == null) {
// Si la valeur ne fait pas partie de la première page, on doit charger la liste complète
// C'est un peu moche mais pour le moment ça marche (les listes ne dépassant pas quelques
// centaines d'élements), on s'arrete par contre si on a atteint le total d'éléments
if(!valeurInitialeAffectee && combo.getStore().getCount() < loader.getTotalCount()) {
loader.load(start, loader.getTotalCount());
} else {
this.getCombo().enable();
}
} else {
combo.setValue(combo.getStore().findModel(champValeurInitiale, valeurInitiale));
valeurInitialeAffectee = true;
this.getCombo().enable();
}
}
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampComboBoxRechercheTempsReelPaginable.java:r1136-1208,1292-1367
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampComboBoxRechercheTempsReelPaginable.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/GrillePaginable.java
New file
0,0 → 1,193
package org.tela_botanica.client.composants;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.tela_botanica.client.composants.pagination.ChargeurListe;
import org.tela_botanica.client.composants.pagination.Proxy;
import org.tela_botanica.client.composants.pagination.TransformateurJSONaModelData;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.composants.GrilleParametrable;
 
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.LoadEvent;
import com.extjs.gxt.ui.client.data.Loader;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
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.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.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
 
public class GrillePaginable<D extends ModelData> extends ContentPanel implements Rafraichissable, GrilleParametrable<D> {
 
//+---------------------------------------------------------------------------------------------------------------+
// Attributs
// Pagination
private int start = 0;
private int limit = 50;
// Récupération, stockage et pagination des données
private ModelType modelType = null;
private Proxy<D> proxy = null;
private TransformateurJSONaModelData<PagingLoadResult<D>> reader = null;
private BasePagingLoadConfig plc = null;
private ChargeurListe<PagingLoadResult<D>> loader = null;
private ListStore<D> storeGrille = null;
// Elements graphiques
EditorGrid<D> grille = null;
List<ColumnConfig> colonnes = null;
ColumnModel modeleDeColonnes = null;
//+---------------------------------------------------------------------------------------------------------------+
// Constructeur
public GrillePaginable(ModelType modeltype, HashMap<String, String> virtualFields, Proxy<D> proxy, List<ColumnConfig> colonnes, ColumnModel modeleDeColonnes) {
// Récupération des paramètres
this.modelType = modeltype;
this.proxy = proxy;
this.colonnes = colonnes;
this.modeleDeColonnes = modeleDeColonnes;
// Formatage du conteneur;
this.setLayout(new FitLayout());
// Création des objets pour la récupération et la pagination des données
plc = new BasePagingLoadConfig();
plc.setLimit(limit);
plc.setOffset(start);
reader = new TransformateurJSONaModelData<PagingLoadResult<D>>(modelType, virtualFields);
creerChargeurDeListe();
creerGrille();
}
 
//+---------------------------------------------------------------------------------------------------------------+
// Accesseurs
public EditorGrid<D> getGrille() {
return grille;
}
public ListStore<D> getStore() {
return storeGrille;
}
public GridSelectionModel<D> getSelectionModel() {
return grille.getSelectionModel();
}
public D getSelection() {
return grille.getSelectionModel().getSelectedItem();
}
@SuppressWarnings("unchecked")
public Proxy getProxy() {
return this.proxy;
}
//+---------------------------------------------------------------------------------------------------------------+
// Méthodes publiques
public void rafraichir(Object nouvellesDonnees) {
}
//+---------------------------------------------------------------------------------------------------------------+
// Méthodes privées
private void creerChargeurDeListe() {
loader = new ChargeurListe<PagingLoadResult<D>>(proxy, reader, this);
loader.setLimit(plc.getLimit());
loader.setOffset(plc.getOffset());
loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
 
}
});
loader.addListener(Loader.Load, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
 
}
});
}
private void creerGrille() {
final PagingToolBar toolBar = new PagingToolBar(this.limit);
toolBar.bind(loader);
this.setBottomComponent(toolBar);
storeGrille = new ListStore<D>(loader);
storeGrille.addListener(Store.Add, new Listener<StoreEvent<D>>() {
public void handleEvent(StoreEvent<D> ce) {
 
}
});
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<D>>() {
public void handleEvent(StoreEvent<D> ce) {
 
}
});
storeGrille.addListener(Store.Update, new Listener<StoreEvent<D>>() {
public void handleEvent(StoreEvent<D> ce) {
 
}
});
GridSelectionModel<D> modeleDeSelection = new GridSelectionModel<D>();
grille = new EditorGrid<D>(storeGrille, modeleDeColonnes);
grille.setHeight("100%");
grille.setBorders(true);
grille.setSelectionModel(modeleDeSelection);
grille.getView().setForceFit(true);
grille.setStripeRows(true);
grille.setBorders(true);
grille.setStateful(true);
grille.addListener(Events.Attach, new Listener<GridEvent<D>>() {
public void handleEvent(GridEvent<D> be) {
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(start);
config.setLimit(limit);
Map<String, Object> state = grille.getState();
if (state.containsKey("offset")) {
int offset = (Integer)state.get("offset");
int limit = (Integer)state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
if (state.containsKey("sortField")) {
config.setSortField((String)state.get("sortField"));
config.setSortDir(SortDir.valueOf((String)state.get("sortDir")));
}
loader.load(config);
}
});
this.add(grille);
}
public void reload() {
loader.load();
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampComboBoxListeValeurs.java
New file
0,0 → 1,158
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
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.vues.Formulaire;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.SortDir;
import com.extjs.gxt.ui.client.store.ListStore;
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.Validator;
import com.google.gwt.core.client.GWT;
 
public class ChampComboBoxListeValeurs extends ComboBox<Valeur> implements Rafraichissable {
private Configuration config = null;
private Mediateur mediateur = null;
 
private String listeValeursCode = null;
private String nomChampATrier = null;
private String valeurDefautId = null;
public ChampComboBoxListeValeurs(String labelDuChamp, String codeDeLaliste) {
initialiserChampComboBox(labelDuChamp, codeDeLaliste, 0);
}
public ChampComboBoxListeValeurs(String labelDuChamp, String codeDeLaliste, int tabIndex) {
initialiserChampComboBox(labelDuChamp, codeDeLaliste, tabIndex);
}
public ChampComboBoxListeValeurs(String labelDuChamp, ValeurListe listeDeValeurs, int tabIndex) {
initialiserChampComboBox(labelDuChamp, null, tabIndex);
rafraichir(listeDeValeurs);
}
private void initialiserChampComboBox(String labelDuChamp, String codeDeLaliste, int tabIndex) {
config = (Configuration) Registry.get(RegistreId.CONFIG);
mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
setForceSelection(true);
setTriggerAction(TriggerAction.ALL);
setDisplayField("nom");
setStore(new ListStore<Valeur>());
setEditable(false);
 
setTabIndex(tabIndex);
if (labelDuChamp == null) {
setLabelSeparator("");
} else {
setFieldLabel(labelDuChamp);
}
setValidator(new Validator() {
public String validate(Field<?> field, String value) {
String retour = null;
if (field.getRawValue().equals("")) {
field.setValue(null);
} else if (getStore().findModel("nom", field.getRawValue()) == null) {
String contenuBrut = field.getRawValue();
field.setValue(null);
field.setRawValue(contenuBrut);
retour = Mediateur.i18nC.selectionnerValeurOuNull();
}
return retour;
}
});
if (codeDeLaliste != null) {
setListeCode(codeDeLaliste);
mediateur.obtenirListeValeurEtRafraichir(this, getListeCode(), null);
}
}
public String getListeCode() {
return listeValeursCode;
}
public void setListeCode(String code) {
listeValeursCode = code;
}
public String getValeur() {
String valeur = "";
if (getValue() != null) {
valeur = getValue().getId();
}
return valeur;
}
public void peupler(String valeur) {
if (valeur.matches("[0-9]+")) {
valeurDefautId = valeur;
actualiserValeurParDefaut();
} else {
setRawValue(valeur);
}
}
public String getTrie() {
String champATrier = "nom";
if (nomChampATrier != null) {
champATrier = nomChampATrier;
}
return champATrier;
}
 
/**
* Définit le nom du champ selon lequel trier, et si trierJusteApres vaut true, trie
* @param champATrier
*/
public void setTrie(String champATrier, boolean trierJusteApres) {
nomChampATrier = champATrier;
if (trierJusteApres) {
trier();
}
}
 
/**
* Définit le nom du champ selon lequel trier, et trie juste après
* @param champATrier
*/
public void setTrie(String champATrier) {
setTrie(champATrier, true);
}
public void actualiserValeurParDefaut() {
if (valeurDefautId != null && getStore() != null) {
setValue(getStore().findModel("id_valeur", valeurDefautId));
}
}
 
/**
* Trie le contenu de la comboboîte selon le nomChampATrier défini. S'il n'y en a aucun, échoue silencieusement (niark niark)
*/
public void trier() {
if (! this.nomChampATrier.isEmpty()) {
this.getStore().sort(this.nomChampATrier, SortDir.ASC);
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
if (listeValeurs.getId().equals(config.getListeId(getListeCode()))) {
Formulaire.rafraichirComboBox(listeValeurs, this, getTrie());
actualiserValeurParDefaut();
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampComboBoxListeValeurs.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampComboBoxListeValeurs.java:r1136-1367
Merged /trunk/src/org/tela_botanica/client/composants/ChampComboBoxListeValeurs.java:r11-853,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/HashMapComposants.java
New file
0,0 → 1,72
package org.tela_botanica.client.composants;
 
import java.util.HashMap;
 
import org.tela_botanica.client.modeles.Valeur;
 
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
 
public class HashMapComposants extends HashMap<Object, Object> {
 
private static final long serialVersionUID = -3087869118215860287L;
 
@SuppressWarnings("unchecked")
public TextField getTextField(String name) {
return (TextField) get(name);
}
public DateField getDateField(String name) {
return (DateField) get(name);
}
public LabelField getLabelField(String name) {
return (LabelField) get(name);
}
public ChampMultiValeurs getChampMultiValeurs(String name) {
return (ChampMultiValeurs) get(name);
}
public ChampMultiValeursPaginable getChampMultiValeursPaginable(String name) {
return (ChampMultiValeursPaginable) get(name);
}
public ChampMultiValeursMultiTypes getChampMultiValeursMultiTypes(String name) {
return (ChampMultiValeursMultiTypes) get(name);
}
public ChampMultiValeursMultiTypesPaginable getChampMultiValeursMultiTypesPaginable(String name) {
return (ChampMultiValeursMultiTypesPaginable) get(name);
}
public ChampMultiValeursImage getChampMultiValeursImage(String name) {
return (ChampMultiValeursImage) get(name);
}
public Radio getRadio(String name) {
return (Radio) get(name);
}
public TextArea getTextArea(String name) {
return (TextArea) get(name);
}
@SuppressWarnings("unchecked")
public ComboBox<Valeur> getComboBoxValeur(String nom) {
return (ComboBox<Valeur>) get(nom);
}
@SuppressWarnings("unchecked")
public ComboBox getComboBox(String nom) {
return (ComboBox) get(nom);
}
public ChampComboBoxRechercheTempsReelPaginable getComboBoxRechercheTempsReelPaginable(String nom) {
return (ChampComboBoxRechercheTempsReelPaginable) get(nom);
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/HashMapComposants.java:r11-969,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/HashMapComposants.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/HashMapComposants.java:r1136-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampSliderPourcentage.java
New file
0,0 → 1,52
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.util.UtilNombre;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SliderEvent;
import com.extjs.gxt.ui.client.widget.Slider;
import com.extjs.gxt.ui.client.widget.form.SliderField;
 
public class ChampSliderPourcentage extends SliderField {
private String message = null;
public ChampSliderPourcentage(String label) {
super(creerSliderPoucentage(label));
message = label;
this.getSlider().addListener(Events.Change, new Listener<SliderEvent>() {
public void handleEvent(SliderEvent be) {
int pourcent = ((Slider) be.getComponent()).getValue();
setFieldLabel(message+" ("+pourcent+"%) ");
}
});
this.setFieldLabel(message);
}
private static Slider creerSliderPoucentage(String message) {
Slider slider = new Slider();
slider.setMinValue(0);
slider.setMaxValue(100);
slider.setValue(0);
slider.setIncrement(1);
slider.setMessage("{0} "+message);
return slider;
}
public String getValeur() {
String valeur = "";
int pourcentage = getSlider().getValue();
if (pourcentage != 0) {
valeur = UtilNombre.formaterEnEntier(pourcentage);
}
return valeur;
}
public void peupler(String valeur) {
if (!UtilString.isEmpty(valeur)) {
setValue(UtilString.formaterEnEntier(valeur));
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/ChampSliderPourcentage.java:r11-857,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampSliderPourcentage.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampSliderPourcentage.java:r1136-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/InfoLogger.java
New file
0,0 → 1,43
package org.tela_botanica.client.composants;
import java.util.Vector;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.vues.FenetreJournal;
import org.tela_botanica.client.vues.StatutVue;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.fx.FxConfig;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.InfoConfig;
 
public class InfoLogger {
/**
* La méthode permet de logger dans la fenêtre journal le message affiché.
* */
public static void display(String title, String text) {
Info.display(title, text);
InfoConfig info = new InfoConfig(title, text);
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).obtenirFenetreJournal().rafraichir(info);
}
public static void display(String title, String text, boolean estErreur) {
Info.display(title, text);
InfoConfig info = new InfoConfig(title, text);
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).obtenirFenetreJournal().rafraichir(info);
}
/**
* Displays a message using the specified config.
*
* @param config the info config
*/
/* public static void display(InfoConfig config, boolean estErreur) {
StatutVue panneauSud = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).obtenirPanneauSud();
panneauSud.afficherMessage(config);
if (estErreur) {
panneauSud.afficherErreur();
}
}*/
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/InfoLogger.java:r11-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/InfoLogger.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/InfoLogger.java:r1136-1368
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampNombre.java
New file
0,0 → 1,73
package org.tela_botanica.client.composants;
 
import java.util.List;
 
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.google.gwt.event.dom.client.KeyCodes;
 
/**
* Un bug dans le champ NumberField originel empêche la saisie de nombres sous
* certaines versions de firefox, d'où la présence de cette classe
*
*/
public class ChampNombre extends NumberField {
public int lastKeyCode;
public List<Character> allowed;
@Override
protected void onKeyDown( FieldEvent fe )
{
super.onKeyDown( fe ) ;
int keyCode = fe.getKeyCode( ) ;
 
if( keyCode == 0 )
{
keyCode = fe.getEvent( ).getCharCode( ) ;
}
 
_setLastKeyCode( keyCode ) ;
}
 
@Override
protected void onKeyPress( FieldEvent fe )
{
fireEvent( Events.KeyPress, new FieldEvent( this, fe.getEvent( ) ) ) ;
 
int keyCode = fe.getKeyCode( ) ;
 
char key = ( char )keyCode ;
 
if( keyCode == 0 )
{
key = ( char )fe.getEvent( ).getCharCode( ) ;
}
 
if( fe.isSpecialKey( _getLastKeyCode( ) )
|| _getLastKeyCode( ) == KeyCodes.KEY_BACKSPACE
|| _getLastKeyCode( ) == KeyCodes.KEY_DELETE
|| fe.isControlKey( ) )
{
return ;
}
 
if( !_getAllowed( ).contains( key ) )
{
fe.stopEvent( ) ;
}
}
 
private native int _getLastKeyCode( ) /*-{
return this.@org.tela_botanica.client.composants.ChampNombre::lastKeyCode ;
}-*/;
 
private native void _setLastKeyCode( int keycode ) /*-{
this.@org.tela_botanica.client.composants.ChampNombre::lastKeyCode = keycode ;
}-*/;
 
private native List<Character> _getAllowed( ) /*-{
return this.@org.tela_botanica.client.composants.ChampNombre::allowed ;
}-*/;
};
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/AproposFenetre.java
New file
0,0 → 1,201
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.i18n.Constantes;
import org.tela_botanica.client.images.Images;
 
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Registry;
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.HtmlContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
 
public class AproposFenetre extends Window {
private Constantes i18nC = null;
private String aproposTpl = null;
private Params aproposParams = null;
private String contributeurTpl = null;
private Params contributeurParams = null;
private String licenceTpl = null;
private Params licenceParams = null;
public AproposFenetre() {
i18nC = Mediateur.i18nC;
setSize(600, 500);
setPlain(true);
setHeadingHtml(i18nC.aproposTitre());
setIcon(Images.ICONES.information());
setLayout(new FitLayout());
initialiserSquelettes();
initialiserParams();
HtmlContainer aproposConteneurDuHtml = formaterSquelette(aproposTpl, aproposParams);
HtmlContainer contributeurConteneurDuHtml = formaterSquelette(contributeurTpl, contributeurParams);
HtmlContainer licenceConteneurDuHtml = formaterSquelette(licenceTpl, licenceParams);
TabPanel aproposOnglets = new TabPanel();
TabItem aproposOnglet = new TabItem(i18nC.aproposTitre());
aproposOnglet.add(aproposConteneurDuHtml);
aproposOnglet.setBorders(false);
aproposOnglet.setScrollMode(Scroll.AUTO);
aproposOnglets.add(aproposOnglet);
TabItem contributeurOnglet = new TabItem(i18nC.aproposTitreContributeur());
contributeurOnglet.add(contributeurConteneurDuHtml);
contributeurOnglet.setBorders(false);
contributeurOnglet.setScrollMode(Scroll.AUTO);
aproposOnglets.add(contributeurOnglet);
TabItem licenceOnglet = new TabItem(i18nC.aproposTitreLicence());
licenceOnglet.add(licenceConteneurDuHtml);
licenceOnglet.setBorders(false);
licenceOnglet.setScrollMode(Scroll.AUTO);
aproposOnglets.add(licenceOnglet);
add(aproposOnglets, new FitData(4));
}
private HtmlContainer formaterSquelette(String squelette, Params parametres) {
ajouterParametreParDefaut(parametres);
String html = Format.substitute(squelette, parametres);
HtmlContainer conteneurDuHtml = new HtmlContainer(html);
return conteneurDuHtml;
}
private void ajouterParametreParDefaut(Params parametres) {
parametres.set("css_label", ComposantClass.LABEL);
parametres.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU);
parametres.set("label_separateur", " :");
}
private void initialiserSquelettes() {
initialiserSqueletteApropos();
initialiserSqueletteContributeur();
initialiserSqueletteLicence();
}
private void initialiserSqueletteApropos() {
aproposTpl =
"<div class='{css_corps}'>"+
" <h2>{appli_nom}</h2>"+
" <p>"+
" <span class='{css_label}'>{i18n_code}{label_separateur}</span> {code}<br />"+
" <span class='{css_label}'>{i18n_version}{label_separateur}</span> {version}<br />"+
" <span class='{css_label}'>{i18n_version_nom}{label_separateur}</span> {version_nom}<br />"+
" <span class='{css_label}'>{i18n_revision}{label_separateur}</span> {revision}<br />"+
" <span class='{css_label}'>{i18n_revision_services}{label_separateur}</span> {revision_services}<br />"+
" <span class='{css_label}'>{i18n_licence}{label_separateur}</span> {licence}"+
" </p>"+
" <hr />"+
" <h2>{i18n_titre_compilation}</h2>"+
" <p>"+
" <span class='{css_label}'>{i18n_compilation_date}{label_separateur}</span> {compilation_date}<br />"+
" <span class='{css_label}'>{i18n_version_java}{label_separateur}</span> {version_java}"+
" </p>"+
" <hr />"+
" <h2>{i18n_titre_framework}</h2>"+
" <p>"+
" <span class='{css_label}'>{i18n_gwt}{label_separateur}</span> {gwt}<br />"+
" <span class='{css_label}'>{i18n_gxt}{label_separateur}</span> {gxt}"+
" </p>"+
" <hr />"+
" <h2>{i18n_titre_navigateur}</h2>"+
" <p>"+
" <span class='{css_label}'>{i18n_navigateur}{label_separateur}</span> {navigateur}<br />"+
" </p>"+
"</div>";
}
private void initialiserSqueletteContributeur() {
contributeurTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_contributeur}</h2>"+
" <p>"+
" <span class='{css_label}'>{i18n_developpeur}{label_separateur}</span> {developpeur}<br />"+
" <span class='{css_label}'>{i18n_traducteur}{label_separateur}</span> {traducteur}<br />"+
" <span class='{css_label}'>{i18n_testeur}{label_separateur}</span> {testeur}"+
" </p>"+
"</div>";
}
private void initialiserSqueletteLicence() {
licenceTpl =
"<div class='{css_corps}'>"+
" <h2>{i18n_titre_licence}</h2>"+
" <div>{licence}</div>"+
"</div>";
}
private void initialiserParams() {
initialiserParamApropos();
initialiserParamContributeur();
initialiserParamLicence();
}
private void initialiserParamApropos() {
aproposParams = new Params();
aproposParams.set("i18n_code", i18nC.aproposCode());
aproposParams.set("i18n_version", i18nC.aproposVersion());
aproposParams.set("i18n_version_nom", i18nC.aproposVersionNom());
aproposParams.set("i18n_revision", i18nC.aproposRevision());
aproposParams.set("i18n_revision_services", i18nC.aproposRevisionServices());
aproposParams.set("i18n_licence", i18nC.aproposLicence());
aproposParams.set("i18n_titre_compilation", i18nC.aproposTitreCompilation());
aproposParams.set("i18n_compilation_date", i18nC.aproposCompilationDate());
aproposParams.set("i18n_version_java", i18nC.aproposVersionJava());
aproposParams.set("i18n_titre_framework", i18nC.aproposTitreFramework());
aproposParams.set("i18n_gwt", i18nC.aproposGwt());
aproposParams.set("i18n_gxt", i18nC.aproposGxt());
aproposParams.set("i18n_titre_navigateur", i18nC.aproposTitreNavigateur());
aproposParams.set("i18n_navigateur", i18nC.aproposNavigateur());
aproposParams.set("appli_nom", (String) Registry.get(RegistreId.APPLI_NOM));
aproposParams.set("code", (String) Registry.get(RegistreId.APPLI_CODE));
aproposParams.set("version", (String) Registry.get(RegistreId.APPLI_VERSION));
aproposParams.set("version_nom", (String) Registry.get(RegistreId.APPLI_VERSION_NOM));
aproposParams.set("revision", (String) Registry.get(RegistreId.APPLI_REVISION));
aproposParams.set("revision_services", (String) Registry.get(RegistreId.SERVICES_REVISION));
aproposParams.set("licence", (String) Registry.get(RegistreId.APPLI_LICENCE));
aproposParams.set("compilation_date", (String) Registry.get(RegistreId.APPLI_COMPILATION_DATE_HEURE));
aproposParams.set("version_java", (String) Registry.get(RegistreId.APPLI_COMPILATION_JAVA_VERSION));
aproposParams.set("gwt", GWT.getVersion());
aproposParams.set("gxt", GXT.getVersion().getRelease());
aproposParams.set("navigateur", GXT.getUserAgent());
}
private void initialiserParamContributeur() {
contributeurParams = new Params();
contributeurParams.set("i18n_titre_contributeur", i18nC.aproposTitreContributeur());
contributeurParams.set("i18n_developpeur", i18nC.aproposDeveloppeur());
contributeurParams.set("i18n_traducteur", i18nC.aproposTraducteur());
contributeurParams.set("i18n_testeur", i18nC.aproposTesteur());
contributeurParams.set("developpeur", (String) Registry.get(RegistreId.APPLI_DEVELOPPEURS));
contributeurParams.set("traducteur", (String) Registry.get(RegistreId.APPLI_TRADUCTEURS));
contributeurParams.set("testeur", (String) Registry.get(RegistreId.APPLI_TESTEURS));
}
private void initialiserParamLicence() {
licenceParams = new Params();
licenceParams.set("i18n_titre_licence", i18nC.aproposTitreLicence());
licenceParams.set("licence", i18nC.licence());
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/AproposFenetre.java:r1136-1367
Merged /trunk/src/org/tela_botanica/client/composants/AproposFenetre.java:r11-1022,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/AproposFenetre.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampComboBoxMultiSelect.java
New file
0,0 → 1,1491
package org.tela_botanica.client.composants;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.core.El;
import com.extjs.gxt.ui.client.core.XDOM;
import com.extjs.gxt.ui.client.core.XTemplate;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoader;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.DomEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.event.ListViewEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.PreviewEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionProvider;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.store.StoreListener;
import com.extjs.gxt.ui.client.util.BaseEventPreview;
import com.extjs.gxt.ui.client.util.DelayedTask;
import com.extjs.gxt.ui.client.util.KeyNav;
import com.extjs.gxt.ui.client.util.Util;
import com.extjs.gxt.ui.client.widget.CheckBoxListView;
import com.extjs.gxt.ui.client.widget.ComponentHelper;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.ListView;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ListModelPropertyEditor;
import com.extjs.gxt.ui.client.widget.form.PropertyEditor;
import com.extjs.gxt.ui.client.widget.form.TriggerField;
import com.extjs.gxt.ui.client.widget.form.ComboBox.ComboBoxMessages;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.TextField.TextFieldMessages;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.RootPanel;
 
 
public class ChampComboBoxMultiSelect<D extends ModelData> extends TriggerField<D> implements SelectionProvider<D> {
 
/**
* ComboBox error messages.
*/
public class ComboBoxMessages extends TextFieldMessages {
 
private String loadingText = GXT.MESSAGES.loadMask_msg();
private String valueNoutFoundText;
 
/**
* Returns the loading text.
*
* @return the loading text
*/
public String getLoadingText() {
return loadingText;
}
 
/**
* Returns the value not found error text.
*
* @return the error text
*/
public String getValueNoutFoundText() {
return valueNoutFoundText;
}
 
/**
* Sets the loading text.
*
* @param loadingText the loading text
*/
public void setLoadingText(String loadingText) {
this.loadingText = loadingText;
}
 
/**
* When using a name/value combo, if the value passed to setValue is not
* found in the store, valueNotFoundText will be displayed as the field text
* if defined.
*
* @param valueNoutFoundText
*/
public void setValueNoutFoundText(String valueNoutFoundText) {
this.valueNoutFoundText = valueNoutFoundText;
}
 
}
 
/**
* TriggerAction enum.
*/
public enum TriggerAction {
ALL, QUERY;
}
 
protected boolean autoComplete = false;
protected boolean delayedCheck;
protected String lastQuery;
 
protected ListStore<D> store;
private String allQuery = "";
private BaseEventPreview eventPreview;
private boolean expanded;
private El footer;
private boolean forceSelection;
private InputElement hiddenInput;
private String itemSelector;
private String lastSelectionText;
private boolean lazyRender = true, initialized;
private LayoutContainer list;
private String listAlign = "tl-bl?";
private String listStyle = "x-combo-list";
private int maxHeight = 300;
private int minChars = 4;
private int minListWidth = 70;
private String mode = "remote";
private int pageSize;
private PagingToolBar pageTb;
private int queryDelay = 500;
private D selectedItem;
private String selectedStyle = "x-combo-selected";
private StoreListener<D> storeListener;
private DelayedTask taTask, dqTask;
private XTemplate template;
private TriggerAction triggerAction = TriggerAction.QUERY;
private boolean typeAhead;
private int typeAheadDelay = 250;
private boolean useQueryCache = true;
private String valueField;
//+----------------------------------------------------------------------------------------------------------------+
// Attributs modifiés ou ajoutés
private CheckBoxListView<D> listView = null;
private String valueFieldSeparator = aDonnee.SEPARATEUR_VALEURS;
private String rawSeparator = ", ";
private List<D> listeInitiale = new ArrayList<D>();
private boolean initialisation = false;
private boolean premierAppel = true;
//+----------------------------------------------------------------------------------------------------------------+
//+----------------------------------------------------------------------------------------------------------------+
// Constructeur modifiés
public ChampComboBoxMultiSelect() {
messages = new ComboBoxMessages();
listView = new CheckBoxListView<D>();
setPropertyEditor(new ListModelPropertyEditor<D>());
monitorWindowResize = true;
windowResizeDelay = 0;
initComponent();
setTriggerAction(TriggerAction.ALL);
}
//+----------------------------------------------------------------------------------------------------------------+
 
public void addSelectionChangedListener(SelectionChangedListener<D> listener) {
addListener(Events.SelectionChange, listener);
}
 
@Override
public void clear() {
getStore().clearFilters();
boolean f = forceSelection;
forceSelection = false;
super.clear();
forceSelection = f;
}
 
/**
* Clears any text/value currently set in the field.
*/
public void clearSelections() {
setRawValue("");
lastSelectionText = "";
applyEmptyText();
value = null;
}
/**
* Execute a query to filter the dropdown list. Fires the BeforeQuery event
* prior to performing the query allowing the query action to be canceled if
* needed.
*
* @param q the query
* @param forceAll true to force the query to execute even if there are
* currently fewer characters in the field than the minimum specified
* by the minChars config option. It also clears any filter
* previously saved in the current store
*/
public void doQuery(String q, boolean forceAll) {
if (q == null) {
q = "";
}
 
FieldEvent fe = new FieldEvent(this);
fe.setValue(q);
if (!fireEvent(Events.BeforeQuery, fe)) {
return;
}
 
if (forceAll || q.length() >= minChars) {
if (!useQueryCache || !q.equals(lastQuery)) {
lastQuery = q;
if (mode.equals("local")) {
selectedItem = null;
store.filter(getDisplayField(), q);
onLoad(null);
} else {
expand();
store.getLoader().load(getParams(q));
}
} else {
selectedItem = null;
onLoad(null);
}
}
}
 
/**
* Returns the all query.
*
* @return the all query
*/
public String getAllQuery() {
return allQuery;
}
 
/**
* Returns the display field.
*
* @return the display field
*/
public String getDisplayField() {
return getPropertyEditor().getDisplayProperty();
}
 
/**
* Returns true if the field's value is forced to one of the value in the
* list.
*
* @return the force selection state
*/
public boolean getForceSelection() {
return forceSelection;
}
 
/**
* Returns the item selector.
*
* @return the item selector
*/
public String getItemSelector() {
return itemSelector;
}
 
/**
* Returns the list's list align value.
*
* @return the list align value
*/
public String getListAlign() {
return listAlign;
}
 
/**
* Returns the list style.
*
* @return the list style
*/
public String getListStyle() {
return listStyle;
}
 
/**
* Returns the loading text.
*
* @return the loading text
*/
public String getLoadingText() {
return getMessages().getLoadingText();
}
 
/**
* Returns the dropdown list's max height.
*
* @return the max height
*/
public int getMaxHeight() {
return maxHeight;
}
 
@Override
public ComboBoxMessages getMessages() {
return (ComboBoxMessages) messages;
}
 
/**
* Returns the min characters used for autocompete and typeahead.
*
* @return the minimum number of characters
*/
public int getMinChars() {
return minChars;
}
 
/**
* Returns the dropdown list's min width.
*
* @return the min width
*/
public int getMinListWidth() {
return minListWidth;
}
 
/**
* Returns the page size.
*
* @return the page size
*/
public int getPageSize() {
return pageSize;
}
 
/**
* Returns the combo's paging tool bar.
*
* @return the tool bar
*/
public PagingToolBar getPagingToolBar() {
return pageTb;
}
 
@Override
public ListModelPropertyEditor<D> getPropertyEditor() {
return (ListModelPropertyEditor<D>) propertyEditor;
}
 
/**
* Returns the query delay.
*
* @return the query delay
*/
public int getQueryDelay() {
return queryDelay;
}
 
/**
* Returns the selected style.
*
* @return the selected style
*/
public String getSelectedStyle() {
return selectedStyle;
}
 
/**
* Returns the combo's store.
*
* @return the store
*/
public ListStore<D> getStore() {
return store;
}
 
/**
* Returns the custom template.
*
* @return the template
*/
public XTemplate getTemplate() {
return template;
}
 
/**
* Returns the trigger action.
*
* @return the trigger action
*/
public TriggerAction getTriggerAction() {
return triggerAction;
}
 
/**
* Returns the type ahead delay in milliseconds.
*
* @return the type ahead delay
*/
public int getTypeAheadDelay() {
return typeAheadDelay;
}
 
/**
* Returns the value field name.
*
* @return the value field name
*/
public String getValueField() {
return valueField;
}
 
 
 
/**
* Returns <code>true</code> if the panel is expanded.
*
* @return the expand state
*/
public boolean isExpanded() {
return expanded;
}
 
/**
* Returns true if lazy rendering is enabled.
*
* @return true of lazy rendering
*/
public boolean isLazyRender() {
return lazyRender;
}
 
/**
* Returns true if type ahead is enabled.
*
* @return the type ahead state
*/
public boolean isTypeAhead() {
return typeAhead;
}
 
/**
* Returns the state if the query cache is used or not.
*
* @return the useQueryCache state
*/
public boolean isUseQueryCache() {
return useQueryCache;
}
 
public void removeSelectionListener(SelectionChangedListener<D> listener) {
removeListener(Events.SelectionChange, listener);
}
 
@Override
public void reset() {
getStore().clearFilters();
boolean f = forceSelection;
forceSelection = false;
super.reset();
forceSelection = f;
}
 
public void select(D sel) {
if (listView != null && sel != null) {
int index = store.indexOf(sel);
selectedItem = sel;
if (index < listView.getElements().size()) {
listView.getSelectionModel().select(sel, false);
fly(listView.getElement(index)).scrollIntoView(listView.getElement(), false);
}
}
}
 
/**
* Select an item in the dropdown list by its numeric index in the list. This
* function does NOT cause the select event to fire. The list must expanded
* for this function to work, otherwise use #setValue.
*
* @param index the index of the item to select
*/
public void select(int index) {
select(store.getAt(index));
}
 
/**
* The text query to send to the server to return all records for the list
* with no filtering (defaults to '').
*
* @param allQuery the all query
*/
public void setAllQuery(String allQuery) {
this.allQuery = allQuery;
}
 
/**
* The underlying data field name to bind to this ComboBox (defaults to
* 'text').
*
* @param displayField the display field
*/
public void setDisplayField(String displayField) {
getPropertyEditor().setDisplayProperty(displayField);
}
 
/**
* Sets the panel's expand state.
*
* @param expand <code>true<code> true to expand
*/
public void setExpanded(boolean expand) {
this.expanded = expand;
if (isRendered()) {
if (expand) {
expand();
} else {
collapse();
}
}
}
 
/**
* Sets whether the combo's value is restricted to one of the values in the
* list, false to allow the user to set arbitrary text into the field
* (defaults to false).
*
* @param forceSelection true to force selection
*/
public void setForceSelection(boolean forceSelection) {
this.forceSelection = forceSelection;
}
 
/**
* This setting is required if a custom XTemplate has been specified.
*
* @param itemSelector the item selector
*/
public void setItemSelector(String itemSelector) {
this.itemSelector = itemSelector;
}
 
/**
* True to lazily render the combo's drop down list (default to true,
* pre-render).
*
* @param lazyRender true to lazy render the drop down list
*/
public void setLazyRender(boolean lazyRender) {
this.lazyRender = lazyRender;
}
 
/**
* Sets a valid anchor position value. See {@link El#alignTo} for details on
* supported anchor positions (defaults to 'tl-bl?').
*
* @param listAlign the new list align value
*/
public void setListAlign(String listAlign) {
this.listAlign = listAlign;
}
 
/**
* Sets the style for the drop down list (defaults to 'x-combo-list');
*
* @param listStyle the list style
*/
public void setListStyle(String listStyle) {
this.listStyle = listStyle;
}
 
/**
* Sets the loading text.
*
* @param loadingText the loading text
*/
public void setLoadingText(String loadingText) {
getMessages().setLoadingText(loadingText);
}
 
/**
* Sets the maximum height in pixels of the dropdown list before scrollbars
* are shown (defaults to 300).
*
* @param maxHeight the max hieght
*/
public void setMaxHeight(int maxHeight) {
this.maxHeight = maxHeight;
}
 
/**
* Sets the minimum number of characters the user must type before
* autocomplete and typeahead active (defaults to 4 if remote, or 0 if local).
*
* @param minChars
*/
public void setMinChars(int minChars) {
this.minChars = minChars;
}
 
/**
* Sets the minimum width of the dropdown list in pixels (defaults to 70, will
* be ignored if listWidth has a higher value).
*
* @param minListWidth the min width
*/
public void setMinListWidth(int minListWidth) {
this.minListWidth = minListWidth;
}
 
/**
* Sets the page size. Only applies when using a paging toolbar.
*
* @param pageSize the page size
*/
public void setPageSize(int pageSize) {
assertPreRender();
this.pageSize = pageSize;
if (pageSize > 0) {
if (pageTb != null) {
pageTb.setPageSize(pageSize);
} else {
pageTb = new PagingToolBar(pageSize);
}
} else {
pageTb = null;
}
}
 
@Override
public void setPropertyEditor(PropertyEditor<D> propertyEditor) {
assert propertyEditor instanceof ListModelPropertyEditor<?> : "PropertyEditor must be a ListModelPropertyEditor instance";
super.setPropertyEditor(propertyEditor);
}
 
/**
* The length of time in milliseconds to delay between the start of typing and
* sending the query to filter the dropdown list.
*
* @param queryDelay the query delay
*/
public void setQueryDelay(int queryDelay) {
this.queryDelay = queryDelay;
}
 
@Override
public void setRawValue(String text) {
if (rendered) {
if (text == null) {
String msg = getMessages().getValueNoutFoundText();
text = msg != null ? msg : "";
}
getInputEl().setValue(text);
}
}
 
/**
* Sets the CSS style name to apply to the selected item in the dropdown list
* (defaults to 'x-combo-selected').
*
* @param selectedStyle the selected style
*/
public void setSelectedStyle(String selectedStyle) {
this.selectedStyle = selectedStyle;
}
 
/**
* Sets the template fragment to be used for the text of each combo list item.
*
* <pre>
*
* &lt;code&gt; combo.setSimpleTemplate(&quot;{abbr} {name}&quot;); &lt;/code&gt;
*
* </pre>
*
* @param html the html used only for the text of each item in the list
*/
public void setSimpleTemplate(String html) {
assertPreRender();
html = "<tpl for=\".\"><div class=x-combo-list-item>" + html + "</div></tpl>";
template = XTemplate.create(html);
}
 
/**
* Sets the combo's store.
*
* @param store the store
*/
public void setStore(ListStore<D> store) {
this.store = store;
}
 
/**
* Sets the custom template used to render the combo's drop down list.Use this
* to create custom UI layouts for items in the list.
* <p>
* If you wish to preserve the default visual look of list items, add the CSS
* class name 'x-combo-list-item' to the template's container element.
*
* @param html the html
*/
public void setTemplate(String html) {
assertPreRender();
template = XTemplate.create(html);
}
 
/**
* Sets the custom template used to render the combo's drop down list.
*
* @param template the template
*/
public void setTemplate(XTemplate template) {
assertPreRender();
this.template = template;
}
 
/**
* The action to execute when the trigger field is activated. Use
* {@link TriggerAction#ALL} to run the query specified by the allQuery config
* option (defaults to {@link TriggerAction#QUERY}).
*
* @param triggerAction the trigger action
*/
public void setTriggerAction(TriggerAction triggerAction) {
this.triggerAction = triggerAction;
}
 
/**
* True to populate and autoselect the remainder of the text being typed after
* a configurable delay ({@link #typeAheadDelay}) if it matches a known value
* (defaults to false)
*
* @param typeAhead
*/
public void setTypeAhead(boolean typeAhead) {
this.typeAhead = typeAhead;
if (rendered) {
if (typeAhead && taTask == null) {
taTask = new DelayedTask(new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
onTypeAhead();
}
});
} else if (!typeAhead && taTask != null) {
taTask.cancel();
taTask = null;
}
}
}
 
/**
* The length of time in milliseconds to wait until the typeahead text is
* displayed if typeAhead = true (defaults to 250).
*
* @param typeAheadDelay the type ahead delay
*/
public void setTypeAheadDelay(int typeAheadDelay) {
this.typeAheadDelay = typeAheadDelay;
}
 
/**
* Set this to false to disable the last query cache (defaults to true).
*
* When set to false the store gets queried on each expand for the data that
* should get displayed in the list. If you use a loader, than each time the
* ComboBox gets expanded, the server gets asked for the data.
*
* You want to do this for example, if you filter the content of this ComboBox
* against some selection in another field.
*
* @param useQueryCache the useQueryCache to set
*/
public void setUseQueryCache(boolean useQueryCache) {
this.useQueryCache = useQueryCache;
}
 
/**
* Sets the model field used to retrieve the "value" from the model. If
* specified, a hidden form field will contain the value. The hidden form
* field name will be the combo's field name plus "-hidden".
*
* @param valueField the value field name
*/
public void setValueField(String valueField) {
this.valueField = valueField;
}
 
protected void collapseIf(PreviewEvent pe) {
if (!list.el().isOrHasChild(pe.getTarget()) && !el().isOrHasChild(pe.getTarget())) {
collapse();
}
}
 
protected D findModel(String property, String value) {
if (value == null) return null;
for (D model : store.getModels()) {
if (value.equals(getPropertyEditor().getStringValue(model))) {
return model;
}
}
return null;
}
 
protected void fireKey(FieldEvent fe) {
if (fe.isNavKeyPress() && !isExpanded() && !delayedCheck) {
fireEvent(Events.SpecialKey, fe);
}
}
 
@Override
protected El getFocusEl() {
return input;
}
 
protected PagingLoadConfig getParams(String query) {
BasePagingLoadConfig config = new BasePagingLoadConfig();
config.setLimit(pageSize);
config.setOffset(0);
config.set("query", query);
return config;
}
 
protected boolean hasFocus() {
return hasFocus || expanded;
}
 
@SuppressWarnings("unchecked")
protected void initComponent() {
storeListener = new StoreListener<D>() {
 
@Override
public void storeBeforeDataChanged(StoreEvent<D> se) {
onBeforeLoad(se);
}
 
@Override
public void storeDataChanged(StoreEvent<D> se) {
onLoad(se);
}
 
};
 
eventPreview = new BaseEventPreview() {
@Override
protected boolean onPreview(PreviewEvent pe) {
switch (pe.getType().getEventCode()) {
case Event.ONSCROLL:
case Event.ONMOUSEWHEEL:
case Event.ONMOUSEDOWN:
collapseIf(pe);
}
return true;
}
};
eventPreview.setAutoHide(false);
 
new KeyNav(this) {
public void onDown(ComponentEvent ce) {
ce.cancelBubble();
if (!isExpanded()) {
onTriggerClick(ce);
} else {
selectNext();
}
}
 
@Override
public void onEnter(ComponentEvent ce) {
if (expanded) {
ce.cancelBubble();
onViewClick(ce, false);
delayedCheck = true;
unsetDelayCheck();
}
}
 
@Override
public void onEsc(ComponentEvent ce) {
if (expanded) {
ce.cancelBubble();
collapse();
}
}
 
@Override
public void onTab(ComponentEvent ce) {
if (expanded) {
onViewClick(ce, false);
}
}
 
@Override
public void onUp(ComponentEvent ce) {
if (expanded) {
ce.cancelBubble();
selectPrev();
}
}
 
};
}
 
protected void onBeforeLoad(StoreEvent<D> se) {
if (!hasFocus()) {
return;
}
if (expanded) {
restrict();
}
}
 
@Override
protected void onDetach() {
collapse();
super.onDetach();
if (eventPreview != null) {
eventPreview.remove();
}
}
 
protected void onEmptyResults() {
collapse();
}
 
@Override
protected void onKeyDown(FieldEvent fe) {
if (fe.getKeyCode() == KeyCodes.KEY_TAB) {
if (expanded) {
onViewClick(fe, false);
}
}
super.onKeyDown(fe);
}
 
@Override
protected void onKeyUp(FieldEvent fe) {
super.onKeyUp(fe);
if (isEditable() && (!fe.isSpecialKey() || fe.getKeyCode() == KeyCodes.KEY_BACKSPACE || fe.getKeyCode() == 46)) {
// last key
dqTask.delay(queryDelay);
}
}
 
protected void onLoad(StoreEvent<D> se) {
if (!isAttached() || !hasFocus()) {
return;
}
if (store.getCount() > 0) {
if (expanded) {
restrict();
} else {
expand();
}
 
if (lastQuery != null && lastQuery.equals(allQuery)) {
if (isEditable()) {
selectAll();
}
} else {
if (typeAhead) {
taTask.delay(typeAheadDelay);
}
}
if (!selectByValue(getRawValue())) {
select(0);
}
} else {
onEmptyResults();
}
}
 
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
initList();
 
if (!autoComplete) {
getInputEl().dom.setAttribute("autocomplete", "off");
}
 
if (mode.equals("local")) {
minChars = 0;
}
 
dqTask = new DelayedTask(new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
initQuery();
}
});
 
if (valueField != null) {
hiddenInput = Document.get().createHiddenInputElement().cast();
hiddenInput.setName(getName() + "-hidden");
getElement().appendChild(hiddenInput);
}
 
if (typeAhead) {
taTask = new DelayedTask(new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
onTypeAhead();
}
});
}
eventPreview.getIgnoreList().add(getElement());
}
 
protected void onSelect(D model, int index) {
FieldEvent fe = new FieldEvent(this);
if (fireEvent(Events.BeforeSelect, fe)) {
setValue(model);
collapse();
fireEvent(Events.Select, fe);
}
}
 
protected void onTriggerClick(ComponentEvent ce) {
super.onTriggerClick(ce);
if (expanded) {
collapse();
} else {
onFocus(null);
if (triggerAction == TriggerAction.ALL) {
doQuery(allQuery, true);
} else {
doQuery(getRawValue(), true);
}
 
}
getInputEl().focus();
}
 
protected void onTypeAhead() {
if (store.getCount() > 0) {
D m = store.getAt(0);
String newValue = propertyEditor.getStringValue(m);
int len = newValue.length();
int selStart = getRawValue().length();
if (selStart != len) {
setRawValue(newValue);
select(selStart, newValue.length());
}
}
}
 
protected void onViewClick(DomEvent de, boolean focus) {
int idx = -1;
// when testing in selenium the items will not be selected as the mouse
// is not moved during the test
Element elem = listView.findElement(de.getTarget());
if (elem != null) {
idx = listView.indexOf(elem);
} else {
D sel = listView.getSelectionModel().getSelectedItem();
if (sel != null) {
idx = store.indexOf(sel);
}
}
if (idx != -1) {
D sel = store.getAt(idx);
onSelect(sel, idx);
}
 
if (focus) {
DeferredCommand.addCommand(new Command() {
public void execute() {
focus();
}
});
}
}
 
protected void onWindowResize(int width, int height) {
collapse();
}
 
@Override
protected void triggerBlur(ComponentEvent ce) {
doForce();
super.triggerBlur(ce);
}
 
protected void unsetDelayCheck() {
DeferredCommand.addCommand(new Command() {
public void execute() {
delayedCheck = false;
}
});
}
 
@Override
protected boolean validateBlur(DomEvent e, Element target) {
return list == null || (list != null && !list.isVisible() && !list.getElement().isOrHasChild(target));
}
 
@Override
protected boolean validateValue(String value) {
if (forceSelection) {
boolean f = forceSelection;
forceSelection = false;
if (getValue() == null) {
forceSelection = f;
String rv = getRawValue();
if (getAllowBlank() && (rv == null || rv.equals(""))) {
return true;
}
markInvalid(getMessages().getBlankText());
return false;
}
forceSelection = f;
}
return super.validateValue(value);
}
 
private void createList(boolean remove) {
RootPanel.get().add(list);
initialized = true;
if (remove) {
RootPanel.get().remove(list);
}
}
 
private void initQuery() {
doQuery(getRawValue(), false);
}
 
private void restrict() {
list.el().setVisibility(false);
listView.setHeight("auto");
list.setHeight("auto");
int w = Math.max(getWidth(), minListWidth);
 
int fh = footer != null ? footer.getHeight() : 0;
int fw = list.el().getFrameWidth("tb") + fh;
 
int h = listView.getHeight() + fw;
 
h = Math.min(h, maxHeight - fw);
list.setSize(w, h);
list.el().makePositionable(true);
list.el().alignTo(getElement(), listAlign, null);
 
h -= fh;
 
int width = w - list.el().getFrameWidth("lr");
listView.syncSize();
listView.setSize(width, h - list.el().getFrameWidth("tb"));
 
if (pageTb != null) {
pageTb.setWidth(width);
}
 
int y = list.el().getY();
int b = y + h;
int vh = XDOM.getViewportSize().height + XDOM.getBodyScrollTop();
if (b > vh) {
y = y - (b - vh) - 5;
list.el().setTop(y);
}
list.el().setVisibility(true);
}
 
private boolean selectByValue(String value) {
D r = findModel(getDisplayField(), value);
if (r != null) {
select(r);
return true;
}
return false;
}
 
private void selectNext() {
int count = store.getCount();
if (count > 0) {
int selectedIndex = store.indexOf(selectedItem);
if (selectedIndex == -1) {
select(0);
} else if (selectedIndex < count - 1) {
select(selectedIndex + 1);
}
}
}
 
private void selectPrev() {
int count = store.getCount();
if (count > 0) {
int selectedIndex = store.indexOf(selectedItem);
if (selectedIndex == -1) {
select(0);
} else if (selectedIndex != 0) {
select(selectedIndex - 1);
}
}
}
 
//+--------------------------------------------------------------------------------------------------------------------+
// Méthode modifiées
@Override
public D getValue() {
return (D) new BaseModelData();
}
 
@Override
public void setValue(D value) {
}
public List<D> getSelection() {
List<D> sel = new ArrayList<D>();
if (listeInitiale != null && initialisation == false) {
sel = listeInitiale;
if (listView.isRendered()) {
initialisation = true;
}
} else if (listView.isRendered()) {
sel = listView.getChecked();
}
return sel;
}
public void setSelection(List<D> selection) {
nettoyerListeDeCasesACocher();
for (D d : selection) {
listView.setChecked(d, true);
}
}
 
/**
* Returns the combo's list view.
*
* @return the view
*/
public CheckBoxListView<D> getListView() {
return listView;
}
/**
* Returns the combo's list view.
*
* @return the view
*/
public CheckBoxListView<D> getView() {
return listView;
}
/**
* Sets the combo's view.
*
* @param view the view
*/
public void setView(CheckBoxListView<D> view) {
this.listView = view;
}
public String getRawSeparator() {
return rawSeparator;
}
public void setRawSeparator(String rawSeparator) {
this.rawSeparator = rawSeparator;
}
public void setValueFieldSeparator(String valueFieldSeparator) {
this.valueFieldSeparator = valueFieldSeparator;
}
public String getValueFieldSeparator() {
return valueFieldSeparator;
}
/**
* Hides the dropdown list if it is currently expanded. Fires the
* <i>Collapse</i> event on completion.
*/
public void collapse() {
if (!expanded) {
return;
}
eventPreview.remove();
expanded = false;
list.hide();
RootPanel.get().remove(list);
fireEvent(Events.Collapse, new FieldEvent(this));
mettreAJour("collapse");
}
/**
* Expands the dropdown list if it is currently hidden. Fires the
* <i>expand</i> event on completion.
*/
public void expand() {
if (expanded || !hasFocus) {
return;
}
expanded = true;
if (!initialized) {
createList(false);
} else {
RootPanel.get().add(list);
}
list.show();
list.layout();
list.el().updateZIndex(0);
restrict();
 
eventPreview.add();
 
fireEvent(Events.Expand, new FieldEvent(this));
if (premierAppel) {
premierAppel = false;
collapse();
expand();
}
}
 
protected void initList() {
if (listView == null) {
setView(new CheckBoxListView<D>());
}
 
String style = getListStyle();
listView.setStyleAttribute("overflowX", "hidden");
listView.setStyleName(style + "-inner");
listView.setStyleAttribute("padding", "0px");
listView.setSelectOnOver(true);
listView.setBorders(false);
listView.setStyleAttribute("backgroundColor", "white");
listView.setSelectStyle(getSelectedStyle());
listView.setLoadingText(getLoadingText());
if (getTemplate() == null) {
listView.setDisplayProperty(getDisplayField());
} else {
listView.setTemplate(getTemplate());
}
setMaxHeight(0);
 
list = new LayoutContainer() {
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
eventPreview.getIgnoreList().add(getElement());
}
};
list.setScrollMode(Scroll.NONE);
list.setShim(true);
list.setShadow(true);
list.setBorders(true);
list.setStyleName(style);
list.hide();
assert store != null : "ComboBox needs a store";
 
list.add(listView);
listView.show();
if (!lazyRender) {
createList(true);
}
bindStore(store, true);
};
protected void doForce() {}
private void bindStore(ListStore<D> store, boolean initial) {
if (this.store != null && !initial) {
this.store.removeStoreListener(storeListener);
if (store == null) {
this.store = null;
if (listView != null) {
listView.setStore(null);
}
}
}
if (store != null) {
this.store = store;
if (store.getLoader() == null) {
mode = "local";
}
if (listView != null) {
listView.setStore(store);
}
store.addStoreListener(storeListener);
}
}
private void updateHiddenValue() {
if (hiddenInput != null) {
hiddenInput.setValue(collecterIdentifiants());
}
}
 
private void mettreAJour(String origine) {
setSelection(getSelection());
setRawValue(collecterTexte());
updateHiddenValue();
}
private void nettoyerListeDeCasesACocher() {
if (listView.isRendered()) {
List<D> listeADecocher = listView.getChecked();
for (D d : listeADecocher) {
listView.setChecked(d, false);
}
}
}
public void peupler(String identifiants) {
peuplerAvecIdentifiant(identifiants);
}
public void peuplerAvecIdentifiant(String identifiants) {
List<D> liste = parserChaine(identifiants, valueFieldSeparator, getValueField());
executerPeuplement(liste);
}
public void peuplerAvecTexte(String texte) {
List<D> liste = parserChaine(texte, rawSeparator, getDisplayField());
executerPeuplement(liste);
}
private void executerPeuplement(List<D> liste) {
listeInitiale = liste;
initialisation = false;
mettreAJour("executerPeuplement");
}
public String collecter() {
return collecterIdentifiants();
}
public String collecterIdentifiants() {
return executerCollecte(getSelection(), getValueField(), valueFieldSeparator);
}
public String collecterTexte() {
return executerCollecte(getSelection(), getDisplayField(), rawSeparator);
}
private String executerCollecte(List<D> selection, String champCle, String separateur) {
String chaineDeSortie = "";
Iterator<D> it = selection.iterator();
while (it.hasNext()) {
D d = it.next();
chaineDeSortie += d.get(champCle);
if (it.hasNext()) {
chaineDeSortie += separateur;
}
}
return chaineDeSortie;
}
private List<D> parserChaine(String chaineAAnalyser, String separateur, String champCle) {
ArrayList<D> liste = new ArrayList<D>();
chaineAAnalyser = chaineAAnalyser.trim();
if (!UtilString.isEmpty(chaineAAnalyser)) {
String[] valeurs = chaineAAnalyser.split(separateur);
int nbreValeurs = valeurs.length;
if (nbreValeurs > 0 && getStore() != null) {
for (int i = 0; i < nbreValeurs; i++) {
String valeur = valeurs[i];
D d = getStore().findModel(champCle, valeur);
liste.add(d);
}
}
}
return liste;
}
public String formaterTexteEnIdentifiants(String texte) {
List<D> liste = parserChaine(texte, rawSeparator, getDisplayField());
return executerCollecte(liste, getValueField(), valueFieldSeparator);
}
public String formaterIdentifiantsEnTexte(String identifiants) {
List<D> liste = parserChaine(identifiants, valueFieldSeparator, getValueField());
return executerCollecte(liste, getDisplayField(), rawSeparator);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampComboBoxMultiSelect.java:r1136-1367
Merged /trunk/src/org/tela_botanica/client/composants/ChampComboBoxMultiSelect.java:r11-1028,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampComboBoxMultiSelect.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/GrilleParametrable.java
New file
0,0 → 1,7
package org.tela_botanica.client.composants;
 
public interface GrilleParametrable<D> {
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/IdentificationFenetre.java
New file
0,0 → 1,189
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
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.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
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.SelectionListener;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.Status;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.google.gwt.event.dom.client.KeyCodes;
 
public class IdentificationFenetre extends Dialog implements Rafraichissable {
private Mediateur mediateur = null;
private Constantes i18nC = null;
protected TextField<String> login = null;
protected TextField<String> motDePasse = null;
protected Button validerBouton = null;
private Button annulerBouton = null;
protected Status status = null;
private String zoneInfoTpl = null;
private HtmlContainer zoneInfoHtml = null;
 
public IdentificationFenetre(Mediateur mediateurCourrant) {
mediateur = mediateurCourrant;
i18nC = Mediateur.i18nC;
initialiserSquelettes();
FormLayout layout = new FormLayout();
layout.setLabelWidth(110);
layout.setDefaultWidth(220);
setLayout(layout);
 
setButtonAlign(HorizontalAlignment.RIGHT);
setButtons("");
setIcon(Images.ICONES.utilisateur());
setHeadingHtml(Registry.get(RegistreId.APPLI_NOM)+" - "+i18nC.identificationTitre());
setModal(true);
setBodyBorder(true);
setBodyStyle("padding: 10px;background: none");
setWidth(450);
setResizable(false);
setAutoWidth(false);
KeyListener keyListener = new KeyListener() {
public void componentKeyUp(ComponentEvent event) {
valider();
}
@SuppressWarnings("unchecked")
public void componentKeyPress(ComponentEvent evenement) {
if (evenement.getKeyCode() == KeyCodes.KEY_ENTER) {
TextField<String> champ = (TextField<String>) evenement.getSource();
if (champ.getFieldLabel().equals(i18nC.motDePasse())) {
validerBouton.fireEvent(Events.Select);
}
}
}
};
 
zoneInfoHtml = new HtmlContainer();
zoneInfoHtml.hide();
add(zoneInfoHtml);
login = new TextField<String>();
login.setMinLength(4);
login.setFieldLabel(i18nC.login());
login.addKeyListener(keyListener);
add(login);
 
motDePasse = new TextField<String>();
motDePasse.setMinLength(4);
motDePasse.setPassword(true);
motDePasse.setFieldLabel(i18nC.motDePasse());
motDePasse.addKeyListener(keyListener);
add(motDePasse);
 
setFocusWidget(login);
}
private void initialiserSquelettes() {
zoneInfoTpl = "<div id='"+ComposantId.DIV_IDENTIFICATION_MSG+"'>{0}</div>";
}
@Override
protected void createButtons() {
super.createButtons();
// FIXME : l'instanciation dans le constructeur ne marche pas pour cette méthode...
i18nC = Mediateur.i18nC;
status = new Status();
status.setBusy(i18nC.identificationVerification());
status.hide();
status.setAutoWidth(true);
getButtonBar().add(status);
getButtonBar().add(new FillToolItem());
validerBouton = new Button(i18nC.valider());
validerBouton.disable(); // Par défaut : dois être en mode disable
validerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
onSubmit();
}
});
annulerBouton = new Button(i18nC.annuler());
annulerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
hide();
}
});
addButton(annulerBouton);
addButton(validerBouton);
}
 
protected void onSubmit() {
status.show();
getButtonBar().disable();
mediateur.connecterUtilisateur(login.getValue(), motDePasse.getValue());
}
 
protected boolean avoirValeur(TextField<String> field) {
return field.getValue() != null && field.getValue().length() > 0;
}
 
protected void valider() {
validerBouton.setEnabled(avoirValeur(login) && avoirValeur(motDePasse) && motDePasse.getValue().length() > 3);
}
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_utilisateur")) {
Utilisateur utilisateurCourant = mediateur.getUtilisateur();
if (!utilisateurCourant.isIdentifie() || !utilisateurCourant.avoirLicenceAcceptee()) {
// Licence n'a jamais été acceptée
if (utilisateurCourant.getLicence().equals("")) {
afficherErreur(i18nC.identificationMauvaise());
// NON à la licence
} else if (utilisateurCourant.getLicence().equals("0")){
afficherErreur(i18nC.licenceAccepter());
mediateur.afficherFenetreLicence(this);
// Cas inconnu
} else {
hide();
}
} else {
hide();
}
}
} else {
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()));
}
}
public void afficherErreur(String erreur) {
status.hide();
getButtonBar().enable();
valider();
zoneInfoHtml.setHtml(Format.substitute(zoneInfoTpl, (new Params()).add(erreur)));
zoneInfoHtml.show();
layout();
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/IdentificationFenetre.java:r1136-1367
Merged /trunk/src/org/tela_botanica/client/composants/IdentificationFenetre.java:r11-59,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/IdentificationFenetre.java:r1383-1511
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampMultiValeurs.java
New file
0,0 → 1,414
package org.tela_botanica.client.composants;
 
import java.util.HashMap;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.event.ButtonEvent;
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.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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.Field;
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.TextField;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
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.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
 
public class ChampMultiValeurs extends LayoutContainer {
//TODO : changer le champRecapitulatif par une hashMap
//TODO : autoriser la modification des champs saisis
 
String idChampCache = null;
String nomLabelChampTxt = "";
String titreErreur = null;
String valeurVideMsg = null;
String valeurIdentiqueMsg = null;
String valeurNonValideMsg = null;
String valeurParDefaut = "";
String validationMasque = null;
String exempleValidation = null;
String boutonSupprimerLabel = "";
LayoutContainer principalLayout = null;
Field<String> champValeurTxt = null;
ComboBox<Valeur> champValeurCombo = null;
HiddenField<String> champRecapitulatif = null;
HashMap<String, LayoutContainer> valeurs = null;
ComboBox<Valeur> types = null;
int largeurTotale = 420;
int largeurBouton = 20;
int largeurChamp = 0;
int largeurType = 0;
boolean estMultiType = false;
boolean estComboBox = false;
public ChampMultiValeurs() {
initialiserChampMultiValeur(null, 0);
}
public ChampMultiValeurs(String label) {
initialiserChampMultiValeur(label, 0);
}
public ChampMultiValeurs(String label, int largeurTotale) {
initialiserChampMultiValeur(label, largeurTotale);
}
public ChampMultiValeurs(boolean estMultiType, String label, int largeurTotale, int largeurType) {
this.estMultiType = estMultiType;
initialiserChampMultiValeur(label, largeurTotale);
}
public ChampMultiValeurs(boolean estCombobox, boolean estMultiType, String label, int largeurTotale, int largeurType) {
this.estMultiType = estMultiType;
this.estComboBox = estCombobox;
setLargeurType(largeurType);
initialiserChampMultiValeur(label, largeurTotale);
}
public ComboBox<Valeur> getTypes() {
return this.types;
}
public void setLabel(String label) {
if (label == null) {
label = "";
}
nomLabelChampTxt = label;
}
public void setLargeurChamp(int largeurMax) {
if (largeurMax != 0 && largeurMax > 20) {
largeurTotale = largeurMax;
}
largeurChamp = largeurTotale - largeurBouton;
}
public void setLargeurType(int largeur) {
largeurType = largeur;
}
public void setValidation (String validation, String exempleValidation) {
this.validationMasque = validation;
this.exempleValidation = exempleValidation;
this.valeurNonValideMsg = Mediateur.i18nM.valeurNonValideMsg(exempleValidation);
}
public void setValeurParDefaut(String valeur) {
this.valeurParDefaut = valeur;
champValeurTxt.setValue(valeur);
}
public void setValeurBoutonSupprimer(String valeur) {
this.boutonSupprimerLabel = valeur;
}
private void initialiserChampMultiValeur(String label, int largeur) {
setLabel(label);
setLargeurChamp(largeur);
titreErreur = Mediateur.i18nC.erreurSaisieTitre();
valeurVideMsg = Mediateur.i18nC.demanderValeur();
valeurIdentiqueMsg = Mediateur.i18nC.valeurDejaPresente();
valeurs = new HashMap<String, LayoutContainer>();
champRecapitulatif = new HiddenField<String>();
champRecapitulatif.setValue("");
setLayout(new FormLayout());
creerChampMultiValeurs();
}
private void creerChampMultiValeurs() {
principalLayout = new LayoutContainer();
principalLayout.setLayout(new RowLayout());
LabelField label = new LabelField(nomLabelChampTxt + ":");
label.setWidth("95%");
principalLayout.add(label);
LayoutContainer colonneConteneur = new LayoutContainer();
colonneConteneur.setLayout(new ColumnLayout());
if (estMultiType == true) {
types = new ComboBox<Valeur>();
types.setDisplayField("nom");
types.setEmptyText("Choisissez:");
types.setStore(new ListStore<Valeur>());
types.setTypeAhead(true);
types.setTriggerAction(TriggerAction.ALL);
types.addListener(Events.Select, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent fe) {
 
}
});
colonneConteneur.add(types, new ColumnData(largeurType));
}
if (estComboBox) {
champValeurCombo = new ComboBox<Valeur>();
champValeurCombo.setDisplayField("nom");
champValeurCombo.setStore(new ListStore<Valeur>());
colonneConteneur.add(champValeurCombo, new ColumnData(largeurChamp));
} else {
champValeurTxt = new TextField<String>();
colonneConteneur.add(champValeurTxt, new ColumnData(largeurChamp));
}
Button ajouterBouton = new Button();
ajouterBouton.setIcon(Images.ICONES.ajouter());
ajouterBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
surAjoutValeur(true);
}
});
colonneConteneur.add(ajouterBouton, new ColumnData(largeurBouton));
principalLayout.add(champRecapitulatif);
principalLayout.add(colonneConteneur);
add(principalLayout);
}
private void surAjoutValeur(boolean validerChamp) {
String valeurChamp = "";
if (estComboBox) {
if (champValeurCombo.getValue() != null) {
valeurChamp = champValeurCombo.getValue().getId();
}
} else {
valeurChamp = champValeurTxt.getValue();
}
if ((valeurChamp == null) || valeurChamp.trim().equals("") || valeurChamp.trim().equals(valeurParDefaut)) {
if(validerChamp) {
MessageBox.alert(titreErreur, valeurVideMsg, null);
}
} else if (valeurs.get(valeurChamp) != null) {
if(validerChamp) {
MessageBox.alert(titreErreur, valeurIdentiqueMsg, null);
}
} else {
if (validationMasque != null && !valeurChamp.matches(validationMasque)) {
if(validerChamp) {
MessageBox.alert(titreErreur, valeurNonValideMsg, null);
}
} else {
if (estMultiType) {
String type = "";
String id = "";
Valeur valeur = types.getValue();
if (valeur != null) {
type = valeur.getNom();
id = valeur.getId();
} else {
type = types.getRawValue();
id = type;
}
if (type.trim().equals("")) {
MessageBox.alert(Mediateur.i18nM.titreErreurSaisie(), Mediateur.i18nM.typeChampMulti(), null);
} else {
ajouterValeur(valeurChamp, type, id);
}
} else {
ajouterValeur(valeurChamp);
}
}
}
}
//TODO: la fonction est valide et la fonction surAjoutValeur ont beaucoup en commun
// voir si on peut les factoriser (ou déplacer les alertes dans les classes appelantes)
public boolean estValide(boolean autoriserVide) {
boolean valide = true;
String valeurChamp = "";
if (estComboBox) {
if (champValeurCombo.getValue() != null) {
valeurChamp = champValeurCombo.getValue().getId();
}
} else {
valeurChamp = champValeurTxt.getValue();
}
if ((valeurChamp == null) || valeurChamp.trim().equals("") || valeurChamp.trim().equals(valeurParDefaut)) {
if(!autoriserVide) {
valide = false;
}
} else if (valeurs.get(valeurChamp) != null) {
if(!autoriserVide) {
valide = false;
}
} else {
if (validationMasque != null && !valeurChamp.matches(validationMasque)) {
valide = false;
} else {
if (estMultiType) {
String type = "";
String id = "";
Valeur valeur = types.getValue();
if (valeur != null) {
type = valeur.getNom();
id = valeur.getId();
} else {
type = types.getRawValue();
id = type;
}
if (type.trim().equals("")) {
valide = false;
}
}
}
}
return valide;
}
public void ajouterValeur(final String texte, final String strValeur, final String id) {
//Implémenté dans classe inférieure
}
public void ajouterValeur(final String texte) {
LayoutContainer colonneLayout = new LayoutContainer();
colonneLayout.setLayout(new ColumnLayout());
valeurs.put(texte, colonneLayout);
Text champTxt = new Text();
champTxt.setText(texte);
colonneLayout.add(champTxt, new ColumnData(largeurChamp));
Button supprimerBouton = new Button();
supprimerBouton.setIcon(Images.ICONES.supprimer());
supprimerBouton.setText(boutonSupprimerLabel);
supprimerBouton.setData("valeur", texte);
supprimerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String valeur = ce.getComponent().getData("valeur");
LayoutContainer valeurLayout = valeurs.get(valeur);
principalLayout.remove(valeurLayout);
valeurs.remove(valeur);
 
supprimerValeurDuRecapitulatif(valeur);
actualiserLayoutGlobal();
}
});
colonneLayout.add(supprimerBouton, new ColumnData(largeurBouton));
// Ajout du layout de la valeur au layout principal
principalLayout.add(colonneLayout);
// Ajout de la valeur au champ récapitulatif des valeurs ajoutées
ajouterValeurAuRecapitulatif(texte);
reinitialiserChamp();
actualiserLayoutGlobal();
}
public void reinitialiserChamp() {
if (estComboBox) {
champValeurCombo.setValue(champValeurCombo.getStore().findModel("id_valeur", valeurParDefaut));
} else {
champValeurTxt.setValue(valeurParDefaut);
}
if (estMultiType) {
types.reset();
}
}
public void actualiserLayoutGlobal() {
layout();
}
public void ajouterValeurAuRecapitulatif(String texte) {
String texteRecapitulatif = "";
if (champRecapitulatif.getValue() != null) {
texteRecapitulatif = champRecapitulatif.getValue();
}
texteRecapitulatif += texte + aDonnee.SEPARATEUR_VALEURS;
champRecapitulatif.setValue(texteRecapitulatif);
}
public void supprimerValeurDuRecapitulatif(String texte) {
 
if (champRecapitulatif.getValue() != null) {
String texteValeur = "";
if (estComboBox) {
// comme c'est le nom de la valeur qui est passée en paramètre,
// on doit récupérer son id
ListStore<Valeur> valeurs = champValeurCombo.getStore();
Valeur objetValeur = valeurs.findModel("nom", texte);
if (objetValeur != null) {
texteValeur = objetValeur.getId();
} else {
texteValeur = texte;
}
} else {
texteValeur = texte;
}
String texteRecapitulatif = champRecapitulatif.getValue();
texteRecapitulatif = texteRecapitulatif.replace(texteValeur + aDonnee.SEPARATEUR_VALEURS, "");
champRecapitulatif.setValue(texteRecapitulatif);
}
}
public String getValeurs() {
// permet de s'assurer qu'une valeur saisie dans le champ mais non ajoutée par le
// clic sur le + soit bien prise en compte
surAjoutValeur(false);
String texteRecapitulatif = "";
if (champRecapitulatif.getValue() != null) {
texteRecapitulatif = champRecapitulatif.getValue();
texteRecapitulatif = texteRecapitulatif.replaceAll("(.*)"+aDonnee.SEPARATEUR_VALEURS+"$", "$1");
}
return texteRecapitulatif;
}
public void peupler(String chaineExistante) {
if (valeurs.size()>0) {
reinitialiser();
}
if (chaineExistante != null && !chaineExistante.trim().equals("")) {
String[] valeurs = chaineExistante.split(aDonnee.SEPARATEUR_VALEURS);
for (int i = 0; i < valeurs.length; i++) {
ajouterValeur(valeurs[i]);
}
}
}
public void reinitialiser() {
//TODO : pourrait etre mieux fait si les valeurs étaient enregistrées dans un
// layout particulier. Il suffirait alors d'enlever les valeurs de ce layout.
principalLayout.removeAll();
initialiserChampMultiValeur(nomLabelChampTxt, largeurTotale);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampMultiValeurs.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampMultiValeurs.java:r1136-1367
Merged /trunk/src/org/tela_botanica/client/composants/ChampMultiValeurs.java:r11-664,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypes.java
New file
0,0 → 1,175
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
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.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.vues.Formulaire;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Text;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
 
public class ChampMultiValeursMultiTypes extends ChampMultiValeurs implements Rafraichissable {
 
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
private String idListeType = null;
private String idListeCombo = null;
public ChampMultiValeursMultiTypes() {
super(false, true, null, 0, 0);
}
public ChampMultiValeursMultiTypes(String label) {
super(false, true, label, 0, 0);
}
public ChampMultiValeursMultiTypes(String label, int largeurTotale, int largeurType) {
super(false, true, label, largeurTotale, largeurType);
}
public ChampMultiValeursMultiTypes(String label, int largeurTotale, boolean combobox) {
super(true, true, label, largeurTotale, largeurTotale);
}
public ChampMultiValeursMultiTypes(String label, int largeurTotale, int largeurType, boolean combobox) {
super(true, true, label, largeurTotale, largeurType);
}
public void initialiserType(String idListe) {
initialiserType(idListe, null);
}
public void initialiserType(String idListe, Sequenceur sequenceur) {
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
idListeType = idListe;
mediateur.obtenirListeValeurEtRafraichir(this, idListeType, sequenceur);
}
public void initialiserCombobox(String idListe) {
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
this.idListeCombo = idListe;
mediateur.obtenirListeValeurEtRafraichir(this, idListeCombo, null);
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
if (listeValeurs.getId().equals(config.getListeId(idListeType))) {
Formulaire.rafraichirComboBox(listeValeurs, types);
} else if (listeValeurs.getId().equals(config.getListeId(idListeCombo))) {
Formulaire.rafraichirComboBox(listeValeurs, champValeurCombo, "id_valeur");
}
}
}
public void ajouterValeur(final String texte, final String type, final String id) {
LayoutContainer colonneConteneur = new LayoutContainer();
colonneConteneur.setLayout(new ColumnLayout());
valeurs.put(id + aDonnee.SEPARATEUR_TYPE_VALEUR + texte, colonneConteneur);
Text champType = new Text();
champType.setText(type + " : ");
champType.setWidth(largeurType);
colonneConteneur.add(champType, new ColumnData(largeurType));
// on recupere le nom de la valeur à partir de son id
 
String texteValeur = texte;
if (estComboBox) {
ListStore<Valeur> valeursStore = champValeurCombo.getStore();
Valeur objetValeur = valeursStore.findModel("id_valeur", texte);
if (objetValeur != null) {
texteValeur = objetValeur.getNom();
}
}
Text champValeur = new Text();
champValeur.setText(texteValeur);
champValeur.setWidth(largeurChamp);
colonneConteneur.add(champValeur, new ColumnData(largeurChamp));
Button supprimerBouton = new Button();
supprimerBouton.setIcon(Images.ICONES.supprimer());
supprimerBouton.setText(boutonSupprimerLabel);
supprimerBouton.setData("valeur", id + aDonnee.SEPARATEUR_TYPE_VALEUR + texte);
supprimerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String valeur = ce.getComponent().getData("valeur");
LayoutContainer valeurLayout = valeurs.get(valeur);
principalLayout.remove(valeurLayout);
valeurs.remove(valeur);
supprimerValeurDuRecapitulatif(valeur);
actualiserLayoutGlobal();
}
});
colonneConteneur.add(supprimerBouton, new ColumnData(largeurBouton));
// Ajout du layout de la valeur au layout principal
principalLayout.add(colonneConteneur);
// Ajout de la valeur au champ récapitulatif des valeurs ajoutées
if (estComboBox && champValeurCombo.getValue() != null) {
ajouterValeurAuRecapitulatif(champValeurCombo.getValue().getId(), id);
} else {
ajouterValeurAuRecapitulatif(texte, id);
}
reinitialiserChamp();
actualiserLayoutGlobal();
}
public void ajouterValeurAuRecapitulatif(String texte, String id) {
String texteRecapitulatif = "";
if (champRecapitulatif.getValue() != null) {
texteRecapitulatif = champRecapitulatif.getValue();
}
texteRecapitulatif += id + aDonnee.SEPARATEUR_TYPE_VALEUR + texte + aDonnee.SEPARATEUR_VALEURS;
champRecapitulatif.setValue(texteRecapitulatif);
}
public void peupler(String chaineExistante) {
 
if (valeurs.size() > 0) {
reinitialiser();
}
if (chaineExistante != null && !chaineExistante.trim().equals("")) {
String[] valeurs = chaineExistante.split(aDonnee.SEPARATEUR_VALEURS);
for (int i = 0; i < valeurs.length; i++) {
String[] idEtValeur = valeurs[i].split(aDonnee.SEPARATEUR_TYPE_VALEUR);
if (idEtValeur.length == 2) {
String idType = idEtValeur[0];
String idValeur = idEtValeur[1];
ListStore<Valeur> typeStore = types.getStore();
Valeur objetType = typeStore.findModel("id_valeur", idType);
String texteType = "";
if (objetType != null) {
texteType = objetType.getNom();
} else {
texteType = idType;
}
 
ajouterValeur(idValeur, texteType, idType);
} else {
InfoLogger.display("ChampMultiValeursMultiTypes > méthode peupler", "Erreur dans le split d'une valeur, chaine="+chaineExistante, true);
}
}
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypes.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypes.java:r1136-1367
Merged /trunk/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypes.java:r11-720,1209-1382
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampFiltreRecherche.java
New file
0,0 → 1,102
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.ListePaginable;
 
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
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.TextField;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.event.dom.client.KeyCodes;
 
public class ChampFiltreRecherche {
private ListePaginable listePaginable;
private Mediateur mediateur;
private ToolBar parent;
private TextField<String> filtre;
private Button annulerFiltre;
private boolean filtreActive = false;
private String termeRecherche = "";
private Text labelFiltre;
 
public ChampFiltreRecherche(Mediateur mediateur, ToolBar parent, ListePaginable listePaginable) {
//Séparation
this.mediateur = mediateur;
this.parent = parent;
this.listePaginable = listePaginable;
parent.add(new SeparatorToolItem());
labelFiltre = new Text("Recherche : ");
labelFiltre.setStyleAttribute("padding-right", "5px");
parent.add(labelFiltre);
filtre = new TextField<String>();
filtre.setWidth(150);
parent.add(filtre);
annulerFiltre = new Button();
annulerFiltre.setIcon(Images.ICONES.annuler());
annulerFiltre.setVisible(false);
parent.add(annulerFiltre);
parent.add(new FillToolItem());
ajouterListeners();
}
private void ajouterListeners() {
annulerFiltre.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
filtre.setValue("");
termeRecherche = "";
filtreActive = false;
listePaginable.filtrerParNom("");
labelFiltre.setStyleAttribute("font-weight", "normal");
changerEtat();
}
});
filtre.addKeyListener(new KeyListener(){
public void componentKeyUp(ComponentEvent ce) {
if (ce.getKeyCode() == KeyCodes.KEY_ENTER) {
termeRecherche = filtre.getValue();
if (termeRecherche == null || termeRecherche.equals("")) {
filtreActive = false;
labelFiltre.setStyleAttribute("font-weight", "normal");
termeRecherche= "";
listePaginable.filtrerParNom("");
changerEtat();
} else {
listePaginable.filtrerParNom(termeRecherche);
labelFiltre.setStyleAttribute("font-weight", "bold");
filtreActive = true;
changerEtat();
}
}
}
});
}
private void changerEtat() {
if (filtreActive == true) {
annulerFiltre.setVisible(true);
} else {
annulerFiltre.setVisible(false);
}
}
public void setListePaginable(ListePaginable listePaginable) {
this.listePaginable = listePaginable;
}
 
public String getFiltreValue() {
return filtre.getValue();
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampMultiValeursImage.java
New file
0,0 → 1,88
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.images.Images;
 
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.user.client.ui.Image;
 
public class ChampMultiValeursImage extends ChampMultiValeurs {
private String height, width;
private LayoutContainer sousContenu = null;
public ChampMultiValeursImage() {
super(null, 0);
initialiserSousContenu();
}
public ChampMultiValeursImage(String label) {
super(label, 0);
initialiserSousContenu();
}
public ChampMultiValeursImage(String label, int largeurTotale) {
super(label, largeurTotale);
initialiserSousContenu();
}
public void initialiserSousContenu() {
sousContenu = new LayoutContainer(new ColumnLayout());
principalLayout.add(sousContenu);
}
public void setImageHeight(String height) {
this.height = height;
}
public void setImageWidth(String width) {
this.width = width;
}
public void ajouterValeur(final String strUrl) {
LayoutContainer lcUrl = new LayoutContainer();
lcUrl.setLayout(new RowLayout());
valeurs.put(strUrl, lcUrl);
Image logo = new Image(strUrl);
logo.setTitle(strUrl);
if (height != null) {
logo.setHeight(height);
}
if (width != null) {
logo.setWidth(width);
}
lcUrl.add(logo);
Button supprimerBouton = new Button();
supprimerBouton.setIcon(Images.ICONES.supprimer());
supprimerBouton.setData("valeur", strUrl);
supprimerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String valeur = ce.getComponent().getData("valeur");
LayoutContainer valeurLayout = valeurs.get(valeur);
sousContenu.remove(valeurLayout);
valeurs.remove(valeur);
supprimerValeurDuRecapitulatif(valeur);
actualiserLayoutGlobal();
}
});
lcUrl.add(supprimerBouton);
// Ajout du layout de la valeur au layout principal
sousContenu.add(lcUrl);
// Ajout de la valeur au champ récapitulatif des valeurs ajoutées
ajouterValeurAuRecapitulatif(strUrl);
reinitialiserChamp();
actualiserLayoutGlobal();
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/ChampMultiValeursImage.java:r11-699,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampMultiValeursImage.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampMultiValeursImage.java:r1136-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypesPaginable.java
New file
0,0 → 1,265
package org.tela_botanica.client.composants;
 
import java.util.HashMap;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.pagination.Proxy;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
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 com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.ButtonEvent;
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.SelectionListener;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
 
public class ChampMultiValeursMultiTypesPaginable extends ChampMultiValeursPaginable implements Rafraichissable {
 
//-------------//
// ATTRIBUTS //
//-------------//
// Elements pour le champ 'types'
ColumnData colonneChampTypes = null;
ChampComboBoxRechercheTempsReelPaginable champTypesComboBox = null;
int largeurChampTypes = 200;
String displayNameChampTypes = "nom";
// Elements pour gérer le type de valeurs que contient le champ
Proxy proxyChampTypes = null;
ModelType modeltypeChampTypes = null;
 
// Variables de traitement
HashMap<Integer, String> tempMapValeurs = null;
//-------------//
// METHODES //
//-------------//
 
/*--------------
Constructeur
--------------*/
public ChampMultiValeursMultiTypesPaginable(String label, int largeurTotale, boolean estCombobox, ModelType modeltypeChampValeur, Proxy proxyChampValeur, String displayNameChampValeur, ModelType modeltypeChampTypes, Proxy proxyChampTypes, String displayNameChampTypes) {
super(label, largeurTotale, estCombobox, modeltypeChampValeur, proxyChampValeur, displayNameChampValeur);
this.proxyChampTypes = proxyChampTypes;
this.modeltypeChampTypes = modeltypeChampTypes;
this.displayNameChampTypes = displayNameChampTypes;
initialiserChampMultiValeursMultiTypesPaginable(label);
}
 
/*------------
Accesseurs
------------*/
//------------//
// Get //------------------------------------------------------------
public ChampComboBoxRechercheTempsReelPaginable getChampTypesComboBox() {
return this.champTypesComboBox;
}
//------------//
// Set //------------------------------------------------------------
@Override
public void setLargeurTotale(int largeurTotale) {
this.largeurTotale = largeurTotale;
largeurChampValeur = largeurTotale - largeurBouton - largeurChampTypes;
}
/*-------------------------------------------
Méthodes protégées et méthodes publiques
--------------------------------------------*/
@Override
public void rafraichir(Object nouvellesDonnees) {
super.rafraichir(nouvellesDonnees);
if (nouvellesDonnees instanceof ValeurListe) {
Valeur v = ((ValeurListe)nouvellesDonnees).toList().get(0);
ajouterValeur(tempMapValeurs.get(Integer.parseInt(v.getId())), v.getNom(), v.getId());
}
}
@Override
protected void ajouterValeur(final String texte, final String type, final String idType) {
LayoutContainer colonneConteneur = new LayoutContainer();
colonneConteneur.setLayout(new ColumnLayout());
valeurs.put(idType + aDonnee.SEPARATEUR_TYPE_VALEUR + texte, colonneConteneur);
Text champType = new Text();
champType.setText(type + " : ");
champType.setWidth(largeurChampTypes);
colonneConteneur.add(champType, new ColumnData(largeurChampTypes));
Text champValeur = new Text();
champValeur.setText(texte);
champValeur.setWidth(largeurChampTypes);
colonneConteneur.add(champValeur, new ColumnData(largeurChampTypes));
Button supprimerBouton = new Button();
supprimerBouton.setIcon(Images.ICONES.supprimer());
supprimerBouton.setText(boutonSupprimerLabel);
supprimerBouton.setData("valeur", idType + aDonnee.SEPARATEUR_TYPE_VALEUR + texte);
supprimerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String valeur = ce.getComponent().getData("valeur");
LayoutContainer valeurLayout = valeurs.get(valeur);
principalLayout.remove(valeurLayout);
valeurs.remove(valeur);
supprimerValeurDuRecapitulatif(valeur);
actualiserLayoutGlobal();
}
});
colonneConteneur.add(supprimerBouton, new ColumnData(largeurBouton));
// Ajout du layout de la valeur au layout principal
principalLayout.add(colonneConteneur);
// Ajout de la valeur au champ récapitulatif des valeurs ajoutées
ajouterValeurAuRecapitulatif(texte, idType);
reinitialiserChamp();
actualiserLayoutGlobal();
}
 
@Override
public void peupler(String chaineExistante) {
if (valeurs.size() > 0) {
reinitialiser();
}
if (chaineExistante != null && !chaineExistante.trim().equals("")) {
String[] valeurs = chaineExistante.split(aDonnee.SEPARATEUR_VALEURS);
for (int i = 0; i < valeurs.length; i++) {
String[] idEtValeur = valeurs[i].split(aDonnee.SEPARATEUR_TYPE_VALEUR);
if (idEtValeur.length == 2) {
String idType = idEtValeur[0];
String idValeur = idEtValeur[1];
// Champ Valeur
if (idType.matches("[0-9]+")) {
tempMapValeurs.put(Integer.parseInt(idType), idValeur);
} else {
tempMapValeurs.put(((Configuration)(Registry.get(RegistreId.CONFIG))).getListeId(idType), idValeur);
}
// Champ Types
mediateur.obtenirValeurEtRafraichir(this,"*", idType, null);
} else {
InfoLogger.display("Erreur", "ChampMultiValeursMultiTypesPaginable. Erreur dans le split de "+chaineExistante, true);
}
}
}
}
 
/*------------------
Méthodes privées
------------------*/
private void initialiserChampMultiValeursMultiTypesPaginable(String label) {
setLargeurTotale(largeurTotale);
tempMapValeurs = new HashMap<Integer,String>();
creerChampMultiValeursMultiTypes();
}
 
private void creerChampMultiValeursMultiTypes() {
/* Creation du champ Types */
champTypesComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyChampTypes, modeltypeChampTypes, displayNameChampTypes);
champTypesComboBox.setWidth(largeurChampTypes);
champTypesComboBox.getCombo().setEmptyText("Type...");
champTypesComboBox.addListener(Events.Select, new Listener<FieldEvent>() {
public void handleEvent(FieldEvent fe) {
 
}
});
 
/* Placement des éléments dans le conteneur */
// le champ "types" doit être graphiquement placé avant les autres champs,
// on doit donc retirer ces derniers avant d'insérer le champ "types"
colonneConteneur.removeAll();
colonneConteneur.setWidth(largeurTotale);
colonneChampTypes = new ColumnData(largeurChampTypes);
colonneChampTypes.setWidth(largeurChampTypes);
colonneConteneur.add(champTypesComboBox, colonneChampTypes);
if (champValeurEstComboBox) {
champValeurComboBox.setWidth(largeurChampValeur);
colonneChampValeur.setWidth(largeurChampValeur);
colonneConteneur.add(champValeurComboBox, colonneChampValeur);
} else {
champValeurTxt.setWidth(largeurChampValeur);
colonneChampValeur.setWidth(largeurChampValeur);
colonneConteneur.add(champValeurTxt, colonneChampValeur);
}
ajouterBouton.setWidth(largeurBouton);
colonneBoutonAjouter.setWidth(largeurBouton);
colonneConteneur.add(ajouterBouton, colonneBoutonAjouter);
 
/* Modification de l'écouteur du bouton Ajouter */
ajouterBouton.removeAllListeners();
ajouterBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
// récupération de la valeur du champ "Valeur"
String valeurChamp = "";
if (champValeurEstComboBox) {
if (champValeurComboBox.getValeur() != null) {
Valeur val = new Valeur(champValeurComboBox.getValeur());
valeurChamp = val.getNom();
}
} else {
valeurChamp = champValeurTxt.getValue();
}
// validation de la valeur avant ajout
if ((valeurChamp == null) || valeurChamp.trim().equals("") || valeurChamp.trim().equals(valeurParDefaut)) {
MessageBox.alert(titreErreur, valeurVideMsg, null);
} else if (valeurs.get(valeurChamp) != null){
MessageBox.alert(titreErreur, valeurIdentiqueMsg, null);
} else {
if (validationMasque != null && !valeurChamp.matches(validationMasque)) {
MessageBox.alert(titreErreur, valeurNonValideMsg, null);
} else { // VALIDATION OK
Valeur type = new Valeur(champTypesComboBox.getValeur());
String typeNomStr = type.getNom();
String typeIdStr = type.getId();
 
if (typeIdStr.trim().equals("")) {
MessageBox.alert(Mediateur.i18nM.titreErreurSaisie(), Mediateur.i18nM.typeChampMulti(), null);
} else {
ajouterValeur(valeurChamp, typeNomStr, typeIdStr);
}
}
}
}
});
}
private void ajouterValeurAuRecapitulatif(String texte, String id) {
String texteRecapitulatif = "";
if (champRecapitulatif.getValue() != null) {
texteRecapitulatif = champRecapitulatif.getValue();
}
texteRecapitulatif += id + aDonnee.SEPARATEUR_TYPE_VALEUR + texte + aDonnee.SEPARATEUR_VALEURS;
champRecapitulatif.setValue(texteRecapitulatif);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypesPaginable.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampMultiValeursMultiTypesPaginable.java:r1136-1208,1292-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampMultiValeursPaginable.java
New file
0,0 → 1,347
package org.tela_botanica.client.composants;
 
import java.util.HashMap;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.composants.pagination.Proxy;
import org.tela_botanica.client.composants.pagination.ProxyValeur;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Valeur;
import org.tela_botanica.client.modeles.aDonnee;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.event.ButtonEvent;
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.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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.Field;
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.TextField;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
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.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
 
public class ChampMultiValeursPaginable extends LayoutContainer implements Rafraichissable {
//TODO : changer le champRecapitulatif par une hashMap
//TODO : autoriser la modification des champs saisis
 
//-------------//
// ATTRIBUTS //
//-------------//
Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
String idChampCache = null;
String titreErreur = null;
String valeurVideMsg = null;
String valeurIdentiqueMsg = null;
String valeurNonValideMsg = null;
String valeurParDefaut = "";
String validationMasque = null;
String exempleValidation = null;
boolean champValeurEstComboBox = false;
 
// Elements pour le champ 'valeurs'
Field<String> champValeurTxt = null;
ChampComboBoxRechercheTempsReelPaginable champValeurComboBox = null;
HiddenField<String> champRecapitulatif = null;
HashMap<String, LayoutContainer> valeurs = null;
// Elements pour gérer le type de valeurs que contient le champ
Proxy proxyChampValeur = null;
ModelType modeltypeChampValeur = null;
String displayNameChampValeur = "nom";
// Elements pour l'UI
LayoutContainer principalLayout = null;
LayoutContainer colonneConteneur = null;
ColumnData colonneChampValeur = null;
ColumnData colonneBoutonAjouter = null;
Button ajouterBouton = null;
int largeurTotale = 500;
int largeurBouton = 20;
int largeurChampValeur = 200;
String boutonSupprimerLabel = "";
String nomLabelChampTxt = "";
 
 
//-------------//
// METHODES //
//-------------//
 
/*--------------
Constructeur
--------------*/
// Usage : Si champValeurEstComboBox est FAUX alors modeltype, proxy et displayName doivent être à Null.
// Sinon ils doivent impérativement être non nuls.
public ChampMultiValeursPaginable(String label, int largeurTotale, boolean champValeurEstComboBox, ModelType modeltype, Proxy proxy, String displayName) {
this.champValeurEstComboBox = champValeurEstComboBox;
if (champValeurEstComboBox) {
if ((proxy == null) || (modeltype == null) || (displayName == null)) {
MessageBox.alert("[ERREUR]","Constructeur de ChampMultiValeursPaginable - paramètre Null",null);
}
else {
this.proxyChampValeur = proxy;
this.modeltypeChampValeur = modeltype;
this.displayNameChampValeur = displayName;
}
}
initialiserChampMultiValeursPaginable(label, largeurTotale);
}
 
/*------------
Accesseurs
------------*/
//------------//
// Get //------------------------------------------------------------
public ChampComboBoxRechercheTempsReelPaginable getChampValeurComboBox() {
if (champValeurEstComboBox) return this.champValeurComboBox;
else return null;
}
 
public Field getChampValeurTxt() {
if (!champValeurEstComboBox) return this.champValeurTxt;
else return null;
}
public String getLabel() {
return this.nomLabelChampTxt;
}
public String getValeurs() {
String texteRecapitulatif = "";
if (champRecapitulatif.getValue() != null) {
texteRecapitulatif = champRecapitulatif.getValue();
texteRecapitulatif = texteRecapitulatif.replaceAll("(.*)"+aDonnee.SEPARATEUR_VALEURS+"$", "$1");
}
return texteRecapitulatif;
}
//------------//
// Set //------------------------------------------------------------
public void setLabel(String label) {
if (label == null) {
label = "";
}
nomLabelChampTxt = label;
}
public void setLargeurTotale(int largeur) {
this.largeurTotale = largeur;
largeurChampValeur = largeurTotale - largeurBouton;
}
public void setValidation (String validation, String exempleValidation) {
this.validationMasque = validation;
this.exempleValidation = exempleValidation;
this.valeurNonValideMsg = Mediateur.i18nM.valeurNonValideMsg(exempleValidation);
}
public void setValeurParDefaut(String valeur) {
this.valeurParDefaut = valeur;
champValeurTxt.setValue(valeur);
}
public void setValeurBoutonSupprimer(String valeur) {
this.boutonSupprimerLabel = valeur;
}
/*------------------
Méthodes publiques
-------------------*/
public void peupler(String chaineExistante) {
if (valeurs.size()>0) {
reinitialiser();
}
if (chaineExistante != null && !chaineExistante.trim().equals("")) {
String[] valeurs = chaineExistante.split(aDonnee.SEPARATEUR_VALEURS);
for (int i = 0; i < valeurs.length; i++) {
ajouterValeur(valeurs[i]);
}
}
}
public void rafraichir(Object nouvellesDonnees) {
}
/*-------------------
Méthodes protégées
--------------------*/
protected void ajouterValeur(final String texte, final String strValeur, final String id) {
//Implémenté dans classe inférieure
}
protected void ajouterValeur(final String texte) {
LayoutContainer colonneLayout = new LayoutContainer();
colonneLayout.setLayout(new ColumnLayout());
valeurs.put(texte, colonneLayout);
Text champTxt = new Text();
champTxt.setText(texte);
colonneLayout.add(champTxt, new ColumnData(largeurChampValeur));
Button supprimerBouton = new Button();
supprimerBouton.setIcon(Images.ICONES.supprimer());
supprimerBouton.setText(boutonSupprimerLabel);
supprimerBouton.setData("valeur", texte);
supprimerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
String valeur = ce.getComponent().getData("valeur");
LayoutContainer valeurLayout = valeurs.get(valeur);
principalLayout.remove(valeurLayout);
valeurs.remove(valeur);
supprimerValeurDuRecapitulatif(valeur);
actualiserLayoutGlobal();
}
});
colonneLayout.add(supprimerBouton, new ColumnData(largeurBouton));
// Ajout du layout de la valeur au layout principal
principalLayout.add(colonneLayout);
// Ajout de la valeur au champ récapitulatif des valeurs ajoutées
ajouterValeurAuRecapitulatif(texte);
reinitialiserChamp();
actualiserLayoutGlobal();
}
protected void reinitialiserChamp() {
if (champValeurEstComboBox) {
champValeurComboBox.getCombo().clear();
} else {
champValeurTxt.setValue(valeurParDefaut);
}
}
protected void actualiserLayoutGlobal() {
layout();
}
protected void ajouterValeurAuRecapitulatif(String texte) {
String texteRecapitulatif = "";
if (champRecapitulatif.getValue() != null) {
texteRecapitulatif = champRecapitulatif.getValue();
}
texteRecapitulatif += texte + aDonnee.SEPARATEUR_VALEURS;
champRecapitulatif.setValue(texteRecapitulatif);
}
protected void supprimerValeurDuRecapitulatif(String texte) {
if (champRecapitulatif.getValue() != null) {
String texteRecapitulatif = champRecapitulatif.getValue();
texteRecapitulatif = texteRecapitulatif.replace(texte + aDonnee.SEPARATEUR_VALEURS, "");
champRecapitulatif.setValue(texteRecapitulatif);
}
}
protected void reinitialiser() {
//TODO : pourrait etre mieux fait si les valeurs étaient enregistrées dans un
// layout particulier. Il suffirait alors d'enlever les valeurs de ce layout.
principalLayout.removeAll();
initialiserChampMultiValeursPaginable(nomLabelChampTxt, largeurTotale);
}
/*------------------
Méthodes privées
-------------------*/
private void initialiserChampMultiValeursPaginable(String label, int largeurTotale) {
setLabel(label);
setLargeurTotale(largeurTotale);
titreErreur = Mediateur.i18nC.erreurSaisieTitre();
valeurVideMsg = Mediateur.i18nC.demanderValeur();
valeurIdentiqueMsg = Mediateur.i18nC.valeurDejaPresente();
valeurs = new HashMap<String, LayoutContainer>();
champRecapitulatif = new HiddenField<String>();
champRecapitulatif.setValue("");
setLayout(new FormLayout());
creerChampMultiValeurs();
}
 
private void creerChampMultiValeurs() {
principalLayout = new LayoutContainer();
principalLayout.setLayout(new RowLayout());
/* Creation du champ Valeur */
LabelField label = new LabelField(nomLabelChampTxt + ":");
label.setWidth("95%");
principalLayout.add(label);
colonneConteneur = new LayoutContainer();
colonneConteneur.setLayout(new ColumnLayout());
colonneChampValeur = new ColumnData(largeurChampValeur);
if (champValeurEstComboBox) {
champValeurComboBox = new ChampComboBoxRechercheTempsReelPaginable(proxyChampValeur, modeltypeChampValeur, displayNameChampValeur);
champValeurComboBox.setWidth(largeurChampValeur);
champValeurComboBox.getCombo().setEmptyText("Valeur...");
colonneConteneur.add(champValeurComboBox, colonneChampValeur);
} else {
champValeurTxt = new TextField<String>();
champValeurTxt.setWidth(largeurChampValeur);
champValeurTxt.setEmptyText("Valeur...");
colonneConteneur.add(champValeurTxt, colonneChampValeur);
}
 
/* Creation du bouton Ajouter */
ajouterBouton = new Button();
ajouterBouton.setWidth(largeurBouton);
ajouterBouton.setIcon(Images.ICONES.ajouter());
ajouterBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
// récupération de la valeur du champ "Valeur"
String valeurChamp = "";
if (champValeurEstComboBox) {
if (champValeurComboBox.getValeur() != null) {
valeurChamp = (new Valeur(champValeurComboBox.getValeur())).getNom();
}
} else {
valeurChamp = champValeurTxt.getValue();
}
// validation de la valeur avant ajout
if ((valeurChamp == null) || valeurChamp.trim().equals("") || valeurChamp.trim().equals(valeurParDefaut)) {
MessageBox.alert(titreErreur, valeurVideMsg, null);
} else if (valeurs.get(valeurChamp) != null) {
MessageBox.alert(titreErreur, valeurIdentiqueMsg, null);
} else {
if (validationMasque != null && !valeurChamp.matches(validationMasque)) {
MessageBox.alert(titreErreur, valeurNonValideMsg, null);
} else {
ajouterValeur(valeurChamp);
}
}
}
});
colonneBoutonAjouter = new ColumnData(largeurBouton);
colonneConteneur.add(ajouterBouton, colonneBoutonAjouter);
 
principalLayout.add(champRecapitulatif);
principalLayout.add(colonneConteneur);
add(principalLayout);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampMultiValeursPaginable.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampMultiValeursPaginable.java:r1136-1208,1292-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ChampCaseACocher.java
New file
0,0 → 1,188
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;
import org.tela_botanica.client.configuration.Configuration;
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.Debug;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
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.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.LabelField;
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.FormPanel.LabelAlign;
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.FormLayout;
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig;
import com.google.gwt.core.client.GWT;
 
public class ChampCaseACocher extends LayoutContainer implements Rafraichissable {
private Configuration config = null;
private Mediateur mediateur = null;
private CheckBoxGroup groupeCaseACocher = null;
private boolean avoirChampAutre = false;
private Field<String> champAutre = null;
 
private String listeValeursCode = null;
private Sequenceur sequenceur = new Sequenceur();
public ChampCaseACocher(String label, String listeCode, boolean avoirChampAutre) {
config = (Configuration) Registry.get(RegistreId.CONFIG);
mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
 
setLayout(creerFormLayout(650, LabelAlign.TOP));
groupeCaseACocher = new CheckBoxGroup();
setLabel(label);
setChampAutre(avoirChampAutre);
setListeCode(listeCode);
mediateur.obtenirListeValeurEtRafraichir(this, getListeCode(), sequenceur);
}
public String getListeCode() {
return listeValeursCode;
}
public void setListeCode(String code) {
listeValeursCode = code;
}
public void setLabel(String label) {
groupeCaseACocher.setFieldLabel(label);
}
public boolean avoirChampAutre() {
return avoirChampAutre;
}
public void setChampAutre(boolean avoirChamp) {
avoirChampAutre = avoirChamp;
if (avoirChampAutre) {
champAutre = new TextArea();
champAutre.setWidth("80%");
}
}
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+"AUTRE"+aDonnee.SEPARATEUR_TYPE_VALEUR+champAutre.getValue();
}
if (!UtilString.isEmpty(valeur)) {
valeur = 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"+aDonnee.SEPARATEUR_TYPE_VALEUR)) {
champAutre.setValue(valeurs[i].replaceFirst("^AUTRE"+aDonnee.SEPARATEUR_TYPE_VALEUR, ""));
} 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) {
formLayout.setLabelWidth(labelWidth);
}
if (labelAlign != null) {
formLayout.setLabelAlign(labelAlign);
}
return formLayout;
}
private void creerChoixMultipleCac(ValeurListe listeValeurs) {
addListener(Events.Hide, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
groupeCaseACocher.reset();
if (avoirChampAutre()) {
champAutre.setValue("");
}
}
});
groupeCaseACocher.setAutoWidth(true);
groupeCaseACocher.setStyleAttribute("padding", "3px");
groupeCaseACocher.setData("liste_id", listeValeurs.getId());
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
Valeur val = listeValeurs.get(it.next());
String nom = val.get("nom");
CheckBox cac = new CheckBox();
cac.setId("val-"+val.getId());
cac.setData("id", val.getId());
cac.setBoxLabel(nom);
if (! val.getDescription().equals("NULL")) {
cac.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription()));
}
groupeCaseACocher.add(cac);
}
add(groupeCaseACocher);
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(new FlowLayout());
conteneur.add(new LabelField("Autre : "));
champAutre.setId("autre-"+listeValeurs.getId());
champAutre.setLabelStyle("font-weight:normal;");
conteneur.add(champAutre, new FormData(500, 0));
add(conteneur);
}
layout();
}
 
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof ValeurListe) {
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
if (listeValeurs.getId().equals(config.getListeId(getListeCode()))) {
creerChoixMultipleCac(listeValeurs);
}
} else {
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/ChampCaseACocher.java:r11-838,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ChampCaseACocher.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ChampCaseACocher.java:r1136-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/ConteneurMultiChamps.java
New file
0,0 → 1,49
package org.tela_botanica.client.composants;
 
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout;
import com.extjs.gxt.ui.client.widget.layout.LayoutData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout.HBoxLayoutAlign;
import com.google.gwt.user.client.ui.Widget;
 
public class ConteneurMultiChamps extends LayoutContainer {
 
private LayoutContainer conteneurDesChamps = null;
 
public ConteneurMultiChamps(String label) {
setLayout(new RowLayout());
LabelField etiquette = new LabelField(label+":");
add(etiquette);
 
ContentPanel panneauGeneral = new ContentPanel(new FitLayout());
panneauGeneral.setHeaderVisible(false);
panneauGeneral.setHeight(25);
HBoxLayout dispositionDesChamps = new HBoxLayout();
dispositionDesChamps.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
conteneurDesChamps = new LayoutContainer();
conteneurDesChamps.setLayout(dispositionDesChamps);
panneauGeneral.add(conteneurDesChamps);
add(panneauGeneral);
}
public void ajouterChamp(Widget widget) {
ajouterChamp(widget, null);
}
public void ajouterChamp(Widget widget, LayoutData dispositionDesDonnees) {
if (dispositionDesDonnees != null) {
conteneurDesChamps.add(widget, dispositionDesDonnees);
} else {
conteneurDesChamps.add(widget);
}
layout();
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/ConteneurMultiChamps.java:r11-858,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/ConteneurMultiChamps.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/ConteneurMultiChamps.java:r1136-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyStructureAPersonne.java
New file
0,0 → 1,82
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyStructureAPersonne<D> extends Proxy {
String structureId = null;
String roleId = null;
public ProxyStructureAPersonne(Sequenceur sequenceur, String structureId, String roleId) {
super(sequenceur);
this.structureId = structureId;
this.roleId = roleId;
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
if (this.structureId != null && !UtilString.isEmpty(this.structureId)) {
mediateur.selectionnerStructureAPersonne(this, this.structureId, this.roleId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
} else {
this.rafraichir(null);
}
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyPersonnes.java
New file
0,0 → 1,70
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyPersonnes<D> extends Proxy {
public ProxyPersonnes(Sequenceur sequenceur) {
super(sequenceur);
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
mediateur.selectionnerPersonne(this, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyPublications.java
New file
0,0 → 1,75
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
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.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyPublications<D> extends Proxy {
public ProxyPublications(Sequenceur sequenceur) {
super(sequenceur);
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
mediateur.selectionnerPublication(this, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
}
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyCollections.java
New file
0,0 → 1,70
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyCollections<D> extends Proxy {
public ProxyCollections(Sequenceur sequenceur) {
super(sequenceur);
}
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
mediateur.selectionnerCollection(this, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
}
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyValeur.java
New file
0,0 → 1,71
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyValeur<D> extends Proxy {
private String nomListe = "";
public ProxyValeur(String nomListe, Sequenceur sequenceur) {
super(sequenceur);
this.nomListe = nomListe;
}
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
mediateur.obtenirListeValeurEtRafraichir(this, nomListe, true, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
}
 
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/pagination/ProxyValeur.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/pagination/ProxyValeur.java:r1136-1208,1292-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ChargeurListe.java
New file
0,0 → 1,115
package org.tela_botanica.client.composants.pagination;
 
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.Log;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.data.BasePagingLoader;
import com.extjs.gxt.ui.client.data.LoadEvent;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ChargeurListe<D extends PagingLoadResult<?>> extends BasePagingLoader<D> {
 
private String recherche = "";
private Rafraichissable vueARafraichir = null;
private boolean doRafraichir = false;
 
@SuppressWarnings("unchecked")
public ChargeurListe(Proxy proxy, TransformateurJSONaModelData reader, Rafraichissable vueARafraichir) {
super(proxy, reader);
this.vueARafraichir = vueARafraichir;
}
public boolean load(Object loadConfig, String recherche, boolean doRafraichir) {
this.doRafraichir = doRafraichir;
if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
lastConfig = loadConfig;
this.recherche = recherche;
loadData(loadConfig, recherche);
return true;
} else {
return false;
}
}
public boolean load(Object loadConfig) {
if (fireEvent(BeforeLoad, new LoadEvent(this, loadConfig))) {
lastConfig = loadConfig;
loadData(loadConfig, recherche);
return true;
}
return false;
}
public void load(int offset, int limit) {
this.offset = offset;
this.limit = limit;
load();
}
public boolean load() {
Object config = (reuseConfig && lastConfig != null) ? lastConfig : newLoadConfig();
config = prepareLoadConfig(config);
return load(config);
}
@SuppressWarnings("unchecked")
protected void loadData(final Object config, String recherche) {
AsyncCallback<D> callback = new AsyncCallback<D>() {
public void onFailure(Throwable caught) {
onLoadFailure(config, caught);
if (!UtilString.isEmpty(caught.getMessage())) {
Log.error("[FAILURE] ChargeurListe : message="+caught.getMessage());
} else {
Log.error("[FAILURE] ChargeurListe : message=NULL. Peut-être le modelType est-il mal paramétré ?");
}
}
public void onSuccess(D result) {
onLoadSuccess(config, result);
/*
// SUPPRIMER LES PREFIXES
if (result instanceof BasePagingLoadResult) {
BasePagingLoadResult retourPaging = (BasePagingLoadResult)result;
List retourListe = retourPaging.getData();
for(int i=0; i< retourListe.size(); i++) {
if (retourListe.get(i) instanceof BaseModelData) {
BaseModelData model = (BaseModelData)retourListe.get(i);
Map<String, Object> a = model.getProperties();
Set<String> cles = a.keySet();
Iterator<String> it = cles.iterator();
while (it.hasNext()) {
String cle = it.next();
if (a.get(cle) != null) {
String cleObjet = "";
cleObjet = cle.replaceFirst("^[A-Za-z]+_", "");
model.set(cleObjet, a.get(cle));
model.remove(cle);
}
}
}
}
}*/
// Cas où il faut rafraichir le combo manuellement
// (cela sert pour charger la valeur initiale du combo au chargement d'un formulaire)
if (doRafraichir) {
Information info = new Information("selectionnerValeurCombo");
info.setDonnee(result);
info.setMessage("");
vueARafraichir.rafraichir(info);
}
}
};
((Proxy) proxy).load((TransformateurJSONaModelData) reader, config, callback, recherche);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/pagination/ChargeurListe.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/pagination/ChargeurListe.java:r1136-1208,1292-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/Proxy.java
New file
0,0 → 1,34
package org.tela_botanica.client.composants.pagination;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.synchronisation.Sequenceur;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public abstract class Proxy<D extends ModelData> extends MemoryProxy<D> implements Rafraichissable {
 
protected Mediateur mediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
protected DataReader<D> reader = null;
protected Object loadConfig = null;
protected AsyncCallback<D> callback = null;
protected static Object data;
protected Sequenceur sequenceur = null;
public Proxy(Sequenceur sequenceur) {
super(data);
this.sequenceur = sequenceur;
}
 
public abstract void load(TransformateurJSONaModelData<D> reader, Object loadConfig, AsyncCallback<D> callback, String recherche);
 
public abstract void rafraichir(Object nouvellesDonnees);
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/pagination/Proxy.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/pagination/Proxy.java:r1136-1208,1292-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyCollectionACommentaire.java
New file
0,0 → 1,80
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyCollectionACommentaire<D> extends Proxy {
String collectionId = null;
public ProxyCollectionACommentaire(Sequenceur sequenceur, String collectionId) {
super(sequenceur);
this.collectionId = collectionId;
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
if (!UtilString.isEmpty(this.collectionId)) {
mediateur.selectionnerCollectionACommentaire(this, this.collectionId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
} else {
this.rafraichir(null);
}
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
D donneesRetour = null;
if (nouvellesDonnees!=null) {
data = nouvellesDonnees;
if (reader != null)
{
donneesRetour = (D) reader.read(loadConfig, data);
}
else
{
donneesRetour = (D) data;
if (donneesRetour instanceof List)
{
donneesRetour = (D) new ArrayList((List) donneesRetour);
}
}
}
callback.onSuccess(donneesRetour);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/TransformateurJSONaModelData.java
New file
0,0 → 1,158
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
 
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.util.Debug;
 
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataField;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.JsonPagingLoadResultReader;
import com.extjs.gxt.ui.client.data.JsonReader;
import com.extjs.gxt.ui.client.data.ListLoadResult;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
 
public class TransformateurJSONaModelData<D> extends JsonPagingLoadResultReader<D> {
 
private ModelType modelType = null;
// HashMap<'nom du champ virtuel', 'nom du champ à binder'>
private HashMap<String, String> virtualFields = null;
public TransformateurJSONaModelData(ModelType modelType, HashMap<String, String> virtualFields) {
super(modelType);
this.modelType = modelType;
this.virtualFields = virtualFields;
}
 
@SuppressWarnings("unchecked")
@Override
protected Object createReturnData(Object loadConfig, List<ModelData> records, int totalCount) {
ListLoadResult<D> result = (ListLoadResult<D>) super.createReturnData(loadConfig, records, totalCount);
 
if (result instanceof PagingLoadResult) {
PagingLoadResult<D> r = (PagingLoadResult<D>) result;
r.setTotalLength(totalCount);
 
if (loadConfig instanceof PagingLoadConfig) {
PagingLoadConfig config = (PagingLoadConfig) loadConfig;
r.setOffset(config.getOffset());
}
}
return result;
 
}
 
@Override
protected BasePagingLoadResult<ModelData> newLoadResult(Object loadConfig, List<ModelData> models) {
return new BasePagingLoadResult<ModelData>(models);
}
 
@SuppressWarnings("unchecked")
public D read(Object loadConfig, Object data) {
JSONObject jsonRoot = null;
if (data instanceof JSONObject) {
jsonRoot = (JSONObject) data;
}
JSONArray root = (JSONArray) jsonRoot.get(modelType.getRoot());
int size = root.size();
ArrayList<ModelData> models = new ArrayList<ModelData>();
for (int i = 0; i < size; i++) {
JSONObject obj = (JSONObject) root.get(i);
ModelData model = newModelInstance();
for (int j = 0; j < modelType.getFieldCount(); j++) {
DataField field = modelType.getField(j);
String name = field.getName();
Class type = field.getType();
String map = field.getMap() != null ? field.getMap() : field.getName();
JSONValue value = obj.get(map);
if (value == null) continue;
if (value.isArray() != null) {
// nothing
} else if (value.isBoolean() != null) {
model.set(name, value.isBoolean().booleanValue());
} else if (value.isNumber() != null) {
if (type != null) {
Double d = value.isNumber().doubleValue();
if (type.equals(Integer.class)) {
model.set(name, d.intValue());
} else if (type.equals(Long.class)) {
model.set(name, d.longValue());
} else if (type.equals(Float.class)) {
model.set(name, d.floatValue());
} else {
model.set(name, d);
}
} else {
model.set(name, value.isNumber().doubleValue());
}
} else if (value.isObject() != null) {
// nothing
} else if (value.isString() != null) {
String s = value.isString().stringValue();
if (type != null) {
if (type.equals(Date.class)) {
if ("timestamp".equals(field.getFormat())) {
Date d = new Date(Long.parseLong(s) * 1000);
model.set(name, d);
} else {
DateTimeFormat format = DateTimeFormat.getFormat(field.getFormat());
Date d = format.parse(s);
model.set(name, d);
}
}
} else {
model.set(name, s);
}
} else if (value.isNull() != null) {
model.set(name, null);
}
if (virtualFields != null) {
Set<String> cles = virtualFields.keySet();
Iterator<String> it = cles.iterator();
while(it.hasNext()) {
String vField = it.next();
// si il y a un champ à binder
if (virtualFields.get(vField) != null) {
model.set(vField, model.get(virtualFields.get(vField)));
}
// sinon affecter la propriété à 'chaîne vide'
else {
model.set(virtualFields.get(vField), "");
}
}
}
}
models.add(model);
}
int totalCount = models.size();
if (modelType.getTotalName() != null) {
totalCount = getTotalCount(jsonRoot);
}
return (D) createReturnData(loadConfig, models, totalCount);
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/pagination/TransformateurJSONaModelData.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/pagination/TransformateurJSONaModelData.java:r1136-1208,1292-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyStructures.java
New file
0,0 → 1,68
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyStructures<D> extends Proxy {
public ProxyStructures(Sequenceur sequenceur) {
super(sequenceur);
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
String nom = (recherche == null) ? "%" : "%" + recherche + "%";
 
BasePagingLoadConfig lc = (BasePagingLoadConfig) loadConfig;
if (UtilString.isNumber(recherche, false)) {
mediateur.selectionnerStructureAvecPaginationProgressive(this, nom, null, "array", lc.getOffset(), lc.getLimit(), sequenceur, false);
} else {
mediateur.selectionnerStructure(this, nom, lc.getOffset(), lc.getLimit(), sequenceur, false);
}
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try {
data = nouvellesDonnees;
Debug.log("Dans ProxyStructure:"+data.toString());
D d = null;
if (reader != null) {
d = (D) reader.read(loadConfig, data);
} else {
d = (D) data;
if (d instanceof List) {
d = (D) new ArrayList((List) d);
}
}
callback.onSuccess(d);
} catch (Exception e){
callback.onFailure(e);
}
}
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyCollectionAPersonne.java
New file
0,0 → 1,83
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyCollectionAPersonne<D> extends Proxy {
String collectionId = null;
String roleId = null;
public ProxyCollectionAPersonne(Sequenceur sequenceur, String collectionId, String roleId) {
super(sequenceur);
this.collectionId = collectionId;
this.roleId = roleId;
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
if (this.collectionId != null && !UtilString.isEmpty(this.collectionId)) {
mediateur.selectionnerCollectionAPersonne(this, this.collectionId, this.roleId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
} else {
this.rafraichir(null);
}
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyCollectionAPublication.java
New file
0,0 → 1,82
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.ValeurListe;
import org.tela_botanica.client.modeles.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyCollectionAPublication<D> extends Proxy {
String collectionId = null;
public ProxyCollectionAPublication(Sequenceur sequenceur, String collectionId) {
super(sequenceur);
this.collectionId = collectionId;
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
if (this.collectionId != null && !UtilString.isEmpty(this.collectionId)) {
mediateur.selectionnerCollectionAPublication(this, this.collectionId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
} else {
this.rafraichir(null);
}
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
D donneesRetour = null;
if (nouvellesDonnees!=null) {
data = nouvellesDonnees;
if (reader != null)
{
donneesRetour = (D) reader.read(loadConfig, data);
}
else
{
donneesRetour = (D) data;
if (donneesRetour instanceof List)
{
donneesRetour = (D) new ArrayList((List) donneesRetour);
}
}
}
callback.onSuccess(donneesRetour);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyCommentaires.java
New file
0,0 → 1,75
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
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.ValeurListeAsyncDao;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyCommentaires<D> extends Proxy {
public ProxyCommentaires(Sequenceur sequenceur) {
super(sequenceur);
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
mediateur.selectionnerCommentaire(this, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
}
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
data = nouvellesDonnees;
D d = null;
 
if (reader != null)
{
d = (D) reader.read(loadConfig, data);
}
else
{
d = (D) data;
if (d instanceof List)
{
d = (D) new ArrayList((List) d);
}
}
 
callback.onSuccess(d);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyPersonnesAPublication.java
New file
0,0 → 1,63
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.List;
 
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Log;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyPersonnesAPublication<D> extends Proxy {
String publicationId = null;
public ProxyPersonnesAPublication(Sequenceur sequenceur, String publicationId) {
super(sequenceur);
this.publicationId = publicationId;
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig) loadConfig;
if (!UtilString.isEmpty(this.publicationId)) {
mediateur.selectionnerPersonnesAPublication(this, this.publicationId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
} else {
this.rafraichir(null);
}
}
public void setPublicationId(String publicationId) {
this.publicationId = publicationId;
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try {
D donneesRetour = null;
if (nouvellesDonnees != null) {
data = nouvellesDonnees;
if (reader != null) {
donneesRetour = (D) reader.read(loadConfig, data);
} else {
donneesRetour = (D) data;
if (donneesRetour instanceof List) {
donneesRetour = (D) new ArrayList((List) donneesRetour);
}
}
}
Log.debug("Dans Proxy : "+donneesRetour.toString());
callback.onSuccess(donneesRetour);
} catch (Exception e) {
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/pagination/ProxyPublicationsAPersonne.java
New file
0,0 → 1,93
package org.tela_botanica.client.composants.pagination;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
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.ValeurListeAsyncDao;
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
import org.tela_botanica.client.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
import org.tela_botanica.client.util.UtilString;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.DataReader;
import com.extjs.gxt.ui.client.data.MemoryProxy;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.user.client.rpc.AsyncCallback;
 
public class ProxyPublicationsAPersonne<D> extends Proxy {
String personneId = null;
List<Valeur> rolesId = null;
public ProxyPublicationsAPersonne(Sequenceur sequenceur, String personneId, List<Valeur> rolesId) {
super(sequenceur);
this.personneId = personneId;
this.rolesId = rolesId;
}
@Override
public void load(TransformateurJSONaModelData reader, Object loadConfig, AsyncCallback callback, String recherche) {
this.reader = reader;
this.callback = callback;
this.loadConfig = loadConfig;
 
BasePagingLoadConfig lc = (BasePagingLoadConfig)loadConfig;
if (!UtilString.isEmpty(this.personneId)) {
mediateur.selectionnerPublicationsAPersonne(this, personneId, rolesId, recherche, lc.getOffset(), lc.getLimit(), sequenceur);
} else {
this.rafraichir(null);
}
}
public void setPersonneId(String personneId) {
this.personneId = personneId;
}
public void setRolesId(List<Valeur> rolesId) {
this.rolesId = rolesId;
}
 
@Override
@SuppressWarnings("unchecked")
public void rafraichir(Object nouvellesDonnees) {
try
{
D donneesRetour = null;
if (nouvellesDonnees!=null) {
data = nouvellesDonnees;
if (reader != null)
{
donneesRetour = (D) reader.read(loadConfig, data);
}
else
{
donneesRetour = (D) data;
if (donneesRetour instanceof List)
{
donneesRetour = (D) new ArrayList((List) donneesRetour);
}
}
}
callback.onSuccess(donneesRetour);
}
catch (Exception e)
{
callback.onFailure(e);
}
}
 
}
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/AideFenetre.java
New file
0,0 → 1,345
package org.tela_botanica.client.composants;
 
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
import org.tela_botanica.client.configuration.Configuration;
import org.tela_botanica.client.images.Images;
import org.tela_botanica.client.modeles.Information;
import org.tela_botanica.client.modeles.Menu;
import org.tela_botanica.client.util.Pattern;
import org.tela_botanica.client.util.Print;
 
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.ButtonScale;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.Request;
import org.tela_botanica.client.http.RequestBuilderWithCredentials;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Event;
 
public class AideFenetre extends Dialog {
 
private static final String SERVICE_NOM = "CoelAide";
private static final String PAGE_SOMMAIRE_CODE = "AideCOELSommaire";
private static final String PAGE_A_OUVRIR_CODE = "AideCOELPresentationGenerale";
private static Menu pagePrincipale = null;
private static Menu menuAOuvrirParDefaut = null;
private TreePanel<Menu> arbre = null;
private TreeStore<Menu> magazin = null;
private StoreFilterField<Menu> filtre = null;
private Menu sommaire = null;
private ContentPanel sommairePanneau = null;
private ContentPanel contenuPanneau = null;
private HtmlContainer conteneurDuHtml;
private LayoutContainer entetePanneau;
private ToolBar sommaireBarreOutils;
public AideFenetre() {
setBodyBorder(false);
setButtons(Dialog.OK);
setIcon(Images.ICONES.appPanneauListe());
setHeadingHtml("COEL - Aide");
setWidth(675);
setHeight(400);
setHideOnButtonClick(true);
setLayout(new BorderLayout());
creerPanneauEntete();
creerPanneauSommaire();
getSommaireArbreModele();
creerPanneauContenu();
}
 
private void creerPanneauEntete() {
entetePanneau = new LayoutContainer();
entetePanneau.setLayout(new FlowLayout());
BorderLayoutData enteteDisposition = new BorderLayoutData(LayoutRegion.NORTH, 30);
add(entetePanneau, enteteDisposition);
}
 
private void creerPanneauSommaire() {
inititialiserSommaireArbreFiltre();
creerSommaire();
sommairePanneau = new ContentPanel();
sommairePanneau.setScrollMode(Scroll.AUTO);
sommairePanneau.setHeight("100%");
sommairePanneau.setHeaderVisible(false);
creerBarreOutilSommaire();
BorderLayoutData sommaireDisposition = new BorderLayoutData(LayoutRegion.WEST, 230, 175, 350);
sommaireDisposition.setMargins(new Margins(0, 5, 0, 0));
sommaireDisposition.setSplit(true);
sommaireDisposition.setFloatable(true);
add(sommairePanneau, sommaireDisposition);
}
 
private void creerBarreOutilSommaire() {
sommaireBarreOutils = new ToolBar();
// FIXME : on peut utiliser l'alignement à droite car cela pose un problème de rendu dans le Hosted Mode
//sommaireBarreOutils.setAlignment(HorizontalAlignment.RIGHT);
creerBoutonPlierDeplier();
sommairePanneau.setTopComponent(sommaireBarreOutils);
}
 
private void creerBoutonPlierDeplier() {
Button plierDeplierToutBtn = new Button();
plierDeplierToutBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
Button boutonPlierDeplierTout = (Button) be.getSource();
if (boutonPlierDeplierTout.getIcon().equals(Images.ICONES.deplierTout())) {
boutonPlierDeplierTout.setIcon(Images.ICONES.replierTout());
arbre.expandAll();
} else if (boutonPlierDeplierTout.getIcon().equals(Images.ICONES.replierTout())) {
boutonPlierDeplierTout.setIcon(Images.ICONES.deplierTout());
arbre.collapseAll();
}
boutonPlierDeplierTout.repaint();
}
});
plierDeplierToutBtn.setIcon(Images.ICONES.deplierTout());
plierDeplierToutBtn.setScale(ButtonScale.SMALL);
plierDeplierToutBtn.setToolTip(Mediateur.i18nC.plierDeplierToutBtn());
sommaireBarreOutils.add(plierDeplierToutBtn);
}
 
private void creerPanneauContenu() {
contenuPanneau = new ContentPanel();
contenuPanneau.setScrollMode(Scroll.AUTO);
creerBarreOutilContenu();
BorderLayoutData contenuDisposition = new BorderLayoutData(LayoutRegion.CENTER);
add(contenuPanneau, contenuDisposition);
}
private void creerBarreOutilContenu() {
Button imprimerBtn = new Button(null, new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent be) {
Print.it(conteneurDuHtml.el().getInnerHtml());
}
});
imprimerBtn.setIcon(Images.ICONES.imprimer());
contenuPanneau.getHeader().insertTool(imprimerBtn, 0);
}
 
private void etendreArbre(Menu menuAOuvrir) {
if (menuAOuvrir != null) {
arbre.setExpanded(menuAOuvrir, true);
arbre.getSelectionModel().select(menuAOuvrir, false);
}
}
private void etendreArbre(String menuCode) {
Menu menuAOuvrir = magazin.findModel("code", menuCode);
etendreArbre(menuAOuvrir);
}
 
private void creerSommaire() {
magazin = new TreeStore<Menu>();
filtre.bind(magazin);
arbre = new TreePanel<Menu>(magazin);
arbre.setAutoLoad(true);
arbre.setHeight("100%");
arbre.setDisplayProperty("nom");
arbre.getStyle().setLeafIcon(Images.ICONES.aide());
arbre.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
public void handleEvent(TreePanelEvent<Menu> tpe) {
Menu menuSelectionne = arbre.getSelectionModel().getSelectedItem();
if (menuSelectionne.get("code") != null) {
selectionSommaire((String) menuSelectionne.get("code"));
}
}
});
}
private void definirMenuAOuvrirParDefaut() {
menuAOuvrirParDefaut = magazin.findModel("code", PAGE_A_OUVRIR_CODE);
}
 
private void selectionSommaire(String page) {
String serviceUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
String aidePageUrl = serviceUrl+SERVICE_NOM+"/"+page;
chargerPageAide(aidePageUrl);
}
private void chargerPageAide(String url) {
conteneurDuHtml = new HtmlContainer() {
public void onBrowserEvent(Event e) {
// Nous vérifions que l'évenement est un clic et qu'il a lieu sur un lien
if (e.getTypeInt() == Event.ONCLICK && e.getEventTarget().toString().startsWith("http://")) {
e.preventDefault();
String urlPageAideCible = e.getEventTarget().toString();
chargerPageAide(urlPageAideCible);
String codePageAideCible = urlPageAideCible.substring(urlPageAideCible.lastIndexOf("/")+1);
etendreArbre(codePageAideCible);
} else {
GWT.log("Event target:"+e.getEventTarget().toString()+" - type :"+e.getTypeInt()+"="+Event.ONCLICK, null);
}
}
};
conteneurDuHtml.setId(ComposantId.PANNEAU_AIDE);
conteneurDuHtml.setWidth(400);
conteneurDuHtml.sinkEvents(Event.ONCLICK);
conteneurDuHtml.setUrl(url);
conteneurDuHtml.recalculate();
contenuPanneau.removeAll();
contenuPanneau.add(conteneurDuHtml);
contenuPanneau.layout();
}
private void inititialiserSommaireArbreFiltre() {
filtre = new StoreFilterField<Menu>() {
@Override
protected boolean doSelect(Store<Menu> magazin, Menu parent, Menu enregistrement, String propriete, String filtre) {
Boolean retour = false;
// Seul les feuilles sont traitées par le filtre
String nomMenu = enregistrement.getNom();
String nomMenuMinuscule = nomMenu.toLowerCase();
String nomFiltreMinuscule = filtre.toLowerCase();
String nomFiltreMinusculeProtege = Pattern.quote(nomFiltreMinuscule);
if (nomMenuMinuscule.matches(".*"+nomFiltreMinusculeProtege+".*")) {
retour = true;
}
return retour;
}
};
filtre.setFieldLabel(Mediateur.i18nC.chercher());
filtre.setLabelStyle("font-weight:normal;");
filtre.setToolTip("Filtrer le sommaire");
filtre.setWidth(200);
FormLayout fl = new FormLayout();
fl.setLabelWidth(55);
ContentPanel fp = new ContentPanel();
fp.setHeaderVisible(false);
fp.setLayout(fl);
fp.add(filtre);
entetePanneau.add(fp);
}
public void getSommaireArbreModele() {
String serviceUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl();
String sommairePageUrl = serviceUrl+SERVICE_NOM+"/"+PAGE_SOMMAIRE_CODE+"/sommaire";
RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, sommairePageUrl);
try {
rb.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// Gestion des exceptions déclenchées par l'exécution de la requête
GWT.log(Mediateur.i18nM.erreurServiceJrest(SERVICE_NOM), exception);
InfoLogger.display(Mediateur.i18nM.erreurRequeteTitre(), Mediateur.i18nM.erreurRequete(), true);
}
public void onErrorHTTP(Request request, Response reponse) {
// Gestion des erreurs HTTP renvoyé par Apache ou JRest
Information info = new Information("erreur_jrest", JSONParser.parse(reponse.getText()).isArray());
GWT.log("Erreur JREST - Code "+reponse.getStatusCode()+"\n"+info.getMessages().toString(), null);
InfoLogger.display("Erreur JREST - Code "+reponse.getStatusCode(), info.toString(), true);
}
public void onResponseReceived(Request request, Response response) {
// Si le code de réponse HTTP ne vaut pas 200 OK, on lance le mécanise d'erreur HTTP
if (response.getStatusCode() != 200) {
onErrorHTTP(request, response);
} else {
if (response.getText().length() != 0 && response.getText() != null) {
final JSONValue responseValue = JSONParser.parse(response.getText());
JSONArray jsonArray = responseValue.isArray();
if (jsonArray != null) {
sommaire = new Menu(Mediateur.i18nC.sommaire());
ajouterMenuRecursivement(sommaire, jsonArray);
 
magazin.removeAll();
magazin.add(sommaire, true);
definirMenuAOuvrirParDefaut();
sommairePanneau.add(arbre);
sommairePanneau.layout();
// Chargement de la page racine
selectionSommaire(pagePrincipale.getCode());
etendreArbre(menuAOuvrirParDefaut);
} else {
GWT.log(Mediateur.i18nM.erreurJson(responseValue.toString()), null);
}
}
}
}
});
} catch (RequestException e) {
e.printStackTrace();
}
}
private void ajouterMenuRecursivement(Menu brancheSommaire, JSONArray tableau) {
final int tailleMax = tableau.size();
 
for (int i = 0; i < tailleMax; i++) {
JSONObject pageCourante = tableau.get(i).isObject() ;
if (pageCourante != null) {
Menu menuCourrant = new Menu();
if (pageCourante.get("code") != null) {
String codeCourant = pageCourante.get("code").isString().stringValue();
menuCourrant.setCode(codeCourant);
}
if (pageCourante.get("txt") != null) {
menuCourrant.setNom(pageCourante.get("txt").isString().stringValue());
}
if (menuCourrant.getNom() == null && menuCourrant.getCode() == null) {
menuCourrant = (Menu) brancheSommaire.getChild((brancheSommaire.getChildCount() - 1));
} else {
if (brancheSommaire != null) {
brancheSommaire.add(menuCourrant);
if (pagePrincipale == null) {
pagePrincipale = menuCourrant;
}
}
}
if (pageCourante.get("liste") != null) {
ajouterMenuRecursivement(menuCourrant, pageCourante.get("liste").isArray());
}
}
}
}
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/AideFenetre.java:r11-60,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/AideFenetre.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/AideFenetre.java:r1136-1367
/branches/v1.11-okuzgozu/src/org/tela_botanica/client/composants/LicenceFenetre.java
New file
0,0 → 1,168
package org.tela_botanica.client.composants;
 
 
import org.tela_botanica.client.Coel;
import org.tela_botanica.client.ComposantClass;
import org.tela_botanica.client.ComposantId;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.RegistreId;
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.UtilisateurAsyncDao;
 
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Format;
import com.extjs.gxt.ui.client.util.Params;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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.CheckBox;
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.RowLayout;
import com.google.gwt.user.client.ui.HTML;
 
public class LicenceFenetre extends Dialog implements Rafraichissable{
private Constantes i18nC = null;
protected Button validerBouton = null;
private Button annulerBouton = null;
private String messageErreurTpl = "<div id='" + ComposantId.DIV_IDENTIFICATION_MSG + "'>{message}</div>";
private LayoutContainer messageErreur;
private HTML texteLicence;
private String licenceTpl = "<div class='{css_corps}'>{licence}</div>";
private IdentificationFenetre fenetreIdentification;
private CheckBox accepter;
public LicenceFenetre(IdentificationFenetre vueARafraichir) {
 
fenetreIdentification = vueARafraichir;
 
setSize(500, 300);
setPlain(true);
setHeadingHtml("Licence d'utilisation");
setIcon(Images.ICONES.application());
setLayout(new RowLayout());
setButtons(Dialog.OKCANCEL);
 
messageErreur = new LayoutContainer();
messageErreur.setLayout(new FitLayout());
add(messageErreur);
 
LayoutContainer licence = new LayoutContainer();
licence.setSize("98%", "75%");
licence.setStyleAttribute("padding", "5px");
licence.setLayout(new FlowLayout());
licence.setScrollMode(Scroll.AUTO);
 
texteLicence = new HTML();
licence.add(texteLicence);
add(licence);
 
LayoutContainer cbContainer = new LayoutContainer(new ColumnLayout());
accepter = new CheckBox();
cbContainer.add(accepter);
add(cbContainer);
Text txtAccepter = new Text(Mediateur.i18nC.licenceJaccepte());
txtAccepter.setStyleAttribute("padding", "3px");
cbContainer.add(txtAccepter);
setClosable(false);
show();
initialiserComposants();
}
public void initialiserComposants() {
Params licenceParam = new Params();
licenceParam.set("message", Mediateur.i18nC.licenceAccepter());
messageErreur.el().setInnerHtml(Format.substitute(messageErreurTpl, licenceParam));
Params parametres = new Params();
String licence = Mediateur.i18nC.licence();
parametres.set("licence", licence);
parametres.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU);
texteLicence.setHTML(Format.substitute(licenceTpl, parametres));
}
 
@Override
protected void createButtons() {
// FIXME : l'instanciation dans le constructeur ne marche pas pour cette méthode...
i18nC = Mediateur.i18nC;
getButtonBar().removeAll();
validerBouton = new Button(i18nC.valider());
validerBouton.setItemId(OK);
validerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
onButtonPressed(ce.getButton());
}
});
annulerBouton = new Button(i18nC.annuler());
annulerBouton.setItemId(CANCEL);
annulerBouton.addSelectionListener(new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
onButtonPressed(ce.getButton());
}
});
addButton(annulerBouton);
addButton(validerBouton);
}
@Override
protected void onButtonPressed(Button button) {
if (Dialog.OK.equals(button.getItemId())) {
button.setEnabled(false);
boolean licenceAcceptee = accepter.getValue();
if (licenceAcceptee == true) {
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).accepterLicence(this);
} else {
hide();
}
} else {
hide();
}
}
public void rafraichir(Object nouvellesDonnees) {
if (nouvellesDonnees instanceof Information) {
Information info = (Information) nouvellesDonnees;
if (info.getType().equals("maj_licence")) {
String licence = info.getDonnee(0).toString();
if (licence.equals("1")) {
if (fenetreIdentification != null && fenetreIdentification.isVisible()) {
// si on est en train de se logger depuis Coel
fenetreIdentification.onSubmit();
} else {
// si on était loggé depuis ailleurs par le SSO,
// get état utilisateur forcé pour rafraîchir l'état de l'utilisateur maitnenant
// que la licence est acceptée - on pourrait sûrement faire mieux
// (ne pas rappeler le SSO ?)
Mediateur lePutainDeMediateur = (Mediateur) Registry.get(RegistreId.MEDIATEUR);
UtilisateurAsyncDao uad = new UtilisateurAsyncDao(lePutainDeMediateur);
uad.getEtatUtilisateur();
}
hide();
} else {
//Licence non acceptée, on masque la fenêtre pour laisser
// affiché la fenêtre d'identification qui est en erreur.
hide();
}
}
}
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /trunk/src/org/tela_botanica/client/composants/LicenceFenetre.java:r11-893,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/composants/LicenceFenetre.java:r1383-1511
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/composants/LicenceFenetre.java:r1136-1368