/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormCommentaire.java |
---|
New file |
0,0 → 1,626 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxMultiSelect; |
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.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaire; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.commentaire.CommentaireListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.FenetreForm; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireBarreValidation; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import org.tela_botanica.client.vues.commentaire.CommentaireForm; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
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.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
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.Info; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
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.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class CollectionFormCommentaire extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "commentaire"; |
private Collection collection = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<CollectionACommentaire> grille; |
private ChampComboBoxMultiSelect<Valeur> typeCombo = null; |
private CollectionACommentaireListe commentairesAjoutes = null; |
private CollectionACommentaireListe commentairesModifies = null; |
private CollectionACommentaireListe commentairesSupprimes = null; |
private ComboBox<Commentaire> commentairesSaisisComboBox = null; |
private Button commentairesBoutonSupprimer = null; |
private Button commentairesBoutonModifier = null; |
private static boolean chargementTypesOk = false; |
private static boolean chargementCommentairesOk = false; |
private FenetreForm fenetreFormulaire = null; |
public CollectionFormCommentaire(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionCommentaire()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection"); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des commentaires |
initialiserGestionCommentaires(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
collection = ((CollectionForm) formulaire).collection; |
} |
private void initialiserGestionCommentaires() { |
idGenere = 1; |
commentairesAjoutes = new CollectionACommentaireListe(); |
commentairesModifies = new CollectionACommentaireListe(); |
commentairesSupprimes = new CollectionACommentaireListe(); |
} |
private void initialiserChargement() { |
chargementCommentairesOk = false; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionCommentaireTitre()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterPersonneBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterPersonneBouton); |
barreOutils.add(new Text(" ou ")); |
commentairesSaisisComboBox = creerComboBoxCommentairesSaisies(); |
barreOutils.add(commentairesSaisisComboBox); |
barreOutils.add(new SeparatorToolItem()); |
commentairesBoutonModifier = creerBoutonModifier(); |
barreOutils.add(commentairesBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
commentairesBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(commentairesBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirPersonneBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirPersonneBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
} |
private Button creerBoutonModifier() { |
Button bouton = new Button(i18nC.modifier()); |
bouton.setIcon(Images.ICONES.vcardModifier()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionACommentaire commentaireSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (commentaireSaisiSelectionne == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulaireCommentaire(String mode) { |
String commentaireId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
CollectionACommentaire commentaierSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
commentaireId = commentaierSaisieSelectionnee.getIdCommentaire(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final CommentaireForm formulaire = creerFormulaireCommentaire(fenetre, commentaireId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private CommentaireForm creerFormulaireCommentaire(final FenetreForm fenetre, String commentaireId) { |
CommentaireForm formulaire = new CommentaireForm(mediateur, commentaireId, this); |
FormPanel panneauFormulaire = formulaire.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre. |
panneauFormulaire.getBottomComponent().hide(); |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulaireCommentaire(fenetre, formulaire); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulaire; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulaireCommentaire(final FenetreForm fenetre, final CommentaireForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulaireCommentaire(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionACommentaire commentaireSaisiSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (commentaireSaisiSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerCommentaire()); |
} else { |
supprimerDansGrille(commentaireSaisiSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private ComboBox<Commentaire> creerComboBoxCommentairesSaisies() { |
ListStore<Commentaire> commentairesSaisiesStore = new ListStore<Commentaire>(); |
commentairesSaisiesStore.add(new ArrayList<Commentaire>()); |
ComboBox<Commentaire> comboBox = new ComboBox<Commentaire>(); |
comboBox.setWidth(200); |
comboBox.setEmptyText(i18nC.chercherCommentaireSaisi()); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setEditable(true); |
comboBox.setDisplayField("titre"); |
comboBox.setStore(commentairesSaisiesStore); |
comboBox.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (commentairesSaisisComboBox.getRawValue() != null && commentairesSaisisComboBox.getRawValue().length() > 0) { |
if (!ce.isNavKeyPress()) { |
obtenirCommentairesSaisis(commentairesSaisisComboBox.getRawValue()); |
} |
} |
} |
}); |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
if (commentairesSaisisComboBox.getValue() instanceof Commentaire) { |
Commentaire commentaireSaisiSelectionnee = commentairesSaisisComboBox.getValue(); |
ajouterDansGrille(commentaireSaisiSelectionnee); |
commentairesSaisisComboBox.setValue(null); |
} |
} |
}); |
return comboBox; |
} |
private void ajouterDansGrille(Commentaire commentaire) { |
ajouterDansGrille(commentaire, null, 0); |
} |
private void ajouterDansGrille(Commentaire commentaire, String type, int index) { |
if (commentaire != null) { |
CollectionACommentaire relationCollectionACommentaire = new CollectionACommentaire(); |
relationCollectionACommentaire.setCommentaire(commentaire); |
relationCollectionACommentaire.setIdCommentaire(commentaire.getId()); |
if (type != null) { |
relationCollectionACommentaire.set("_type_", type); |
} |
// Gestion de l'id de la collection |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
relationCollectionACommentaire.setIdCollection(collection.getId()); |
} |
relationCollectionACommentaire.set("_etat_", aDonnee.ETAT_AJOUTE); |
corrigerChampsGrille(relationCollectionACommentaire); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(relationCollectionACommentaire, index); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} |
} |
private void supprimerDansGrille(CollectionACommentaire relationCollectionACommentaire) { |
if (relationCollectionACommentaire != null) { |
// Ajout de la personne supprimée à la liste |
if ((relationCollectionACommentaire.get("_etat_").equals("") || !relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& relationCollectionACommentaire.getId() != null |
&& !relationCollectionACommentaire.getId().equals("")) { |
Debug.log("Nbre commentaires supprimées avant:"+commentairesSupprimes.size()); |
commentairesSupprimes.put("id"+idGenere++, relationCollectionACommentaire); |
Debug.log("Commentaires supprimées : "+relationCollectionACommentaire.getCommentaire().getId()); |
Debug.log("Nbre commentaires supprimées :"+commentairesSupprimes.size()); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(relationCollectionACommentaire); |
} |
} |
private EditorGrid<CollectionACommentaire> creerGrille() { |
ListStore<CollectionACommentaire> storeGrille = new ListStore<CollectionACommentaire>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionACommentaire>>() { |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionACommentaire>>() { |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionACommentaire>>() { |
public void handleEvent(StoreEvent<CollectionACommentaire> ce) { |
if (ce.getRecord().isModified("_type_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
Debug.log("id type modifié : "+ce.getModel().get("_type_")); |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE); |
} |
} |
}); |
RowNumberer pluginLigneNumero = new RowNumberer(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(pluginLigneNumero); |
colonnes.add(creerColonneType()); |
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150)); |
colonnes.add(new ColumnConfig("_texte_", i18nC.commentaireTexte(), 75)); |
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 35)); |
colonnes.add(creerColonneAcces()); |
GridSelectionModel<CollectionACommentaire> modeleDeSelection = new GridSelectionModel<CollectionACommentaire>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
EditorGrid<CollectionACommentaire> grille = new EditorGrid<CollectionACommentaire>(storeGrille, modeleDeColonnes); |
grille.setHeight("100%"); |
grille.setBorders(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addPlugin(pluginLigneNumero); |
grille.getView().setForceFit(true); |
grille.setAutoExpandColumn("_titre_"); |
grille.setStripeRows(true); |
grille.setTrackMouseOver(true); |
return grille; |
} |
private ColumnConfig creerColonneType() { |
typeCombo = new ChampComboBoxMultiSelect<Valeur>(); |
typeCombo.setDisplayField("nom"); |
typeCombo.setValueField("id_valeur"); |
typeCombo.setStore(new ListStore<Valeur>()); |
typeCombo.setEditable(false); |
typeCombo.setForceSelection(true); |
CellEditor typeEditeur = new CellEditor(typeCombo) { |
@SuppressWarnings("unchecked") |
@Override |
public Object preProcessValue(Object valeur) { |
Valeur retour = new Valeur(); |
if (valeur != null ) { |
if (valeur instanceof String) { |
((ChampComboBoxMultiSelect<Valeur>) getField()).peuplerAvecTexte(valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (getField().getRawValue() != null ) { |
retour = getField().getRawValue(); |
} |
Debug.log("Post : "+retour); |
return retour; |
} |
}; |
GridCellRenderer<CollectionACommentaire> typeRendu = new GridCellRenderer<CollectionACommentaire>() { |
@Override |
public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) { |
String type = model.get("_type_"); |
Debug.log("Initialisation type origine :"+type); |
if (typeCombo.getStore() != null && type != null && (type.matches("[0-9]+") || type.contains(aDonnee.SEPARATEUR_VALEURS))) { |
type = typeCombo.formaterIdentifiantsEnTexte(type); |
model.set("_type_", type); |
Debug.log("Initialisation :"+type); |
} |
return type; |
} |
}; |
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100); |
typeColonne.setEditor(typeEditeur); |
typeColonne.setRenderer(typeRendu); |
return typeColonne; |
} |
private ColumnConfig creerColonneAcces() { |
GridCellRenderer<CollectionACommentaire> accesRendu = new GridCellRenderer<CollectionACommentaire>() { |
@Override |
public String render(CollectionACommentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionACommentaire> store, Grid<CollectionACommentaire> grid) { |
String acces = (model.getCommentaire().etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee()); |
model.set("_public_", acces); |
return acces; |
} |
}; |
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30); |
accesColonne.setRenderer(accesRendu); |
return accesColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
commentairesBoutonSupprimer.enable(); |
commentairesBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
commentairesBoutonSupprimer.disable(); |
commentairesBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else if (nouvellesDonnees instanceof CommentaireListe) { |
CommentaireListe listeCommentaires = (CommentaireListe) nouvellesDonnees; |
rafraichirCommentairesListe(listeCommentaires); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (chargementTypesOk && chargementCommentairesOk) { |
peupler(); |
initialiserChargement(); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("typeCommentaireCollection"))) { |
List<Valeur> liste = listeValeurs.toList(); |
if (liste.size() > 0) { |
ListStore<Valeur> store = typeCombo.getStore(); |
store.removeAll(); |
store.add(liste); |
store.sort("nom", SortDir.ASC); |
typeCombo.setStore(store); |
} |
chargementTypesOk = true; |
} else { |
GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null); |
} |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (info.getType().equals("liste_collection_a_commentaire")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
collection.setCommentairesLiees((CollectionACommentaireListe) info.getDonnee(0)); |
chargementCommentairesOk = true; |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées |
// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées |
mediateur.ajouterCollectionACommentaire(this, collectionId, commentairesAjoutes); |
} |
} else if (type.equals("commentaire_modifiee")) { |
if (info.getDonnee(0) != null) { |
Commentaire commentaire = (Commentaire) info.getDonnee(0); |
CollectionACommentaire commentaireDansGrille = grille.getStore().findModel("id_commentaire", commentaire.getId()); |
int index = grille.getStore().indexOf(commentaireDansGrille); |
grille.getStore().remove(commentaireDansGrille); |
String typeCommentaire = (String) commentaireDansGrille.get("_type_"); |
ajouterDansGrille(commentaire, typeCommentaire, index); |
} |
} else if (type.equals("commentaire_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Commentaire commentaire = (Commentaire) info.getDonnee(0); |
ajouterDansGrille(commentaire); |
} |
} else if (info.getType().equals("modif_collection_a_commentaire")) { |
Info.display("Modification des notes liées à la collection", info.toString()); |
initialiserGestionCommentaires(); |
} else if (info.getType().equals("suppression_collection_a_commentaire")) { |
Info.display("Suppression des notes liées à la collection", info.toString()); |
initialiserGestionCommentaires(); |
} else if (info.getType().equals("ajout_collection_a_commentaire")) { |
Info.display("Ajout des notes liées à la collection", info.toString()); |
initialiserGestionCommentaires(); |
} |
} |
private void rafraichirCommentairesListe(CommentaireListe listeCommentaires) { |
commentairesSaisisComboBox.getStore().removeAll(); |
commentairesSaisisComboBox.getStore().add(listeCommentaires.toList()); |
commentairesSaisisComboBox.expand(); |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(collection.getCommentairesLiees().toList()); |
grille.recalculate(); |
layout(); |
Info.display(i18nC.chargementCommentaire(), i18nC.ok()); |
} |
public void collecter() { |
if (etreAccede()) { |
int nbreCommentaire = grille.getStore().getCount(); |
for (int i = 0; i < nbreCommentaire; i++) { |
CollectionACommentaire relationCollectionACommentaire = grille.getStore().getAt(i); |
if (relationCollectionACommentaire.get("_etat_") != null) { |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type |
commentairesModifies.put("id"+idGenere++, relationCollectionACommentaire); |
Debug.log("Commentaires modifiés : "+relationCollectionACommentaire.getCommentaire().getTitre()); |
} |
if (relationCollectionACommentaire.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
corrigerChampsGrille(relationCollectionACommentaire);// Nous modifions l'id_type |
commentairesAjoutes.put("id"+idGenere++, relationCollectionACommentaire); |
Debug.log("Commentaires ajoutés : "+relationCollectionACommentaire.getCommentaire().getTitre()); |
} |
// Initialisation de la grille |
relationCollectionACommentaire.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
private void corrigerChampsGrille(CollectionACommentaire relationCollectionACommentaire) { |
String type = relationCollectionACommentaire.get("_type_"); |
relationCollectionACommentaire.setType(typeCombo.formaterTexteEnIdentifiants(type)); |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (commentairesAjoutes.size() == 0 && commentairesModifies.size() == 0 && commentairesSupprimes.size() == 0) { |
Info.display("Modification des notes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
mediateur.ajouterCollectionACommentaire(this, collection.getId(), commentairesAjoutes); |
mediateur.modifierCollectionACommentaire(this, commentairesModifies); |
mediateur.supprimerCollectionACommentaire(this, commentairesSupprimes); |
} |
} |
} |
private void obtenirCommentairesSaisis(String titre) { |
mediateur.selectionnerCommentaireParTitre(this, titre+"%"); |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCollectionACommentaire(this, collection.getId()); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormDescription.java |
---|
New file |
0,0 → 1,900 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.InterneValeur; |
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.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.modeles.collection.UniteBase; |
import org.tela_botanica.client.modeles.collection.UniteRangement; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilNombre; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.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.MessageBoxEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
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.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.NumberField; |
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.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.grid.AggregationRowConfig; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
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.HeaderGroupConfig; |
import com.extjs.gxt.ui.client.widget.grid.SummaryType; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
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.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.i18n.client.NumberFormat; |
public class CollectionFormDescription extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "description"; |
private Collection collection = null; |
private CollectionBotanique collectionBotanique = null; |
private Collection collectionCollectee = null; |
private CollectionBotanique collectionBotaniqueCollectee = null; |
private static ListStore<InterneValeur> precisionStore = null; |
private ChampComboBoxListeValeurs typesCollectionBotaCombo = null; |
private NumberField nbreEchantillonChp = null; |
private EditorGrid<UniteRangement> uniteRangementGrille = null; |
private ChampComboBoxListeValeurs etatUniteRangementCombo = null; |
private EditorGrid<UniteBase> uniteBaseGrille = null; |
private ChampCaseACocher typePapierConservationChp = null; |
private ChampCaseACocher methodeConservationChp = null; |
private ChampSliderPourcentage specimenFixationPourcentChp = null; |
private ChampSliderPourcentage etiquetteFixationPourcentChp = null; |
private ChampCaseACocher specimentMethodeFixationChp = null; |
private ChampCaseACocher etiquetteMethodeFixationSurSupportChp = null; |
private ChampCaseACocher etiquetteMethodeFixationSurSpecimenChp = null; |
private ChampCaseACocher typeEcritureChp = null; |
private ChampComboBoxListeValeurs traitementCombo = null; |
private ChampCaseACocher poisonTraitementChp = null; |
private ChampCaseACocher insecteTraitementChp = null; |
private ChampComboBoxListeValeurs etatGeneralCombo = null; |
private ChampComboBoxListeValeurs determinationCombo = null; |
private ChampMultiValeursMultiTypes specimenDegradationChp = null; |
private ChampMultiValeursMultiTypes presentationDegradationChp = null; |
public CollectionFormDescription(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionDescription()); |
FormLayout formulaireLayout = (FormLayout) this.getLayout(); |
formulaireLayout.setLabelAlign(LabelAlign.LEFT); |
formulaireLayout.setLabelWidth(300); |
creerFieldsetPrecision(); |
creerStorePrecision(); |
creerUniteRangement(); |
creerUniteBase(); |
creerFieldsetConservation(); |
creerFieldsetEtiquette(); |
creerFieldsetTraitement(); |
creerFieldsetEtat(); |
layout(); |
} |
private void creerFieldsetPrecision() { |
FieldSet precisionFieldSet = new FieldSet(); |
precisionFieldSet.setHeading(i18nC.collectionTitrePrecision()); |
precisionFieldSet.setCollapsible(true); |
precisionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
typesCollectionBotaCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionBotanique(), "typeCollectionBota"); |
typesCollectionBotaCombo.setTabIndex(tabIndex++); |
precisionFieldSet.add(typesCollectionBotaCombo, new FormData(250, 0)); |
nbreEchantillonChp = new NumberField(); |
nbreEchantillonChp.setFieldLabel(i18nC.nbreEchantillon()); |
nbreEchantillonChp.setToolTip(i18nC.nbreEchantillonInfo()); |
nbreEchantillonChp.setFormat(NumberFormat.getFormat("#")); |
precisionFieldSet.add(nbreEchantillonChp); |
this.add(precisionFieldSet); |
} |
private static void creerStorePrecision() { |
if (precisionStore == null) { |
precisionStore = new ListStore<InterneValeur>(); |
precisionStore.add(new InterneValeur(UniteRangement.COMPTE_APPROXIMATIF, Mediateur.i18nC.precisionApproximatif())); |
precisionStore.add(new InterneValeur(UniteRangement.COMPTE_EXACT, Mediateur.i18nC.precisionExact())); |
} |
} |
private static String getPrecisionNom(String precisionAbr) { |
String precision = ""; |
if (!precisionAbr.equals("NULL")) { |
creerStorePrecision(); |
InterneValeur precisionValeur = precisionStore.findModel("abr", precisionAbr); |
if (precisionValeur != null && !precisionValeur.getNom().equals("NULL")) { |
precision = precisionValeur.getNom(); |
} |
} |
return precision; |
} |
private static String getPrecisionAbr(String precisionNom) { |
String precision = ""; |
if (!precisionNom.equals("NULL")) { |
creerStorePrecision(); |
InterneValeur precisionValeur = precisionStore.findModel("nom", precisionNom); |
if (precisionValeur != null) { |
precision = precisionValeur.getAbr(); |
} |
} |
return precision; |
} |
private ComboBox<InterneValeur> getChampPrecision() { |
ComboBox<InterneValeur> precisionCombo = new ComboBox<InterneValeur>(); |
precisionCombo.setForceSelection(true); |
precisionCombo.setTriggerAction(TriggerAction.ALL); |
precisionCombo.setDisplayField("nom"); |
precisionCombo.setStore(precisionStore); |
precisionCombo.setEditable(false); |
return precisionCombo; |
} |
private void creerUniteRangement() { |
ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteRangementTitre()); |
uniteRangementGrille = creerGrilleUniteRangement(); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteRangement"); |
panneauGrille.add(uniteRangementGrille); |
ToolBar barreOutils = creerBarreOutilsGrilleUniteRangement(); |
panneauGrille.setTopComponent(barreOutils); |
add(panneauGrille); |
} |
private ContentPanel creerPanneauContenantGrille(String titre) { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(titre); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
panneau.setScrollMode(Scroll.AUTO); |
panneau.setCollapsible(true); |
panneau.setStyleAttribute("margin", "5px 0"); |
return panneau; |
} |
private EditorGrid<UniteRangement> creerGrilleUniteRangement() { |
ListStore<UniteRangement> storeGrille = new ListStore<UniteRangement>(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150)); |
NumberField champNombre = new NumberField(); |
champNombre.setFormat(NumberFormat.getFormat("#")); |
ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50); |
nombreColonne.setEditor(new CellEditor(champNombre)); |
nombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(nombreColonne); |
CellEditor editeurPrecision = new CellEditor(getChampPrecision()) { |
@Override |
public Object preProcessValue(Object valeur) { |
InterneValeur retour = null; |
if (valeur != null ) { |
if (precisionStore.findModel("nom", valeur.toString()) != null) { |
retour = precisionStore.findModel("nom", valeur.toString()); |
} else if (precisionStore.findModel("abr", valeur.toString()) != null) { |
retour = precisionStore.findModel("abr", valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof InterneValeur) { |
InterneValeur valeurInterne = (InterneValeur) valeur; |
retour = valeurInterne.getNom(); |
} |
} |
return retour; |
} |
}; |
ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50); |
precisionColonne.setEditor(editeurPrecision); |
colonnes.add(precisionColonne); |
TextField<String> formatChp = new TextField<String>(); |
ColumnConfig formatColonne = new ColumnConfig("format", i18nC.collectionUniteFormat(), 100); |
formatColonne.setEditor(new CellEditor(formatChp)); |
colonnes.add(formatColonne); |
GridSelectionModel<UniteRangement> modeleDeSelection = new GridSelectionModel<UniteRangement>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>(); |
total.setHtml("type", i18nC.total()); |
total.setSummaryType("nombre", SummaryType.SUM); |
total.setSummaryFormat("nombre", NumberFormat.getFormat("#")); |
modeleDeColonnes.addAggregationRow(total); |
EditorGrid<UniteRangement> grilleUniteRangement = new EditorGrid<UniteRangement>(storeGrille, modeleDeColonnes); |
grilleUniteRangement.setHeight(300); |
grilleUniteRangement.setBorders(true); |
grilleUniteRangement.setSelectionModel(modeleDeSelection); |
grilleUniteRangement.getView().setForceFit(true); |
grilleUniteRangement.getView().setAutoFill(true); |
grilleUniteRangement.setAutoExpandColumn("type"); |
grilleUniteRangement.setStripeRows(true); |
grilleUniteRangement.setTrackMouseOver(true); |
return grilleUniteRangement; |
} |
private String collecterGrilleUniteRangement() { |
String truk = ""; |
int nbreUnite = uniteRangementGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteRangement unite = uniteRangementGrille.getStore().getAt(i); |
if (unite.getTypeAutre()) { |
truk += unite.getType(); |
} else { |
truk += unite.getId(); |
} |
truk += aDonnee.SEPARATEUR_TYPE_VALEUR; |
truk += UtilNombre.formaterEnEntier(unite.getNombre())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecision())+aDonnee.SEPARATEUR_DONNEES; |
truk += unite.getFormat(); |
truk += (i == (nbreUnite - 1)) ? "" : aDonnee.SEPARATEUR_VALEURS; |
} |
return truk; |
} |
private void peuplerGrilleUniteRangement(String valeurTruk) { |
if (!UtilString.isEmpty(valeurTruk)) { |
HashMap<String,UniteRangement> unitesEnregistrees = parserValeurUniteRangement(valeurTruk); |
ArrayList<UniteRangement> listeUniteMaj = new ArrayList<UniteRangement>(); |
int nbreUnite = uniteRangementGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteRangement uniteDansGrille = uniteRangementGrille.getStore().getAt(i); |
UniteRangement uniteEnregistree = unitesEnregistrees.get(uniteDansGrille.getId()); |
if (uniteEnregistree != null) { |
uniteEnregistree.setType(uniteDansGrille.getType()); |
listeUniteMaj.add(uniteEnregistree); |
} else { |
listeUniteMaj.add(uniteDansGrille); |
} |
} |
Iterator<String> it = unitesEnregistrees.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.matches(aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR)) { |
UniteRangement uniteAutreEnregistree = unitesEnregistrees.get(cle); |
listeUniteMaj.add(uniteAutreEnregistree); |
} |
} |
uniteRangementGrille.getStore().removeAll(); |
uniteRangementGrille.getStore().add(listeUniteMaj); |
layout(); |
} |
} |
public static HashMap<String,UniteRangement> parserValeurUniteRangement(String valeurTruk) { |
HashMap<String,UniteRangement> unitesEnregistrees = new HashMap<String,UniteRangement>(); |
if (!UtilString.isEmpty(valeurTruk)) { |
String[] unites = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS)); |
for (int i = 0; i < unites.length; i++) { |
String[] uniteTypeIdDonnees = unites[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
String uniteChaineDonnees = uniteTypeIdDonnees[1]; |
String[] uniteDonnees = uniteChaineDonnees.split(Pattern.quote(aDonnee.SEPARATEUR_DONNEES)); |
UniteRangement uniteRangement = new UniteRangement(); |
if (uniteDonnees.length > 0) { |
uniteRangement.setNombre(UtilString.formaterEnEntier(uniteDonnees[0])); |
} |
if (uniteDonnees.length > 1) { |
uniteRangement.setPrecision(getPrecisionNom(uniteDonnees[1])); |
} |
if (uniteDonnees.length > 2) { |
uniteRangement.setFormat(uniteDonnees[2]); |
} |
if (uniteTypeIdDonnees[0].matches("[0-9]+")) { |
uniteRangement.setId(uniteTypeIdDonnees[0]); |
uniteRangement.setTypeAutre(false); |
unitesEnregistrees.put(uniteTypeIdDonnees[0], uniteRangement); |
} else { |
uniteRangement.setType(uniteTypeIdDonnees[0]); |
uniteRangement.setTypeAutre(true); |
String id = aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR+uniteTypeIdDonnees[0]+"-"+i; |
unitesEnregistrees.put(id, uniteRangement); |
} |
} |
} |
return unitesEnregistrees; |
} |
private ToolBar creerBarreOutilsGrilleUniteRangement() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouterUniteRangement(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new SeparatorToolItem()); |
Button supprimerBouton = creerBoutonSupprimerUniteRangement(); |
barreOutils.add(supprimerBouton); |
barreOutils.add(new SeparatorToolItem()); |
barreOutils.add(new Text(i18nC.collectionUniteRangementEtatGeneralLabel())); |
etatUniteRangementCombo = new ChampComboBoxListeValeurs("", "etat"); |
etatUniteRangementCombo.setEmptyText(i18nC.collectionUniteRangementEtatGeneral()); |
etatUniteRangementCombo.setToolTip(i18nC.collectionUniteRangementEtatGeneralInfo()); |
etatUniteRangementCombo.setTrie("id_valeur"); |
etatUniteRangementCombo.setWidth(300); |
barreOutils.add(etatUniteRangementCombo); |
return barreOutils; |
} |
private Button creerBoutonAjouterUniteRangement() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.ajouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteRangementSaisirType()); |
box.addCallback(new Listener<MessageBoxEvent>() { |
public void handleEvent(MessageBoxEvent be) { |
if (!UtilString.isEmpty(be.getValue()) && !be.getValue().matches("[0-9]+")) { |
final UniteRangement unite = new UniteRangement(); |
unite.setType(be.getValue()); |
unite.setTypeAutre(true); |
uniteRangementGrille.getStore().add(unite); |
} else { |
Info.display("Information", "Vous ne pouvez pas saisir de valeur vide ou numérique"); |
} |
} |
}); |
} |
}); |
return bouton; |
} |
private Button creerBoutonSupprimerUniteRangement() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.supprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
UniteRangement uniteRangementSelectionnee = uniteRangementGrille.getSelectionModel().getSelectedItem(); |
if (uniteRangementSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteRangement())); |
} else if (uniteRangementSelectionnee.getTypeAutre() == false) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteRangementAjoute()); |
} else { |
uniteRangementGrille.getStore().remove(uniteRangementSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private void creerUniteBase() { |
ContentPanel panneauGrille = creerPanneauContenantGrille(i18nC.collectionUniteBaseTitre()); |
uniteBaseGrille = creerGrilleUniteBase(); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeUniteBase"); |
panneauGrille.add(uniteBaseGrille); |
ToolBar barreOutils = creerBarreOutilsGrilleUniteBase(); |
panneauGrille.setTopComponent(barreOutils); |
add(panneauGrille); |
} |
private EditorGrid<UniteBase> creerGrilleUniteBase() { |
ListStore<UniteBase> storeGrille = new ListStore<UniteBase>(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("type", i18nC.collectionUniteType(), 150)); |
NumberField champNombre = new NumberField(); |
champNombre.setFormat(NumberFormat.getFormat("#")); |
CellEditor editeurNombre = new CellEditor(champNombre); |
ColumnConfig nombreColonne = new ColumnConfig("nombre", i18nC.collectionUniteNbre(), 50); |
nombreColonne.setEditor(editeurNombre); |
nombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(nombreColonne); |
CellEditor editeurPrecision = new CellEditor(getChampPrecision()) { |
@Override |
public Object preProcessValue(Object valeur) { |
InterneValeur retour = null; |
if (valeur != null ) { |
if (precisionStore.findModel("nom", valeur.toString()) != null) { |
retour = precisionStore.findModel("nom", valeur.toString()); |
} else if (precisionStore.findModel("abr", valeur.toString()) != null) { |
retour = precisionStore.findModel("abr", valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof InterneValeur) { |
InterneValeur valeurInterne = (InterneValeur) valeur; |
retour = valeurInterne.getNom(); |
} |
} |
return retour; |
} |
}; |
ColumnConfig precisionColonne = new ColumnConfig("precision", i18nC.collectionUnitePrecision(), 50); |
precisionColonne.setEditor(editeurPrecision); |
colonnes.add(precisionColonne); |
TextField<String> formatChp = new TextField<String>(); |
ColumnConfig formatColonne = new ColumnConfig("format", i18nC.collectionUniteFormat(), 100); |
formatColonne.setEditor(new CellEditor(formatChp)); |
colonnes.add(formatColonne); |
ColumnConfig partNombreColonne = new ColumnConfig("nombre_part", i18nC.collectionUniteNbre(), 50); |
partNombreColonne.setEditor(editeurNombre); |
partNombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(partNombreColonne); |
ColumnConfig partPrecisionColonne = new ColumnConfig("precision_part", i18nC.collectionUnitePrecision(), 50); |
partPrecisionColonne.setEditor(editeurPrecision); |
colonnes.add(partPrecisionColonne); |
ColumnConfig spNombreColonne = new ColumnConfig("nombre_sp", i18nC.collectionUniteNbre(), 50); |
spNombreColonne.setEditor(editeurNombre); |
spNombreColonne.setNumberFormat(NumberFormat.getFormat("#")); |
colonnes.add(spNombreColonne); |
ColumnConfig spPrecisionColonne = new ColumnConfig("precision_sp", i18nC.collectionUnitePrecision(), 50); |
spPrecisionColonne.setEditor(editeurPrecision); |
colonnes.add(spPrecisionColonne); |
GridSelectionModel<UniteBase> modeleDeSelection = new GridSelectionModel<UniteBase>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.addHeaderGroup(0, 0, new HeaderGroupConfig(i18nC.collectionUniteBase(), 1, 4)); |
modeleDeColonnes.addHeaderGroup(0, 4, new HeaderGroupConfig(i18nC.collectionUniteBasePart(), 1, 2)); |
modeleDeColonnes.addHeaderGroup(0, 6, new HeaderGroupConfig(i18nC.collectionUniteBaseSp(), 1, 2)); |
AggregationRowConfig<UniteBase> total = new AggregationRowConfig<UniteBase>(); |
total.setHtml("type", "TOTAL"); |
total.setSummaryType("nombre", SummaryType.SUM); |
total.setSummaryFormat("nombre", NumberFormat.getFormat("#")); |
total.setSummaryType("nombre_part", SummaryType.SUM); |
total.setSummaryFormat("nombre_part", NumberFormat.getFormat("#")); |
total.setSummaryType("nombre_sp", SummaryType.SUM); |
total.setSummaryFormat("nombre_sp", NumberFormat.getFormat("#")); |
modeleDeColonnes.addAggregationRow(total); |
EditorGrid<UniteBase> grilleUniteBase = new EditorGrid<UniteBase>(storeGrille, modeleDeColonnes); |
grilleUniteBase.setHeight(200); |
grilleUniteBase.setBorders(true); |
grilleUniteBase.setSelectionModel(modeleDeSelection); |
grilleUniteBase.getView().setForceFit(true); |
grilleUniteBase.getView().setAutoFill(true); |
grilleUniteBase.setAutoExpandColumn("type"); |
grilleUniteBase.setStripeRows(true); |
grilleUniteBase.setTrackMouseOver(true); |
return grilleUniteBase; |
} |
private String collecterGrilleUniteBase() { |
String truk = ""; |
int nbreUnite = uniteBaseGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteBase unite = uniteBaseGrille.getStore().getAt(i); |
if (unite.getTypeAutre()) { |
truk += unite.getType(); |
} else { |
truk += unite.getId(); |
} |
truk += aDonnee.SEPARATEUR_TYPE_VALEUR; |
truk += UtilNombre.formaterEnEntier(unite.getNombre())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecision())+aDonnee.SEPARATEUR_DONNEES; |
truk += unite.getFormat()+aDonnee.SEPARATEUR_DONNEES; |
truk += UtilNombre.formaterEnEntier(unite.getNombrePart())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecisionPart())+aDonnee.SEPARATEUR_DONNEES; |
truk += UtilNombre.formaterEnEntier(unite.getNombreSp())+aDonnee.SEPARATEUR_DONNEES; |
truk += getPrecisionAbr(unite.getPrecisionSp()); |
truk += (i == (nbreUnite - 1)) ? "" : aDonnee.SEPARATEUR_VALEURS; |
} |
return truk; |
} |
private void peuplerGrilleUniteBase(String valeurTruk) { |
if (!UtilString.isEmpty(valeurTruk)) { |
HashMap<String,UniteBase> unitesEnregistrees = parserValeurUniteBase(valeurTruk); |
ArrayList<UniteBase> listeUniteMaj = new ArrayList<UniteBase>(); |
int nbreUnite = uniteBaseGrille.getStore().getCount(); |
for (int i = 0; i < nbreUnite; i++) { |
UniteBase uniteDansGrille = uniteBaseGrille.getStore().getAt(i); |
UniteBase uniteEnregistree = unitesEnregistrees.get(uniteDansGrille.getId()); |
if (uniteEnregistree != null) { |
uniteEnregistree.setType(uniteDansGrille.getType()); |
listeUniteMaj.add(uniteEnregistree); |
} else { |
listeUniteMaj.add(uniteDansGrille); |
} |
} |
Iterator<String> it = unitesEnregistrees.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.matches(aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR)) { |
UniteBase uniteAutreEnregistree = unitesEnregistrees.get(cle); |
listeUniteMaj.add(uniteAutreEnregistree); |
} |
} |
uniteBaseGrille.getStore().removeAll(); |
uniteBaseGrille.getStore().add(listeUniteMaj); |
layout(); |
} |
} |
public static HashMap<String,UniteBase> parserValeurUniteBase(String valeurTruk) { |
HashMap<String,UniteBase> unitesEnregistrees = new HashMap<String,UniteBase>(); |
if (!UtilString.isEmpty(valeurTruk)) { |
String[] unites = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS)); |
for (int i = 0; i < unites.length; i++) { |
String[] uniteTypeIdDonnees = unites[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
String uniteChaineDonnees = uniteTypeIdDonnees[1]; |
String[] uniteDonnees = uniteChaineDonnees.split(Pattern.quote(aDonnee.SEPARATEUR_DONNEES)); |
UniteBase uniteBase = new UniteBase(); |
if (uniteDonnees.length > 0) { |
uniteBase.setNombre(UtilString.formaterEnEntier(uniteDonnees[0])); |
} |
if (uniteDonnees.length > 1) { |
uniteBase.setPrecision(getPrecisionNom(uniteDonnees[1])); |
} |
if (uniteDonnees.length > 2) { |
uniteBase.setFormat(uniteDonnees[2]); |
} |
if (uniteDonnees.length > 3) { |
uniteBase.setNombrePart(UtilString.formaterEnEntier(uniteDonnees[3])); |
} |
if (uniteDonnees.length > 4) { |
uniteBase.setPrecisionPart(getPrecisionNom(uniteDonnees[4])); |
} |
if (uniteDonnees.length > 5) { |
uniteBase.setNombreSp(UtilString.formaterEnEntier(uniteDonnees[5])); |
} |
if (uniteDonnees.length > 6) { |
uniteBase.setPrecisionSp(getPrecisionNom(uniteDonnees[6])); |
} |
if (uniteTypeIdDonnees[0].matches("[0-9]+")) { |
uniteBase.setId(uniteTypeIdDonnees[0]); |
uniteBase.setTypeAutre(false); |
unitesEnregistrees.put(uniteTypeIdDonnees[0], uniteBase); |
} else { |
uniteBase.setType(uniteTypeIdDonnees[0]); |
uniteBase.setTypeAutre(true); |
String id = aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR+uniteTypeIdDonnees[0]+"-"+i; |
unitesEnregistrees.put(id, uniteBase); |
} |
} |
} |
return unitesEnregistrees; |
} |
private ToolBar creerBarreOutilsGrilleUniteBase() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouterUniteBase(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new SeparatorToolItem()); |
Button supprimerBouton = creerBoutonSupprimerUniteBase(); |
barreOutils.add(supprimerBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouterUniteBase() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.ajouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
final MessageBox box = MessageBox.prompt(i18nC.collectionUniteType(), i18nC.collectionUniteBaseSaisirType()); |
box.addCallback(new Listener<MessageBoxEvent>() { |
public void handleEvent(MessageBoxEvent be) { |
if (!UtilString.isEmpty(be.getValue()) && !be.getValue().matches("[0-9]+")) { |
final UniteBase unite = new UniteBase(); |
unite.setType(be.getValue()); |
unite.setTypeAutre(true); |
uniteBaseGrille.getStore().add(unite); |
} else { |
Info.display("Information", "Vous ne pouvez pas saisir de valeur vide ou numérique"); |
} |
} |
}); |
} |
}); |
return bouton; |
} |
private Button creerBoutonSupprimerUniteBase() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.supprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
UniteBase uniteBaseSelectionnee = uniteBaseGrille.getSelectionModel().getSelectedItem(); |
if (uniteBaseSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), Mediateur.i18nM.veuillezSelectionner(i18nC.selectionnerUniteBase())); |
} else if (uniteBaseSelectionnee.getTypeAutre() == false) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerUniteBaseAjoute()); |
} else { |
uniteBaseGrille.getStore().remove(uniteBaseSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private void creerFieldsetConservation() { |
FieldSet conservationFieldSet = new FieldSet(); |
conservationFieldSet.setHeading(i18nC.collectionTitreConservation()); |
conservationFieldSet.setCollapsible(true); |
conservationFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
typePapierConservationChp = new ChampCaseACocher(i18nC.typePapierConservation(), "typePapier", true); |
conservationFieldSet.add(typePapierConservationChp); |
methodeConservationChp = new ChampCaseACocher(i18nC.methodeConservation(), "methodeRangement", true); |
conservationFieldSet.add(methodeConservationChp); |
this.add(conservationFieldSet); |
} |
private void creerFieldsetEtiquette() { |
FieldSet etiquetteFieldSet = new FieldSet(); |
etiquetteFieldSet.setHeading(i18nC.collectionTitreEtiquette()); |
etiquetteFieldSet.setCollapsible(true); |
etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
Text fixationPoucentLabel = new Text(i18nC.fixationPourcent()); |
etiquetteFieldSet.add(fixationPoucentLabel); |
specimenFixationPourcentChp = new ChampSliderPourcentage(i18nC.specimenFixationPourcent()); |
etiquetteFieldSet.add(specimenFixationPourcentChp, new FormData(200, 0)); |
etiquetteFixationPourcentChp = new ChampSliderPourcentage(i18nC.etiquetteFixationPourcent()); |
etiquetteFieldSet.add(etiquetteFixationPourcentChp, new FormData(200, 0)); |
specimentMethodeFixationChp = new ChampCaseACocher(i18nC.specimenMethodeFixation(), "methodeFixation", true); |
etiquetteFieldSet.add(specimentMethodeFixationChp); |
etiquetteMethodeFixationSurSupportChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSupport(), "methodeFixation", true); |
etiquetteFieldSet.add(etiquetteMethodeFixationSurSupportChp); |
etiquetteMethodeFixationSurSpecimenChp = new ChampCaseACocher(i18nC.etiquetteMethodeFixationSurSpecimen(), "methodeFixationSurSpecimen", true); |
etiquetteFieldSet.add(etiquetteMethodeFixationSurSpecimenChp); |
typeEcritureChp = new ChampCaseACocher(i18nC.typeEcriture(), "typeEcriture", false); |
etiquetteFieldSet.add(typeEcritureChp); |
this.add(etiquetteFieldSet); |
} |
private void creerFieldsetTraitement() { |
FieldSet traitementFieldSet = new FieldSet(); |
traitementFieldSet.setHeading(i18nC.collectionTitreTraitement()); |
traitementFieldSet.setCollapsible(true); |
traitementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
traitementCombo = new ChampComboBoxListeValeurs(i18nC.collectionTraitement(), "onpi"); |
traitementCombo.setTrie("id_valeur"); |
traitementFieldSet.add(traitementCombo, new FormData(300, 0)); |
poisonTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementPoison(), "poisonTraitement", true); |
traitementFieldSet.add(poisonTraitementChp); |
insecteTraitementChp = new ChampCaseACocher(i18nC.collectionTraitementInsecte(), "insecteTraitement", true); |
traitementFieldSet.add(insecteTraitementChp); |
this.add(traitementFieldSet); |
} |
private void creerFieldsetEtat() { |
FieldSet etatFieldSet = new FieldSet(); |
etatFieldSet.setHeading(i18nC.collectionTitreEtatEtDegradation()); |
etatFieldSet.setCollapsible(true); |
etatFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
etatGeneralCombo = new ChampComboBoxListeValeurs(i18nC.collectionEtatGeneral(), "etat"); |
etatGeneralCombo.setToolTip(i18nC.collectionEtatGeneralInfo()); |
etatGeneralCombo.setTrie("id_valeur"); |
etatFieldSet.add(etatGeneralCombo, new FormData(300, 0)); |
specimenDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationSpecimen(), 150, true); |
specimenDegradationChp.initialiserType("specimenDegradation"); |
specimenDegradationChp.initialiserCombobox("niveauImportance"); |
etatFieldSet.add(specimenDegradationChp); |
presentationDegradationChp = new ChampMultiValeursMultiTypes(i18nC.degradationPresentation(), 150, 200, true); |
presentationDegradationChp.initialiserType("supportDegradation"); |
presentationDegradationChp.initialiserCombobox("niveauImportance"); |
etatFieldSet.add(presentationDegradationChp); |
determinationCombo = new ChampComboBoxListeValeurs(i18nC.collectionDetermination(), "niveauDetermination"); |
determinationCombo.setTrie("id_valeur"); |
etatFieldSet.add(determinationCombo, new FormData(450, 0)); |
this.add(etatFieldSet); |
} |
public void peupler() { |
initialiserCollection(); |
if (collectionBotanique != null) { |
typesCollectionBotaCombo.peupler(collectionBotanique.getType()); |
if (!UtilString.isEmpty(collectionBotanique.getNbreEchantillon())) { |
nbreEchantillonChp.setValue(Integer.parseInt(collectionBotanique.getNbreEchantillon())); |
} |
peuplerGrilleUniteRangement(collectionBotanique.getUniteRangement()); |
etatUniteRangementCombo.peupler(collectionBotanique.getUniteRangementEtat()); |
peuplerGrilleUniteBase(collectionBotanique.getUniteBase()); |
typePapierConservationChp.peupler(collectionBotanique.getConservationPapierType()); |
methodeConservationChp.peupler(collectionBotanique.getConservationMethode()); |
specimenFixationPourcentChp.peupler(collectionBotanique.getSpecimenFixationPourcent()); |
etiquetteFixationPourcentChp.peupler(collectionBotanique.getEtiquetteFixationPourcent()); |
specimentMethodeFixationChp.peupler(collectionBotanique.getSpecimenFixationMethode()); |
etiquetteMethodeFixationSurSupportChp.peupler(collectionBotanique.getEtiquetteFixationSupport()); |
etiquetteMethodeFixationSurSpecimenChp.peupler(collectionBotanique.getEtiquetteFixationSpecimen()); |
typeEcritureChp.peupler(collectionBotanique.getEtiquetteEcriture()); |
traitementCombo.peupler(collectionBotanique.getTraitement()); |
poisonTraitementChp.peupler(collectionBotanique.getTraitementPoison()); |
insecteTraitementChp.peupler(collectionBotanique.getTraitementInsecte()); |
etatGeneralCombo.peupler(collectionBotanique.getEtatGeneral()); |
specimenDegradationChp.peupler(collectionBotanique.getDegradationSpecimen()); |
presentationDegradationChp.peupler(collectionBotanique.getDegradationPresentation()); |
determinationCombo.peupler(collectionBotanique.getDetermination()); |
} |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionBotaniqueCollectee.setType(typesCollectionBotaCombo.getValeur()); |
if (nbreEchantillonChp.getValue() != null) { |
collectionBotaniqueCollectee.setNbreEchantillon(Integer.toString(nbreEchantillonChp.getValue().intValue())); |
} |
collectionBotaniqueCollectee.setUniteRangement(collecterGrilleUniteRangement()); |
collectionBotaniqueCollectee.setUniteRangementEtat(etatUniteRangementCombo.getValeur()); |
collectionBotaniqueCollectee.setUniteBase(collecterGrilleUniteBase()); |
collectionBotaniqueCollectee.setConservationPapierType(typePapierConservationChp.getValeur()); |
collectionBotaniqueCollectee.setConservationMethode(methodeConservationChp.getValeur()); |
collectionBotaniqueCollectee.setSpecimenFixationPourcent(specimenFixationPourcentChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteFixationPourcent(etiquetteFixationPourcentChp.getValeur()); |
collectionBotaniqueCollectee.setSpecimenFixationMethode(specimentMethodeFixationChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteFixationSupport(etiquetteMethodeFixationSurSupportChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteFixationSpecimen(etiquetteMethodeFixationSurSpecimenChp.getValeur()); |
collectionBotaniqueCollectee.setEtiquetteEcriture(typeEcritureChp.getValeur()); |
collectionBotaniqueCollectee.setTraitement(traitementCombo.getValeur()); |
collectionBotaniqueCollectee.setTraitementPoison(poisonTraitementChp.getValeur()); |
collectionBotaniqueCollectee.setTraitementInsecte(insecteTraitementChp.getValeur()); |
collectionBotaniqueCollectee.setEtatGeneral(etatGeneralCombo.getValeur()); |
collectionBotaniqueCollectee.setDegradationSpecimen(specimenDegradationChp.getValeurs()); |
collectionBotaniqueCollectee.setDegradationPresentation(presentationDegradationChp.getValeurs()); |
collectionBotaniqueCollectee.setDetermination(determinationCombo.getValeur()); |
} |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
if (collection != null) { |
collectionBotanique = collection.getBotanique(); |
} |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
if (collectionCollectee != null) { |
collectionBotaniqueCollectee = collectionCollectee.getBotanique(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("typeUniteRangement"))) { |
Iterator<String> it = listeValeurs.keySet().iterator(); |
while (it.hasNext()) { |
Valeur valeur = listeValeurs.get(it.next()); |
UniteRangement unite = new UniteRangement(); |
unite.setId(valeur.getId()); |
unite.setType(valeur.getNom()); |
unite.setTypeAutre(false); |
uniteRangementGrille.getStore().add(unite); |
} |
} else if (listeValeurs.getId().equals(config.getListeId("typeUniteBase"))) { |
Iterator<String> it = listeValeurs.keySet().iterator(); |
while (it.hasNext()) { |
Valeur valeur = listeValeurs.get(it.next()); |
UniteBase unite = new UniteBase(); |
unite.setId(valeur.getId()); |
unite.setType(valeur.getNom()); |
unite.setTypeAutre(false); |
uniteBaseGrille.getStore().add(unite); |
} |
} else { |
Debug.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!"); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormInventaire.java |
---|
New file |
0,0 → 1,118 |
package org.tela_botanica.client.vues.collection; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
public class CollectionFormInventaire extends FormulaireOnglet { |
public static final String ID = "inventaire"; |
private Collection collection = null; |
private CollectionBotanique collectionBotanique = null; |
private Collection collectionCollectee = null; |
private CollectionBotanique collectionBotaniqueCollectee = null; |
private ChampComboBoxListeValeurs existenceInventaireCombo = null; |
private ChampComboBoxListeValeurs auteurInventaireCombo = null; |
private ChampComboBoxListeValeurs formeInventaireCombo = null; |
private TextArea infoInventaireChp = null; |
private ChampCaseACocher digitalInventaireChp = null; |
private ChampSliderPourcentage pourcentDigitalInventaireChp = null; |
private ChampComboBoxListeValeurs etatInventaireCombo = null; |
private TextArea typeDonneeInventaireChp = null; |
public CollectionFormInventaire(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionInventaire()); |
int tabIndex = formulaireCourrant.tabIndex; |
existenceInventaireCombo = new ChampComboBoxListeValeurs(i18nC.existenceInventaireCollection(), "onpi", tabIndex++); |
existenceInventaireCombo.setTrie("id_valeur"); |
add(existenceInventaireCombo, new FormData(300, 0)); |
auteurInventaireCombo = new ChampComboBoxListeValeurs(i18nC.auteurInventaireCollection(), "onpi", tabIndex++); |
auteurInventaireCombo.setTrie("id_valeur"); |
auteurInventaireCombo.setTabIndex(tabIndex++); |
add(auteurInventaireCombo, new FormData(300, 0)); |
formeInventaireCombo = new ChampComboBoxListeValeurs(i18nC.formeInventaireCollection(), "inventaireForme", tabIndex++); |
formeInventaireCombo.setTabIndex(tabIndex++); |
add(formeInventaireCombo, new FormData(300, 0)); |
infoInventaireChp = new TextArea(); |
infoInventaireChp.setTabIndex(tabIndex++); |
infoInventaireChp.setFieldLabel(i18nC.infoInventaireCollection()); |
add(infoInventaireChp, new FormData(550, 0)); |
digitalInventaireChp = new ChampCaseACocher(i18nC.digitalInventaireCollection(), "inventaireLogiciel", true); |
add(digitalInventaireChp); |
pourcentDigitalInventaireChp = new ChampSliderPourcentage(i18nC.pourcentDigitalInventaireCollection()); |
pourcentDigitalInventaireChp.setTabIndex(tabIndex++); |
add(pourcentDigitalInventaireChp, new FormData(200, 0)); |
etatInventaireCombo = new ChampComboBoxListeValeurs(i18nC.etatInventaireCollection(), "inventaireEtat", tabIndex++); |
etatInventaireCombo.setTabIndex(tabIndex++); |
add(etatInventaireCombo, new FormData(300, 0)); |
typeDonneeInventaireChp = new TextArea(); |
typeDonneeInventaireChp.setTabIndex(tabIndex++); |
typeDonneeInventaireChp.setFieldLabel(i18nC.typeDonneeInventaireCollection()); |
add(typeDonneeInventaireChp, new FormData(550, 0)); |
} |
public void peupler() { |
initialiserCollection(); |
if (collectionBotanique != null) { |
existenceInventaireCombo.peupler(collectionBotanique.getInventaire()); |
auteurInventaireCombo.peupler(collectionBotanique.getInventaireAuteur()); |
formeInventaireCombo.peupler(collectionBotanique.getInventaireForme()); |
infoInventaireChp.setValue(collectionBotanique.getInventaireInfo()); |
digitalInventaireChp.peupler(collectionBotanique.getInventaireDigital()); |
pourcentDigitalInventaireChp.peupler(collectionBotanique.getInventaireDigitalPourcent()); |
etatInventaireCombo.peupler(collectionBotanique.getInventaireEtat()); |
typeDonneeInventaireChp.setValue(collectionBotanique.getInventaireDonneesTypes()); |
} |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionBotaniqueCollectee.setInventaire(existenceInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireAuteur(auteurInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireForme(formeInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireInfo(infoInventaireChp.getValue()); |
collectionBotaniqueCollectee.setInventaireDigital(digitalInventaireChp.getValeur()); |
collectionBotaniqueCollectee.setInventaireDigitalPourcent(pourcentDigitalInventaireChp.getValeur()); |
collectionBotaniqueCollectee.setInventaireEtat(etatInventaireCombo.getValeur()); |
collectionBotaniqueCollectee.setInventaireDonneesTypes(typeDonneeInventaireChp.getValue()); |
} |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
if (collection != null) { |
collectionBotanique = collection.getBotanique(); |
} |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
if (collectionCollectee != null) { |
collectionBotaniqueCollectee = collectionCollectee.getBotanique(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormPersonne.java |
---|
New file |
0,0 → 1,671 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
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.InterneValeur; |
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.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe; |
import org.tela_botanica.client.modeles.collection.UniteBase; |
import org.tela_botanica.client.modeles.collection.UniteRangement; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.structure.StructureAPersonne; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.FenetreForm; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireBarreValidation; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import org.tela_botanica.client.vues.personne.PersonneForm; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.EventType; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.KeyListener; |
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.store.Record; |
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.Info; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.HeaderGroupConfig; |
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.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.dom.client.Element; |
import com.google.gwt.event.dom.client.KeyCodes; |
public class CollectionFormPersonne extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "personne"; |
private Collection collection = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<CollectionAPersonne> grille; |
private ComboBox<Valeur> typeRelationCombo = null; |
private CollectionAPersonneListe personnesAjoutees = null; |
private CollectionAPersonneListe personnesSupprimees = null; |
private ComboBox<Personne> personnesSaisisComboBox = null; |
private Button personnesBoutonSupprimer = null; |
private Button personnesBoutonModifier = null; |
private ListStore<Valeur> listeIon = null; |
private FenetreForm fenetreFormulaire = null; |
public CollectionFormPersonne(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionPersonne()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
mediateur.obtenirListeValeurEtRafraichir(this, "ion"); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonneCollection"); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
idGenere = 1; |
personnesAjoutees = new CollectionAPersonneListe(); |
personnesSupprimees = new CollectionAPersonneListe(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
collection = ((CollectionForm) formulaire).collection; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionPersonneTitre()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterPersonneBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterPersonneBouton); |
barreOutils.add(new Text(" ou ")); |
personnesSaisisComboBox = creerComboBoxPersonnesSaisies(); |
barreOutils.add(personnesSaisisComboBox); |
barreOutils.add(new SeparatorToolItem()); |
personnesBoutonModifier = creerBoutonModifier(); |
barreOutils.add(personnesBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
personnesBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(personnesBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirPersonneBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirPersonneBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
} |
private Button creerBoutonModifier() { |
Button bouton = new Button(i18nC.modifier()); |
bouton.setIcon(Images.ICONES.vcardModifier()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionAPersonne personneSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
if (personneSaisiSelectionne == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String personneId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
CollectionAPersonne personneSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
personneId = personneSaisieSelectionnee.getIdPersonne(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PersonneForm formulaire = creerFormulairePersonne(fenetre, personneId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PersonneForm creerFormulairePersonne(final FenetreForm fenetre, String personneId) { |
PersonneForm formulaire = new PersonneForm(mediateur, personneId, this); |
FormPanel panneauFormulaire = formulaire.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre. |
panneauFormulaire.getBottomComponent().hide(); |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePersonne(fenetre, formulaire); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulaire; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePersonne(final FenetreForm fenetre, final PersonneForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionAPersonne personneSaisiSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (personneSaisiSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPersonne()); |
} else { |
supprimerDansGrille(personneSaisiSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private ComboBox<Personne> creerComboBoxPersonnesSaisies() { |
ListStore<Personne> personnesSaisiesStore = new ListStore<Personne>(); |
personnesSaisiesStore.add(new ArrayList<Personne>()); |
ComboBox<Personne> comboBox = new ComboBox<Personne>(); |
comboBox.setWidth(200); |
comboBox.setEmptyText(i18nC.chercherPersonneSaisi()); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setEditable(true); |
comboBox.setDisplayField("fmt_nom_complet"); |
comboBox.setStore(personnesSaisiesStore); |
comboBox.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (personnesSaisisComboBox.getRawValue() != null && personnesSaisisComboBox.getRawValue().length() > 0) { |
if (!ce.isNavKeyPress()) { |
obtenirPersonnesSaisis(personnesSaisisComboBox.getRawValue()); |
} |
} |
} |
}); |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
if (personnesSaisisComboBox.getValue() instanceof Personne) { |
Personne personneSaisiSelectionnee = personnesSaisisComboBox.getValue(); |
ajouterDansGrille(personneSaisiSelectionnee); |
personnesSaisisComboBox.setValue(null); |
} |
} |
}); |
return comboBox; |
} |
private void ajouterDansGrille(Personne personne) { |
ajouterDansGrille(personne, null, 0); |
} |
private void ajouterDansGrille(Personne personne, String relation, int index) { |
if (personne != null) { |
CollectionAPersonne relationCollectionPersonne = new CollectionAPersonne(); |
relationCollectionPersonne.setPersonne(personne); |
relationCollectionPersonne.setIdPersonne(personne.getId()); |
if (relation != null) { |
relationCollectionPersonne.set("_role_", relation); |
} |
// Gestion de l'id de la collection |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
relationCollectionPersonne.setIdCollection(collection.getId()); |
} |
relationCollectionPersonne.set("_etat_", aDonnee.ETAT_AJOUTE); |
corrigerChampsGrille(relationCollectionPersonne); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(relationCollectionPersonne, index); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} |
} |
private void supprimerDansGrille(CollectionAPersonne relationCollectionPersonne) { |
if (relationCollectionPersonne != null) { |
// Ajout de la personne supprimée à la liste |
if ((relationCollectionPersonne.get("_etat_").equals("") || !relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& relationCollectionPersonne.getId() != null |
&& !relationCollectionPersonne.getId().equals("")) { |
Debug.log("Nbre personnes supprimées avant:"+personnesSupprimees.size()); |
personnesSupprimees.put("id"+idGenere++, relationCollectionPersonne); |
GWT.log("Personne supprimées : "+relationCollectionPersonne.getPersonne().getId()+" "+relationCollectionPersonne.getPersonne().getPrenom()+" "+relationCollectionPersonne.getPersonne().getNom(), null); |
Debug.log("Nbre personnes supprimées :"+personnesSupprimees.size()); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(relationCollectionPersonne); |
} |
} |
private EditorGrid<CollectionAPersonne> creerGrille() { |
ListStore<CollectionAPersonne> storeGrille = new ListStore<CollectionAPersonne>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionAPersonne>>() { |
public void handleEvent(StoreEvent<CollectionAPersonne> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionAPersonne>>() { |
public void handleEvent(StoreEvent<CollectionAPersonne> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Update, new Listener<StoreEvent<CollectionAPersonne>>() { |
public void handleEvent(StoreEvent<CollectionAPersonne> ce) { |
if (ce.getRecord().isModified("_role_") && !ce.getModel().get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
Debug.log("id role modifié"); |
ce.getModel().set("_etat_", aDonnee.ETAT_MODIFIE); |
} |
} |
}); |
RowNumberer pluginLigneNumero = new RowNumberer(); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(pluginLigneNumero); |
colonnes.add(creerColonneRole()); |
colonnes.add(new ColumnConfig("fmt_nom_complet", i18nC.personneNomComplet(), 150)); |
colonnes.add(new ColumnConfig("nom", i18nC.personneNom(), 75)); |
colonnes.add(new ColumnConfig("prenom", i18nC.personnePrenom(), 75)); |
colonnes.add(new ColumnConfig("naissance_date", i18nC.date(), 75)); |
colonnes.add(new ColumnConfig("naissance_lieu", i18nC.lieu(), 100)); |
colonnes.add(creerColonneDeces()); |
colonnes.add(new ColumnConfig("deces_date", i18nC.date(), 75)); |
colonnes.add(new ColumnConfig("deces_lieu", i18nC.lieu(), 100)); |
GridSelectionModel<CollectionAPersonne> modeleDeSelection = new GridSelectionModel<CollectionAPersonne>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.addHeaderGroup(0, 1, new HeaderGroupConfig(i18nC.personneIdentite(), 1, 4)); |
modeleDeColonnes.addHeaderGroup(0, 5, new HeaderGroupConfig(i18nC.personneNaissance(), 1, 2)); |
modeleDeColonnes.addHeaderGroup(0, 7, new HeaderGroupConfig(i18nC.personneDeces(), 1, 3)); |
EditorGrid<CollectionAPersonne> grillePersonne = new EditorGrid<CollectionAPersonne>(storeGrille, modeleDeColonnes); |
grillePersonne.setHeight("100%"); |
grillePersonne.setBorders(true); |
grillePersonne.setSelectionModel(modeleDeSelection); |
grillePersonne.addPlugin(pluginLigneNumero); |
grillePersonne.getView().setForceFit(true); |
grillePersonne.setAutoExpandColumn("fmt_nom_complet"); |
grillePersonne.setStripeRows(true); |
grillePersonne.setTrackMouseOver(true); |
return grillePersonne; |
} |
private ColumnConfig creerColonneRole() { |
typeRelationCombo = new ComboBox<Valeur>(); |
typeRelationCombo.setForceSelection(true); |
typeRelationCombo.setTriggerAction(TriggerAction.ALL); |
typeRelationCombo.setDisplayField("nom"); |
typeRelationCombo.setStore(new ListStore<Valeur>()); |
typeRelationCombo.setEditable(false); |
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire()); |
CellEditor editeurRelation = new CellEditor(typeRelationCombo) { |
@Override |
public Object preProcessValue(Object valeur) { |
Valeur retour = null; |
if (valeur != null ) { |
Debug.log(valeur.toString()); |
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof Valeur) { |
Valeur valeurOntologie = (Valeur) valeur; |
retour = valeurOntologie.getNom(); |
} |
} |
return retour; |
} |
}; |
GridCellRenderer<CollectionAPersonne> relationRendu = new GridCellRenderer<CollectionAPersonne>() { |
@Override |
public String render(CollectionAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPersonne> store, Grid<CollectionAPersonne> grille) { |
// Gestion du texte afficher dans la cellule |
String role = modele.get("_role_"); |
if (typeRelationCombo.getStore() != null && role.matches("[0-9]+")) { |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getNom(); |
} |
modele.set("_role_", role); |
return role; |
} |
}; |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonneCollection(), 75); |
typeRelationColonne.setEditor(editeurRelation); |
typeRelationColonne.setRenderer(relationRendu); |
return typeRelationColonne; |
} |
public ColumnConfig creerColonneDeces() { |
GridCellRenderer<CollectionAPersonne> decesRendu = new GridCellRenderer<CollectionAPersonne>() { |
@Override |
public String render(CollectionAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPersonne> store, Grid<CollectionAPersonne> grid) { |
String deces = modele.getPersonne().getDeces(); |
if (listeIon != null && modele.getPersonne().getDeces().matches("[0-9]+")) { |
deces = listeIon.findModel("id_valeur", modele.getPersonne().getDeces()).getNom(); |
} |
modele.set("_deces_", deces); |
return deces; |
} |
}; |
ColumnConfig decesColonne = new ColumnConfig("_deces_", Mediateur.i18nC.personneDecedeeInterogation(), 50); |
decesColonne.setRenderer(decesRendu); |
return decesColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
personnesBoutonSupprimer.enable(); |
personnesBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
personnesBoutonSupprimer.disable(); |
personnesBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("ion"))) { |
listeIon = new ListStore<Valeur>(); |
listeIon.add(listeValeurs.toList()); |
} else if (listeValeurs.getId().equals(config.getListeId("relationPersonneCollection"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo); |
} else { |
GWT.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!", null); |
} |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (type.equals("liste_personne")) { |
if (info.getDonnee(0) != null) { |
PersonneListe personnes = (PersonneListe) info.getDonnee(0); |
List<Personne> liste = personnes.toList(); |
personnesSaisisComboBox.getStore().removeAll(); |
personnesSaisisComboBox.getStore().add(liste); |
personnesSaisisComboBox.expand(); |
} |
} else if (info.getType().equals("liste_collection_a_personne")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
collection.setPersonnesLiees((CollectionAPersonneListe) info.getDonnee(0)); |
peupler(); |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les personnes liées |
// En mode AJOUT, il ne peut que y avoir des personnes liées ajoutées |
mediateur.ajouterCollectionAPersonne(this, collectionId, personnesAjoutees); |
} |
} else if (type.equals("personne_modifiee")) { |
if (info.getDonnee(0) != null) { |
Personne personne = (Personne) info.getDonnee(0); |
CollectionAPersonne personneDansGrille = grille.getStore().findModel("id_personne", personne.getId()); |
int index = grille.getStore().indexOf(personneDansGrille); |
grille.getStore().remove(personneDansGrille); |
String role = (String) personneDansGrille.get("_role_"); |
ajouterDansGrille(personne, role, index); |
} |
} else if (type.equals("personne_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Personne personne = (Personne) info.getDonnee(0); |
ajouterDansGrille(personne); |
} |
} else if (info.getType().equals("modif_collection_a_personne")) { |
Info.display("Modification des personnes liées à la collection", info.toString()); |
} else if (info.getType().equals("suppression_collection_a_personne")) { |
Info.display("Suppression des personnes liées à la collection", info.toString()); |
} else if (info.getType().equals("ajout_collection_a_personne")) { |
Info.display("Ajout des personnes liées à la collection", info.toString()); |
} |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(collection.getPersonnesLiees().toList()); |
layout(); |
Info.display(i18nC.chargementPersonne(), i18nC.ok()); |
} |
public ArrayList<String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
String personneNumero = ""; |
int nbrePersonne = grille.getStore().getCount(); |
if (nbrePersonne > 0) { |
for (int i = 0; i < nbrePersonne; i++) { |
CollectionAPersonne personne = grille.getStore().getAt(i); |
if (personne.get("_role_").equals("")) { |
personneNumero += (i != 0 ? ", " : "")+(i+1); |
} |
} |
if (!personneNumero.equals("")) { |
messages.add("Veuillez indiquez le type de relation existant entre la collection et les personnes numéros : "+personneNumero); |
} |
} |
return messages; |
} |
public void collecter() { |
if (etreAccede()) { |
int nbrePersonne = grille.getStore().getCount(); |
for (int i = 0; i < nbrePersonne; i++) { |
CollectionAPersonne relationCollectionPersonne = grille.getStore().getAt(i); |
if (relationCollectionPersonne.get("_etat_") != null) { |
if (relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role |
personnesSupprimees.put("id"+idGenere++, relationCollectionPersonne); |
Debug.log("AVANT:"+relationCollectionPersonne.getIdRole()); |
CollectionAPersonne relationAAjouter = (CollectionAPersonne) relationCollectionPersonne.cloner(new CollectionAPersonne()); |
corrigerChampsGrille(relationAAjouter);// Nous modifions l'id_role |
Debug.log("APRES:"+relationAAjouter.getIdRole()); |
personnesAjoutees.put("id"+idGenere++, relationAAjouter); |
GWT.log("Personne modifiées : "+relationAAjouter.getPersonne().getPrenom()+" "+relationAAjouter.getPersonne().getNom(), null); |
} |
if (relationCollectionPersonne.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
corrigerChampsGrille(relationCollectionPersonne);// Nous modifions l'id_role |
personnesAjoutees.put("id"+idGenere++, relationCollectionPersonne); |
GWT.log("Personne ajoutées : "+relationCollectionPersonne.getPersonne().getPrenom()+" "+relationCollectionPersonne.getPersonne().getNom(), null); |
} |
// Initialisation de la grille |
relationCollectionPersonne.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
private void corrigerChampsGrille(CollectionAPersonne relationCollectionPersonne) { |
String role = relationCollectionPersonne.get("_role_"); |
String champModele = "nom"; |
if (role.matches("[0-9]+")) { |
champModele = "id_valeur"; |
} |
if (typeRelationCombo.getStore().findModel(champModele, role) != null) { |
String idRole = typeRelationCombo.getStore().findModel(champModele, role).getId(); |
relationCollectionPersonne.setIdRole(idRole); |
} |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (personnesAjoutees.size() == 0 && personnesSupprimees.size() == 0) { |
Info.display("Modification des personnes liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
// Ajout des relations CollectionAPersonne |
if (personnesAjoutees.size() != 0) { |
mediateur.ajouterCollectionAPersonne(this, collection.getId(), personnesAjoutees); |
} |
// Suppression des relations StructureAPersonne |
if (personnesSupprimees.size() != 0) { |
mediateur.supprimerCollectionAPersonne(this, personnesSupprimees); |
Debug.log("Nbre personnes supprimées :"+personnesSupprimees.size()); |
} |
} |
} |
} |
private void obtenirPersonnesSaisis(String nom) { |
mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%"); |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCollectionAPersonne(this, collection.getId(), null); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormPublication.java |
---|
New file |
0,0 → 1,548 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
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.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionAPublication; |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.FenetreForm; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireBarreValidation; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import org.tela_botanica.client.vues.publication.PublicationForm; |
import com.extjs.gxt.ui.client.core.XTemplate; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
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.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
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.Info; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.RowExpander; |
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.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class CollectionFormPublication extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "publication"; |
private Collection collection = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<CollectionAPublication> grille; |
private CollectionAPublicationListe publicationsAjoutees = null; |
private CollectionAPublicationListe publicationsSupprimees = null; |
private ComboBox<Publication> publicationsSaisiesComboBox = null; |
private Button publicationsBoutonSupprimer = null; |
private Button publicationsBoutonModifier = null; |
private FenetreForm fenetreFormulaire = null; |
public CollectionFormPublication(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionPublication()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
idGenere = 1; |
publicationsAjoutees = new CollectionAPublicationListe(); |
publicationsSupprimees = new CollectionAPublicationListe(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
collection = ((CollectionForm) formulaire).collection; |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionPublicationTitre()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new Text(" ou ")); |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis(); |
barreOutils.add(publicationsSaisiesComboBox); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonModifier = creerBoutonModifier(); |
barreOutils.add(publicationsBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(publicationsBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
} |
private Button creerBoutonModifier() { |
Button bouton = new Button(i18nC.modifier()); |
bouton.setIcon(Images.ICONES.vcardModifier()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionAPublication publicationSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String publicationId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
CollectionAPublication publicationSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
publicationId = publicationSaisiSelectionne.getIdPublication(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) { |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this); |
FormPanel panneauFormulaire = formulairePublication.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre. |
panneauFormulaire.getBottomComponent().hide(); |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulairePublication; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
CollectionAPublication publicationSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
supprimerDansGrille(publicationSaisieSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCollectionAPublication(this, collection.getId()); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
private ComboBox<Publication> creerComboBoxPublicationsSaisis() { |
ListStore<Publication> publicationsSaisiesStore = new ListStore<Publication>(); |
ComboBox<Publication> comboBox = new ComboBox<Publication>(); |
comboBox.setWidth(400); |
comboBox.setEmptyText(i18nC.chercherPublicationSaisi()); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setEditable(true); |
comboBox.setDisplayField("fmt_nom_complet"); |
comboBox.setStore(publicationsSaisiesStore); |
comboBox.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (publicationsSaisiesComboBox.getRawValue() != null && publicationsSaisiesComboBox.getRawValue().length() > 0) { |
if (!ce.isNavKeyPress()) { |
obtenirPublicationsSaisies(publicationsSaisiesComboBox.getRawValue()); |
} |
} |
} |
}); |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
if (publicationsSaisiesComboBox.getValue() instanceof Publication) { |
Publication publicationSaisieSelectionne = publicationsSaisiesComboBox.getValue(); |
ajouterDansGrille(publicationSaisieSelectionne); |
publicationsSaisiesComboBox.setValue(null); |
} |
} |
}); |
return comboBox; |
} |
private void ajouterDansGrille(Publication publication) { |
ajouterDansGrille(publication, 0); |
} |
private void ajouterDansGrille(Publication publication, int index) { |
if (publication != null) { |
CollectionAPublication publicationLiee = new CollectionAPublication(); |
publicationLiee.setPublication(publication); |
publicationLiee.setIdPublication(publication.getId()); |
// Gestion de l'id de la collection |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
publicationLiee.setIdCollection(collection.getId()); |
} |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(publicationLiee, 0); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} |
} |
private void supprimerDansGrille(CollectionAPublication publicationLiee) { |
if (publicationLiee != null) { |
// Ajout de la personne supprimée à la liste |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& publicationLiee.getId() != null |
&& !publicationLiee.getId().equals("")) { |
Debug.log("Nbre publications supprimées avant:"+publicationsSupprimees.size()); |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
GWT.log("Publications supprimée : "+publicationLiee.getPublication().getId()+" "+publicationLiee.getPublication().getNomComplet(), null); |
Debug.log("Nbre publications supprimées :"+publicationsSupprimees.size()); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(publicationLiee); |
} |
} |
private EditorGrid<CollectionAPublication> creerGrille() { |
ListStore<CollectionAPublication> storeGrille = new ListStore<CollectionAPublication>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<CollectionAPublication>>() { |
public void handleEvent(StoreEvent<CollectionAPublication> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<CollectionAPublication>>() { |
public void handleEvent(StoreEvent<CollectionAPublication> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
RowNumberer numeroPlugin = new RowNumberer(); |
numeroPlugin.setHeader("#"); |
XTemplate infoTpl = XTemplate.create("<p>"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {fmt_auteur}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {titre}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {collection}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+ |
"</p>"); |
RowExpander expansionPlugin = new RowExpander(); |
expansionPlugin.setTemplate(infoTpl); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(expansionPlugin); |
colonnes.add(numeroPlugin); |
colonnes.add(new ColumnConfig("fmt_auteur", i18nC.publicationAuteurs(), 150)); |
colonnes.add(new ColumnConfig("titre", i18nC.publicationTitre(), 150)); |
colonnes.add(new ColumnConfig("collection", i18nC.publicationRevueCollection(), 75)); |
colonnes.add(creerColonneEditeur()); |
colonnes.add(creerColonneAnneePublication()); |
colonnes.add(new ColumnConfig("indication_nvt", i18nC.publicationNvt(), 75)); |
colonnes.add(new ColumnConfig("fascicule", i18nC.publicationFascicule(), 75)); |
colonnes.add(new ColumnConfig("truk_pages", i18nC.publicationPage(), 50)); |
GridSelectionModel<CollectionAPublication> modeleDeSelection = new GridSelectionModel<CollectionAPublication>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info"); |
EditorGrid<CollectionAPublication> grillePublications = new EditorGrid<CollectionAPublication>(storeGrille, modeleDeColonnes); |
grillePublications.setHeight("100%"); |
grillePublications.setBorders(true); |
grillePublications.setSelectionModel(modeleDeSelection); |
grillePublications.addPlugin(expansionPlugin); |
grillePublications.addPlugin(numeroPlugin); |
grillePublications.getView().setForceFit(true); |
grillePublications.setAutoExpandColumn("titre"); |
grillePublications.setStripeRows(true); |
grillePublications.setTrackMouseOver(true); |
return grillePublications; |
} |
private ColumnConfig creerColonneEditeur() { |
GridCellRenderer<CollectionAPublication> editeurRendu = new GridCellRenderer<CollectionAPublication>() { |
@Override |
public String render(CollectionAPublication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPublication> store, Grid<CollectionAPublication> grid) { |
String editeur = model.getPublication().getNomEditeur(); |
model.set("_editeur_", editeur); |
return editeur; |
} |
}; |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135); |
editeurColonne.setRenderer(editeurRendu); |
return editeurColonne; |
} |
private ColumnConfig creerColonneAnneePublication() { |
GridCellRenderer<CollectionAPublication> datePublicationRendu = new GridCellRenderer<CollectionAPublication>() { |
@Override |
public String render(CollectionAPublication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<CollectionAPublication> store, Grid<CollectionAPublication> grid) { |
String annee = model.getPublication().getAnneeParution(); |
model.set("_annee_", annee); |
return annee; |
} |
}; |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75); |
datePublicationColonne.setRenderer(datePublicationRendu); |
return datePublicationColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
publicationsBoutonSupprimer.enable(); |
publicationsBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
publicationsBoutonSupprimer.disable(); |
publicationsBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else if (nouvellesDonnees instanceof PublicationListe) { |
PublicationListe listePublications = (PublicationListe) nouvellesDonnees; |
rafraichirPublicationListe(listePublications); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
private void rafraichirPublicationListe(PublicationListe listePublications) { |
publicationsSaisiesComboBox.getStore().removeAll(); |
publicationsSaisiesComboBox.getStore().add(listePublications.toList()); |
publicationsSaisiesComboBox.expand(); |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (type.equals("liste_collection_a_publication")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
collection.setPublicationsLiees((CollectionAPublicationListe) info.getDonnee(0)); |
peupler(); |
} |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
// Suite à la récupération de l'id de la collection nouvellement ajoutée nous ajoutons les publications liées |
// En mode AJOUT, il ne peut que y avoir des publications liées ajoutées |
mediateur.ajouterCollectionAPublication(this, collectionId, publicationsAjoutees); |
} |
} else if (type.equals("publication_modifiee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
CollectionAPublication publicationDansGrille = grille.getStore().findModel("id_publication", publication.getId()); |
int index = grille.getStore().indexOf(publicationDansGrille); |
grille.getStore().remove(publicationDansGrille); |
ajouterDansGrille(publication, index); |
} |
} else if (type.equals("publication_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
ajouterDansGrille(publication); |
} |
} else if (type.equals("suppression_collection_a_publication")) { |
Info.display("Suppression des publications liées à la collection", info.toString()); |
} else if (type.equals("ajout_collection_a_publication")) { |
Info.display("Ajout des publications liées à la collection", info.toString()); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null); |
} |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(collection.getPublicationsLiees().toList()); |
layout(); |
Info.display(i18nC.chargementPublication(), i18nC.ok()); |
} |
public void collecter() { |
if (etreAccede()) { |
int nbrePublication = grille.getStore().getCount(); |
for (int i = 0; i < nbrePublication; i++) { |
CollectionAPublication publicationLiee = grille.getStore().getAt(i); |
if (publicationLiee.get("_etat_") != null) { |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
CollectionAPublication relationAAjouter = (CollectionAPublication) publicationLiee.cloner(new CollectionAPublication()); |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter); |
Debug.log(publicationLiee.toString()); |
} |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
publicationsAjoutees.put("id"+idGenere++, publicationLiee); |
Debug.log(publicationLiee.toString()); |
} |
// Initialisation de la grille |
publicationLiee.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) { |
Info.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
// Ajout des relations CollectionAPublication |
if (publicationsAjoutees.size() != 0) { |
mediateur.ajouterCollectionAPublication(this, collection.getId(), publicationsAjoutees); |
Debug.log("Nbre publications ajoutées :"+publicationsAjoutees.size()); |
} |
// Suppression des relations CollectionAPublication |
if (publicationsSupprimees.size() != 0) { |
mediateur.supprimerCollectionAPublication(this, publicationsSupprimees); |
Debug.log("Nbre publications supprimées :"+publicationsSupprimees.size()); |
} |
} |
} |
} |
private void obtenirPublicationsSaisies(String nom) { |
mediateur.selectionnerPublicationParNomComplet(this, null, "%"+nom+"%"); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormContenu.java |
---|
New file |
0,0 → 1,336 |
package org.tela_botanica.client.vues.collection; |
import java.util.HashMap; |
import java.util.Iterator; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.composants.ConteneurMultiChamps; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilDate; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.form.DateField; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData; |
public class CollectionFormContenu extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "contenu"; |
private Collection collection = null; |
private CollectionBotanique collectionBotanique = null; |
private Collection collectionCollectee = null; |
private CollectionBotanique collectionBotaniqueCollectee = null; |
private ChampCaseACocher natureChp = null; |
private TextArea specialiteChp = null; |
private ChampComboBoxListeValeurs dateDebutCombo = null; |
private ChampComboBoxListeValeurs dateFinCombo = null; |
private DateField dateDebutChp = null; |
private DateField dateFinChp = null; |
private TextArea annotationClassementChp = null; |
private ChampComboBoxListeValeurs etatClassementCombo = null; |
private ChampComboBoxListeValeurs precisionDateCombo = null; |
private ChampComboBoxListeValeurs precisionLocaliteCombo = null; |
private TextArea etiquetteAnnotationChp = null; |
private ChampComboBoxListeValeurs integreCollectionCombo = null; |
private ChampComboBoxListeValeurs infoIntegreCollectionCombo = null; |
private ChampSliderPourcentage auteurTitrePourcentChp; |
private ChampSliderPourcentage famillePourcentChp; |
private ChampSliderPourcentage genrePourcentChp; |
private ChampSliderPourcentage spPourcentChp; |
private ChampSliderPourcentage auteurSpPourcentChp; |
private ChampSliderPourcentage localitePourcentChp; |
private ChampSliderPourcentage datePourcentChp; |
public CollectionFormContenu(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionContenu()); |
creerFieldsetNature(); |
// TODO : réaliser un champ couverture géographique détaillé |
creerFieldsetPeriode(); |
creerFieldsetClassement(); |
creerFieldsetEtiquette(); |
creerFieldsetIntegration(); |
} |
private void creerFieldsetNature() { |
FieldSet natureFieldSet = new FieldSet(); |
natureFieldSet.setHeading(i18nC.collectionNatureTitre()); |
natureFieldSet.setCollapsible(true); |
natureFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
natureChp = new ChampCaseACocher(i18nC.natureVegetaleContenu(), "natureVegetale", false); |
natureFieldSet.add(natureChp); |
specialiteChp = new TextArea(); |
specialiteChp.setFieldLabel(i18nC.specialiteCollection()); |
specialiteChp.setToolTip(i18nC.specialiteCollectionInfo()); |
natureFieldSet.add(specialiteChp, new FormData(550, 0)); |
add(natureFieldSet); |
} |
private void creerFieldsetPeriode() { |
FieldSet periodeFieldSet = new FieldSet(); |
periodeFieldSet.setHeading(i18nC.collectionConstitutionTitre()); |
periodeFieldSet.setCollapsible(true); |
periodeFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
ConteneurMultiChamps dateDebutConteneur = new ConteneurMultiChamps(i18nC.dateDebutCollection()); |
dateDebutChp = new DateField(); |
dateDebutChp.getPropertyEditor().setFormat(UtilDate.formatDateFr); |
dateDebutChp.getPropertyEditor().setParseStrict(false); |
dateDebutChp.setFormatValue(true); |
dateDebutConteneur.ajouterChamp(dateDebutChp, new HBoxLayoutData(new Margins(0, 20, 0, 0))); |
dateDebutCombo = new ChampComboBoxListeValeurs(null, "dateDebut"); |
dateDebutCombo.setTrie("id_valeur"); |
dateDebutConteneur.ajouterChamp(dateDebutCombo); |
periodeFieldSet.add(dateDebutConteneur); |
ConteneurMultiChamps dateFinConteneur = new ConteneurMultiChamps(i18nC.dateFinCollection()); |
dateFinChp = new DateField(); |
dateFinChp.getPropertyEditor().setFormat(UtilDate.formatDateFr); |
dateFinChp.getPropertyEditor().setParseStrict(false); |
dateFinChp.setFormatValue(true); |
dateFinConteneur.ajouterChamp(dateFinChp, new HBoxLayoutData(new Margins(0, 20, 0, 0))); |
dateFinCombo = new ChampComboBoxListeValeurs(null, "dateFin"); |
dateFinCombo.setTrie("id_valeur"); |
dateFinConteneur.ajouterChamp(dateFinCombo); |
periodeFieldSet.add(dateFinConteneur); |
Text infoDate = new Text(i18nC.dateApproximativeInfo()); |
periodeFieldSet.add(infoDate); |
add(periodeFieldSet); |
} |
private void creerFieldsetClassement() { |
FieldSet classementFieldSet = new FieldSet(); |
classementFieldSet.setHeading(i18nC.collectionClassementTitre()); |
classementFieldSet.setCollapsible(true); |
classementFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
etatClassementCombo = new ChampComboBoxListeValeurs(i18nC.etatClassementCollection(), "etatClassement", tabIndex++); |
classementFieldSet.add(etatClassementCombo); |
annotationClassementChp = new TextArea(); |
annotationClassementChp.setFieldLabel(i18nC.annotationClassementCollection()); |
classementFieldSet.add(annotationClassementChp, new FormData(550, 0)); |
Text infoClassement = new Text(i18nC.annotationClassementCollectionInfo()); |
classementFieldSet.add(infoClassement); |
add(classementFieldSet); |
} |
private void creerFieldsetEtiquette() { |
FieldSet etiquetteFieldSet = new FieldSet(); |
etiquetteFieldSet.setHeading(i18nC.collectionEtiquetteTitre()); |
etiquetteFieldSet.setCollapsible(true); |
etiquetteFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
Text renseignementPoucentLabel = new Text(i18nC.renseignementEtiquetteCollection()); |
renseignementPoucentLabel.setTagName("label"); |
renseignementPoucentLabel.setStyleName("x-form-item-label"); |
etiquetteFieldSet.add(renseignementPoucentLabel); |
auteurTitrePourcentChp = new ChampSliderPourcentage(i18nC.auteurTitrePourcentCollection()); |
etiquetteFieldSet.add(auteurTitrePourcentChp, new FormData(200, 0)); |
famillePourcentChp = new ChampSliderPourcentage(i18nC.famillePourcentCollection()); |
etiquetteFieldSet.add(famillePourcentChp, new FormData(200, 0)); |
genrePourcentChp = new ChampSliderPourcentage(i18nC.genrePourcentCollection()); |
etiquetteFieldSet.add(genrePourcentChp, new FormData(200, 0)); |
spPourcentChp = new ChampSliderPourcentage(i18nC.spPourcentCollection()); |
etiquetteFieldSet.add(spPourcentChp, new FormData(200, 0)); |
auteurSpPourcentChp = new ChampSliderPourcentage(i18nC.auteurSpPourcentCollection()); |
etiquetteFieldSet.add(auteurSpPourcentChp, new FormData(200, 0)); |
localitePourcentChp = new ChampSliderPourcentage(i18nC.localitePourcentCollection()); |
etiquetteFieldSet.add(localitePourcentChp, new FormData(200, 0)); |
datePourcentChp = new ChampSliderPourcentage(i18nC.datePourcentCollection()); |
etiquetteFieldSet.add(datePourcentChp, new FormData(200, 0)); |
precisionLocaliteCombo = new ChampComboBoxListeValeurs(i18nC.precisionLocaliteCollection(), "onep", tabIndex++); |
etiquetteFieldSet.add(precisionLocaliteCombo); |
precisionDateCombo = new ChampComboBoxListeValeurs(i18nC.precisionDateCollection(), "onep", tabIndex++); |
etiquetteFieldSet.add(precisionDateCombo); |
etiquetteAnnotationChp = new TextArea(); |
etiquetteAnnotationChp.setFieldLabel(i18nC.etiquetteAnnotationCollection()); |
etiquetteAnnotationChp.setToolTip(i18nC.etiquetteAnnotationCollectionInfo()); |
etiquetteFieldSet.add(etiquetteAnnotationChp, new FormData(550, 0)); |
add(etiquetteFieldSet); |
} |
private String collecterEtiquetteRenseignement() { |
String renseignement = ""; |
renseignement += creerTypeValeur("AT", auteurTitrePourcentChp.getValeur()); |
renseignement += creerTypeValeur("F", famillePourcentChp.getValeur()); |
renseignement += creerTypeValeur("G", genrePourcentChp.getValeur()); |
renseignement += creerTypeValeur("SP", spPourcentChp.getValeur()); |
renseignement += creerTypeValeur("ASP", auteurSpPourcentChp.getValeur()); |
renseignement += creerTypeValeur("L", localitePourcentChp.getValeur()); |
renseignement += creerTypeValeur("D", datePourcentChp.getValeur()); |
renseignement = renseignement.replaceFirst(aDonnee.SEPARATEUR_VALEURS+"$", ""); |
return renseignement; |
} |
private String creerTypeValeur(String type, String valeur) { |
String retour = ""; |
if (!UtilString.isEmpty(valeur)) { |
retour = type+aDonnee.SEPARATEUR_TYPE_VALEUR+valeur+aDonnee.SEPARATEUR_VALEURS; |
} |
return retour; |
} |
private void peuplerEtiquetteRenseignement(String valeurTruk) { |
HashMap<String,String> infos = parserEtiquetteRenseignement(valeurTruk); |
if (infos != null) { |
Iterator<String> it = infos.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.equals("AT")) { |
auteurTitrePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("F")) { |
famillePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("G")) { |
genrePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("SP")) { |
spPourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("ASP")) { |
auteurSpPourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("L")) { |
localitePourcentChp.peupler(infos.get(cle)); |
} else if (cle.equals("D")) { |
datePourcentChp.peupler(infos.get(cle)); |
} |
} |
} |
} |
public static HashMap<String,String> parserEtiquetteRenseignement(String valeurTruk) { |
HashMap<String,String> infos = null; |
if (!UtilString.isEmpty(valeurTruk)) { |
infos = new HashMap<String,String>(); |
String[] pourcentages = valeurTruk.split(Pattern.quote(aDonnee.SEPARATEUR_VALEURS)); |
for (int i = 0; i < pourcentages.length; i++) { |
String[] pourcentageIdValeur = pourcentages[i].split(Pattern.quote(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
String id = pourcentageIdValeur[0]; |
String valeur = pourcentageIdValeur[1]; |
infos.put(id, valeur); |
} |
} |
return infos; |
} |
private void creerFieldsetIntegration() { |
FieldSet integrationFieldSet = new FieldSet(); |
integrationFieldSet.setHeading(i18nC.collectionIntegreeTitre()); |
integrationFieldSet.setCollapsible(true); |
integrationFieldSet.setLayout(Formulaire.creerFormLayout(350, alignementLabelDefaut)); |
integreCollectionCombo = new ChampComboBoxListeValeurs(i18nC.integreCollection(), "onpi", tabIndex++); |
integrationFieldSet.add(integreCollectionCombo); |
infoIntegreCollectionCombo = new ChampComboBoxListeValeurs(i18nC.infoIntegreCollection(), "onp", tabIndex++); |
integrationFieldSet.add(infoIntegreCollectionCombo); |
Text infoIntegration = new Text(i18nC.infoIntegrationCollection()); |
integrationFieldSet.add(infoIntegration); |
add(integrationFieldSet); |
} |
public void peupler() { |
initialiserCollection(); |
if (collectionBotanique != null) { |
natureChp.peupler(collectionBotanique.getNature()); |
specialiteChp.setValue(collectionBotanique.getSpecialite()); |
dateDebutChp.setValue(UtilString.formaterEnDate(collectionBotanique.getRecolteDateDebut())); |
dateDebutCombo.peupler(collectionBotanique.getRecolteDateDebutType()); |
dateFinChp.setValue(UtilString.formaterEnDate(collectionBotanique.getRecolteDateFin())); |
dateFinCombo.peupler(collectionBotanique.getRecolteDateFinType()); |
etatClassementCombo.peupler(collectionBotanique.getClassementEtat()); |
annotationClassementChp.setValue(collectionBotanique.getClassementAnnotation()); |
peuplerEtiquetteRenseignement(collectionBotanique.getEtiquetteRenseignement()); |
precisionLocaliteCombo.peupler(collectionBotanique.getPrecisionLocalite()); |
precisionDateCombo.peupler(collectionBotanique.getPrecisionDate()); |
etiquetteAnnotationChp.setValue(collectionBotanique.getAnnotationsDiverses()); |
integreCollectionCombo.peupler(collectionBotanique.getCollectionIntegre()); |
infoIntegreCollectionCombo.peupler(collectionBotanique.getCollectionIntegreInfo()); |
} |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionBotaniqueCollectee.setNature(natureChp.getValeur()); |
collectionBotaniqueCollectee.setSpecialite(specialiteChp.getValue()); |
collectionBotaniqueCollectee.setRecolteDateDebut(UtilDate.formaterEnString(dateDebutChp.getValue())); |
collectionBotaniqueCollectee.setRecolteDateDebutType(dateDebutCombo.getValeur()); |
collectionBotaniqueCollectee.setRecolteDateFin(UtilDate.formaterEnString(dateFinChp.getValue())); |
collectionBotaniqueCollectee.setRecolteDateFinType(dateFinCombo.getValeur()); |
collectionBotaniqueCollectee.setClassementEtat(etatClassementCombo.getValeur()); |
collectionBotaniqueCollectee.setClassementAnnotation(annotationClassementChp.getValue()); |
collectionBotaniqueCollectee.setEtiquetteRenseignement(collecterEtiquetteRenseignement()); |
collectionBotaniqueCollectee.setPrecisionLocalite(precisionLocaliteCombo.getValeur()); |
collectionBotaniqueCollectee.setPrecisionDate(precisionDateCombo.getValeur()); |
collectionBotaniqueCollectee.setAnnotationsDiverses(etiquetteAnnotationChp.getValue()); |
collectionBotaniqueCollectee.setCollectionIntegre(integreCollectionCombo.getValeur()); |
collectionBotaniqueCollectee.setCollectionIntegreInfo(infoIntegreCollectionCombo.getValeur()); |
} |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
if (collection != null) { |
collectionBotanique = collection.getBotanique(); |
} |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
if (collectionCollectee != null) { |
collectionBotaniqueCollectee = collectionCollectee.getBotanique(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionVue.java |
---|
New file |
0,0 → 1,60 |
package org.tela_botanica.client.vues.collection; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.util.Debug; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
public class CollectionVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private CollectionListeVue listeCollectionPanneau = null; |
private CollectionDetailVue detailCollectionPanneau = null; |
public CollectionVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
listeCollectionPanneau = new CollectionListeVue(mediateur); |
add(listeCollectionPanneau, new BorderLayoutData(LayoutRegion.CENTER)); |
detailCollectionPanneau = new CollectionDetailVue(mediateur); |
BorderLayoutData dispositionSud = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
dispositionSud.setSplit(true); |
dispositionSud.setMargins(new Margins(5, 0, 0, 0)); |
add(detailCollectionPanneau, dispositionSud); |
} |
public void rafraichir(Object nouvellesDonnees) { |
// Nous passons l'objet aux méthodes rafraichir des panneaux composant le panneau principal Structure |
if (nouvellesDonnees instanceof Collection) { |
detailCollectionPanneau.rafraichir(nouvellesDonnees); |
} else if (nouvellesDonnees instanceof CollectionListe) { |
listeCollectionPanneau.rafraichir(nouvellesDonnees); |
mediateur.desactiverChargement(); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("liste_collection_a_personne") |
|| info.getType().equals("liste_collection_a_publication") |
|| info.getType().equals("liste_collection_a_commentaire")) { |
detailCollectionPanneau.rafraichir(nouvellesDonnees); |
} else if (info.getType().equals("suppression_collection")) { |
listeCollectionPanneau.rafraichir(nouvellesDonnees); |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionListeVue.java |
---|
New file |
0,0 → 1,202 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
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.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.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class CollectionListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Grid<Collection> grille = null; |
private ListStore<Collection> store = null; |
private Button modifier; |
private Button supprimer; |
private Button ajouter; |
private BarrePaginationVue pagination = null; |
public CollectionListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
setLayout(new FitLayout()); |
setHeading(i18nC.collectionListeTitre()); |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicAjouterCollection(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicModifierCollection(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
clicSupprimerCollection(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("nom", i18nC.personneNom(), 300)); |
colonnes.add(new ColumnConfig("structure_nom", i18nC.structure(), 200)); |
colonnes.add(new ColumnConfig("structure_ville", i18nC.ville(), 150)); |
colonnes.get(1).setHidden(true); |
ColumnModel modeleDeColonne = new ColumnModel(colonnes); |
GridSelectionModel<Collection> modeleDeSelection = new GridSelectionModel<Collection>(); |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Collection>() { |
public void selectionChanged(SelectionChangedEvent<Collection> event) { |
Collection collectionSelectionnee = (Collection) event.getSelectedItem(); |
clicListe(collectionSelectionnee); |
} |
}); |
store = new ListStore<Collection>(); |
store.sort("nom", SortDir.ASC); |
grille = new Grid<Collection>(store, modeleDeColonne); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("nom"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new CollectionListe(), mediateur); |
setBottomComponent(pagination); |
} |
private void clicListe(Collection collection) { |
if (collection != null && store.getCount() > 0) { |
mediateur.clicListeCollection(collection); |
} |
} |
private void clicSupprimerCollection(List<Collection> collectionsASupprimer) { |
if (store.getCount() > 0) { |
mediateur.clicSupprimerCollection(this, collectionsASupprimer); |
} |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin == 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof CollectionListe) { |
CollectionListe collections = (CollectionListe) nouvellesDonnees; |
pagination.setlistePaginable(collections); |
int[] pt = collections.getPageTable(); |
pagination.rafraichir(collections.getPageTable()); |
if (collections != null) { |
List<Collection> liste = collections.toList(); |
store.removeAll(); |
store.add(liste); |
mediateur.actualiserPanneauCentral(); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getType().equals("suppression_collection")) { |
// Affichage d'un message d'information |
Info.display(i18nC.suppressionCollection(), info.toString().replaceAll("\n", "<br />")); |
supprimerCollectionsSelectionnees(); |
gererEtatActivationBouton(); |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
layout(); |
} |
private void supprimerCollectionsSelectionnees() { |
List<Collection> collectionsSelectionnees = grille.getSelectionModel().getSelectedItems(); |
Iterator<Collection> it = collectionsSelectionnees.iterator(); |
while (it.hasNext()) { |
grille.getStore().remove(it.next()); |
} |
layout(true); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionFormGeneral.java |
---|
New file |
0,0 → 1,433 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampCaseACocher; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeurs; |
import org.tela_botanica.client.composants.ConteneurMultiChamps; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
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.store.ListStore; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.Field; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.HiddenField; |
import com.extjs.gxt.ui.client.widget.form.NumberField; |
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.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData; |
import com.google.gwt.i18n.client.NumberFormat; |
public class CollectionFormGeneral extends FormulaireOnglet implements Rafraichissable { |
public static final String ID = "general"; |
private Collection collection = null; |
private Collection collectionCollectee = null; |
private HiddenField<String> idCollectionChp = null; |
private ComboBox<Projet> projetsCombo = null; |
private ComboBox<Structure> structuresCombo = null; |
private ComboBox<Collection> collectionsCombo = null; |
private ChampCaseACocher periodeConstitutionChp = null; |
private ChampComboBoxListeValeurs groupementPrincipeCombo = null; |
private ChampMultiValeurs lieuCouvertureChp = null; |
private ChampComboBoxListeValeurs specimenTypeCombo = null; |
private ChampComboBoxListeValeurs precisionTypeNbreCombo = null; |
private NumberField nbreTypeChp = null; |
private ChampComboBoxListeValeurs classementSpecimenTypeCombo = null; |
private ChampComboBoxListeValeurs typeDepotCombo = null; |
private TextField<String> coteChp = null; |
private ChampMultiValeurs idAlternatifsChp = null; |
private ChampMultiValeurs nomsAlternatifsChp = null; |
private ChampMultiValeurs codesAlternatifsChp = null; |
private TextArea descriptionSpecialisteChp = null; |
private TextArea descriptionChp = null; |
private TextArea historiqueChp = null; |
private ChampMultiValeurs urlsChp = null; |
private ChampComboBoxListeValeurs butRealisationCombo = null; |
public CollectionFormGeneral(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId(ID); |
setText(Mediateur.i18nC.collectionGeneral()); |
creerChampsCache(); |
creerFieldsetLiaison(); |
creerFieldsetAdministratif(); |
creerFieldsetDescription(); |
creerFieldsetCouverture(); |
creerFieldsetType(); |
} |
private void initialiserCollection() { |
collection = ((CollectionForm) formulaire).collection; |
collectionCollectee = ((CollectionForm) formulaire).collectionCollectee; |
} |
private void creerChampsCache() { |
// Champs cachés |
idCollectionChp = new HiddenField<String>(); |
this.add(idCollectionChp); |
} |
private void creerFieldsetLiaison() { |
FieldSet liaisonFieldSet = new FieldSet(); |
liaisonFieldSet.setHeading(i18nC.liaisonTitreCollection()); |
liaisonFieldSet.setCollapsible(true); |
liaisonFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
projetsCombo = new ComboBox<Projet>(); |
projetsCombo.setTabIndex(tabIndex++); |
projetsCombo.setFieldLabel(i18nC.projetChamp()); |
projetsCombo.setDisplayField("nom"); |
projetsCombo.setForceSelection(true); |
projetsCombo.setValidator(new Validator() { |
@Override |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
projetsCombo.setTriggerAction(TriggerAction.ALL); |
projetsCombo.setStore(new ListStore<Projet>()); |
projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
projetsCombo.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire()); |
liaisonFieldSet.add(projetsCombo, new FormData(450, 0)); |
mediateur.selectionnerProjet(this, null); |
structuresCombo = new ComboBox<Structure>(); |
structuresCombo.setTabIndex(tabIndex++); |
structuresCombo.setFieldLabel(i18nC.lienStructureCollection()); |
structuresCombo.setDisplayField("nom"); |
structuresCombo.setForceSelection(true); |
structuresCombo.setValidator(new Validator() { |
@Override |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (structuresCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
structuresCombo.setTriggerAction(TriggerAction.ALL); |
structuresCombo.setStore(new ListStore<Structure>()); |
liaisonFieldSet.add(structuresCombo, new FormData(450, 0)); |
mediateur.selectionnerStructureParProjet(this, null); |
collectionsCombo = new ComboBox<Collection>(); |
collectionsCombo.setTabIndex(tabIndex++); |
collectionsCombo.setFieldLabel(i18nC.lienMereCollection()); |
collectionsCombo.setDisplayField("nom"); |
collectionsCombo.setForceSelection(true); |
collectionsCombo.setValidator(new Validator() { |
@Override |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (collectionsCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
collectionsCombo.setTriggerAction(TriggerAction.ALL); |
collectionsCombo.setStore(new ListStore<Collection>()); |
liaisonFieldSet.add(collectionsCombo, new FormData(450, 0)); |
mediateur.selectionnerCollectionParProjet(this, null); |
this.add(liaisonFieldSet); |
} |
private void creerFieldsetAdministratif() { |
// Fieldset ADMINISTRATIF |
FieldSet administratifFieldSet = new FieldSet(); |
administratifFieldSet.setHeading(i18nC.collectionGeneralTitre()); |
administratifFieldSet.setCollapsible(true); |
administratifFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
typeDepotCombo = new ChampComboBoxListeValeurs(i18nC.typeDepot(), "typeDepot", tabIndex++); |
administratifFieldSet.add(typeDepotCombo); |
coteChp = new TextField<String>(); |
coteChp.setTabIndex(tabIndex++); |
coteChp.setFieldLabel(i18nC.cote()); |
administratifFieldSet.add(coteChp, new FormData(450, 0)); |
idAlternatifsChp = new ChampMultiValeurs(i18nC.idAlternatifCollection()); |
administratifFieldSet.add(idAlternatifsChp); |
nomsAlternatifsChp = new ChampMultiValeurs(i18nC.intituleAlternatifCollection()); |
administratifFieldSet.add(nomsAlternatifsChp); |
codesAlternatifsChp = new ChampMultiValeurs(i18nC.codeAlternatifCollection()); |
administratifFieldSet.add(codesAlternatifsChp); |
this.add(administratifFieldSet); |
} |
private void creerFieldsetDescription() { |
// Fieldset DESCRIPTION |
FieldSet descriptionFieldSet = new FieldSet(); |
descriptionFieldSet.setHeading(i18nC.collectionDescriptionTitre()); |
descriptionFieldSet.setCollapsible(true); |
descriptionFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
descriptionChp = new TextArea(); |
descriptionChp.setFieldLabel(i18nC.description()); |
descriptionFieldSet.add(descriptionChp, new FormData(550, 0)); |
descriptionSpecialisteChp = new TextArea(); |
descriptionSpecialisteChp.setFieldLabel(i18nC.descriptionSpecialiste()); |
descriptionFieldSet.add(descriptionSpecialisteChp, new FormData(550, 0)); |
historiqueChp = new TextArea(); |
historiqueChp.setFieldLabel(i18nC.historique()); |
descriptionFieldSet.add(historiqueChp, new FormData(550, 0)); |
urlsChp = new ChampMultiValeurs(i18nC.urlsCollection()); |
descriptionFieldSet.add(urlsChp); |
this.add(descriptionFieldSet); |
} |
private void creerFieldsetCouverture() { |
FieldSet couvertureFieldSet = new FieldSet(); |
couvertureFieldSet.setHeading("Couvertures"); |
couvertureFieldSet.setCollapsible(true); |
couvertureFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
periodeConstitutionChp = new ChampCaseACocher(i18nC.periodeConstitution(), "siecleNaturaliste", false); |
couvertureFieldSet.add(periodeConstitutionChp); |
groupementPrincipeCombo = new ChampComboBoxListeValeurs(i18nC.groupementPrincipeCollection(), "groupementPrincipe", tabIndex++); |
groupementPrincipeCombo.setToolTip(i18nC.groupementPrincipeCollectionInfo()); |
couvertureFieldSet.add(groupementPrincipeCombo); |
butRealisationCombo = new ChampComboBoxListeValeurs(i18nC.butCollection(), "realisationBut", tabIndex++); |
couvertureFieldSet.add(butRealisationCombo); |
lieuCouvertureChp = new ChampMultiValeurs(i18nC.lieuCouvertureCollection()); |
couvertureFieldSet.add(lieuCouvertureChp); |
this.add(couvertureFieldSet); |
} |
private void creerFieldsetType() { |
FieldSet typeFieldSet = new FieldSet(); |
typeFieldSet.setHeading("Spécimens «types»"); |
typeFieldSet.setCollapsible(true); |
typeFieldSet.setLayout(Formulaire.creerFormLayout(largeurLabelDefaut, alignementLabelDefaut)); |
specimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.specimenTypeCollection(), "onpi", tabIndex++); |
typeFieldSet.add(specimenTypeCombo); |
ConteneurMultiChamps nbreTypeConteneur = new ConteneurMultiChamps(i18nC.nbreSpecimenTypeCollection()); |
nbreTypeChp = new NumberField(); |
nbreTypeChp.setFormat(NumberFormat.getFormat("#")); |
nbreTypeConteneur.ajouterChamp(nbreTypeChp, new HBoxLayoutData(new Margins(0, 20, 0, 0))); |
precisionTypeNbreCombo = new ChampComboBoxListeValeurs(null, "ea"); |
precisionTypeNbreCombo.setTrie("id_valeur"); |
precisionTypeNbreCombo.setEmptyText(i18nC.precisionNbreSpecimenTypeCollectionChpVide()); |
nbreTypeConteneur.ajouterChamp(precisionTypeNbreCombo); |
typeFieldSet.add(nbreTypeConteneur); |
classementSpecimenTypeCombo = new ChampComboBoxListeValeurs(i18nC.classementSpecimenTypeCollection(), "typeClassement", tabIndex++); |
typeFieldSet.add(classementSpecimenTypeCombo); |
Text infoType = new Text(i18nC.specimenTypeCollectionInfo()); |
typeFieldSet.add(infoType); |
this.add(typeFieldSet); |
} |
public void peupler() { |
initialiserCollection(); |
if (collection != null) { |
idCollectionChp.setValue(collection.getId()); |
setValeurComboProjets(); |
setValeurComboStructures(); |
setValeurComboCollections(); |
typeDepotCombo.peupler(collection.getTypeDepot()); |
coteChp.setValue(collection.getCote()); |
idAlternatifsChp.peupler(collection.getIdAlternatif()); |
nomsAlternatifsChp.peupler(collection.getNomAlternatif()); |
codesAlternatifsChp.peupler(collection.getCode()); |
descriptionChp.setValue(collection.getDescription()); |
descriptionSpecialisteChp.setValue(collection.getDescriptionSpecialiste()); |
historiqueChp.setValue(collection.getHistorique()); |
urlsChp.peupler(collection.getUrls()); |
periodeConstitutionChp.peupler(collection.getPeriodeConstitution()); |
groupementPrincipeCombo.peupler(collection.getGroupementPrincipe()); |
butRealisationCombo.peupler(collection.getGroupementBut()); |
lieuCouvertureChp.peupler(collection.getCouvertureLieu()); |
specimenTypeCombo.peupler(collection.getSpecimenType()); |
nbreTypeChp.setValue((collection.getSpecimenTypeNbre().equals("") ? 0 : Integer.parseInt(collection.getSpecimenTypeNbre()))); |
precisionTypeNbreCombo.peupler(collection.getSpecimenTypeNbrePrecision()); |
classementSpecimenTypeCombo.peupler(collection.getSpecimenTypeClassement()); |
} |
} |
public ArrayList<String> verifier() { |
ArrayList<String> messages = new ArrayList<String>(); |
if (projetsCombo.getValue() == null || !projetsCombo.isValid()) { |
messages.add(i18nM.selectionObligatoire(i18nC.articleUn()+" "+i18nC.projetSingulier(), i18nC.articleLa()+" "+i18nC.collectionSingulier())); |
} |
return messages; |
} |
public void collecter() { |
initialiserCollection(); |
if (etreAccede()) { |
collectionCollectee.setId(idCollectionChp.getValue()); |
collectionCollectee.setIdProjet(getValeurComboProjets()); |
collectionCollectee.setIdStructure(getValeurComboStructures()); |
collectionCollectee.setCollectionMereId(getValeurComboCollections()); |
collectionCollectee.setTypeDepot(typeDepotCombo.getValeur()); |
collectionCollectee.setCote(coteChp.getValue()); |
collectionCollectee.setIdAlternatif(idAlternatifsChp.getValeurs()); |
collectionCollectee.setNomAlternatif(nomsAlternatifsChp.getValeurs()); |
collectionCollectee.setCode(codesAlternatifsChp.getValeurs()); |
collectionCollectee.setDescription(descriptionChp.getValue()); |
collectionCollectee.setDescriptionSpecialiste(descriptionSpecialisteChp.getValue()); |
collectionCollectee.setHistorique(historiqueChp.getValue()); |
collectionCollectee.setUrls(urlsChp.getValeurs()); |
collectionCollectee.setPeriodeConstitution(periodeConstitutionChp.getValeur()); |
collectionCollectee.setGroupementPrincipe(groupementPrincipeCombo.getValeur()); |
collectionCollectee.setGroupementBut(butRealisationCombo.getValeur()); |
collectionCollectee.setCouvertureLieu(lieuCouvertureChp.getValeurs()); |
collectionCollectee.setSpecimenType(specimenTypeCombo.getValeur()); |
if (nbreTypeChp.getValue() != null) { |
collectionCollectee.setSpecimenTypeNbre(nbreTypeChp.getValue().toString()); |
} |
collectionCollectee.setSpecimenTypeNbrePrecision(precisionTypeNbreCombo.getValeur()); |
collectionCollectee.setSpecimenTypeClassement(classementSpecimenTypeCombo.getValeur()); |
} |
} |
private String getValeurComboProjets() { |
String valeur = ""; |
if (projetsCombo.getValue() != null) { |
valeur = projetsCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboProjets() { |
if (projetsCombo.getStore() != null && collection != null) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", collection.getIdProjet())); |
} |
} |
private String getValeurComboStructures() { |
String valeur = ""; |
if (structuresCombo.getValue() != null) { |
valeur = structuresCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboStructures() { |
if (structuresCombo.getStore() != null && collection != null) { |
structuresCombo.setValue(structuresCombo.getStore().findModel("id_structure", collection.getIdStructure())); |
} |
} |
private String getValeurComboCollections() { |
String valeur = ""; |
if (collectionsCombo.getValue() != null) { |
valeur = collectionsCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboCollections() { |
if (collectionsCombo.getStore() != null && collection != null) { |
collectionsCombo.setValue(collectionsCombo.getStore().findModel("id_collection", collection.getCollectionMereId())); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(projets, projetsCombo); |
setValeurComboProjets(); |
} else if (nouvellesDonnees instanceof StructureListe) { |
StructureListe structures = (StructureListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(structures, structuresCombo); |
setValeurComboStructures(); |
} else if (nouvellesDonnees instanceof CollectionListe) { |
CollectionListe collections = (CollectionListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(collections, collectionsCombo); |
setValeurComboCollections(); |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
private void rafraichirValeurListe(ValeurListe listeValeurs) { |
if (listeValeurs.getId().equals(config.getListeId("typeDepot"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeDepotCombo); |
} else { |
Debug.log("Gestion de la liste "+listeValeurs.getId()+" non implémenté!"); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionDetailVue.java |
---|
New file |
0,0 → 1,1116 |
package org.tela_botanica.client.vues.collection; |
import java.util.HashMap; |
import java.util.Iterator; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
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.collection.Collection; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaire; |
import org.tela_botanica.client.modeles.collection.CollectionACommentaireListe; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonne; |
import org.tela_botanica.client.modeles.collection.CollectionAPersonneListe; |
import org.tela_botanica.client.modeles.collection.CollectionAPublication; |
import org.tela_botanica.client.modeles.collection.CollectionAPublicationListe; |
import org.tela_botanica.client.modeles.collection.CollectionBotanique; |
import org.tela_botanica.client.modeles.collection.UniteBase; |
import org.tela_botanica.client.modeles.collection.UniteRangement; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilNombre; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.DetailVue; |
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.Html; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
public class CollectionDetailVue extends DetailVue implements Rafraichissable { |
private Collection collection = null; |
private boolean collectionChargementOk = false; |
private boolean personnesLieesChargementOk = false; |
private boolean publicationsLieesChargementOk = false; |
private boolean commentairesLieesChargementOk = false; |
private Structure structure = null; |
private String enteteTpl = null; |
private String generalTpl = null; |
private String personneTpl = null; |
private String tableauPersonnesLieesTpl = null; |
private String lignePersonneLieeTpl = null; |
private String publicationTpl = null; |
private String tableauPublicationsLieesTpl = null; |
private String lignePublicationLieeTpl = null; |
private String descriptionTpl = null; |
private String contenuTpl = null; |
private String inventaireTpl = null; |
private String commentaireTpl = null; |
private String tableauCommentairesLieesTpl = null; |
private String ligneCommentaireLieeTpl = null; |
private ContentPanel panneauPrincipal = null; |
private Html entete = null; |
private TabPanel onglets = null; |
private TabItem generalOnglet = null; |
private TabItem personneOnglet = null; |
private TabItem publicationOnglet = null; |
private TabItem descriptionOnglet = null; |
private TabItem contenuOnglet = null; |
private TabItem inventaireOnglet = null; |
private TabItem commentaireOnglet = null; |
private String tableauUniteRangementTpl; |
private String ligneUniteRangementTpl; |
private String tableauUniteBaseTpl; |
private String ligneUniteBaseTpl; |
public CollectionDetailVue(Mediateur mediateurCourant) { |
super(mediateurCourant); |
initialiserTousLesTpl(); |
chargerOntologie(); |
panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(false); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
panneauPrincipal.setTopComponent(entete); |
onglets = new TabPanel(); |
onglets.setId(ComposantId.ZONE_DETAIL_CORPS); |
onglets.setBodyBorder(false); |
generalOnglet = new TabItem(i18nC.structureInfoGeneral()); |
generalOnglet.setLayout(new AnchorLayout()); |
generalOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(generalOnglet); |
personneOnglet = new TabItem(i18nC.collectionPersonne()); |
personneOnglet.setLayout(new AnchorLayout()); |
personneOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(personneOnglet); |
publicationOnglet = new TabItem(i18nC.collectionPublication()); |
publicationOnglet.setLayout(new AnchorLayout()); |
publicationOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(publicationOnglet); |
descriptionOnglet = new TabItem(i18nC.collectionDescription()); |
descriptionOnglet.setLayout(new AnchorLayout()); |
descriptionOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(descriptionOnglet); |
contenuOnglet = new TabItem(i18nC.collectionContenu()); |
contenuOnglet.setLayout(new AnchorLayout()); |
contenuOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(contenuOnglet); |
inventaireOnglet = new TabItem(i18nC.collectionInventaire()); |
inventaireOnglet.setLayout(new AnchorLayout()); |
inventaireOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(inventaireOnglet); |
commentaireOnglet = new TabItem(i18nC.collectionCommentaire()); |
commentaireOnglet.setLayout(new AnchorLayout()); |
commentaireOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(commentaireOnglet); |
panneauPrincipal.add(onglets); |
add(panneauPrincipal); |
} |
private void initialiserTousLesTpl() { |
initialiserEnteteHtmlTpl(); |
initialiserGeneralTpl(); |
initialiserPersonneTpl(); |
initialiserTableauPersonnesLieesTpl(); |
initialiserLignePersonneLieeTpl(); |
initialiserPublicationTpl(); |
initialiserTableauPublicationsLieesTpl(); |
initialiserLignePublicationLieeTpl(); |
initialiserContenuTpl(); |
initialiserDescriptionTpl(); |
initialiserTableauUniteRangementTpl(); |
initialiserLigneUniteRangementTpl(); |
initialiserTableauUniteBaseTpl(); |
initialiserLigneUniteBaseTpl(); |
initialiserInventaireTpl(); |
initialiserCommentaireTpl(); |
initialiserTableauCommentairesLieesTpl(); |
initialiserLigneCommentaireLieeTpl(); |
} |
private void initialiserEnteteHtmlTpl() { |
enteteTpl = |
"<div id='{css_id}'>"+ |
" <h1>{nom}</h1>"+ |
" <h2>{structure}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" + |
"</div>"; |
} |
private void initialiserGeneralTpl() { |
generalTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_identification}</h2>"+ |
" <span class='{css_label}'>{i18n_nom_alternatif} :</span> {nom_alternatif}<br />"+ |
" <span class='{css_label}'>{i18n_mere} :</span> {mere}<br />"+ |
" <span class='{css_label}'>{i18n_type_ncd} :</span> {type_ncd}<br />"+ |
" <span class='{css_label}'>{i18n_type_depot} :</span> {type_depot}<br />"+ |
" <span class='{css_label}'>{i18n_id_alternatif} :</span> {id_alternatif}<br />"+ |
" <span class='{css_label}'>{i18n_code} :</span> {code}<br />"+ |
" <span class='{css_label}'>{i18n_cote} :</span> {cote}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_general_collection_titre}</h2>"+ |
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+ |
" <span class='{css_label}'>{i18n_description_specialiste} :</span> {description_specialiste}<br />"+ |
" <span class='{css_label}'>{i18n_historique} :</span> {historique}<br />"+ |
" <span class='{css_label}'>{i18n_web} :</span> {web}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_couverture_collection_titre}</h2>"+ |
" <span class='{css_label}'>{i18n_groupement_principe} :</span> {groupement_principe}<br />"+ |
" <span class='{css_label}'>{i18n_groupement_but} :</span> {groupement_but}<br />"+ |
" <span class='{css_label}'>{i18n_couverture_geo} :</span> {couverture_geo}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_specimen_type_titre}</h2>"+ |
" <span class='{css_label}'>{i18n_specimen_type_presence} :</span> {specimen_type_presence}<br />"+ |
" <span class='{css_label}'>{i18n_specimen_type_nombre} :</span> {specimen_type_nombre}<br />"+ |
" <span class='{css_label}'>{i18n_specimen_type_classement} :</span> {specimen_type_classement}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
"</div>"; |
} |
private void initialiserPersonneTpl() { |
personneTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_personne}</h2>"+ |
" {tableau_personnes_liees}"+ |
"</div>"; |
} |
private void initialiserTableauPersonnesLieesTpl() { |
tableauPersonnesLieesTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_relation}</th>" + |
" <th>{i18n_nom_complet}</th>" + |
" <th>{i18n_nom}</th>" + |
" <th>{i18n_prenom}</th>" + |
" <th>{i18n_naissance_date}</th>" + |
" <th>{i18n_naissance_lieu}</th>" + |
" <th>{i18n_etre_decede}</th>" + |
" <th>{i18n_deces_date}</th>" + |
" <th>{i18n_deces_lieu}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLignePersonneLieeTpl() { |
lignePersonneLieeTpl = |
"<tr>"+ |
" <td>{relation}</td>"+ |
" <td>{nom_complet}</td>"+ |
" <td>{nom}</td>"+ |
" <td>{prenom}</td>"+ |
" <td>{naissance_date}</td>"+ |
" <td>{naissance_lieu}</td>"+ |
" <td>{etre_decede}</td>"+ |
" <td>{deces_date}</td>"+ |
" <td>{deces_lieu}</td>"+ |
"</tr>"; |
} |
private void initialiserPublicationTpl() { |
publicationTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_publication}</h2>"+ |
" {tableau_publications_liees}"+ |
"</div>"; |
} |
private void initialiserTableauPublicationsLieesTpl() { |
tableauPublicationsLieesTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_auteur}</th>" + |
" <th>{i18n_titre}</th>" + |
" <th>{i18n_revue}</th>" + |
" <th>{i18n_editeur}</th>" + |
" <th>{i18n_annee}</th>" + |
" <th>{i18n_nvt}</th>" + |
" <th>{i18n_fascicule}</th>" + |
" <th>{i18n_page}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLignePublicationLieeTpl() { |
lignePublicationLieeTpl = |
"<tr>"+ |
" <td>{auteur}</td>"+ |
" <td>{titre}</td>"+ |
" <td>{revue}</td>"+ |
" <td>{editeur}</td>"+ |
" <td>{annee}</td>"+ |
" <td>{nvt}</td>"+ |
" <td>{fascicule}</td>"+ |
" <td>{page}</td>"+ |
"</tr>"; |
} |
private void initialiserDescriptionTpl() { |
descriptionTpl = |
"<div class='{css_corps}'>"+ |
" <div>"+ |
" <h2>{i18n_titre_description}</h2>"+ |
" <span class='{css_label}'>{i18n_type_botanique} :</span> {type_botanique}<br />"+ |
" <span class='{css_label}'>{i18n_nbre_echantillon} :</span> {nbre_echantillon}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_unite_rangement}</h2>"+ |
" <span class='{css_label}'>{i18n_etat_unite_rangement} :</span> {etat_unite_rangement}<br />"+ |
" {tableau_unite_rangement}"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_unite_base}</h2>"+ |
" {tableau_unite_base}"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_conservation}</h2>"+ |
" <span class='{css_label}'>{i18n_type_papier} :</span> {type_papier}<br />"+ |
" <span class='{css_label}'>{i18n_conservation_methode} :</span> {conservation_methode}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_etiquette}</h2>"+ |
" <span class='{css_label}'>{i18n_specimen_fixation_pourcent} :</span> {specimen_fixation_pourcent}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_fixation_pourcent} :</span> {etiquette_fixation_pourcent}<br />"+ |
" <span class='{css_label}'>{i18n_specimen_fixation_methode} :</span> {specimen_fixation_methode}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_fixation_methode_support} :</span> {etiquette_fixation_methode_support}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_fixation_methode_specimen} :</span> {etiquette_fixation_methode_specimen}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_type_ecriture} :</span> {etiquette_type_ecriture}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_traitement}</h2>"+ |
" <span class='{css_label}'>{i18n_traitement} :</span> {traitement}<br />"+ |
" <span class='{css_label}'>{i18n_traitement_poison} :</span> {traitement_poison}<br />"+ |
" <span class='{css_label}'>{i18n_traitement_insecte} :</span> {traitement_insecte}<br />"+ |
" </div>"+ |
" <div>"+ |
" <h2>{i18n_titre_etat_degradation}</h2>"+ |
" <span class='{css_label}'>{i18n_etat_general} :</span> {etat_general}<br />"+ |
" <span class='{css_label}'>{i18n_degradation_specimen} :</span> {degradation_specimen}<br />"+ |
" <span class='{css_label}'>{i18n_degradation_presentation} :</span> {degradation_presentation}<br />"+ |
" <span class='{css_label}'>{i18n_determination} :</span> {determination}<br />"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserTableauUniteRangementTpl() { |
tableauUniteRangementTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_type}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" <th>{i18n_format}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLigneUniteRangementTpl() { |
ligneUniteRangementTpl = |
"<tr>"+ |
" <td>{type}</td>"+ |
" <td>{nombre}</td>"+ |
" <td>{precision}</td>"+ |
" <td>{format}</td>"+ |
"</tr>"; |
} |
private void initialiserTableauUniteBaseTpl() { |
tableauUniteBaseTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th colspan='4'>{i18n_unite_base}</th>" + |
" <th colspan='2'>{i18n_part}</th>" + |
" <th colspan='2'>{i18n_sp}</th>" + |
" </tr>"+ |
" <tr>" + |
" <th>{i18n_type}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" <th>{i18n_format}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" <th>{i18n_nombre}</th>" + |
" <th>{i18n_precision}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLigneUniteBaseTpl() { |
ligneUniteBaseTpl = |
"<tr>"+ |
" <td>{type}</td>"+ |
" <td>{nombre}</td>"+ |
" <td>{precision}</td>"+ |
" <td>{format}</td>"+ |
" <td>{part_nombre}</td>"+ |
" <td>{part_precision}</td>"+ |
" <td>{sp_nombre}</td>"+ |
" <td>{sp_precision}</td>"+ |
"</tr>"; |
} |
private void initialiserContenuTpl() { |
contenuTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_nature}</h2>"+ |
" <span class='{css_label}'>{i18n_nature} :</span> {nature}<br />"+ |
" <span class='{css_label}'>{i18n_specialite} :</span> {specialite}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_constitution}</h2>"+ |
" <span class='{css_label}'>{i18n_periode} :</span> {periode}<br />"+ |
" <span class='{css_label}'>{i18n_date_debut} :</span> {date_debut}<br />"+ |
" <span class='{css_label}'>{i18n_date_fin} :</span> {date_fin}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_classement}</h2>"+ |
" <span class='{css_label}'>{i18n_classement_etat} :</span> {classement_etat}<br />"+ |
" <span class='{css_label}'>{i18n_classement} :</span> {classement}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_etiquette}</h2>"+ |
" <span class='{css_label}'>{i18n_etiquette_renseignement} :</span> {etiquette_renseignement}<br />"+ |
" <span class='{css_label}'>{i18n_precision_localite} :</span> {precision_localite}<br />"+ |
" <span class='{css_label}'>{i18n_precision_date} :</span> {precision_date}<br />"+ |
" <span class='{css_label}'>{i18n_etiquette_annotation} :</span> {etiquette_annotation}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_integree}</h2>"+ |
" <span class='{css_label}'>{i18n_collection_integration} :</span> {collection_integration}<br />"+ |
" <span class='{css_label}'>{i18n_collection_integration_info} :</span> {collection_integration_info}<br />"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserInventaireTpl() { |
inventaireTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_inventaire}</h2>"+ |
" <span class='{css_label}'>{i18n_existence} :</span> {existence}<br />"+ |
" <span class='{css_label}'>{i18n_participation_auteur} :</span> {participation_auteur}<br />"+ |
" <span class='{css_label}'>{i18n_forme} :</span> {forme}<br />"+ |
" <span class='{css_label}'>{i18n_info} :</span> {info}<br />"+ |
" <span class='{css_label}'>{i18n_digital} :</span> {digital}<br />"+ |
" <span class='{css_label}'>{i18n_digital_pourcent} :</span> {digital_pourcent}<br />"+ |
" <span class='{css_label}'>{i18n_etat} :</span> {etat}<br />"+ |
" <span class='{css_label}'>{i18n_type_donnee} :</span> {type_donnee}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
"</div>"; |
} |
private void initialiserCommentaireTpl() { |
commentaireTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_commentaire}</h2>"+ |
" {tableau_commentaires_liees}"+ |
"</div>"; |
} |
private void initialiserTableauCommentairesLieesTpl() { |
tableauCommentairesLieesTpl = |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_type}</th>" + |
" <th>{i18n_titre}</th>" + |
" <th>{i18n_ponderation}</th>" + |
" <th>{i18n_public}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLigneCommentaireLieeTpl() { |
ligneCommentaireLieeTpl = |
"<tr>"+ |
" <td>{type}</td>"+ |
" <td>{titre}</td>"+ |
" <td>{ponderation}</td>"+ |
" <td>{public}</td>"+ |
"</tr>"+ |
"<tr>"+ |
" <td colspan='4'>{texte}</td>"+ |
"</tr>"; |
} |
private void chargerOntologie() { |
String[] listesCodes = {"typeCollectionBota", "typeCollectionNcd", "typeDepot", "groupementPrincipe", |
"realisationBut", "onpi", "ea", "typeClassement", "relationPersonneCollection", "ion", |
"typeUniteRangement", "etat", "typeUniteBase", "typePapier", "methodeRangement", "methodeFixation", |
"methodeFixationSurSpecimen", "typeEcriture", "poisonTraitement", "insecteTraitement", "specimenDegradation", |
"niveauImportance", "supportDegradation", "niveauDetermination", "natureVegetale", "siecleNaturaliste", |
"dateDebut", "dateFin", "etat", "onep", "onp", "inventaireForme", "inventaireLogiciel", "inventaireEtat", |
"etatClassement", "typeCommentaireCollection"}; |
lancerChargementListesValeurs(listesCodes); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Collection) { |
collection = (Collection) nouvellesDonnees; |
collectionChargementOk = true; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
projets = (ProjetListe) nouvellesDonnees; |
projetsChargementOk = true; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees; |
receptionerListeValeurs(listeValeursReceptionnee); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("liste_collection_a_personne")) { |
lierCollectionAPersonne((CollectionAPersonneListe) info.getDonnee(0)); |
} else if (info.getType().equals("liste_collection_a_publication")) { |
lierCollectionAPublication((CollectionAPublicationListe) info.getDonnee(0)); |
} else if (info.getType().equals("liste_collection_a_commentaire")) { |
lierCollectionACommentaire((CollectionACommentaireListe) info.getDonnee(0)); |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
if (avoirDonneesChargees()) { |
afficherDetail(); |
} |
} |
protected void lierCollectionAPersonne(CollectionAPersonneListe personnes) { |
collection.setPersonnesLiees(personnes); |
personnesLieesChargementOk = true; |
} |
protected void lierCollectionAPublication(CollectionAPublicationListe publications) { |
collection.setPublicationsLiees(publications); |
publicationsLieesChargementOk = true; |
} |
protected void lierCollectionACommentaire(CollectionACommentaireListe commentaires) { |
collection.setCommentairesLiees(commentaires); |
commentairesLieesChargementOk = true; |
} |
private boolean avoirDonneesChargees() { |
boolean ok = false; |
//Debug.log("projetsChargementOk:"+projetsChargementOk+"-collectionChargementOk:"+collectionChargementOk+"-ontologieChargementOk:"+ontologieChargementOk+"-personnesLieesChargementOk:"+personnesLieesChargementOk+"-publicationsLieesChargementOk:"+publicationsLieesChargementOk); |
if (projetsChargementOk && collectionChargementOk && ontologieChargementOk && personnesLieesChargementOk && publicationsLieesChargementOk && commentairesLieesChargementOk) { |
ok = true; |
} |
return ok; |
} |
private void afficherDetail() { |
if (collection != null) { |
afficherEntete(); |
afficherIdentification(); |
afficherPersonne(); |
afficherPublication(); |
afficherDescription(); |
afficherContenu(); |
afficherInventaire(); |
afficherCommentaire(); |
} |
layout(); |
} |
private void afficherEntete() { |
Params enteteParams = new Params(); |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE); |
enteteParams.set("css_meta", ComposantClass.META); |
enteteParams.set("i18n_id", i18nC.id()); |
enteteParams.set("nom", collection.getNom()); |
enteteParams.set("structure", collection.getStructureNom()); |
enteteParams.set("id", collection.getId()); |
enteteParams.set("guid", collection.getGuid()); |
enteteParams.set("projet", construireTxtProjet(collection.getIdProjet())); |
String eHtml = Format.substitute(enteteTpl, enteteParams); |
entete.getElement().setInnerHTML(eHtml); |
} |
private void afficherIdentification() { |
Params generalParams = new Params(); |
generalParams.set("i18n_titre_identification", i18nC.titreAdministratif()); |
generalParams.set("i18n_nom_alternatif", i18nC.intituleAlternatifCollection()); |
generalParams.set("i18n_mere", i18nC.collectionMere()); |
generalParams.set("i18n_type_ncd", i18nC.typeCollectionNcd()); |
generalParams.set("i18n_type_depot", i18nC.typeDepot()); |
generalParams.set("i18n_id_alternatif", i18nC.idAlternatifCollection()); |
generalParams.set("i18n_code", i18nC.codeAlternatifCollection()); |
generalParams.set("i18n_cote", i18nC.cote()); |
generalParams.set("i18n_general_collection_titre", i18nC.collectionGeneralTitre()); |
generalParams.set("i18n_description", i18nC.description()); |
generalParams.set("i18n_description_specialiste", i18nC.descriptionSpecialiste()); |
generalParams.set("i18n_historique", i18nC.historique()); |
generalParams.set("i18n_web", i18nC.siteWeb()); |
generalParams.set("i18n_couverture_collection_titre", i18nC.collectionCouvertureTitre()); |
generalParams.set("i18n_groupement_principe", i18nC.groupementPrincipe()); |
generalParams.set("i18n_groupement_but", i18nC.groupementBut()); |
generalParams.set("i18n_couverture_geo", i18nC.couvertureGeo()); |
generalParams.set("i18n_specimen_type_titre", i18nC.collectionSpecimenTypeTitre()); |
generalParams.set("i18n_specimen_type_presence", i18nC.specimenTypeCollectionDetail()); |
generalParams.set("i18n_specimen_type_nombre", i18nC.nbreSpecimenTypeCollectionDetail()); |
generalParams.set("i18n_specimen_type_classement", i18nC.classementSpecimenTypeCollectionDetail()); |
String nomAlternatif = construireTxtTruck(collection.getNomAlternatif()); |
String typeNcd = construireTxtListeOntologie(collection.getTypeNcd()); |
String typeDepot = construireTxtListeOntologie(collection.getTypeDepot()); |
String idAlternatif = construireTxtTruck(collection.getIdAlternatif()); |
String code = construireTxtTruck(collection.getCode()); |
String urls = construireTxtTruck(collection.getUrls()); |
String groupementBut = construireTxtListeOntologie(collection.getGroupementBut()); |
String groupementPrincipe = construireTxtListeOntologie(collection.getGroupementPrincipe()); |
String couvertureGeo = construireTxtTruck(collection.getCouvertureLieu()); |
String specimenTypePresence = construireTxtListeOntologie(collection.getSpecimenType()); |
String specimenTypeNombrePrecision = construireTxtListeOntologie(collection.getSpecimenTypeNbrePrecision()); |
String specimenTypeNombre = ""; |
if (!collection.getSpecimenTypeNbre().equals("0") && !collection.getSpecimenTypeNbre().equals("")) { |
specimenTypeNombre = collection.getSpecimenTypeNbre()+" ("+specimenTypeNombrePrecision+")"; |
} |
String specimenTypeClassement = construireTxtListeOntologie(collection.getSpecimenTypeClassement()); |
generalParams.set("nom_alternatif", nomAlternatif); |
generalParams.set("mere", collection.getCollectionMereNom()); |
generalParams.set("type_ncd", typeNcd); |
generalParams.set("type_depot", typeDepot); |
generalParams.set("id_alternatif", idAlternatif); |
generalParams.set("code", code); |
generalParams.set("cote", collection.getCote()); |
generalParams.set("description", collection.getDescription()); |
generalParams.set("description_specialiste", collection.getDescriptionSpecialiste()); |
generalParams.set("historique", collection.getHistorique()); |
generalParams.set("web", urls); |
generalParams.set("groupement_principe", groupementPrincipe); |
generalParams.set("groupement_but", groupementBut); |
generalParams.set("couverture_geo", couvertureGeo); |
generalParams.set("specimen_type_presence", specimenTypePresence); |
generalParams.set("specimen_type_nombre", specimenTypeNombre); |
generalParams.set("specimen_type_classement", specimenTypeClassement); |
afficherOnglet(generalTpl, generalParams, generalOnglet); |
} |
private void afficherPersonne() { |
String tableauPersonneHtml = ""; |
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) { |
tableauPersonneHtml = construireTableauPersonnesLiees(); |
} |
Params personneParams = new Params(); |
personneParams.set("i18n_titre_personne", i18nC.collectionPersonneTitre()); |
personneParams.set("tableau_personnes_liees", tableauPersonneHtml); |
afficherOnglet(personneTpl, personneParams, personneOnglet); |
} |
private String construireTableauPersonnesLiees() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_relation", i18nC.typeRelationPersonneCollection()); |
contenuParams.set("i18n_nom_complet", i18nC.personneNomComplet()); |
contenuParams.set("i18n_prenom", i18nC.personnePrenom()); |
contenuParams.set("i18n_nom", i18nC.personneNom()); |
contenuParams.set("i18n_naissance_date", i18nC.personneDateNaissance()); |
contenuParams.set("i18n_naissance_lieu", i18nC.personneLieuNaissance()); |
contenuParams.set("i18n_etre_decede", i18nC.personneDeces()); |
contenuParams.set("i18n_deces_date", i18nC.personneDateDeces()); |
contenuParams.set("i18n_deces_lieu", i18nC.personneLieuDeces()); |
String lignesPersonnel = ""; |
if (collection.getPersonnesLiees() != null) { |
Iterator<String> it = collection.getPersonnesLiees().keySet().iterator(); |
while (it.hasNext()) { |
CollectionAPersonne relationCollectionAPersonne = collection.getPersonnesLiees().get(it.next()); |
Personne personne = relationCollectionAPersonne.getPersonne(); |
String relation = construireTxtListeOntologie(relationCollectionAPersonne.getIdRole()); |
String etreDecede = construireTxtListeOntologie(personne.getDeces()); |
Params ligneParams = new Params(); |
ligneParams.set("relation", relation); |
ligneParams.set("nom_complet", personne.getNomComplet()); |
ligneParams.set("nom", personne.getNom()); |
ligneParams.set("prenom", personne.getPrenom()); |
ligneParams.set("naissance_date", personne.getNaissanceDate()); |
ligneParams.set("naissance_lieu", personne.getNaissanceLieu()); |
ligneParams.set("etre_decede", etreDecede); |
ligneParams.set("deces_date", personne.getDecesDate()); |
ligneParams.set("deces_lieu", personne.getDecesLieu()); |
lignesPersonnel += Format.substitute(lignePersonneLieeTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesPersonnel)) { |
contenuParams.set("lignes", lignesPersonnel); |
cHtml = Format.substitute(tableauPersonnesLieesTpl, contenuParams); |
} |
return cHtml; |
} |
private void afficherPublication() { |
Params publicationParams = new Params(); |
publicationParams.set("i18n_titre_publication", i18nC.collectionPublicationTitre()); |
String tableauPublicationHtml = ""; |
if (collection.getPersonnesLiees() != null && collection.getPersonnesLiees().size() > 0) { |
tableauPublicationHtml = construireTableauPublicationsLiees(); |
} |
publicationParams.set("tableau_publications_liees", tableauPublicationHtml); |
afficherOnglet(publicationTpl, publicationParams, publicationOnglet); |
} |
private String construireTableauPublicationsLiees() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_auteur", i18nC.publicationAuteurs()); |
contenuParams.set("i18n_titre", i18nC.publicationTitre()); |
contenuParams.set("i18n_revue", i18nC.publicationRevueCollection()); |
contenuParams.set("i18n_editeur", i18nC.publicationEditeur()); |
contenuParams.set("i18n_annee", i18nC.publicationDateParution()); |
contenuParams.set("i18n_nvt", i18nC.publicationNvt()); |
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule()); |
contenuParams.set("i18n_page", i18nC.publicationPage()); |
String lignesPublication = ""; |
if (collection.getPublicationsLiees() != null) { |
Iterator<String> it = collection.getPublicationsLiees().keySet().iterator(); |
while (it.hasNext()) { |
CollectionAPublication relationCollectionAPublication = collection.getPublicationsLiees().get(it.next()); |
Publication publication = relationCollectionAPublication.getPublication(); |
Params ligneParams = new Params(); |
ligneParams.set("auteur", publication.getAuteur()); |
ligneParams.set("titre", publication.getTitre()); |
ligneParams.set("revue", publication.getCollection()); |
ligneParams.set("editeur", publication.getEditeur()); |
ligneParams.set("annee", publication.getAnneeParution()); |
ligneParams.set("nvt", publication.getIndicationNvt()); |
ligneParams.set("fascicule", publication.getFascicule()); |
ligneParams.set("page", publication.getPages()); |
lignesPublication += Format.substitute(lignePublicationLieeTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesPublication)) { |
contenuParams.set("lignes", lignesPublication); |
cHtml = Format.substitute(tableauPublicationsLieesTpl, contenuParams); |
} |
return cHtml; |
} |
private void afficherDescription() { |
Params descriptionParams = new Params(); |
descriptionParams.set("i18n_titre_description", i18nC.collectionDescriptionTitre()); |
descriptionParams.set("i18n_type_botanique", i18nC.typeCollectionBotanique()); |
descriptionParams.set("i18n_nbre_echantillon", i18nC.nbreEchantillon()); |
descriptionParams.set("i18n_titre_unite_rangement", i18nC.collectionUniteRangementTitre()); |
descriptionParams.set("i18n_etat_unite_rangement", i18nC.collectionUniteRangementEtatGeneralDetail()); |
descriptionParams.set("i18n_titre_unite_base", i18nC.collectionUniteBaseTitre()); |
descriptionParams.set("i18n_titre_conservation", i18nC.collectionTitreConservation()); |
descriptionParams.set("i18n_type_papier", i18nC.typePapierConservationDetail()); |
descriptionParams.set("i18n_conservation_methode", i18nC.methodeConservationDetail()); |
descriptionParams.set("i18n_titre_etiquette", i18nC.collectionTitreEtiquette()); |
descriptionParams.set("i18n_specimen_fixation_pourcent", i18nC.specimenFixationPourcent()); |
descriptionParams.set("i18n_etiquette_fixation_pourcent", i18nC.etiquetteFixationPourcent()); |
descriptionParams.set("i18n_specimen_fixation_methode", i18nC.specimenMethodeFixationDetail()); |
descriptionParams.set("i18n_etiquette_fixation_methode_support", i18nC.etiquetteMethodeFixationSurSupportDetail()); |
descriptionParams.set("i18n_etiquette_fixation_methode_specimen", i18nC.etiquetteMethodeFixationSurSpecimenDetail()); |
descriptionParams.set("i18n_etiquette_type_ecriture", i18nC.typeEcritureDetail()); |
descriptionParams.set("i18n_titre_traitement", i18nC.collectionTitreTraitement()); |
descriptionParams.set("i18n_traitement", i18nC.collectionTraitementDetail()); |
descriptionParams.set("i18n_traitement_poison", i18nC.collectionTraitementPoisonDetail()); |
descriptionParams.set("i18n_traitement_insecte", i18nC.collectionTraitementInsecteDetail()); |
descriptionParams.set("i18n_titre_etat_degradation", i18nC.collectionTitreEtatEtDegradation()); |
descriptionParams.set("i18n_etat_general", i18nC.collectionEtatGeneralDetail()); |
descriptionParams.set("i18n_degradation_specimen", i18nC.degradationSpecimenDetail()); |
descriptionParams.set("i18n_degradation_presentation", i18nC.degradationPresentationDetail()); |
descriptionParams.set("i18n_determination", i18nC.collectionDeterminationDetail()); |
String typeBota = construireTxtListeOntologie(collection.getBotanique().getType()); |
descriptionParams.set("type_botanique", typeBota); |
descriptionParams.set("nbre_echantillon", collection.getBotanique().getNbreEchantillon()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
String etatUniteRangement = construireTxtListeOntologie(collectionBotanique.getUniteRangementEtat()); |
String tableauUniteRangementHtml = construireTableauUniteRangement(); |
String tableauUniteBaseHtml = construireTableauUniteBase(); |
descriptionParams.set("tableau_unite_rangement", tableauUniteRangementHtml); |
descriptionParams.set("etat_unite_rangement", etatUniteRangement); |
descriptionParams.set("tableau_unite_base", tableauUniteBaseHtml); |
String typePapier = construireTxtListeOntologie(collectionBotanique.getConservationPapierType()); |
String conservationMethode = construireTxtListeOntologie(collectionBotanique.getConservationMethode()); |
descriptionParams.set("type_papier", typePapier); |
descriptionParams.set("conservation_methode", conservationMethode); |
String specimenFixationMethode = construireTxtListeOntologie(collectionBotanique.getSpecimenFixationMethode()); |
String etiquetteFixationMethodeSupport = construireTxtListeOntologie(collectionBotanique.getEtiquetteFixationSupport()); |
String etiquetteFixationMethodeSpecimen = construireTxtListeOntologie(collectionBotanique.getEtiquetteFixationSpecimen()); |
String etiquetteTypeEcriture = construireTxtListeOntologie(collectionBotanique.getEtiquetteEcriture()); |
descriptionParams.set("specimen_fixation_pourcent", collectionBotanique.getSpecimenFixationPourcent()); |
descriptionParams.set("etiquette_fixation_pourcent", collectionBotanique.getEtiquetteFixationPourcent()); |
descriptionParams.set("specimen_fixation_methode", specimenFixationMethode); |
descriptionParams.set("etiquette_fixation_methode_support", etiquetteFixationMethodeSupport); |
descriptionParams.set("etiquette_fixation_methode_specimen", etiquetteFixationMethodeSpecimen); |
descriptionParams.set("etiquette_type_ecriture", etiquetteTypeEcriture); |
String traitement = construireTxtListeOntologie(collectionBotanique.getTraitement()); |
String traitementPoison = construireTxtListeOntologie(collectionBotanique.getTraitementPoison()); |
String traitementInsecte = construireTxtListeOntologie(collectionBotanique.getTraitementInsecte()); |
descriptionParams.set("traitement", traitement); |
descriptionParams.set("traitement_poison", traitementPoison); |
descriptionParams.set("traitement_insecte", traitementInsecte); |
String etatGeneral = construireTxtListeOntologie(collectionBotanique.getEtatGeneral()); |
boolean valeurEstOntologie = false; |
boolean typeEstOntologie = true; |
boolean donneeEstOntologie = true; |
String degradationSpecimen = construireTxtListeOntologie(collectionBotanique.getDegradationSpecimen(), valeurEstOntologie, typeEstOntologie, donneeEstOntologie); |
String degradationPresentation = construireTxtListeOntologie(collectionBotanique.getDegradationPresentation(), valeurEstOntologie, typeEstOntologie, donneeEstOntologie); |
String determination = construireTxtListeOntologie(collectionBotanique.getDetermination()); |
descriptionParams.set("etat_general", etatGeneral); |
descriptionParams.set("degradation_specimen", degradationSpecimen); |
descriptionParams.set("degradation_presentation", degradationPresentation); |
descriptionParams.set("determination", determination); |
afficherOnglet(descriptionTpl, descriptionParams, descriptionOnglet); |
} |
private String construireTableauUniteRangement() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_type", i18nC.collectionUniteType()); |
contenuParams.set("i18n_nombre", i18nC.collectionUniteNbre()); |
contenuParams.set("i18n_precision", i18nC.collectionUnitePrecision()); |
contenuParams.set("i18n_format", i18nC.collectionUniteFormat()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
HashMap<String,UniteRangement> unites = CollectionFormDescription.parserValeurUniteRangement(collectionBotanique.getUniteRangement()); |
String lignesUnite = ""; |
Iterator<String> it = unites.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
UniteRangement unite = unites.get(cle); |
if (unite.getNombre() != 0) { |
Params ligneParams = new Params(); |
if (unite.getTypeAutre()) { |
ligneParams.set("type", unite.getType()); |
} else { |
ligneParams.set("type", construireTxtListeOntologie(unite.getId())); |
} |
ligneParams.set("nombre", UtilNombre.formaterEnEntier(unite.getNombre())); |
ligneParams.set("precision", unite.getPrecision()); |
ligneParams.set("format", unite.getFormat()); |
lignesUnite += Format.substitute(ligneUniteRangementTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesUnite)) { |
contenuParams.set("lignes", lignesUnite); |
cHtml = Format.substitute(tableauUniteRangementTpl, contenuParams); |
} |
return cHtml; |
} |
private String construireTableauUniteBase() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_unite_base", i18nC.collectionUniteBase()); |
contenuParams.set("i18n_part", i18nC.collectionUniteBasePart()); |
contenuParams.set("i18n_sp", i18nC.collectionUniteBaseSp()); |
contenuParams.set("i18n_type", i18nC.collectionUniteType()); |
contenuParams.set("i18n_nombre", i18nC.collectionUniteNbre()); |
contenuParams.set("i18n_precision", i18nC.collectionUnitePrecision()); |
contenuParams.set("i18n_format", i18nC.collectionUniteFormat()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
HashMap<String,UniteBase> unites = CollectionFormDescription.parserValeurUniteBase(collectionBotanique.getUniteBase()); |
String lignesUnite = ""; |
Iterator<String> it = unites.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
UniteBase unite = unites.get(cle); |
if (unite.getNombre() != 0 || unite.getNombrePart() != 0 || unite.getNombreSp() != 0) { |
Params ligneParams = new Params(); |
if (unite.getTypeAutre()) { |
ligneParams.set("type", unite.getType()); |
} else { |
ligneParams.set("type", construireTxtListeOntologie(unite.getId())); |
} |
ligneParams.set("nombre", UtilNombre.formaterEnEntier(unite.getNombre())); |
ligneParams.set("precision", unite.getPrecision()); |
ligneParams.set("format", unite.getFormat()); |
ligneParams.set("part_nombre", UtilNombre.formaterEnEntier(unite.getNombrePart())); |
ligneParams.set("part_precision", unite.getPrecisionPart()); |
ligneParams.set("sp_nombre", UtilNombre.formaterEnEntier(unite.getNombreSp())); |
ligneParams.set("sp_precision", unite.getPrecisionSp()); |
lignesUnite += Format.substitute(ligneUniteBaseTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesUnite)) { |
contenuParams.set("lignes", lignesUnite); |
cHtml = Format.substitute(tableauUniteBaseTpl, contenuParams); |
} |
return cHtml; |
} |
private void afficherContenu() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_titre_nature", i18nC.collectionNatureTitre()); |
contenuParams.set("i18n_nature", i18nC.natureVegetaleContenuDetail()); |
contenuParams.set("i18n_specialite", i18nC.specialiteCollectionDetail()); |
contenuParams.set("i18n_titre_constitution", i18nC.collectionConstitutionTitre()); |
contenuParams.set("i18n_periode", i18nC.periodeConstitutionDetail()); |
contenuParams.set("i18n_date_debut", i18nC.dateDebutCollectionDetail()); |
contenuParams.set("i18n_date_fin", i18nC.dateFinCollectionDetail()); |
contenuParams.set("i18n_titre_classement", i18nC.collectionClassementTitre()); |
contenuParams.set("i18n_classement_etat", i18nC.etatClassementCollectionDetail()); |
contenuParams.set("i18n_classement", i18nC.annotationClassementCollectionDetail()); |
contenuParams.set("i18n_titre_etiquette", i18nC.collectionEtiquetteTitre()); |
contenuParams.set("i18n_etiquette_renseignement", i18nC.etiquetteRenseignementDetail()); |
contenuParams.set("i18n_precision_localite", i18nC.precisionLocaliteDetail()); |
contenuParams.set("i18n_precision_date", i18nC.precisionDateDetail()); |
contenuParams.set("i18n_etiquette_annotation", i18nC.etiquetteAnnotationDetail()); |
contenuParams.set("i18n_titre_integree", i18nC.collectionIntegreeTitre()); |
contenuParams.set("i18n_collection_integration", i18nC.integreCollectionDetail()); |
contenuParams.set("i18n_collection_integration_info", i18nC.infoIntegreCollectionDetail()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
String nature = construireTxtListeOntologie(collectionBotanique.getNature()); |
contenuParams.set("nature", nature); |
contenuParams.set("specialite", collectionBotanique.getSpecialite()); |
String periode = construireTxtListeOntologie(collection.getPeriodeConstitution()); |
String dateDebut = collectionBotanique.getRecolteDateDebut(); |
String dateDebutPrecision = construireTxtListeOntologie(collectionBotanique.getRecolteDateDebutType()); |
String dateDebutRecolte = (UtilString.isEmpty(dateDebut)) ? "" : dateDebut+" ("+dateDebutPrecision+")"; |
String dateFin = collectionBotanique.getRecolteDateFin(); |
String dateFinPrecision = construireTxtListeOntologie(collectionBotanique.getRecolteDateFinType()); |
String dateFinRecolte = (UtilString.isEmpty(dateFin)) ? "" : dateFin+" ("+dateFinPrecision+")"; |
contenuParams.set("periode", periode); |
contenuParams.set("date_debut", dateDebutRecolte); |
contenuParams.set("date_fin", dateFinRecolte); |
String classementEtat = construireTxtListeOntologie(collectionBotanique.getClassementEtat()); |
contenuParams.set("classement_etat", classementEtat); |
contenuParams.set("classement", collectionBotanique.getClassementAnnotation()); |
String etiquetteRenseignements = ""; |
HashMap<String,String> infos = CollectionFormContenu.parserEtiquetteRenseignement(collectionBotanique.getEtiquetteRenseignement()); |
if (infos != null) { |
Iterator<String> it = infos.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (cle.equals("AT")) { |
etiquetteRenseignements += i18nC.etiquetteAuteurCollection(); |
} else if (cle.equals("F")) { |
etiquetteRenseignements += i18nC.etiquetteFamille(); |
} else if (cle.equals("G")) { |
etiquetteRenseignements += i18nC.etiquetteGenre(); |
} else if (cle.equals("SP")) { |
etiquetteRenseignements += i18nC.etiquetteSp(); |
} else if (cle.equals("ASP")) { |
etiquetteRenseignements += i18nC.etiquetteAuteurSp(); |
} else if (cle.equals("L")) { |
etiquetteRenseignements += i18nC.etiquetteLocalite(); |
} else if (cle.equals("D")) { |
etiquetteRenseignements += i18nC.etiquetteDateRecolte(); |
} else { |
etiquetteRenseignements += i18nC.inconnue(); |
} |
etiquetteRenseignements += ": "+infos.get(cle)+"%,"; |
} |
} |
String precisionLocalite = construireTxtListeOntologie(collectionBotanique.getPrecisionLocalite()); |
String precisionDate = construireTxtListeOntologie(collectionBotanique.getPrecisionDate()); |
contenuParams.set("etiquette_renseignement", etiquetteRenseignements); |
contenuParams.set("precision_localite", precisionLocalite); |
contenuParams.set("precision_date", precisionDate); |
contenuParams.set("etiquette_annotation", collectionBotanique.getAnnotationsDiverses()); |
String collectionIntegration = construireTxtListeOntologie(collectionBotanique.getCollectionIntegre()); |
String collectionIntegrationInfo = construireTxtListeOntologie(collectionBotanique.getCollectionIntegreInfo()); |
contenuParams.set("collection_integration", collectionIntegration); |
contenuParams.set("collection_integration_info", collectionIntegrationInfo); |
afficherOnglet(contenuTpl, contenuParams, contenuOnglet); |
} |
private void afficherInventaire() { |
Params inventaireParams = new Params(); |
inventaireParams.set("i18n_titre_inventaire", i18nC.collectionInventaireTitre()); |
inventaireParams.set("i18n_existence", i18nC.existenceInventaireCollectionDetail()); |
inventaireParams.set("i18n_participation_auteur", i18nC.auteurInventaireCollectionDetail()); |
inventaireParams.set("i18n_forme", i18nC.formeInventaireCollectionDetail()); |
inventaireParams.set("i18n_info", i18nC.infoInventaireCollectionDetail()); |
inventaireParams.set("i18n_digital", i18nC.digitalInventaireCollectionDetail()); |
inventaireParams.set("i18n_digital_pourcent", i18nC.pourcentDigitalInventaireCollectionDetail()); |
inventaireParams.set("i18n_etat", i18nC.etatInventaireCollectionDetail()); |
inventaireParams.set("i18n_type_donnee", i18nC.typeDonneeInventaireCollectionDetail()); |
CollectionBotanique collectionBotanique = collection.getBotanique(); |
String existence = construireTxtListeOntologie(collectionBotanique.getInventaire()); |
String participationAuteur = construireTxtListeOntologie(collectionBotanique.getInventaireAuteur()); |
String forme = construireTxtListeOntologie(collectionBotanique.getInventaireForme()); |
String digital = construireTxtListeOntologie(collectionBotanique.getInventaireDigital()); |
String digitalPourcent = collectionBotanique.getInventaireDigitalPourcent()+"%"; |
String etat = construireTxtListeOntologie(collectionBotanique.getInventaireEtat()); |
inventaireParams.set("existence", existence); |
inventaireParams.set("participation_auteur", participationAuteur); |
inventaireParams.set("forme", forme); |
inventaireParams.set("info", collectionBotanique.getInventaireInfo()); |
inventaireParams.set("digital", digital); |
inventaireParams.set("digital_pourcent", digitalPourcent); |
inventaireParams.set("etat", etat); |
inventaireParams.set("type_donnee", collectionBotanique.getInventaireDonneesTypes()); |
afficherOnglet(inventaireTpl, inventaireParams, inventaireOnglet); |
} |
private void afficherCommentaire() { |
String tableauCommentaireHtml = ""; |
if (collection.getCommentairesLiees() != null && collection.getCommentairesLiees().size() > 0) { |
tableauCommentaireHtml = construireTableauCommentairesLiees(); |
} |
Params personneParams = new Params(); |
personneParams.set("i18n_titre_commentaire", i18nC.collectionCommentaireTitre()); |
personneParams.set("tableau_commentaires_liees", tableauCommentaireHtml); |
afficherOnglet(commentaireTpl, personneParams, commentaireOnglet); |
} |
private String construireTableauCommentairesLiees() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_type", i18nC.commentaireType()); |
contenuParams.set("i18n_titre", i18nC.commentaireTitre()); |
contenuParams.set("i18n_texte", i18nC.commentaireTexte()); |
contenuParams.set("i18n_ponderation", i18nC.commentairePonderation()); |
contenuParams.set("i18n_public", i18nC.commentairePublic()); |
String lignesCommentaire = ""; |
if (collection.getCommentairesLiees() != null) { |
Iterator<String> it = collection.getCommentairesLiees().keySet().iterator(); |
while (it.hasNext()) { |
CollectionACommentaire relationCollectionACommentaire = collection.getCommentairesLiees().get(it.next()); |
Commentaire commentaire = relationCollectionACommentaire.getCommentaire(); |
String type = construireTxtListeOntologie(relationCollectionACommentaire.getType()); |
String acces = (commentaire.etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee()); |
Params ligneParams = new Params(); |
ligneParams.set("type", type); |
ligneParams.set("titre", commentaire.getTitre()); |
ligneParams.set("texte", commentaire.getTexte()); |
ligneParams.set("ponderation", commentaire.getPonderation()+"/100"); |
ligneParams.set("public", acces); |
lignesCommentaire += Format.substitute(ligneCommentaireLieeTpl, ligneParams); |
} |
} |
String cHtml = i18nC.nonRenseigne(); |
if (!UtilString.isEmpty(lignesCommentaire)) { |
contenuParams.set("lignes", lignesCommentaire); |
cHtml = Format.substitute(tableauCommentairesLieesTpl, contenuParams); |
} |
return cHtml; |
} |
protected String getNomStructure() { |
String nomStructure = ""; |
if (structure != null) { |
nomStructure = structure.getNom(); |
} else { |
nomStructure = collection.getIdStructure(); |
} |
return nomStructure; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/collection/CollectionForm.java |
---|
New file |
0,0 → 1,406 |
package org.tela_botanica.client.vues.collection; |
import java.util.ArrayList; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.collection.Collection; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilArray; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.structure.StructureForm; |
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.Info; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
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.FormData; |
import com.google.gwt.core.client.GWT; |
public class CollectionForm extends Formulaire implements Rafraichissable { |
protected Collection collection = null; |
protected Collection collectionCollectee = null; |
private ChampComboBoxListeValeurs typesCollectionCombo = null; |
private TabPanel onglets = null; |
private CollectionFormGeneral generalOnglet = null; |
private CollectionFormPersonne personneOnglet = null; |
private CollectionFormPublication publicationOnglet = null; |
private CollectionFormDescription descriptionOnglet = null; |
private CollectionFormContenu contenuOnglet = null; |
private CollectionFormInventaire inventaireOnglet = null; |
private CollectionFormCommentaire commentaireOnglet = null; |
private TextField<String> nomChp = null; |
public CollectionForm(Mediateur mediateurCourrant, String collectionId) { |
initialiserCollectionForm(mediateurCourrant, collectionId); |
} |
private void initialiserCollectionForm(Mediateur mediateurCourrant, String collectionId) { |
collection = new Collection(); |
collection.setId(collectionId); |
String modeDeCreation = (UtilString.isEmpty(collection.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION); |
genererTitreFormulaire(); |
creerOnglets(); |
creerFieldsetPrincipal(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateurCourrant.selectionnerCollection(this, collectionId, null); |
mediateurCourrant.selectionnerCollectionAPersonne(this, collectionId, null); |
mediateurCourrant.selectionnerCollectionAPublication(this, collectionId); |
mediateurCourrant.selectionnerCollectionACommentaire(this, collectionId); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.collectionTitreFormAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.collectionTitreFormModif(); |
if (collection != null) { |
titre += " - "+i18nC.id()+": "+collection.getId(); |
} |
} |
panneauFormulaire.setHeading(titre); |
} |
private void creerFieldsetPrincipal() { |
FieldSet principalFieldSet = new FieldSet(); |
principalFieldSet.setHeading("Info"); |
principalFieldSet.setCollapsible(true); |
principalFieldSet.setLayout(Formulaire.creerFormLayout(150, LabelAlign.LEFT)); |
nomChp = new TextField<String>(); |
nomChp.setTabIndex(tabIndex++); |
nomChp.setFieldLabel(i18nC.nomCollection()); |
nomChp.setAllowBlank(false); |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
nomChp.getMessages().setBlankText(i18nC.champObligatoire()); |
principalFieldSet.add(nomChp, new FormData(450, 0)); |
Listener<BaseEvent> ecouteurTypeCollection = new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
Valeur valeur = typesCollectionCombo.getValue(); |
// Gestion des onglets en fonction du type de collection |
mediateur.activerChargement(""); |
if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) { |
activerOngletsHerbier(); |
} else { |
activerOngletsDefaut(); |
} |
mediateur.desactiverChargement(); |
} |
}; |
typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++); |
typesCollectionCombo.peupler(Valeur.COLLECTION_NCD_HERBIER); |
typesCollectionCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
typesCollectionCombo.addListener(Events.Change, ecouteurTypeCollection); |
typesCollectionCombo.addListener(Events.Select, ecouteurTypeCollection); |
typesCollectionCombo.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
principalFieldSet.add(typesCollectionCombo, new FormData(150, 0)); |
typesCollectionCombo.fireEvent(Events.Select); |
panneauFormulaire.setTopComponent(principalFieldSet); |
} |
private void activerOngletsDefaut() { |
if (onglets.findItem(CollectionFormGeneral.ID, false) == null) { |
onglets.add(generalOnglet); |
} |
if (onglets.findItem(CollectionFormPersonne.ID, false) == null) { |
onglets.add(personneOnglet); |
} |
if (onglets.findItem(CollectionFormPublication.ID, false) != null) { |
onglets.remove(publicationOnglet); |
} |
if (onglets.findItem(CollectionFormDescription.ID, false) != null) { |
onglets.remove(descriptionOnglet); |
} |
if (onglets.findItem(CollectionFormContenu.ID, false) != null) { |
onglets.remove(contenuOnglet); |
} |
if (onglets.findItem(CollectionFormInventaire.ID, false) != null) { |
onglets.remove(inventaireOnglet); |
} |
if (onglets.findItem(CollectionFormCommentaire.ID, false) != null) { |
onglets.remove(commentaireOnglet); |
} |
panneauFormulaire.layout(); |
} |
private void activerOngletsHerbier() { |
if (onglets.findItem(CollectionFormGeneral.ID, false) == null) { |
onglets.add(generalOnglet); |
} |
if (onglets.findItem(CollectionFormPersonne.ID, false) == null) { |
onglets.add(personneOnglet); |
} |
if (onglets.findItem(CollectionFormPublication.ID, false) == null) { |
onglets.add(publicationOnglet); |
} |
if (onglets.findItem(CollectionFormDescription.ID, false) == null) { |
onglets.add(descriptionOnglet); |
} |
if (onglets.findItem(CollectionFormContenu.ID, false) == null) { |
onglets.add(contenuOnglet); |
} |
if (onglets.findItem(CollectionFormInventaire.ID, false) == null) { |
onglets.add(inventaireOnglet); |
} |
if (onglets.findItem(CollectionFormCommentaire.ID, false) == null) { |
onglets.add(commentaireOnglet); |
} |
panneauFormulaire.layout(); |
} |
private void creerOnglets() { |
onglets = new TabPanel(); |
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) |
onglets.setHeight("100%"); |
// Onlget formulaire GENERAL |
onglets.add(creerOngletGeneral()); |
// Onlget formulaire AUTEUR |
onglets.add(creerOngletPersonne()); |
// Onlget formulaire PUBLICATION |
onglets.add(creerOngletPublication()); |
// Onlget formulaire DESCRIPTION |
onglets.add(creerOngletDescription()); |
// Onlget formulaire CONTENU |
onglets.add(creerOngletContenu()); |
// Onlget formulaire INVENTAIRE |
onglets.add(creerOngletInventaire()); |
// Onlget formulaire COMMENTAIRE |
onglets.add(creerOngletCommentaire()); |
// Sélection de l'onglet par défaut |
onglets.setSelection(generalOnglet); |
panneauFormulaire.add(onglets); |
} |
private TabItem creerOngletGeneral() { |
generalOnglet = new CollectionFormGeneral(this); |
return generalOnglet; |
} |
private TabItem creerOngletPersonne() { |
personneOnglet = new CollectionFormPersonne(this); |
return personneOnglet; |
} |
private TabItem creerOngletPublication() { |
publicationOnglet = new CollectionFormPublication(this); |
return publicationOnglet; |
} |
private TabItem creerOngletDescription() { |
descriptionOnglet = new CollectionFormDescription(this); |
return descriptionOnglet; |
} |
private TabItem creerOngletContenu() { |
contenuOnglet = new CollectionFormContenu(this); |
return contenuOnglet; |
} |
private TabItem creerOngletInventaire() { |
inventaireOnglet = new CollectionFormInventaire(this); |
return inventaireOnglet; |
} |
private TabItem creerOngletCommentaire() { |
commentaireOnglet = new CollectionFormCommentaire(this); |
return commentaireOnglet; |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
controlerFermetureApresRafraichissement(); |
} |
private void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
if (info.getType().equals("modif_collection")) { |
Info.display("Modification d'une collection", info.toString()); |
} else if (info.getType().equals("selection_collection")) { |
Info.display("Modification d'une collection", info.toString()); |
if (info.getDonnee(0) != null) { |
collection = (Collection) info.getDonnee(0); |
} |
peupler(); |
genererTitreFormulaire(); |
} else if (info.getType().equals("ajout_collection")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String collectionId = (String) info.getDonnee(0); |
Info.display("Ajout d'une collection", "La collection '"+collectionId+"' a bien été ajoutée"); |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons les personnes et les publications liées |
personneOnglet.rafraichir(info); |
publicationOnglet.rafraichir(info); |
commentaireOnglet.rafraichir(info); |
} else { |
Info.display("Ajout d'une collection", info.toString()); |
} |
} else if (info.getType().equals("liste_collection_a_personne")) { |
personneOnglet.rafraichir(info); |
} else if (info.getType().equals("liste_collection_a_publication")) { |
publicationOnglet.rafraichir(info); |
} else if (info.getType().equals("liste_collection_a_commentaire")) { |
commentaireOnglet.rafraichir(info); |
} |
} |
private void peupler() { |
if (collection != null) { |
nomChp.setValue(collection.getNom()); |
typesCollectionCombo.peupler(collection.getTypeNcd()); |
peuplerOnglets(); |
} |
} |
private void peuplerOnglets() { |
generalOnglet.peupler(); |
descriptionOnglet.peupler(); |
contenuOnglet.peupler(); |
inventaireOnglet.peupler(); |
commentaireOnglet.peupler(); |
} |
public boolean soumettreFormulaire() { |
// Vérification de la validité des champs du formulaire |
boolean formulaireValide = verifierFormulaire(); |
if (formulaireValide) { |
// Collecte des données du formulaire |
Collection collectionAEnregistrer = collecterCollection(); |
if (mode.equals(MODE_AJOUTER)) { |
mediateur.ajouterCollection(this, collectionAEnregistrer); |
Debug.log("enfin"); |
} else if (mode.equals(MODE_MODIFIER)) { |
if (collectionAEnregistrer == null) { |
Info.display("Modification d'une collection", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
mediateur.modifierCollection(this, collectionAEnregistrer); |
} |
} |
soumettreOnglets(); |
} |
return formulaireValide; |
} |
private void soumettreOnglets() { |
personneOnglet.soumettre(); |
publicationOnglet.soumettre(); |
commentaireOnglet.soumettre(); |
} |
public void reinitialiserFormulaire() { |
if (mode.equals(StructureForm.MODE_MODIFIER)) { |
mediateur.afficherFormCollection(collection.getId()); |
} else { |
mediateur.afficherFormCollection(null); |
} |
} |
private Collection collecterCollection() { |
collectionCollectee = (Collection) collection.cloner(new Collection()); |
this.collecter(); |
collecterOnglets(); |
Collection collectionARetourner = null; |
if (!collectionCollectee.comparer(collection) || !collectionCollectee.getBotanique().comparer(collection.getBotanique())) { |
collectionARetourner = collection = collectionCollectee; |
} |
return collectionARetourner; |
} |
private void collecter() { |
collectionCollectee.setNom(nomChp.getValue()); |
collectionCollectee.setTypeNcd(typesCollectionCombo.getValue().getId()); |
} |
private void collecterOnglets() { |
generalOnglet.collecter(); |
personneOnglet.collecter(); |
publicationOnglet.collecter(); |
descriptionOnglet.collecter(); |
contenuOnglet.collecter(); |
inventaireOnglet.collecter(); |
commentaireOnglet.collecter(); |
} |
public boolean verifierFormulaire() { |
ArrayList<String> messages = new ArrayList<String>(); |
// Vérification des infos sur le nom de la collection |
if (nomChp.getValue() == null |
|| nomChp.getValue().equals("") |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getNom().equals(""))) { |
messages.add("Veuillez donner un nom à la collection."); |
} |
// Vérification des infos sur le type de collection |
if (typesCollectionCombo.getValue() == null |
|| typesCollectionCombo.getValue().equals("") |
|| (mode.equals(MODE_MODIFIER) && collection != null && collection.getIdProjet().equals(""))) { |
messages.add("Veuillez sélectionner un type pour la collection."); |
} |
messages.addAll(verifierOnglets()); |
// Affichage des messages d'alerte |
if (messages.size() != 0) { |
String[] tableauDesMessages = {}; |
tableauDesMessages = messages.toArray(tableauDesMessages); |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDesMessages, "<br />"), null); |
return false; |
} |
return true; |
} |
private ArrayList<String> verifierOnglets() { |
ArrayList<String> messages = new ArrayList<String>(); |
messages.addAll(generalOnglet.verifier()); |
messages.addAll(personneOnglet.verifier()); |
return messages; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/FenetreForm.java |
---|
New file |
0,0 → 1,20 |
package org.tela_botanica.client.vues; |
import com.extjs.gxt.ui.client.widget.Window; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class FenetreForm extends Window{ |
public FenetreForm(String titre) { |
int hauteur = (int) Math.ceil(com.google.gwt.user.client.Window.getClientHeight() * .8); |
int largeur = (int) Math.ceil(com.google.gwt.user.client.Window.getClientWidth() * .8); |
GWT.log("Taille:"+hauteur+"x"+largeur, null); |
setSize(largeur, hauteur); |
setPlain(true); |
setModal(true); |
setBlinkModal(true); |
setHeading(titre); |
setLayout(new FitLayout()); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/FormulaireOnglet.java |
---|
New file |
0,0 → 1,79 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.configuration.Configuration; |
import org.tela_botanica.client.i18n.Constantes; |
import org.tela_botanica.client.i18n.ErrorMessages; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.event.ComponentEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.layout.FormLayout; |
public abstract class FormulaireOnglet extends TabItem implements Rafraichissable { |
protected Formulaire formulaire = null; |
protected Mediateur mediateur = null; |
protected Constantes i18nC = null; |
protected ErrorMessages i18nM = null; |
protected Configuration config = null; |
protected String mode = null; |
protected int tabIndex = 100; |
protected static LabelAlign alignementLabelDefaut = LabelAlign.LEFT; |
protected static int largeurLabelDefaut = 250; |
public FormulaireOnglet() { |
parametrer(this); |
addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
setAcces(true); |
actualiser(); |
} |
}); |
} |
public static void parametrer(TabItem onglet) { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(largeurLabelDefaut); |
layout.setLabelAlign(alignementLabelDefaut); |
onglet.setLayout(layout); |
onglet.setStyleAttribute("padding", "10px"); |
onglet.setScrollMode(Scroll.AUTO); |
onglet.setData("acces", false); |
} |
protected void initialiserOnglet(Formulaire formulaireCourrant) { |
formulaire = formulaireCourrant; |
mediateur = formulaire.mediateur; |
i18nC = Mediateur.i18nC; |
i18nM = Mediateur.i18nM; |
config = (Configuration) Registry.get(RegistreId.CONFIG); |
mode = formulaire.mode; |
tabIndex = formulaire.tabIndex; |
} |
public void actualiser() { |
layout(); |
} |
public void setAcces(boolean acces) { |
this.setData("acces", acces); |
} |
public boolean etreAccede() { |
boolean acces = false; |
if (isAttached()) { |
acces = this.getData("acces"); |
} |
return acces; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/NavigationVue.java |
---|
New file |
0,0 → 1,39 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.Mediateur; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.util.Padding; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout; |
import com.extjs.gxt.ui.client.widget.layout.VBoxLayoutData; |
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout.VBoxLayoutAlign; |
public class NavigationVue extends ContentPanel { |
private Mediateur mediateur = null; |
private MenuVue menu = null; |
private FiltreVue filtre = null; |
public NavigationVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
VBoxLayout layout = new VBoxLayout(); |
layout.setPadding(new Padding(0)); |
layout.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH); |
setHeading(Mediateur.i18nC.titreNavigation()); |
setLayout(layout); |
menu = new MenuVue(mediateur); |
add(menu, new VBoxLayoutData(new Margins(0))); |
filtre = new FiltreVue(mediateur); |
add(filtre, new VBoxLayoutData(new Margins(0))); |
} |
public MenuVue getMenu() { |
return menu; |
} |
public FiltreVue getFiltre() { |
return filtre; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureDetailVue.java |
---|
New file |
0,0 → 1,638 |
package org.tela_botanica.client.vues.structure; |
import java.util.Iterator; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
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.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureAPersonne; |
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe; |
import org.tela_botanica.client.modeles.structure.StructureConservation; |
import org.tela_botanica.client.modeles.structure.StructureValorisation; |
import org.tela_botanica.client.vues.DetailVue; |
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.Html; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class StructureDetailVue extends DetailVue implements Rafraichissable { |
private String enteteTpl = null; |
private String identificationTpl = null; |
private String personnelTpl = null; |
private String tableauPersonnelTpl = null; |
private String lignePersonnelTpl = null; |
private String conservationTpl = null; |
private String traitementConservationTpl = null; |
private String valorisationTpl = null; |
private String typeTraitementConservationTpl = null; |
private String rechercheValorisationTpl = null; |
private Structure structure = null; |
private boolean structureChargementOk = false; |
private StructureAPersonneListe personnel = null; |
private boolean personnelChargementOk = false; |
private StructureValorisation valorisation = null; |
private StructureConservation conservation = null; |
private ContentPanel panneauPrincipal = null; |
private Html entete = null; |
private TabPanel onglets = null; |
private TabItem identificationOnglet = null; |
private TabItem personnelOnglet = null; |
private TabItem conservationOnglet = null; |
private TabItem valorisationOnglet = null; |
public StructureDetailVue(Mediateur mediateurCourant) { |
super(mediateurCourant); |
initialiserTousLesTpl(); |
chargerOntologie(); |
panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(false); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
panneauPrincipal.setTopComponent(entete); |
onglets = new TabPanel(); |
onglets.setId(ComposantId.ZONE_DETAIL_CORPS); |
onglets.setBodyBorder(false); |
identificationOnglet = new TabItem(i18nC.structureInfoGeneral()); |
identificationOnglet.setLayout(new AnchorLayout()); |
identificationOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(identificationOnglet); |
personnelOnglet = new TabItem(i18nC.structureInfoPersonnel()); |
personnelOnglet.setLayout(new AnchorLayout()); |
personnelOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(personnelOnglet); |
conservationOnglet = new TabItem(i18nC.structureInfoConservation()); |
conservationOnglet.setLayout(new AnchorLayout()); |
conservationOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(conservationOnglet); |
valorisationOnglet = new TabItem(i18nC.structureInfoValorisation()); |
valorisationOnglet.setLayout(new AnchorLayout()); |
valorisationOnglet.setScrollMode(Scroll.AUTO); |
onglets.add(valorisationOnglet); |
panneauPrincipal.add(onglets); |
add(panneauPrincipal); |
} |
private void chargerOntologie() { |
String[] listesCodes = {"stpr", "stpu", "statut", "fonction", "pays", "localStockage", "meubleStockage", |
"parametreStockage", "autreCollection", "onep", "opRestau", "autreMateriel", "poisonTraitement", |
"insecteTraitement", "actionValorisation", "continentEtFr", "typeRecherche"}; |
lancerChargementListesValeurs(listesCodes); |
} |
private void afficherDetailInstitution() { |
if (structure != null) { |
personnel = structure.getPersonnel(); |
valorisation = structure.getValorisation(); |
conservation = structure.getConservation(); |
afficherEntete(); |
afficherIdentification(); |
if (personnel != null) { |
afficherPersonnel(); |
} |
if (conservation != null) { |
afficherConservation(); |
} |
if (valorisation != null) { |
afficherValorisation(); |
} |
} |
layout(); |
} |
private void afficherEntete() { |
Params enteteParams = new Params(); |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE); |
enteteParams.set("css_meta", ComposantClass.META); |
enteteParams.set("i18n_id", i18nC.id()); |
enteteParams.set("nom", structure.getNom()); |
enteteParams.set("ville", structure.getVille()); |
enteteParams.set("id", structure.getId()); |
enteteParams.set("guid", structure.getGuid()); |
enteteParams.set("projet", construireTxtProjet(structure.getIdProjet())); |
String eHtml = Format.substitute(enteteTpl, enteteParams); |
entete.getElement().setInnerHTML(eHtml); |
} |
private void afficherIdentification() { |
Params identificationParams = new Params(); |
identificationParams.set("i18n_titre_administratif", i18nC.titreAdministratif()); |
identificationParams.set("i18n_acronyme", i18nC.acronyme()); |
identificationParams.set("i18n_statut", i18nC.statut()); |
identificationParams.set("i18n_date_fondation", i18nC.dateFondation()); |
identificationParams.set("i18n_nbre_personnel", i18nC.nbrePersonnel()); |
identificationParams.set("i18n_titre_description", i18nC.description()); |
identificationParams.set("i18n_description", i18nC.description()); |
identificationParams.set("i18n_titre_adresse", i18nC.adresse()); |
identificationParams.set("i18n_adresse", i18nC.adresse()); |
identificationParams.set("i18n_cp", i18nC.codePostal()); |
identificationParams.set("i18n_ville", i18nC.ville()); |
identificationParams.set("i18n_region", i18nC.region()); |
identificationParams.set("i18n_pays", i18nC.pays()); |
identificationParams.set("i18n_titre_communication", i18nC.titreCommunication()); |
identificationParams.set("i18n_tel", i18nC.telephone()); |
identificationParams.set("i18n_fax", i18nC.FAX()); |
identificationParams.set("i18n_courriel", i18nC.courriel()); |
identificationParams.set("i18n_acces", i18nC.acces()); |
identificationParams.set("i18n_web", i18nC.siteWeb()); |
String acronyme = construireTxtTruck(structure.getIdAlternatif()); |
String typePrive = construireTxtListeOntologie(structure.getTypePrive()); |
String typePublic = construireTxtListeOntologie(structure.getTypePublic()); |
String pays = construireTxtListeOntologie(structure.getPays()); |
String web = construireTxtTruck(structure.getUrl()); |
identificationParams.set("acronyme", acronyme); |
identificationParams.set("statut", typePrive+typePublic); |
identificationParams.set("date_fondation", structure.getDateFondationFormatLong()); |
identificationParams.set("nbre_personnel", structure.getNbrePersonne()); |
identificationParams.set("description", structure.getDescription()); |
identificationParams.set("adresse", structure.getAdresse()); |
identificationParams.set("cp", structure.getCodePostal()); |
identificationParams.set("ville", structure.getVille()); |
identificationParams.set("region", structure.getRegion()); |
identificationParams.set("pays", pays); |
identificationParams.set("tel", structure.getTelephoneFixe()); |
identificationParams.set("fax", structure.getFax()); |
identificationParams.set("courriel", structure.getCourriel()); |
identificationParams.set("acces", structure.getConditionAcces()); |
identificationParams.set("web", web); |
afficherOnglet(identificationTpl, identificationParams, identificationOnglet); |
} |
private void afficherPersonnel() { |
String tableauPersonnelHtml = ""; |
if (personnel.size() > 0) { |
tableauPersonnelHtml = construireTableauDuPersonnel(); |
} |
Params personnelParams = new Params(); |
personnelParams.set("i18n_titre_personnel", i18nC.titrePersonnel()); |
personnelParams.set("i18n_nbre_personnel_collection", i18nC.nbrePersonnelCollection()); |
personnelParams.set("nbre_personnel_collection", personnel.size()); |
personnelParams.set("tableau_personnel", tableauPersonnelHtml); |
afficherOnglet(personnelTpl, personnelParams, personnelOnglet); |
} |
private String construireTableauDuPersonnel() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_titre_membre", i18nC.titreMembre()); |
contenuParams.set("i18n_fonction", i18nC.fonction()); |
contenuParams.set("i18n_prenom", i18nC.personnePrenom()); |
contenuParams.set("i18n_nom", i18nC.personneNom()); |
contenuParams.set("i18n_tel", i18nC.FIX()); |
contenuParams.set("i18n_fax", i18nC.FAX()); |
contenuParams.set("i18n_courriel", i18nC.courrielPrincipal()); |
contenuParams.set("i18n_statut", i18nC.statut()); |
contenuParams.set("i18n_tps_w", i18nC.tpsTravail()); |
contenuParams.set("i18n_specialite", i18nC.specialite()); |
contenuParams.set("i18n_contact", i18nC.boolContact()); |
String lignesPersonnel = ""; |
Iterator<String> it = personnel.keySet().iterator(); |
while (it.hasNext()) { |
StructureAPersonne personne = personnel.get(it.next()); |
Params ligneParams = new Params(); |
String fonction = construireTxtListeOntologie(personne.getFonction()); |
String statut = construireTxtListeOntologie(personne.getStatut()); |
String contact = formaterOuiNon(personne.getContact()); |
ligneParams.set("fonction", fonction); |
ligneParams.set("prenom", personne.getPrenom()); |
ligneParams.set("nom", personne.getNom()); |
ligneParams.set("tel_fix", personne.getTelephoneFixe()); |
ligneParams.set("tel_fax", personne.getFax()); |
ligneParams.set("courriel", personne.getCourriel()); |
ligneParams.set("statut", statut); |
ligneParams.set("tps_w", personne.getBotaTravailHebdoTps()); |
ligneParams.set("specialite", personne.afficherSpecialite()); |
ligneParams.set("contact", contact); |
lignesPersonnel += Format.substitute(lignePersonnelTpl, ligneParams); |
} |
contenuParams.set("lignes", lignesPersonnel); |
String cHtml = Format.substitute(tableauPersonnelTpl, contenuParams); |
return cHtml; |
} |
private void afficherConservation() { |
Params conservationParams = new Params(); |
conservationParams.set("i18n_titre_conservation_personnel", i18nC.titreConservationPersonnel()); |
conservationParams.set("i18n_formation", i18nC.formation()); |
conservationParams.set("i18n_formation_interet", i18nC.formationInteret()); |
conservationParams.set("i18n_titre_local", i18nC.titreLocal()); |
conservationParams.set("i18n_local_specifique", i18nC.localSpecifique()); |
conservationParams.set("i18n_meuble_specifique", i18nC.meubleSpecifique()); |
conservationParams.set("i18n_local_parametre", i18nC.localParametre()); |
conservationParams.set("i18n_conservation_en_commun", i18nC.conservationEnCommun()); |
conservationParams.set("i18n_acces_controle", i18nC.accesControle()); |
conservationParams.set("i18n_titre_operation", i18nC.titreOperation()); |
conservationParams.set("i18n_restauration", i18nC.restauration()); |
conservationParams.set("i18n_materiel_conservation", i18nC.materielConservation()); |
conservationParams.set("i18n_traitement", i18nC.traitement()); |
conservationParams.set("i18n_titre_acquisition", i18nC.titreAcquisition()); |
conservationParams.set("i18n_acquisition_collection", i18nC.acquisitionCollection()); |
conservationParams.set("i18n_acquisition_echantillon", i18nC.acquisitionEchantillon()); |
conservationParams.set("formation", formaterOuiNon(conservation.getFormation())); |
conservationParams.set("formation_info", formaterSautDeLigne(conservation.getFormationInfo())); |
conservationParams.set("formation_interet", formaterOuiNon(conservation.getFormationInteret())); |
conservationParams.set("meuble_specifique", conservation.getStockageMeuble()); |
String chaineAAnalyser = conservation.getStockageLocal(); |
String chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("local_specifique", chaineAAfficher); |
chaineAAnalyser = conservation.getStockageMeuble(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("meuble_specifique", chaineAAfficher); |
chaineAAnalyser = conservation.getStockageParametre(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("local_parametre", chaineAAfficher); |
conservationParams.set("conservation_en_commun", formaterOuiNon(conservation.getCollectionCommune())); |
chaineAAnalyser = conservation.getCollectionAutre(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("collection_autre", formaterParenthese(chaineAAfficher)); |
conservationParams.set("acces_controle", formaterOuiNon(conservation.getAccesControle())); |
conservationParams.set("restauration", formaterOuiNon(conservation.getRestauration())); |
chaineAAnalyser = conservation.getRestaurationOperation(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("restauration_operation", formaterParenthese(chaineAAfficher)); |
chaineAAnalyser = conservation.getMaterielConservation(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("materiel_conservation", chaineAAfficher); |
chaineAAnalyser = conservation.getMaterielAutre(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("materiel_autre", formaterParenthese(chaineAAfficher)); |
conservationParams.set("traitement", formaterOuiNon(conservation.getTraitement())); |
chaineAAnalyser = conservation.getTraitements(); |
chaineAAfficher = construireTxtListeOntologie(chaineAAnalyser); |
conservationParams.set("traitements", formaterParenthese(chaineAAfficher)); |
conservationParams.set("acquisition_collection", formaterOuiNon(conservation.getAcquisitionCollection())); |
conservationParams.set("acquisition_echantillon", formaterOuiNon(conservation.getAcquisitionEchantillon())); |
conservationParams.set("acquisition_traitement_info", construireTraitement()); |
afficherOnglet(conservationTpl, conservationParams, conservationOnglet); |
} |
private String construireTraitement() { |
String cHtml = ""; |
String echantillon = conservation.getAcquisitionEchantillon(); |
if (echantillon.equals("1")) { |
Params traitementConservationParams = new Params(); |
traitementConservationParams.set("i18n_acquisition_traitement", i18nC.acquisitionTraitement()); |
traitementConservationParams.set("acquisition_traitement", formaterOuiNon(conservation.getAcquisitionTraitement())); |
traitementConservationParams.set("acquisition_traitement_type_info", construireTraitementType()); |
cHtml = Format.substitute(traitementConservationTpl, traitementConservationParams); |
} |
return cHtml; |
} |
private String construireTraitementType() { |
String cHtml = ""; |
String traitement = conservation.getAcquisitionTraitement(); |
if (traitement.equals("1")) { |
Params typeTraitementParams = new Params(); |
typeTraitementParams.set("i18n_acquisition_traitement_insecte", i18nC.acquisitionTraitementInsecte()); |
typeTraitementParams.set("i18n_acquisition_traitement_poison", i18nC.acquisitionTraitementPoison()); |
String acquisitionTraitementInsecte = construireTxtListeOntologie(conservation.getAcquisitionTraitementInsecte()); |
typeTraitementParams.set("acquisition_traitement_insecte", acquisitionTraitementInsecte); |
String acquisitionTraitementPoison = construireTxtListeOntologie(conservation.getAcquisitionTraitementPoison()); |
typeTraitementParams.set("acquisition_traitement_poison", acquisitionTraitementPoison); |
cHtml = Format.substitute(typeTraitementConservationTpl, typeTraitementParams); |
} |
return cHtml; |
} |
private void afficherValorisation() { |
Params valorisationParams = new Params(); |
valorisationParams.set("i18n_titre_action_valorisation", i18nC.titreActionValorisation()); |
valorisationParams.set("i18n_action", i18nC.action()); |
valorisationParams.set("i18n_action_publication", i18nC.actionPublication()); |
valorisationParams.set("i18n_collection_autre", i18nC.collectionAutre()); |
valorisationParams.set("i18n_action_future", i18nC.actionFuture()); |
valorisationParams.set("action", formaterOuiNon(valorisation.getAction())); |
String actionInfo = construireTxtListeOntologie(valorisation.getActionInfo()); |
valorisationParams.set("action_info", formaterParenthese(actionInfo)); |
valorisationParams.set("action_publication", valorisation.getPublication()); |
String collectionAutre = construireTxtListeOntologie(valorisation.getCollectionAutre()); |
valorisationParams.set("collection_autre", collectionAutre); |
valorisationParams.set("action_future", formaterOuiNon(valorisation.getActionFuture())); |
valorisationParams.set("action_future_info", formaterParenthese(valorisation.getActionFutureInfo())); |
valorisationParams.set("i18n_titre_recherche_scientifique", i18nC.titreRechercherScientifique()); |
valorisationParams.set("i18n_recherche", i18nC.recherche()); |
valorisationParams.set("recherche", formaterOuiNon(valorisation.getRecherche())); |
valorisationParams.set("recherche_info", construireRecherche()); |
valorisationParams.set("i18n_titre_acces_usage", i18nC.titreAccesUsage()); |
valorisationParams.set("i18n_acces", i18nC.acces()); |
valorisationParams.set("i18n_visite", i18nC.visite()); |
valorisationParams.set("acces", formaterOuiNon(valorisation.getAccesSansMotif())); |
valorisationParams.set("acces_info", formaterParenthese(valorisation.getAccesSansMotifInfo())); |
valorisationParams.set("visite", formaterOuiNon(valorisation.getVisiteAvecMotif())); |
valorisationParams.set("visite_info", formaterParenthese(valorisation.getVisiteAvecMotifInfo())); |
afficherOnglet(valorisationTpl, valorisationParams, valorisationOnglet); |
} |
private String construireRecherche() { |
String cHtml = ""; |
String recherche = valorisation.getRecherche(); |
if (recherche.equals("1")) { |
Params rechercheParams = new Params(); |
rechercheParams.set("i18n_recherche_provenance", i18nC.rechercheProvenance()); |
rechercheParams.set("i18n_recherche_type", i18nC.rechercheType()); |
String rechercheProvenance = construireTxtListeOntologie(valorisation.getRechercheProvenance()); |
rechercheParams.set("recherche_provenance", rechercheProvenance); |
String rechercheType = construireTxtListeOntologie(valorisation.getRechercheType()); |
rechercheParams.set("recherche_type", rechercheType); |
cHtml = Format.substitute(rechercheValorisationTpl, rechercheParams); |
} |
return cHtml; |
} |
private void initialiserTousLesTpl() { |
initialiserEnteteTpl(); |
initialiserIdentificationTpl(); |
initialiserPersonnelTpl(); |
initialiserTableauPersonnelTpl(); |
initialiserLignePersonnelTpl(); |
initialiserConservationTpl(); |
initialiserTraitementConservationTpl(); |
initialiserTypeTraitementConservationTpl(); |
initialiserValorisationTpl(); |
initialiserRechercheValorisationTpl(); |
} |
private void initialiserEnteteTpl() { |
enteteTpl = |
"<div id='{css_id}'>"+ |
" <h1>{nom}</h1>"+ |
" <h2>{ville}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" + |
" " + |
"</div>"; |
} |
private void initialiserIdentificationTpl() { |
identificationTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_administratif}</h2>"+ |
" <span class='{css_label}'>{i18n_acronyme} :</span> {acronyme}<br />"+ |
" <span class='{css_label}'>{i18n_acces} :</span> {acces}<br />"+ |
" <span class='{css_label}'>{i18n_statut} :</span> {statut}<br />"+ |
" <span class='{css_label}'>{i18n_date_fondation} :</span> {date_fondation}<br />"+ |
" <span class='{css_label}'>{i18n_nbre_personnel} :</span> {nbre_personnel}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_description}</h2>"+ |
" {description}"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_adresse}</h2>"+ |
" <span class='{css_label}'>{i18n_adresse} :</span> {adresse}<br />" + |
" <span class='{css_label}'>{i18n_cp} :</span> {cp}<br />" + |
" <span class='{css_label}'>{i18n_ville} :</span> {ville}<br />" + |
" <span class='{css_label}'>{i18n_region} :</span> {region}<br />" + |
" <span class='{css_label}'>{i18n_pays} :</span> {pays}<br />" + |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_communication}</h2>"+ |
" <span class='{css_label}'>{i18n_tel} :</span> {tel}<br />"+ |
" <span class='{css_label}'>{i18n_fax} :</span> {fax}<br />"+ |
" <span class='{css_label}'>{i18n_courriel} :</span> {courriel}<br />"+ |
" <span class='{css_label}'>{i18n_web} :</span> {web}<br />"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserPersonnelTpl() { |
personnelTpl = |
"<div class='{css_corps}'>"+ |
" <h2>{i18n_titre_personnel}</h2>"+ |
" <p><span class='{css_label}'>{i18n_nbre_personnel_collection} :</span> {nbre_personnel_collection}</p>"+ |
" {tableau_personnel}"+ |
"</div>"; |
} |
private void initialiserTableauPersonnelTpl() { |
tableauPersonnelTpl = |
"<h3>{i18n_titre_membre}</h3>"+ |
"<table>"+ |
" <thead>"+ |
" <tr>" + |
" <th>{i18n_fonction}</th>" + |
" <th>{i18n_prenom}</th>" + |
" <th>{i18n_nom}</th>" + |
" <th>{i18n_tel}</th>" + |
" <th>{i18n_fax}</th>" + |
" <th>{i18n_courriel}</th>" + |
" <th>{i18n_statut}</th>" + |
" <th>{i18n_tps_w}</th>" + |
" <th>{i18n_specialite}</th>" + |
" <th>{i18n_contact}</th>" + |
" </tr>"+ |
" </thead>"+ |
" <tbody>"+ |
" {lignes}"+ |
" </tbody>"+ |
"</table>"; |
} |
private void initialiserLignePersonnelTpl() { |
lignePersonnelTpl = |
"<tr>"+ |
" <td>{fonction}</td>"+ |
" <td>{prenom}</td>"+ |
" <td>{nom}</td>"+ |
" <td>{tel_fix}</td>" + |
" <td>{tel_fax}</td>" + |
" <td>{courriel}</td>" + |
" <td>{statut}</td>" + |
" <td>{tps_w}</td>" + |
" <td>{specialite}</td>" + |
" <td>{contact}</td>" + |
"</tr>"; |
} |
private void initialiserConservationTpl() { |
conservationTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_conservation_personnel}</h2>"+ |
" <span class='{css_label}'>{i18n_formation} :</span> {formation}<br />"+ |
" {formation_info}<br />"+ |
" <span class='{css_label}'>{i18n_formation_interet} :</span> {formation_interet}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_local}</h2>"+ |
" <span class='{css_label}'>{i18n_local_specifique} :</span> {local_specifique}<br />"+ |
" <span class='{css_label}'>{i18n_meuble_specifique} :</span> {meuble_specifique}<br />"+ |
" <span class='{css_label}'>{i18n_local_parametre} :</span> {local_parametre}<br />"+ |
" <span class='{css_label}'>{i18n_conservation_en_commun} :</span> {conservation_en_commun} {collection_autre}<br />"+ |
" <span class='{css_label}'>{i18n_acces_controle} :</span> {acces_controle}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_operation}</h2>"+ |
" <span class='{css_label}'>{i18n_restauration} :</span> {restauration} {restauration_operation}<br />"+ |
" <span class='{css_label}'>{i18n_materiel_conservation} :</span> {materiel_conservation} {materiel_autre}<br />"+ |
" <span class='{css_label}'>{i18n_traitement} :</span> {traitement} {traitements}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_acquisition}</h2>"+ |
" <span class='{css_label}'>{i18n_acquisition_collection} :</span> {acquisition_collection}<br />"+ |
" <span class='{css_label}'>{i18n_acquisition_echantillon} :</span> {acquisition_echantillon}<br />"+ |
" {acquisition_traitement_info}" + |
" </div>"+ |
"</div>"; |
} |
private void initialiserTraitementConservationTpl() { |
traitementConservationTpl = |
"<span class='{css_indentation} {css_label}'>{i18n_acquisition_traitement} :</span> {acquisition_traitement}<br />"+ |
" <div class='{css_indentation}'>"+ |
" {acquisition_traitement_type_info}"+ |
" </div>"; |
} |
private void initialiserTypeTraitementConservationTpl() { |
typeTraitementConservationTpl = |
"<span class='{css_indentation} {css_label}'>{i18n_acquisition_traitement_insecte} :</span> {acquisition_traitement_insecte}<br />"+ |
"<span class='{css_indentation} {css_label}'>{i18n_acquisition_traitement_poison} :</span> {acquisition_traitement_poison}<br />"; |
} |
private void initialiserValorisationTpl() { |
valorisationTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_action_valorisation}</h2>"+ |
" <span class='{css_label}'>{i18n_action} :</span> {action} {action_info}<br />"+ |
" <span class='{css_label}'>{i18n_action_publication} :</span> {action_publication}<br />"+ |
" <span class='{css_label}'>{i18n_collection_autre} :</span> {collection_autre}<br />"+ |
" <span class='{css_label}'>{i18n_action_future} :</span> {action_future} {action_future_info}<br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_recherche_scientifique}</h2>"+ |
" <span class='{css_label}'>{i18n_recherche} :</span> {recherche}<br />"+ |
" {recherche_info}"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_acces_usage}</h2>"+ |
" <span class='{css_label}'>{i18n_visite} :</span> {visite} {visite_info}<br />"+ |
" <span class='{css_label}'>{i18n_acces} :</span> {acces} {acces_info}<br />"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserRechercheValorisationTpl() { |
rechercheValorisationTpl = |
"<span class='{css_indentation} {css_label}'>{i18n_recherche_provenance} :</span> {recherche_provenance}<br />"+ |
"<span class='{css_indentation} {css_label}'>{i18n_recherche_type} :</span> {recherche_type}<br />"; |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Structure) { |
structure = (Structure) nouvellesDonnees; |
structureChargementOk = true; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
projets = (ProjetListe) nouvellesDonnees; |
projetsChargementOk = true; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees; |
receptionerListeValeurs(listeValeursReceptionnee); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("liste_structure_a_personne")) { |
allouerPersonnelAStructure((StructureAPersonneListe) info.getDonnee(0)); |
personnelChargementOk = true; |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (avoirDonneesChargees()) { |
afficherDetailInstitution(); |
} |
} |
protected void allouerPersonnelAStructure(StructureAPersonneListe personnel) { |
structure.setPersonnel(personnel); |
} |
private boolean avoirDonneesChargees() { |
boolean ok = false; |
if (projetsChargementOk && structureChargementOk && personnelChargementOk && ontologieChargementOk) { |
ok = true; |
} |
return ok; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureForm.java |
---|
New file |
0,0 → 1,2149 |
package org.tela_botanica.client.vues.structure; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
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.InterneValeur; |
import org.tela_botanica.client.modeles.InterneValeurListe; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureAPersonne; |
import org.tela_botanica.client.modeles.structure.StructureAPersonneListe; |
import org.tela_botanica.client.modeles.structure.StructureConservation; |
import org.tela_botanica.client.modeles.structure.StructureValorisation; |
import org.tela_botanica.client.util.UtilArray; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
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.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.store.Record; |
import com.extjs.gxt.ui.client.store.Store; |
import com.extjs.gxt.ui.client.store.StoreEvent; |
import com.extjs.gxt.ui.client.widget.Component; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Html; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
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.form.CheckBoxGroup; |
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.Field; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.HiddenField; |
import com.extjs.gxt.ui.client.widget.form.LabelField; |
import com.extjs.gxt.ui.client.widget.form.NumberField; |
import com.extjs.gxt.ui.client.widget.form.Radio; |
import com.extjs.gxt.ui.client.widget.form.RadioGroup; |
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.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig; |
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.ColumnData; |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.tips.ToolTipConfig; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.i18n.client.NumberFormat; |
import com.google.gwt.user.client.Window; |
public class StructureForm extends Formulaire implements Rafraichissable { |
private static int decompteRafraichissementPersonnel = 0; |
private TabPanel onglets = null; |
private TabItem identificationOnglet = null; |
private TabItem personnelOnglet = null; |
private TabItem conservationOnglet = null; |
private TabItem valorisationOnglet = null; |
private HiddenField<String> idStructureChp = null; |
// Onglet IDENTIFICATION |
private Structure identification = null; |
private ListStore<Valeur> magazinLstpr = null; |
private ComboBox<Valeur> comboLstpr = null; |
private ListStore<Valeur> magazinLstpu = null; |
private ComboBox<Valeur> comboLstpu = null; |
private ListStore<Valeur> magazinLiStatut = null; |
private ComboBox<Valeur> comboLiStatut = null; |
private ListStore<Valeur> fonctionsMagazin = null; |
private ComboBox<Valeur> fonctionsCombo = null; |
private ComboBox<InterneValeur> comboAcronyme = null; |
private TextField<String> ihChp = null; |
private TextField<String> mnhnChp = null; |
private ComboBox<InterneValeur> comboTypeStructure = null; |
private TextField<String> nomStructureChp = null; |
private DateField dateFondationChp = null; |
private TextArea adrChp = null; |
private TextField<String> cpChp = null; |
private TextField<String> villeChp = null; |
private ComboBox<Valeur> comboRegion = null; |
private TextField<String> telChp = null; |
private TextField<String> faxChp = null; |
private TextField<String> emailChp = null; |
private TextField<String> urlChp = null; |
private ListStore<Valeur> magazinPays = null; |
private ListStore<Valeur> magazinRegion = null; |
private ComboBox<Valeur> comboPays = null; |
// Onglet PERSONNEL |
private StructureAPersonneListe personnel = null; |
private StructureAPersonneListe personnelAjoute = null; |
private StructureAPersonneListe personnelModifie = null; |
private StructureAPersonneListe personnelSupprime = null; |
private NumberField nbreTotalPersonneStructureChp = null; |
private EditorGrid<StructureAPersonne> grillePersonnel = null; |
private ListStore<StructureAPersonne> personnelGrilleMagazin = null; |
// Onglet CONSERVATION |
private StructureConservation conservation = null; |
private RadioGroup formationMarkRGrpChp = null; |
private RadioGroup interetFormationMarkRGrpChp = null; |
private RadioGroup collectionCommuneMarkRGrpChp = null; |
private RadioGroup accesControleMarkRGrpChp = null; |
private RadioGroup restaurationMarkRGrpChp = null; |
private RadioGroup traitementMarkRGrpChp = null; |
private RadioGroup collectionAcquisitionMarkRGrpChp = null; |
private RadioGroup echantillonAcquisitionMarkRGrpChp = null; |
private TextField<String> localStockageAutreChp = null; |
private TextField<String> meubleStockageAutreChp = null; |
private TextField<String> parametreStockageAutreChp = null; |
private TextField<String> collectionAutreAutreChp = null; |
private TextField<String> autreCollectionAutreChp = null; |
private TextField<String> opRestauAutreChp = null; |
private TextField<String> autreMaterielAutreChp = null; |
private TextField<String> poisonTraitementAutreChp = null; |
private TextField<String> traitementAutreChp = null; |
private TextField<String> insecteTraitementAutreChp = null; |
private TextField<String> actionAutreChp = null; |
private TextField<String> provenanceRechercheAutreChp = null; |
private TextField<String> typeRechercheAutreChp = null; |
private CheckBoxGroup localStockageTrukCacGrpChp = null; |
private LayoutContainer localStockageTrukCp = null; |
private CheckBoxGroup meubleStockageTrukCacGrpChp = null; |
private LayoutContainer meubleStockageTrukCp = null; |
private CheckBoxGroup parametreStockageTrukCacGrpChp = null; |
private LayoutContainer parametreStockageTrukCp = null; |
private LayoutContainer collectionAutreTrukCp = null; |
private CheckBoxGroup collectionAutreTrukCacGrpChp = null; |
private CheckBoxGroup opRestauTrukCacGrpChp = null; |
private LayoutContainer opRestauTrukCp = null; |
private CheckBoxGroup autreMaterielTrukCacGrpChp = null; |
private LayoutContainer autreMaterielTrukCp = null; |
private LayoutContainer traitementTrukCp = null; |
private CheckBoxGroup traitementTrukCacGrpChp = null; |
private LayoutContainer poisonTraitementTrukCp = null; |
private LayoutContainer insecteTraitementTrukCp = null; |
private CheckBoxGroup insecteTraitementTrukCacGrpChp = null; |
private CheckBoxGroup poisonTraitementTrukCacGrpChp = null; |
private LayoutContainer autreCollectionTrukCp = null; |
private CheckBoxGroup autreCollectionTrukCacGrpChp = null; |
private LayoutContainer provenanceRechercheTrukCp = null; |
private CheckBoxGroup provenanceRechercheTrukCacGrpChp = null; |
private CheckBoxGroup typeRechercheTrukCacGrpChp = null; |
private LayoutContainer typeRechercheTrukCp = null; |
private TextField<String> futureActionChp = null; |
private TextField<String> sansMotifAccesChp = null; |
private TextField<String> avecMotifAccesChp = null; |
private TextField<String> formationChp = null; |
private RadioGroup traitementAcquisitionMarkRGrpChp = null; |
private LabelField traitementAcquisitionMarkLabel = null; |
private RadioGroup materielConservationCeRGrpChp = null; |
// Onglet VALORISATION |
private StructureValorisation valorisation = null; |
private RadioGroup actionMarkRGrpChp = null; |
private LayoutContainer actionTrukCp = null; |
private CheckBoxGroup actionTrukCacGrpChp = null; |
private RadioGroup futureActionMarkRGrpChp = null; |
private RadioGroup rechercheMarkRGrpChp = null; |
private RadioGroup sansMotifAccesMarkRGrpChp = null; |
private RadioGroup avecMotifAccesMarkRGrpChp = null; |
private TextField<String> publicationChp = null; |
private LayoutContainer materielConservationCp = null; |
private ListStore<Personne> personneExistanteMagazin = null; |
private ComboBox<Personne> personneExistanteCombo = null; |
private Button supprimerPersonnelBtn = null; |
private ListStore<Projet> projetsMagazin = null; |
private ComboBox<Projet> projetsCombo = null; |
private CellEditor fonctionEditor = null; |
private List<Valeur> fonctionsListe = null; |
public StructureForm(Mediateur mediateurCourrant, String modeDeCreation) { |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.STRUCTURE); |
// Ajout du titre |
panneauFormulaire.setHeading(i18nC.titreAjoutFormStructurePanneau()); |
// Création des onglets |
onglets = creerOnglets(); |
// Ajout des onglets au formulaire général |
panneauFormulaire.add(onglets); |
} |
protected TabPanel creerOnglets() { |
TabPanel ongletsStructure = new TabPanel(); |
// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) |
ongletsStructure.setHeight("100%"); |
// Onlget formulaire IDENTIFICATION |
ongletsStructure.add(creerOngletIdentification()); |
// Onlget formulaire PERSONNEL |
ongletsStructure.add(creerOngletPersonnel()); |
// Onlget formulaire CONSERVATION |
ongletsStructure.add(creerOngletConservation()); |
// Onlget formulaire VALORISATION |
ongletsStructure.add(creerOngletValorisation()); |
// Sélection de l'onglet par défaut |
//ongletsStructure(personnelOnglet); |
return ongletsStructure; |
} |
public void reinitialiserFormulaire() { |
if (mode.equals(StructureForm.MODE_MODIFIER)) { |
mediateur.afficherFormStructure(identification.getId()); |
} else { |
mediateur.afficherFormStructure(null); |
} |
} |
public boolean soumettreFormulaire() { |
// Vérification de la validité des champs du formulaire |
boolean fomulaireValide = verifierFormulaire(); |
if (fomulaireValide) { |
// Collecte des données du formulaire |
Structure structure = collecterStructureIdentification(); |
StructureConservation conservation = collecterStructureConservation(); |
StructureValorisation valorisation = collecterStructureValorisation(); |
collecterStructurePersonnel(); |
if (mode.equals(MODE_AJOUTER)) { |
// Ajout des informations sur la Structure |
mediateur.ajouterStructure(this, structure, conservation, valorisation); |
// L'ajout des relations StructureAPersonne se fait quand la structure a été ajoutée |
// Voir la méthode rafraichir(). |
} else if (mode.equals(MODE_MODIFIER)) { |
// Modification des informations sur la Structure |
if (structure == null && conservation == null && valorisation == null) { |
Info.display("Modification d'une institution", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
mediateur.modifierStructure(this, identification.getId(), structure, conservation, valorisation); |
} |
if (personnelModifie.size() == 0 && personnelAjoute.size() == 0 && personnelSupprime.size() == 0) { |
Info.display("Modification du personnel", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
if (personnelModifie.size() != 0) { |
decompteRafraichissementPersonnel++; |
mediateur.modifierStructureAPersonne(this, personnelModifie); |
} |
// Ajout des relations StructureAPersonne |
if (personnelAjoute.size() != 0) { |
decompteRafraichissementPersonnel++; |
mediateur.ajouterStructureAPersonne(this, identification.getId(), personnelAjoute); |
} |
// Suppression des relations StructureAPersonne |
if (personnelSupprime.size() != 0) { |
decompteRafraichissementPersonnel++; |
mediateur.supprimerStructureAPersonne(this, personnelSupprime); |
} |
} |
} |
} |
return fomulaireValide; |
} |
public boolean verifierFormulaire() { |
ArrayList<String> messages = new ArrayList<String>(); |
// Vérification des infos sur le nom de la structure |
if ( (identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue() == null) || |
(identificationOnglet.getData("acces").equals(true) && nomStructureChp.getValue().equals("")) || |
(identificationOnglet.getData("acces").equals(false) && identification.getNom().equals(""))) { |
messages.add("Veuillez indiquez un nom à l'institution."); |
} |
// Vérification des infos sur le projet de la structure |
if ( (identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue() == null) || |
(identificationOnglet.getData("acces").equals(true) && projetsCombo.getValue().equals("")) || |
(identificationOnglet.getData("acces").equals(false) && identification.getIdProjet().equals(""))) { |
messages.add("Veuillez sélectionner un projet pour l'institution."); |
} |
// Vérification du Personnel |
if (personnelOnglet.getData("acces").equals(true)) { |
String personnelNumero = ""; |
int nbrePersonne = personnelGrilleMagazin.getCount(); |
for (int i = 0; i < nbrePersonne; i++) { |
StructureAPersonne personne = personnelGrilleMagazin.getAt(i); |
if (personne.getNom().equals("") || personne.getPrenom().equals("")) { |
personnelNumero += (i != 0 ? ", " : "")+(i+1); |
} |
} |
if (!personnelNumero.equals("")) { |
messages.add("Veuillez indiquez un prénom et un nom au personnel numéro : "+personnelNumero); |
} |
} |
// Affichage des messages d'alerte |
if (messages.size() != 0) { |
String[] a = {}; |
a = messages.toArray(a); |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(a, "\n\n"), null); |
return false; |
} |
return true; |
} |
private StructureValorisation collecterStructureValorisation() { |
StructureValorisation valorisationARetourner = null; |
if (valorisationOnglet.getData("acces").equals(true)) { |
// Création de l'objet |
StructureValorisation valorisationCollectee = (StructureValorisation) valorisation.cloner(new StructureValorisation()); |
// ACTION |
if (actionMarkRGrpChp.getValue() != null) { |
valorisationCollectee.setAction(actionMarkRGrpChp.getValue().getValueAttribute()); |
} |
// ACTION INFO |
valorisationCollectee.setActionInfo(creerChaineDenormalisee(actionTrukCacGrpChp.getValues())); |
valorisationCollectee.setActionInfo("AUTRE", actionAutreChp.getValue()); |
// PUBLICATION |
valorisationCollectee.setPublication(publicationChp.getValue()); |
// COLLECTION AUTRE |
valorisationCollectee.setCollectionAutre(creerChaineDenormalisee(autreCollectionTrukCacGrpChp.getValues())); |
valorisationCollectee.setCollectionAutre("AUTRE", autreCollectionAutreChp.getValue()); |
// ACTION FUTURE |
if (futureActionMarkRGrpChp.getValue() != null) { |
valorisationCollectee.setActionFuture(futureActionMarkRGrpChp.getValue().getValueAttribute()); |
} |
// ACTION FUTURE INFO |
valorisationCollectee.setActionFutureInfo(futureActionChp.getValue()); |
// RECHERCHE |
if (rechercheMarkRGrpChp.getValue() != null) { |
valorisationCollectee.setRecherche(rechercheMarkRGrpChp.getValue().getValueAttribute()); |
// RECHERCHE PROVENANCE |
valorisationCollectee.setRechercheProvenance(creerChaineDenormalisee(provenanceRechercheTrukCacGrpChp.getValues())); |
valorisationCollectee.setRechercheProvenance("AUTRE", provenanceRechercheAutreChp.getValue()); |
// RECHERCHE TYPE |
valorisationCollectee.setRechercheType(creerChaineDenormalisee(typeRechercheTrukCacGrpChp.getValues())); |
valorisationCollectee.setRechercheType("AUTRE", typeRechercheAutreChp.getValue()); |
} |
// ACCÈS SANS MOTIF |
if (sansMotifAccesMarkRGrpChp.getValue() != null) { |
valorisationCollectee.setAccesSansMotif(sansMotifAccesMarkRGrpChp.getValue().getValueAttribute()); |
} |
// ACCÈS SANS MOTIF INFO |
valorisationCollectee.setAccesSansMotifInfo(sansMotifAccesChp.getValue()); |
// VISITE AVEC MOTIF |
if (avecMotifAccesMarkRGrpChp.getValue() != null) { |
valorisationCollectee.setVisiteAvecMotif(avecMotifAccesMarkRGrpChp.getValue().getValueAttribute()); |
} |
// VISITE AVEC MOTIF INFO |
valorisationCollectee.setVisiteAvecMotifInfo(avecMotifAccesChp.getValue()); |
// Retour de l'objet |
if (!valorisationCollectee.comparer(valorisation)) { |
valorisationARetourner = valorisation = valorisationCollectee; |
} |
} |
return valorisationARetourner; |
} |
private void peuplerStructureValorisation() { |
if (mode.equals(MODE_AJOUTER)) { |
// Indique que l'onglet a pu être modifié pour la méthode collecter... |
valorisationOnglet.setData("acces", true); |
// Initialisation de l'objet Structure |
valorisation = new StructureValorisation(); |
} |
if (mode.equals(MODE_MODIFIER) && valorisation != null && valorisationOnglet.getData("acces").equals(false)) { |
// ACTION : |
//TODO : check below: |
((Radio) actionMarkRGrpChp.get((valorisation.getAction().equals("1") ? 0 : 1))).setValue(true); |
// ACTION INFO |
peuplerCasesACocher(valorisation.getActionInfo(), actionTrukCacGrpChp, actionAutreChp); |
// PUBLICATION |
publicationChp.setValue(valorisation.getPublication()); |
// COLLECTION AUTRE |
peuplerCasesACocher(valorisation.getCollectionAutre(), autreCollectionTrukCacGrpChp, autreCollectionAutreChp); |
// ACTION FUTURE |
((Radio) futureActionMarkRGrpChp.get((valorisation.getActionFuture().equals("1") ? 0 : 1))).setValue(true); |
// ACTION FUTURE INFO |
futureActionChp.setValue(valorisation.getActionFutureInfo()); |
// RECHERCHE |
((Radio) rechercheMarkRGrpChp.get((valorisation.getRecherche().equals("1") ? 0 : 1))).setValue(true); |
// RECHERCHE PROVENANCE |
peuplerCasesACocher(valorisation.getRechercheProvenance(), provenanceRechercheTrukCacGrpChp, provenanceRechercheAutreChp); |
// RECHERCHE TYPE |
peuplerCasesACocher(valorisation.getRechercheType(), typeRechercheTrukCacGrpChp, typeRechercheAutreChp); |
// ACCÈS SANS MOTIF |
((Radio) sansMotifAccesMarkRGrpChp.get((valorisation.getAccesSansMotif().equals("1") ? 0 : 1))).setValue(true); |
// ACCÈS SANS MOTIF INFO |
sansMotifAccesChp.setValue(valorisation.getAccesSansMotifInfo()); |
// VISITE AVEC MOTIF |
((Radio) avecMotifAccesMarkRGrpChp.get((valorisation.getVisiteAvecMotif().equals("1") ? 0 : 1))).setValue(true); |
// VISITE AVEC MOTIF INFO |
avecMotifAccesChp.setValue(valorisation.getVisiteAvecMotifInfo()); |
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... |
valorisationOnglet.setData("acces", true); |
} |
} |
private StructureConservation collecterStructureConservation() { |
StructureConservation conservationARetourner = null; |
if (conservationOnglet.getData("acces").equals(true)) { |
// Création de l'objet |
StructureConservation conservationCollectee = (StructureConservation) conservation.cloner(new StructureConservation()); |
// FORMATION |
if (formationMarkRGrpChp.getValue() != null) { |
conservationCollectee.setFormation(formationMarkRGrpChp.getValue().getValueAttribute()); |
} |
// FORMATION INFO |
conservationCollectee.setFormationInfo(formationChp.getValue()); |
// FORMATION INTERET |
if (interetFormationMarkRGrpChp.getValue() != null) { |
conservationCollectee.setFormationInteret(interetFormationMarkRGrpChp.getValue().getValueAttribute()); |
} |
// STOCKAGE LOCAL |
conservationCollectee.setStockageLocal(creerChaineDenormalisee(localStockageTrukCacGrpChp.getValues())); |
conservationCollectee.setStockageLocal("AUTRE", localStockageAutreChp.getValue()); |
// STOCKAGE MEUBLE |
conservationCollectee.setStockageMeuble(creerChaineDenormalisee(meubleStockageTrukCacGrpChp.getValues())); |
conservationCollectee.setStockageMeuble("AUTRE", meubleStockageAutreChp.getValue()); |
// STOCKAGE PAREMETRE |
conservationCollectee.setStockageParametre(creerChaineDenormalisee(parametreStockageTrukCacGrpChp.getValues())); |
conservationCollectee.setStockageParametre("AUTRE", parametreStockageAutreChp.getValue()); |
// COLLECTION COMMUNE |
if (collectionCommuneMarkRGrpChp.getValue() != null) { |
conservationCollectee.setCollectionCommune(collectionCommuneMarkRGrpChp.getValue().getValueAttribute()); |
} |
// COLLECTION AUTRE |
conservationCollectee.setCollectionAutre(creerChaineDenormalisee(collectionAutreTrukCacGrpChp.getValues())); |
conservationCollectee.setCollectionAutre("AUTRE", collectionAutreAutreChp.getValue()); |
// ACCÈS CONTROLÉ |
if (accesControleMarkRGrpChp.getValue() != null) { |
conservationCollectee.setAccesControle(accesControleMarkRGrpChp.getValue().getValueAttribute()); |
} |
// RESTAURATION |
if (restaurationMarkRGrpChp.getValue() != null) { |
conservationCollectee.setRestauration(restaurationMarkRGrpChp.getValue().getValueAttribute()); |
} |
// RESTAURATION OPÉRATION |
conservationCollectee.setRestaurationOperation(creerChaineDenormalisee(opRestauTrukCacGrpChp.getValues())); |
conservationCollectee.setRestaurationOperation("AUTRE", opRestauAutreChp.getValue()); |
// MATERIEL CONSERVATION |
if (materielConservationCeRGrpChp.getValue() != null) { |
conservationCollectee.setMaterielConservation(materielConservationCeRGrpChp.getValue().getValueAttribute()); |
// MATERIEL AUTRE |
conservationCollectee.setMaterielAutre(creerChaineDenormalisee(autreMaterielTrukCacGrpChp.getValues())); |
conservationCollectee.setMaterielAutre("AUTRE", autreMaterielAutreChp.getValue()); |
} |
// TRAITEMENT |
if (traitementMarkRGrpChp.getValue() != null) { |
conservationCollectee.setTraitement(traitementMarkRGrpChp.getValue().getValueAttribute()); |
} |
// TRAIEMENTS |
conservationCollectee.setTraitements(creerChaineDenormalisee(traitementTrukCacGrpChp.getValues())); |
conservationCollectee.setTraitements("AUTRE", traitementAutreChp.getValue()); |
// ACQUISITION COLLECTION |
if (collectionAcquisitionMarkRGrpChp.getValue() != null) { |
conservationCollectee.setAcquisitionCollection(collectionAcquisitionMarkRGrpChp.getValue().getValueAttribute()); |
} |
// ACQUISITION ECHANTILLON |
if (echantillonAcquisitionMarkRGrpChp.getValue() != null) { |
conservationCollectee.setAcquisitionEchantillon(echantillonAcquisitionMarkRGrpChp.getValue().getValueAttribute()); |
} |
// ACQUISITION TRAITEMENT |
if (traitementAcquisitionMarkRGrpChp.getValue() != null) { |
conservationCollectee.setAcquisitionTraitement(traitementAcquisitionMarkRGrpChp.getValue().getValueAttribute()); |
} |
// ACQUISITION TRAITEMENT POISON |
conservationCollectee.setAcquisitionTraitementPoison(creerChaineDenormalisee(poisonTraitementTrukCacGrpChp.getValues())); |
conservationCollectee.setAcquisitionTraitementPoison("AUTRE", poisonTraitementAutreChp.getValue()); |
// ACQUISITION TRAITEMENT INSECTE |
conservationCollectee.setAcquisitionTraitementInsecte(creerChaineDenormalisee(insecteTraitementTrukCacGrpChp.getValues())); |
conservationCollectee.setAcquisitionTraitementInsecte("AUTRE", insecteTraitementAutreChp.getValue()); |
// Retour de l'objet |
if (!conservationCollectee.comparer(conservation)) { |
GWT.log("Collecte différent de Retour", null); |
conservationARetourner = conservation = conservationCollectee; |
} |
} |
return conservationARetourner; |
} |
private void peuplerStructureConservation() { |
if (mode.equals(MODE_AJOUTER)) { |
// Indique que l'onglet a pu être modifié pour la méthode collecter... |
conservationOnglet.setData("acces", true); |
// Initialisation de l'objet Structure |
conservation = new StructureConservation(); |
} |
if (mode.equals(MODE_MODIFIER) && conservation != null && conservationOnglet.getData("acces").equals(false)) { |
// FORMATION |
// Bouton oui, à toujours l'index 0 donc on teste en fonction... |
((Radio) formationMarkRGrpChp.get((conservation.getFormation().equals("1") ? 0 : 1))).setValue(true); |
// FORMATION INFO |
formationChp.setValue(conservation.getFormationInfo()); |
// FORMATION INTERET |
((Radio) interetFormationMarkRGrpChp.get((conservation.getFormationInteret().equals("1") ? 0 : 1))).setValue(true); |
// STOCKAGE LOCAL |
peuplerCasesACocher(conservation.getStockageLocal(), localStockageTrukCacGrpChp,localStockageAutreChp); |
// STOCKAGE MEUBLE |
peuplerCasesACocher(conservation.getStockageMeuble(), meubleStockageTrukCacGrpChp, meubleStockageAutreChp); |
// STOCKAGE PAREMETRE |
peuplerCasesACocher(conservation.getStockageParametre(), parametreStockageTrukCacGrpChp, parametreStockageAutreChp); |
// COLLECTION COMMUNE |
((Radio) collectionCommuneMarkRGrpChp.get((conservation.getCollectionCommune().equals("1") ? 0 : 1))).setValue(true); |
// COLLECTION AUTRE |
peuplerCasesACocher(conservation.getCollectionAutre(), collectionAutreTrukCacGrpChp, collectionAutreAutreChp); |
// ACCÈS CONTROLÉ |
((Radio) accesControleMarkRGrpChp.get((conservation.getAccesControle().equals("1") ? 0 : 1))).setValue(true); |
// RESTAURATION |
((Radio) restaurationMarkRGrpChp.get((conservation.getRestauration().equals("1") ? 0 : 1))).setValue(true); |
// RESTAURATION OPÉRATION |
peuplerCasesACocher(conservation.getRestaurationOperation(), opRestauTrukCacGrpChp, opRestauAutreChp); |
// MATERIEL CONSERVATION |
peuplerBoutonsRadio(conservation.getMaterielConservation(), materielConservationCeRGrpChp); |
// MATERIEL AUTRE |
peuplerCasesACocher(conservation.getMaterielAutre(), autreMaterielTrukCacGrpChp, autreMaterielAutreChp); |
// TRAITEMENT |
((Radio) traitementMarkRGrpChp.get((conservation.getTraitement().equals("1") ? 0 : 1))).setValue(true); |
// TRAITEMENTS |
peuplerCasesACocher(conservation.getTraitements(), traitementTrukCacGrpChp, traitementAutreChp); |
// ACQUISITION COLLECTION |
((Radio) collectionAcquisitionMarkRGrpChp.get((conservation.getAcquisitionCollection().equals("1") ? 0 : 1))).setValue(true); |
// ACQUISITION ECHANTILLON |
((Radio) echantillonAcquisitionMarkRGrpChp.get((conservation.getAcquisitionEchantillon().equals("1") ? 0 : 1))).setValue(true); |
// ACQUISITION TRAITEMENT |
((Radio) traitementAcquisitionMarkRGrpChp.get((conservation.getAcquisitionTraitement().equals("1") ? 0 : 1))).setValue(true); |
// ACQUISITION TRAITEMENT POISON |
peuplerCasesACocher(conservation.getAcquisitionTraitementPoison(), poisonTraitementTrukCacGrpChp, poisonTraitementAutreChp); |
// ACQUISITION TRAITEMENT INSECTE |
peuplerCasesACocher(conservation.getAcquisitionTraitementInsecte(), insecteTraitementTrukCacGrpChp, insecteTraitementAutreChp); |
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... |
conservationOnglet.setData("acces", true); |
} |
} |
private Structure collecterStructureIdentification() { |
Structure structureARetourner = null; |
if (identificationOnglet.getData("acces").equals(true)) { |
Structure structureCollectee = (Structure) identification.cloner(new Structure()); |
structureCollectee.setId(idStructureChp.getValue()); |
structureCollectee.setNom(nomStructureChp.getValue()); |
// Récupération de l'identifiant du projet |
if (projetsCombo.getValue() != null) { |
structureCollectee.setIdProjet(projetsCombo.getValue().getId()); |
} |
// Récupération de l'acronyme (= identifiant alternatif) |
structureCollectee.setIdAlternatif(null); |
if (comboAcronyme.getValue() != null) { |
String typeAcronyme = comboAcronyme.getValue().getAbr(); |
if (typeAcronyme == "IH") { |
structureCollectee.setIdAlternatif(typeAcronyme+"##"+ihChp.getValue()); |
} else if (typeAcronyme == "MNHN") { |
structureCollectee.setIdAlternatif(typeAcronyme+"##"+mnhnChp.getValue()); |
} |
} |
// Récupération statut de la structure |
structureCollectee.setTypePublic(null); |
structureCollectee.setTypePrive(null); |
if (comboTypeStructure.getValue() != null) { |
String typeStructure = comboTypeStructure.getValue().getAbr(); |
if (typeStructure == "stpu" && comboLstpu.getValue() != null) { |
structureCollectee.setTypePublic(comboLstpu.getValue().getId()); |
} else if (typeStructure == "stpr" && comboLstpr.getValue() != null) { |
structureCollectee.setTypePrive(comboLstpr.getValue().getId()); |
} |
} |
structureCollectee.setDateFondation(dateFondationChp.getValue()); |
structureCollectee.setAdresse(adrChp.getValue()); |
structureCollectee.setCodePostal(cpChp.getValue()); |
structureCollectee.setVille(villeChp.getValue()); |
String strRegion = ""; |
Valeur valeurRegion = comboRegion.getValue(); |
if (valeurRegion == null) { |
strRegion = "AUTRE##" + comboRegion.getRawValue(); |
} else { |
strRegion = valeurRegion.getId(); |
} |
structureCollectee.setRegion(strRegion); |
structureCollectee.setPays(null); |
if (comboPays.getValue() != null) { |
structureCollectee.setPays(comboPays.getValue().getId()); |
} else if (comboPays.getRawValue() != "") { |
structureCollectee.setPays(comboPays.getRawValue()); |
} |
structureCollectee.setTelephoneFixe(telChp.getValue()); |
structureCollectee.setFax(faxChp.getValue()); |
structureCollectee.setCourriel(emailChp.getValue()); |
structureCollectee.setUrl(Structure.URL_SITE, urlChp.getValue()); |
if (nbreTotalPersonneStructureChp.getValue() != null) { |
structureCollectee.setNbrePersonne(nbreTotalPersonneStructureChp.getValue().intValue()); |
} |
if (!structureCollectee.comparer(identification)) { |
structureARetourner = identification = structureCollectee; |
} |
} |
System.out.println(structureARetourner); |
return structureARetourner; |
} |
private void peuplerStructureIdentification() { |
if (mode.equals(MODE_AJOUTER)) { |
// Indique que l'ongleta pu être modifié pour la méthode collecter... |
identificationOnglet.setData("acces", true); |
// Initialisation de l'objet Structure |
identification = new Structure(); |
// Indication du projet sélectionné par défaut |
String projetCourantId = ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getProjetId(); |
if (projetCourantId != null && !projetCourantId.equals("0")) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", projetCourantId)); |
} |
} |
if (mode.equals(MODE_MODIFIER) && identification != null && identificationOnglet.getData("acces").equals(false)) { |
idStructureChp.setValue(identification.getId()); |
nomStructureChp.setValue(identification.getNom()); |
if (!identification.getIdProjet().equals("0")) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", identification.getIdProjet())); |
} |
if (!identification.getIdAlternatif().isEmpty()) { |
String[] acronyme = identification.getIdAlternatif().split("##"); |
//#436 : Ne pas afficher "null" |
if (UtilString.isEmpty(acronyme[1]) || acronyme[1].equals("null")) { |
acronyme[1] = ""; |
} |
if (acronyme[0].matches("^IH$")) { |
comboAcronyme.setValue(InterneValeurListe.getTypeAcronymeIH()); |
ihChp.setValue(acronyme[1]); |
} else if (acronyme[0].matches("^MNHN$")) { |
comboAcronyme.setValue(InterneValeurListe.getTypeAcronymeMNHN()); |
mnhnChp.setValue(acronyme[1]); |
} |
} |
if (!identification.getTypePrive().isEmpty()) { |
if (identification.getTypePrive().matches("^[0-9]+$")) { |
comboTypeStructure.setValue(InterneValeurListe.getTypePrivee()); |
comboLstpr.setValue(comboLstpr.getStore().findModel("id_valeur", identification.getTypePrive())); |
} |
} else if (!identification.getTypePublic().isEmpty()) { |
if (identification.getTypePublic().matches("^[0-9]+$")) { |
comboTypeStructure.setValue(InterneValeurListe.getTypePublique()); |
comboLstpu.setValue(comboLstpu.getStore().findModel("id_valeur", identification.getTypePublic())); |
} |
} |
dateFondationChp.setValue(identification.getDateFondation()); |
adrChp.setValue(identification.getAdresse()); |
cpChp.setValue(identification.getCodePostal()); |
villeChp.setValue(identification.getVille()); |
mettreAJourRegion(); |
//(identification.getRegion()); |
if (identification.getPays().matches("^[0-9]+$")) { |
comboPays.setValue(comboPays.getStore().findModel("id_valeur", identification.getPays())); |
} else { |
comboPays.setRawValue(identification.getPays()); |
} |
telChp.setValue(identification.getTelephoneFixe()); |
faxChp.setValue(identification.getFax()); |
emailChp.setValue(identification.getCourriel()); |
urlChp.setValue(identification.getUrl("WEB")); |
nbreTotalPersonneStructureChp.setValue(identification.getNbrePersonne()); |
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... |
identificationOnglet.setData("acces", true); |
} |
} |
private TabItem creerOngletValorisation() { |
valorisationOnglet = creerOnglet("Valorisation", "valorisation"); |
valorisationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP)); |
Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
peuplerStructureValorisation(); |
valorisationOnglet.layout(); |
} |
}; |
valorisationOnglet.addListener(Events.Select, ecouteurSelection); |
actionMarkRGrpChp = creerChoixUniqueRadioGroupe("action_mark", "ouiNon"); |
actionMarkRGrpChp.setFieldLabel("Avez-vous réalisé des actions de valorisation de vos collections botaniques ou avez-vous été sollicités pour la valorisation de ces collections ?"); |
valorisationOnglet.add(actionMarkRGrpChp); |
actionTrukCp = creerChoixMultipleCp(); |
actionTrukCp.hide(); |
actionTrukCacGrpChp = new CheckBoxGroup(); |
actionTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?"); |
valorisationOnglet.add(actionTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "actionValorisation"); |
publicationChp = new TextArea(); |
publicationChp.setFieldLabel("Quelques titres des ouvrages, articles scientifiques, ..."); |
valorisationOnglet.add(publicationChp, new FormData(550, 0)); |
autreCollectionTrukCp = creerChoixMultipleCp(); |
autreCollectionTrukCacGrpChp = new CheckBoxGroup(); |
autreCollectionTrukCacGrpChp.setFieldLabel("L'organisme dispose-t-il d'autres collections (permettant une valorisation pluridisciplinaire) ?"); |
valorisationOnglet.add(autreCollectionTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "autreCollection"); |
futureActionMarkRGrpChp = creerChoixUniqueRadioGroupe("future_action_mark", "ouiNon"); |
futureActionMarkRGrpChp.setFieldLabel("Envisagez vous des actions de valorisation dans le cadre de votre politique culturelle ?"); |
valorisationOnglet.add(futureActionMarkRGrpChp); |
futureActionChp = new TextArea(); |
futureActionChp.setFieldLabel("Si oui, lesquelles ?"); |
futureActionChp.hide(); |
futureActionChp.addListener(Events.Hide, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
((TextArea) be.getSource()).setValue(""); |
} |
}); |
valorisationOnglet.add(futureActionChp, new FormData(550, 0)); |
rechercheMarkRGrpChp = creerChoixUniqueRadioGroupe("recherche_mark", "ouiNon"); |
rechercheMarkRGrpChp.setFieldLabel("Vos collections botaniques sont-elles utilisées pour des recherches scientifiques ?"); |
valorisationOnglet.add(rechercheMarkRGrpChp); |
provenanceRechercheTrukCp = creerChoixMultipleCp(); |
provenanceRechercheTrukCp.hide(); |
provenanceRechercheTrukCacGrpChp = new CheckBoxGroup(); |
provenanceRechercheTrukCacGrpChp.setFieldLabel("Si oui, par des chercheurs (professionnels ou amateurs) de quelle provenance ?"); |
valorisationOnglet.add(provenanceRechercheTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "continentEtFr"); |
typeRechercheTrukCp = creerChoixMultipleCp(); |
typeRechercheTrukCp.hide(); |
typeRechercheTrukCacGrpChp = new CheckBoxGroup(); |
typeRechercheTrukCacGrpChp.setFieldLabel("Et pour quelles recherches ?"); |
valorisationOnglet.add(typeRechercheTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeRecherche"); |
sansMotifAccesMarkRGrpChp = creerChoixUniqueRadioGroupe("sans_motif_acces_mark", "ouiNon"); |
sansMotifAccesMarkRGrpChp.setFieldLabel("Peut-on consulter vos collections botaniques sans motif de recherches scientifiques ?"); |
valorisationOnglet.add(sansMotifAccesMarkRGrpChp); |
valorisationOnglet.add(sansMotifAccesChp = new TextArea(), new FormData(550, 0)); |
sansMotifAccesChp.hide(); |
sansMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
((TextArea) be.getSource()).setValue(""); |
} |
}); |
sansMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les consulter ?"); |
avecMotifAccesMarkRGrpChp = creerChoixUniqueRadioGroupe("avec_motif_acces_mark", "ouiNon"); |
avecMotifAccesMarkRGrpChp.setFieldLabel("Peut-on visiter vos collections botaniques avec des objectifs de recherches scientifiques ?"); |
valorisationOnglet.add(avecMotifAccesMarkRGrpChp); |
valorisationOnglet.add(avecMotifAccesChp = new TextArea(), new FormData(550, 0)); |
avecMotifAccesChp.hide(); |
avecMotifAccesChp.addListener(Events.Hide, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
((TextArea) be.getSource()).setValue(""); |
} |
}); |
avecMotifAccesChp.setFieldLabel("Si oui, quelles démarches doit-on faire pour les visiter ?"); |
return valorisationOnglet; |
} |
private TabItem creerOngletConservation() { |
conservationOnglet = creerOnglet("Conservation", "conservation"); |
conservationOnglet.setLayout(creerFormLayout(650, LabelAlign.TOP)); |
Listener<ComponentEvent> ecouteurSelection = new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
peuplerStructureConservation(); |
conservationOnglet.layout(); |
} |
}; |
conservationOnglet.addListener(Events.Select, ecouteurSelection); |
formationMarkRGrpChp = creerChoixUniqueRadioGroupe("formation_mark", "ouiNon"); |
formationMarkRGrpChp.setFieldLabel("Le personnel s'occupant des collections a-t-il suivi des formations en conservations ?"); |
conservationOnglet.add(formationMarkRGrpChp); |
formationChp = new TextArea(); |
formationChp.hide(); |
formationChp.addListener(Events.Hide, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
((TextArea) be.getSource()).setValue(""); |
} |
}); |
formationChp.setFieldLabel("Si oui, lesquelles ?"); |
conservationOnglet.add(formationChp); |
interetFormationMarkRGrpChp = creerChoixUniqueRadioGroupe("interet_formation_mark", "ouiNon"); |
interetFormationMarkRGrpChp.setFieldLabel("Seriez vous intéressé par une formation à la conservation et à la restauration d'herbier ?"); |
conservationOnglet.add(interetFormationMarkRGrpChp); |
localStockageTrukCacGrpChp = new CheckBoxGroup(); |
localStockageTrukCacGrpChp.setFieldLabel("Avez vous des locaux spécifiques de stockage des collections botaniques ?"); |
localStockageTrukCp = creerChoixMultipleCp(); |
conservationOnglet.add(localStockageTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "localStockage"); |
meubleStockageTrukCp = creerChoixMultipleCp(); |
meubleStockageTrukCacGrpChp = new CheckBoxGroup(); |
meubleStockageTrukCacGrpChp.setFieldLabel("Avez vous des meubles spécifiques au stockage des collections botaniques ?"); |
conservationOnglet.add(meubleStockageTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "meubleStockage"); |
parametreStockageTrukCp = creerChoixMultipleCp(); |
parametreStockageTrukCacGrpChp = new CheckBoxGroup(); |
parametreStockageTrukCacGrpChp.setFieldLabel("Quels paramètres maîtrisez vous ?"); |
conservationOnglet.add(parametreStockageTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "parametreStockage"); |
collectionCommuneMarkRGrpChp = creerChoixUniqueRadioGroupe("collection_commune_mark", "ouiNon"); |
collectionCommuneMarkRGrpChp.setFieldLabel("Les collections botaniques sont-elles conservées avec d'autres collections dans les mêmes locaux (problème de conservation en commun) ?"); |
conservationOnglet.add(collectionCommuneMarkRGrpChp); |
collectionAutreTrukCp = creerChoixMultipleCp(); |
collectionAutreTrukCacGrpChp = new CheckBoxGroup(); |
collectionAutreTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?"); |
collectionAutreTrukCp.hide(); |
conservationOnglet.add(collectionAutreTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "autreCollection"); |
accesControleMarkRGrpChp = creerChoixUniqueRadioGroupe("mark_acces_controle", "ouiNon"); |
accesControleMarkRGrpChp.setFieldLabel("L'accès à vos collections botanique est-il contrôlé (ex. : manipulation réservées à des personnes compétentes) ?"); |
conservationOnglet.add(accesControleMarkRGrpChp); |
restaurationMarkRGrpChp = creerChoixUniqueRadioGroupe("restauration_mark", "ouiNon"); |
restaurationMarkRGrpChp.setFieldLabel("Effectuez vous des opérations de restauration ou de remise en état de vos collections botaniques ?"); |
conservationOnglet.add(restaurationMarkRGrpChp); |
opRestauTrukCp = creerChoixMultipleCp(); |
opRestauTrukCacGrpChp = new CheckBoxGroup(); |
opRestauTrukCacGrpChp.setFieldLabel("Si oui, lesquelles ?"); |
opRestauTrukCp.hide(); |
conservationOnglet.add(opRestauTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "opRestau"); |
// Création d'un ContentPanel vide et du groupe de bouton radio |
// Le groupe de bouton radio recevra les boutons au moment de la réception des données (rafraichir()) et ser à ce moment là ajouter au ContenetPanel |
materielConservationCp = creerChoixMultipleCp(); |
conservationOnglet.add(materielConservationCp); |
materielConservationCeRGrpChp = creerChoixUniqueRadioGroupe("materiel_conservation_ce", "onep"); |
materielConservationCeRGrpChp.setFieldLabel("Utilisez vous du matériel de conservation ?"); |
materielConservationCeRGrpChp.setToolTip(new ToolTipConfig("Matériel de conservation", "matériel spécialisé pour la conservation des archives ou du patrimoine fragile. Ce matériel possède des propriétés mécaniques et chimiques qui font qu'il résiste dans le temps et que sa dégradation n'entraîne pas de dommages sur le matériel qu'il aide à conserver. Exemples : papier neutre, papier gommé, etc...")); |
mediateur.obtenirListeValeurEtRafraichir(this, "onep"); |
autreMaterielTrukCp = creerChoixMultipleCp(); |
autreMaterielTrukCacGrpChp = new CheckBoxGroup(); |
autreMaterielTrukCacGrpChp.setFieldLabel("Si non, qu'utilisez vous comme matériel ?"); |
autreMaterielTrukCp.hide(); |
conservationOnglet.add(autreMaterielTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "autreMateriel"); |
traitementMarkRGrpChp = creerChoixUniqueRadioGroupe("traitement_mark", "ouiNon"); |
traitementMarkRGrpChp.setFieldLabel("Réalisez vous actuellement des traitements globaux contre les insectes ?"); |
conservationOnglet.add(traitementMarkRGrpChp); |
traitementTrukCp = creerChoixMultipleCp(); |
traitementTrukCp.hide(); |
traitementTrukCacGrpChp = new CheckBoxGroup(); |
traitementTrukCacGrpChp.setFieldLabel("Si oui, lesquels ?"); |
conservationOnglet.add(traitementTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "insecteTraitement"); |
collectionAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("collection_acquisition_mark", "ouiNon"); |
collectionAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, vos collections botaniques s'accroissent-elles de nouvelles acquisitions ?"); |
conservationOnglet.add(collectionAcquisitionMarkRGrpChp); |
echantillonAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("echantillon_acquisition_mark", "ouiNon"); |
echantillonAcquisitionMarkRGrpChp.setFieldLabel("Actuellement, mettez vous en herbier de nouveaux échantillons ?"); |
conservationOnglet.add(echantillonAcquisitionMarkRGrpChp); |
traitementAcquisitionMarkRGrpChp = creerChoixUniqueRadioGroupe("traitement_acquisition_mark", "ouiNon"); |
traitementAcquisitionMarkRGrpChp.hide(); |
traitementAcquisitionMarkRGrpChp.setFieldLabel("Si oui, faites-vous un traitement contre les insectes avant l'intégration dans vos collections ?"); |
conservationOnglet.add(traitementAcquisitionMarkRGrpChp); |
traitementAcquisitionMarkLabel = new LabelField(); |
traitementAcquisitionMarkLabel.hide(); |
traitementAcquisitionMarkLabel.setFieldLabel("Si oui, lesquels ?"); |
conservationOnglet.add(traitementAcquisitionMarkLabel); |
poisonTraitementTrukCp = creerChoixMultipleCp(); |
poisonTraitementTrukCp.hide(); |
poisonTraitementTrukCacGrpChp = new CheckBoxGroup(); |
poisonTraitementTrukCacGrpChp.setFieldLabel("Empoisonnement"); |
poisonTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;"); |
poisonTraitementTrukCacGrpChp.setLabelSeparator(""); |
conservationOnglet.add(poisonTraitementTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "poisonTraitement"); |
insecteTraitementTrukCp = creerChoixMultipleCp(); |
insecteTraitementTrukCp.hide(); |
insecteTraitementTrukCacGrpChp = new CheckBoxGroup(); |
insecteTraitementTrukCacGrpChp.setLabelStyle("font-weight:normal;text-decoration:underline;"); |
insecteTraitementTrukCacGrpChp.setLabelSeparator(""); |
insecteTraitementTrukCacGrpChp.setFieldLabel("Désinsectisation"); |
conservationOnglet.add(insecteTraitementTrukCp); |
mediateur.obtenirListeValeurEtRafraichir(this, "insecteTraitement"); |
conservationOnglet.add(new Html("<br />")); |
return conservationOnglet; |
} |
private void collecterStructurePersonnel() { |
if (personnelOnglet.getData("acces").equals(true)) { |
personnelGrilleMagazin.commitChanges(); |
int nbrePersonne = personnelGrilleMagazin.getCount(); |
for (int i = 0; i < nbrePersonne; i++) { |
StructureAPersonne personne = personnelGrilleMagazin.getAt(i); |
// Seules les lignes ajoutées ou modifiées sont prises en compte. |
Record record = personnelGrilleMagazin.getRecord(personne); |
if (personnelGrilleMagazin.getModifiedRecords().contains(record) == true |
|| (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE) )) { |
// Gestion de l'id de la structure |
if (mode.equals("MODIF")) { |
personne.setIdStructure(identification.getId()); |
} |
// Récupération de l'id du projet de la structure qui servira aussi pour les Personnes crées dans ce formulaire |
if (personne.getIdPersonne().equals("") && projetsCombo.getValue() != null) { |
personne.setIdProjetPersonne(projetsCombo.getValue().getId()); |
} |
// Gestion de la fonction |
String fonction = personne.get("fonction"); |
if (fonction != null && !fonction.equals("")) { |
Valeur valeurRecherche = fonctionsCombo.getStore().findModel("nom", fonction); |
if (valeurRecherche != null) { |
personne.setFonction(valeurRecherche.getId()); |
} else { |
personne.setFonction("AUTRE", fonction); |
} |
} else { |
personne.setFonction(""); |
} |
// Gestion de la notion de "contact" |
personne.setContact(false); |
if (personne.get("contact").equals(true)) { |
personne.setContact(true); |
} |
// Gestion du statut |
String statut = personne.get("statut"); |
if (statut != null && !statut.equals("")) { |
Valeur valeurRecherche = comboLiStatut.getStore().findModel("nom", statut); |
if (valeurRecherche != null) { |
personne.setStatut(valeurRecherche.getId()); |
} else { |
personne.setStatut("AUTRE", statut); |
} |
} else { |
personne.setStatut(""); |
} |
// Gestion du temps de travail |
personne.setBotaTravailHebdoTps(personne.get("travail").toString()); |
// Gestion du téléphone |
String telephoneFixe = personne.get("tel_fix"); |
personne.setTelephoneFixe(telephoneFixe); |
// Gestion du fax |
String fax = personne.get("tel_fax"); |
personne.setFax(fax); |
// Gestion du courriel |
String courriel = personne.get("courriel"); |
personne.setCourriel(courriel); |
// Gestion de la spécialité |
String specialite = personne.get("specialite"); |
personne.setSpecialite(specialite); |
// Ajout de la personne dans la liste correspondant à son état (ajouté ou modifié) |
if (personne.get("etat") != null && personne.get("etat").equals(StructureAPersonne.ETAT_AJOUTE)) {// Une personne ajoutée |
personnelAjoute.put(""+i, personne); |
} else {// Une personne modifiée |
personnelModifie.put(personne.getId(), personne); |
} |
} else { |
GWT.log("Personne non modifiées : "+personne.getPrenom()+" "+personne.getNom(), null); |
} |
} |
} |
} |
private void peuplerStructurePersonnel() { |
if (mode.equals(MODE_MODIFIER) && personnel != null) { |
ArrayList<StructureAPersonne> personnes = new ArrayList<StructureAPersonne>(); |
for (Iterator<String> it = personnel.keySet().iterator(); it.hasNext();) { |
String index = it.next(); |
// Gestion de la fonction |
if (fonctionsMagazin != null && !((String) personnel.get(index).getFonction()).startsWith("AUTRE##")) { |
if (fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()) != null) { |
personnel.get(index).set("fonction", fonctionsMagazin.findModel("id_valeur", personnel.get(index).getFonction()).getNom()); |
} |
} else { |
personnel.get(index).set("fonction", personnel.get(index).getFonction().replaceFirst("AUTRE##", "")); |
} |
// Gestion de la notion de "contact" |
personnel.get(index).set("contact", (personnel.get(index).getContact().equals("1") ? true : false)); |
// Gestion du statut |
if (magazinLiStatut != null && ((String) personnel.get(index).getStatut()).matches("^[0-9]+$")) { |
personnel.get(index).set("statut", magazinLiStatut.findModel("id_valeur", personnel.get(index).getStatut()).getNom()); |
} else { |
personnel.get(index).set("statut", personnel.get(index).getStatut().replaceFirst("AUTRE##", "")); |
} |
// Gestion du temps de travail |
String tps = personnel.get(index).getBotaTravailHebdoTps(); |
personnel.get(index).set("travail", (tps.matches("^[0-9]+$") ? Integer.parseInt(tps) : 0)); |
personnes.add(personnel.get(index)); |
} |
personnelGrilleMagazin.removeAll(); |
personnelGrilleMagazin.add(personnes); |
// Nous vidons la variable personnel une fois qu'elle a remplie la grille |
personnel = null; |
} |
} |
private TabItem creerOngletPersonnel() { |
// Création des objets contenant les manipulations de la grille |
personnelModifie = new StructureAPersonneListe(); |
personnelAjoute = new StructureAPersonneListe(); |
personnelSupprime = new StructureAPersonneListe(); |
personnelOnglet = creerOnglet("Personnel", "personnel"); |
personnelOnglet.setLayout(creerFormLayout(400, LabelAlign.LEFT)); |
personnelOnglet.setStyleAttribute("padding", "0"); |
personnelOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
// Indique que l'onglet a été rempli et a pu être modifié pour la méthode collecter... |
personnelOnglet.setData("acces", true); |
// Rafraichissement du contenu de la grille du personnel |
if (mode.equals(MODE_AJOUTER)) { |
rafraichirPersonnel(); |
} |
} |
}); |
ContentPanel cp = new ContentPanel(); |
cp.setHeading("Personnes travaillant sur les collections"); |
cp.setIcon(Images.ICONES.table()); |
//cp.setScrollMode(Scroll.AUTO); |
cp.setLayout(new FitLayout()); |
//cp.setWidth(1250); |
//cp.setHeight("100%"); |
cp.setFrame(true); |
personnelGrilleMagazin = new ListStore<StructureAPersonne>(); |
personnelGrilleMagazin.addListener(Store.Add, new Listener<StoreEvent<StructureAPersonne>>() { |
public void handleEvent(StoreEvent<StructureAPersonne> ce) { |
// Activation du bouton supprimer si la grille contient un élément |
if (grillePersonnel.getStore().getCount() > 0) { |
supprimerPersonnelBtn.enable(); |
} |
} |
}); |
RowNumberer r = new RowNumberer(); |
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); |
GridSelectionModel<StructureAPersonne> sm = new GridSelectionModel<StructureAPersonne>(); |
configs.add(r); |
ColumnConfig column = new ColumnConfig("fonction", "Fonction", 150); |
fonctionsMagazin = new ListStore<Valeur>(); |
fonctionsCombo = new ComboBox<Valeur>(); |
fonctionsCombo.setTriggerAction(TriggerAction.ALL); |
fonctionsCombo.setEditable(true); |
fonctionsCombo.setDisplayField("nom"); |
fonctionsCombo.setStore(fonctionsMagazin); |
mediateur.obtenirListeValeurEtRafraichir(this, "fonction"); |
fonctionEditor = new CellEditor(fonctionsCombo) { |
@Override |
public Object preProcessValue(Object valeur) { |
Valeur retour = null; |
if (valeur != null) { |
String chaineTransmise = (String) valeur; |
if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) { |
fonctionsMagazin.add(fonctionsListe); |
} |
if (fonctionsMagazin.findModel("id_valeur", chaineTransmise) != null) { |
retour = fonctionsMagazin.findModel("id_valeur", chaineTransmise); |
} else if (fonctionsMagazin.findModel("nom", chaineTransmise) != null) { |
retour = fonctionsMagazin.findModel("nom", chaineTransmise); |
} else { |
retour = new Valeur("", chaineTransmise, "", ""); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = ""; |
Valeur fonctionTrouvee = null; |
if (valeur == null) { |
String valeurBrute = this.getField().getRawValue(); |
if (fonctionsMagazin.getCount() == 0 && fonctionsListe != null) { |
fonctionsMagazin.add(fonctionsListe); |
} |
if (valeurBrute.matches("^[0-9]+$") && fonctionsMagazin.findModel("id_valeur", valeurBrute) != null) { |
fonctionTrouvee = fonctionsMagazin.findModel("id_valeur", valeurBrute); |
} else { |
retour = valeurBrute; |
} |
} else if (valeur instanceof Valeur) { |
fonctionTrouvee = (Valeur) valeur; |
} |
if (fonctionTrouvee != null) { |
retour = fonctionTrouvee.getNom(); |
} |
return retour; |
} |
}; |
column.setEditor(fonctionEditor); |
configs.add(column); |
column = new ColumnConfig("prenom", "Prénom", 100); |
TextField<String> prenomChp = new TextField<String>(); |
prenomChp.setAllowBlank(false); |
prenomChp.getMessages().setBlankText("Ce champ est obligatoire."); |
prenomChp.setAutoValidate(true); |
prenomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
prenomChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
column.setEditor(new CellEditor(prenomChp)); |
configs.add(column); |
column = new ColumnConfig("nom", "Nom", 100); |
TextField<String> nomChp = new TextField<String>(); |
nomChp.setAllowBlank(false); |
nomChp.getMessages().setBlankText("Ce champ est obligatoire."); |
nomChp.setAutoValidate(true); |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
column.setEditor(new CellEditor(nomChp)); |
configs.add(column); |
column = new ColumnConfig("tel_fix", "Téléphone fixe", 100); |
TextField<String> telChp = new TextField<String>(); |
column.setEditor(new CellEditor(telChp)); |
configs.add(column); |
column = new ColumnConfig("tel_fax", "Fax", 100); |
TextField<String> faxChp = new TextField<String>(); |
column.setEditor(new CellEditor(faxChp)); |
configs.add(column); |
column = new ColumnConfig("courriel", "Courriel principal", 200); |
TextField<String> emailChp = new TextField<String>(); |
column.setEditor(new CellEditor(emailChp)); |
configs.add(column); |
magazinLiStatut = new ListStore<Valeur>(); |
magazinLiStatut.add(new ArrayList<Valeur>()); |
comboLiStatut = new ComboBox<Valeur>(); |
comboLiStatut.setTriggerAction(TriggerAction.ALL); |
comboLiStatut.setEditable(false); |
comboLiStatut.disableTextSelection(true); |
comboLiStatut.setDisplayField("nom"); |
comboLiStatut.setStore(magazinLiStatut); |
mediateur.obtenirListeValeurEtRafraichir(this, "statut"); |
CellEditor statutEditor = new CellEditor(comboLiStatut) { |
@Override |
public Object preProcessValue(Object value) { |
if (value == null) { |
return value; |
} |
return comboLiStatut.getStore().findModel("nom", (String) value); |
} |
@Override |
public Object postProcessValue(Object value) { |
if (value == null) { |
return value; |
} |
return ((Valeur) value).get("nom"); |
} |
}; |
column = new ColumnConfig("statut", "Statut", 100); |
column.setEditor(statutEditor); |
configs.add(column); |
column = new ColumnConfig("travail", "Temps travail", 100); |
column.setNumberFormat(NumberFormat.getFormat("##")); |
NumberField tpsWChp = new NumberField(); |
tpsWChp.setFormat(NumberFormat.getFormat("##")); |
tpsWChp.setToolTip("Ce champ doit contenir un nombre"); |
column.setEditor(new CellEditor(tpsWChp)); |
configs.add(column); |
column = new ColumnConfig("specialite", "Spécialité principale", 150); |
TextField<String> speChp = new TextField<String>(); |
column.setEditor(new CellEditor(speChp)); |
configs.add(column); |
CheckColumnConfig checkColumn = new CheckColumnConfig("contact", "Contact ?", 60); |
configs.add(checkColumn); |
ToolBar toolBar = new ToolBar(); |
Button ajouterPersonnelBtn = new Button("Ajouter"); |
ajouterPersonnelBtn.setIcon(Images.ICONES.vcardAjouter()); |
ajouterPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
} |
}); |
toolBar.add(ajouterPersonnelBtn); |
toolBar.add(new SeparatorToolItem()); |
supprimerPersonnelBtn = new Button("Supprimer"); |
supprimerPersonnelBtn.setIcon(Images.ICONES.vcardSupprimer()); |
supprimerPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem(); |
if (personne != null) { |
// Ajout de la personne supprimée à la liste |
if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) { |
personnelSupprime.put(personne.getId(), personne); |
} |
// Suppression de l'enregistrement de la grille |
grillePersonnel.getStore().remove(personne); |
// Désactivation du bouton supprimer si la grille contient plus d'élément |
if (grillePersonnel.getStore().getCount() == 0) { |
//TODO : check : Item -> component |
ce.getComponent().disable(); |
} |
} |
} |
}); |
toolBar.add(supprimerPersonnelBtn); |
toolBar.add(new SeparatorToolItem()); |
Button rafraichirPersonnelBtn = new Button("Rafraichir"); |
rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir()); |
rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
rafraichirPersonnel(); |
} |
}); |
toolBar.add(rafraichirPersonnelBtn); |
toolBar.add(new SeparatorToolItem()); |
personneExistanteMagazin = new ListStore<Personne>(); |
personneExistanteMagazin.add(new ArrayList<Personne>()); |
personneExistanteCombo = new ComboBox<Personne>(); |
personneExistanteCombo.setWidth(200); |
personneExistanteCombo.setEmptyText("Chercher une personne existante..."); |
personneExistanteCombo.setTriggerAction(TriggerAction.ALL); |
personneExistanteCombo.setEditable(true); |
personneExistanteCombo.setDisplayField("fmt_nom_complet"); |
personneExistanteCombo.setStore(personneExistanteMagazin); |
personneExistanteCombo.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (!ce.isNavKeyPress() && personneExistanteCombo.getRawValue() != null && personneExistanteCombo.getRawValue().length() > 0) { |
rafraichirPersonneExistante(personneExistanteCombo.getRawValue()); |
} |
} |
}); |
// TODO : dans GXT 2.0 plus besoin de l'adaptateur, on peut ajouter la combobox directement sur la toolbar |
//> CHECK |
toolBar.add(personneExistanteCombo); |
Button ajouterPersonneExistanteBtn = new Button("Ajouter"); |
ajouterPersonneExistanteBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
Personne personneExistante = personneExistanteCombo.getValue(); |
if (personneExistante != null) { |
StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
membreDuPersonnel.setIdPersonne(personneExistante.getId()); |
membreDuPersonnel.setIdProjetPersonne(personneExistante.getIdProjet()); |
membreDuPersonnel.setNom(personneExistante.getNom()); |
membreDuPersonnel.setPrenom(personneExistante.getPrenom()); |
membreDuPersonnel.setTelephone(personneExistante.getTelephone()); |
membreDuPersonnel.setCourriel(personneExistante.selectionnerCourriel(1)); |
membreDuPersonnel.setSpecialite(personneExistante.afficherSpecialite()); |
ajouterMembreAGrillePersonnel(membreDuPersonnel); |
} |
} |
}); |
toolBar.add(ajouterPersonneExistanteBtn); |
cp.setTopComponent(toolBar); |
ColumnModel cm = new ColumnModel(configs); |
grillePersonnel = new EditorGrid<StructureAPersonne>(personnelGrilleMagazin, cm); |
grillePersonnel.setHeight("100%"); |
grillePersonnel.setBorders(true); |
grillePersonnel.setSelectionModel(sm); |
grillePersonnel.addPlugin(checkColumn); |
grillePersonnel.addPlugin(r); |
grillePersonnel.getView().setForceFit(true); |
grillePersonnel.setAutoExpandColumn("specialite"); |
grillePersonnel.setStripeRows(true); |
grillePersonnel.setTrackMouseOver(true); |
cp.add(grillePersonnel); |
personnelOnglet.add(cp); |
return personnelOnglet; |
} |
private TabItem creerOngletIdentification() { |
//+-----------------------------------------------------------------------------------------------------------+ |
// Onlget formulaire IDENTIFICATION |
identificationOnglet = creerOnglet("Identification", "identification"); |
identificationOnglet.addListener(Events.Select, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
peuplerStructureIdentification(); |
identificationOnglet.layout(); |
} |
}); |
//+-----------------------------------------------------------------------------------------------------------+ |
// Champs cachés |
idStructureChp = new HiddenField<String>(); |
//+-----------------------------------------------------------------------------------------------------------+ |
// Fieldset IDENTITÉ |
FieldSet fieldSetIdentite = new FieldSet(); |
fieldSetIdentite.setHeading("Identité"); |
fieldSetIdentite.setCollapsible(true); |
fieldSetIdentite.setLayout(creerFormLayout(120, LabelAlign.LEFT)); |
nomStructureChp = new TextField<String>(); |
nomStructureChp.setTabIndex(tabIndex++); |
nomStructureChp.setFieldLabel("Nom de la structure"); |
nomStructureChp.setAllowBlank(false); |
nomStructureChp.getMessages().setBlankText("Ce champ est obligatoire."); |
nomStructureChp.addStyleName(ComposantClass.OBLIGATOIRE); |
nomStructureChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
fieldSetIdentite.add(nomStructureChp, new FormData(450, 0)); |
projetsMagazin = new ListStore<Projet>(); |
mediateur.selectionnerProjet(this, null); |
projetsCombo = new ComboBox<Projet>(); |
projetsCombo.setTabIndex(tabIndex++); |
projetsCombo.setFieldLabel("Projet"); |
projetsCombo.setLabelSeparator(""); |
projetsCombo.setDisplayField("nom"); |
projetsCombo.setEditable(false); |
projetsCombo.setTriggerAction(TriggerAction.ALL); |
projetsCombo.setStore(projetsMagazin); |
projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
projetsCombo.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
fieldSetIdentite.add(projetsCombo, new FormData(450, 0)); |
// Création du sous-formulaire : Acronyme |
LayoutContainer ligne = new LayoutContainer(); |
ligne.setLayout(new ColumnLayout()); |
ligne.setSize(600, -1); |
LayoutContainer gauche = new LayoutContainer(); |
gauche.setLayout(creerFormLayout(120, LabelAlign.LEFT)); |
LayoutContainer droite = new LayoutContainer(); |
droite.setLayout(creerFormLayout(10, LabelAlign.LEFT)); |
ListStore<InterneValeur> acronymes = new ListStore<InterneValeur>(); |
acronymes.add(InterneValeurListe.getTypeAcronyme()); |
comboAcronyme = new ComboBox<InterneValeur>(); |
comboAcronyme.setTabIndex(tabIndex++); |
comboAcronyme.setEmptyText("Sélectioner un type d'acronyme..."); |
comboAcronyme.setFieldLabel("Type d'acronyme"); |
comboAcronyme.setDisplayField("nom"); |
comboAcronyme.setStore(acronymes); |
comboAcronyme.setEditable(false); |
comboAcronyme.setTypeAhead(true); |
comboAcronyme.setTriggerAction(TriggerAction.ALL); |
comboAcronyme.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() { |
@Override |
public void selectionChanged(SelectionChangedEvent<InterneValeur> se) { |
String acronymeAbr = se.getSelectedItem().getAbr(); |
if (acronymeAbr.equals("IH")) { |
mnhnChp.hide(); |
ihChp.show(); |
} else if (acronymeAbr.equals("MNHN")) { |
ihChp.hide(); |
mnhnChp.show(); |
} else if (acronymeAbr.equals("")) { |
ihChp.hide(); |
mnhnChp.hide(); |
comboAcronyme.clearSelections(); |
} |
} |
}); |
gauche.add(comboAcronyme, new FormData("95%")); |
ihChp = new TextField<String>(); |
ihChp.setTabIndex(tabIndex++); |
ihChp.setLabelSeparator(""); |
ihChp.setToolTip("Index Herbariorum : herbier de plus de 5000 échantillons"); |
ihChp.hide(); |
droite.add(ihChp, new FormData("95%")); |
mnhnChp = new TextField<String>(); |
mnhnChp.setTabIndex(tabIndex++); |
mnhnChp.setLabelSeparator(""); |
mnhnChp.setToolTip("Acronyme MNHN : herbier de moins de 5000 échantillons"); |
mnhnChp.hide(); |
droite.add(mnhnChp, new FormData("95%")); |
ligne.add(gauche, new ColumnData(.5)); |
ligne.add(droite, new ColumnData(.5)); |
fieldSetIdentite.add(ligne); |
// Création du sous-formulaire : Type de Structure |
LayoutContainer ligneTs = new LayoutContainer(); |
ligneTs.setLayout(new ColumnLayout()); |
ligneTs.setSize(600, -1); |
LayoutContainer gaucheTs = new LayoutContainer(); |
gaucheTs.setLayout(creerFormLayout(120, LabelAlign.LEFT)); |
LayoutContainer droiteTs = new LayoutContainer(); |
droiteTs.setLayout(creerFormLayout(10, LabelAlign.LEFT)); |
ListStore<InterneValeur> typesStructure = new ListStore<InterneValeur>(); |
typesStructure.add(InterneValeurListe.getTypeStructure()); |
comboTypeStructure = new ComboBox<InterneValeur>(); |
comboTypeStructure.setTabIndex(tabIndex++); |
comboTypeStructure.setEmptyText("Sélectioner un type de structure..."); |
comboTypeStructure.setFieldLabel("Statut des structures"); |
comboTypeStructure.setDisplayField("nom"); |
comboTypeStructure.setStore(typesStructure); |
comboTypeStructure.setEditable(false); |
comboTypeStructure.setTypeAhead(true); |
comboTypeStructure.setTriggerAction(TriggerAction.ALL); |
comboTypeStructure.addSelectionChangedListener(new SelectionChangedListener<InterneValeur>() { |
@Override |
public void selectionChanged(SelectionChangedEvent<InterneValeur> se) { |
String typeAbr = se.getSelectedItem().getAbr(); |
if (typeAbr.equals("stpu")) { |
comboLstpr.hide(); |
comboLstpu.show(); |
} else if (typeAbr.equals("stpr")) { |
comboLstpu.hide(); |
comboLstpr.show(); |
} else if (typeAbr.equals("")) { |
comboLstpr.hide(); |
comboLstpu.hide(); |
comboTypeStructure.clearSelections(); |
} |
} |
}); |
gaucheTs.add(comboTypeStructure, new FormData("95%")); |
magazinLstpu = new ListStore<Valeur>(); |
comboLstpu = new ComboBox<Valeur>(); |
comboLstpu.setTabIndex(tabIndex++); |
//comboLstpu.setFieldLabel("Statut des structures publiques"); |
comboLstpu.setLabelSeparator(""); |
comboLstpu.setDisplayField("nom"); |
comboLstpu.setEditable(false); |
comboLstpu.setTriggerAction(TriggerAction.ALL); |
comboLstpu.setStore(magazinLstpu); |
comboLstpu.hide(); |
droiteTs.add(comboLstpu, new FormData("95%")); |
mediateur.obtenirListeValeurEtRafraichir(this, "stpu"); |
magazinLstpr = new ListStore<Valeur>(); |
comboLstpr = new ComboBox<Valeur>(); |
comboLstpr.setTabIndex(tabIndex++); |
//comboLstpr.setFieldLabel("Statut des structures privées"); |
comboLstpr.setLabelSeparator(""); |
comboLstpr.setDisplayField("nom"); |
comboLstpr.setEditable(false); |
comboLstpr.setTriggerAction(TriggerAction.ALL); |
comboLstpr.setStore(magazinLstpr); |
comboLstpr.hide(); |
droiteTs.add(comboLstpr, new FormData("95%")); |
mediateur.obtenirListeValeurEtRafraichir(this, "stpr"); |
ligneTs.add(gaucheTs, new ColumnData(0.5)); |
ligneTs.add(droiteTs, new ColumnData(0.5)); |
fieldSetIdentite.add(ligneTs); |
dateFondationChp = new DateField(); |
dateFondationChp.setTabIndex(tabIndex++); |
dateFondationChp.setFieldLabel("Date de fondation"); |
dateFondationChp.getPropertyEditor().getFormat(); |
dateFondationChp.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy")); |
dateFondationChp.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa»."); |
fieldSetIdentite.add(dateFondationChp); |
nbreTotalPersonneStructureChp = new NumberField(); |
nbreTotalPersonneStructureChp.setFieldLabel("Nombre de personne travaillant dans l'institution"); |
nbreTotalPersonneStructureChp.setFormat(NumberFormat.getFormat("#")); |
nbreTotalPersonneStructureChp.setToolTip(i18nC.champNumerique()); |
fieldSetIdentite.add(nbreTotalPersonneStructureChp); |
identificationOnglet.add(fieldSetIdentite); |
//+-----------------------------------------------------------------------------------------------------------+ |
// Fieldset ADRESSE |
LayoutContainer principalFdAdresse = new LayoutContainer(); |
principalFdAdresse.setLayout(new ColumnLayout()); |
principalFdAdresse.setSize(600, -1); |
LayoutContainer gaucheFdAdresse = new LayoutContainer(); |
gaucheFdAdresse.setLayout(creerFormLayout(null, LabelAlign.LEFT)); |
LayoutContainer droiteFdAdresse = new LayoutContainer(); |
droiteFdAdresse.setLayout(creerFormLayout(null, LabelAlign.LEFT)); |
FieldSet fieldSetAdresse = new FieldSet(); |
fieldSetAdresse.setHeading("Adresse"); |
fieldSetAdresse.setCollapsible(true); |
fieldSetAdresse.setLayout(creerFormLayout(null, LabelAlign.LEFT)); |
adrChp = new TextArea(); |
adrChp.setTabIndex(tabIndex++); |
adrChp.setFieldLabel("Adresse"); |
fieldSetAdresse.add(adrChp, new FormData(550, 0)); |
cpChp = new TextField<String>(); |
cpChp.setTabIndex(tabIndex++); |
cpChp.setFieldLabel("Code postal"); |
gaucheFdAdresse.add(cpChp, new FormData("95%")); |
villeChp = new TextField<String>(); |
villeChp.setTabIndex(tabIndex++); |
villeChp.setFieldLabel("Ville"); |
gaucheFdAdresse.add(villeChp, new FormData("95%")); |
magazinPays = new ListStore<Valeur>(); |
comboPays = new ComboBox<Valeur>(); |
comboPays.setTabIndex(tabIndex++); |
comboPays.setFieldLabel("Pays"); |
comboPays.setEmptyText("Sélectionner un pays..."); |
comboPays.setEditable(true); |
comboPays.setLabelSeparator(""); |
comboPays.setDisplayField("nom"); |
comboPays.setTemplate(getTemplatePays()); |
comboPays.setTypeAhead(true); |
comboPays.setTriggerAction(TriggerAction.ALL); |
comboPays.setStore(magazinPays); |
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() { |
public void selectionChanged(SelectionChangedEvent se) { |
// Rafraichir avec le pays sélectionné |
obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString()); |
} |
}; |
comboPays.addSelectionChangedListener(selectionChange); |
droiteFdAdresse.add(comboPays, new FormData("95%")); |
mediateur.obtenirListeValeurEtRafraichir(this, "pays"); |
magazinRegion = new ListStore<Valeur>(); |
comboRegion = new ComboBox<Valeur>(); |
comboRegion.setTabIndex(tabIndex++); |
comboRegion.setFieldLabel("Région"); |
comboRegion.setEmptyText("Sélectionner une région..."); |
comboRegion.setDisplayField("nom"); |
comboRegion.setTypeAhead(true); |
comboRegion.setTriggerAction(TriggerAction.ALL); |
comboRegion.setStore(magazinRegion); |
droiteFdAdresse.add(comboRegion, new FormData("95%")); |
principalFdAdresse.add(gaucheFdAdresse, new ColumnData(.5)); |
principalFdAdresse.add(droiteFdAdresse, new ColumnData(.5)); |
fieldSetAdresse.add(principalFdAdresse); |
identificationOnglet.add(fieldSetAdresse); |
//+-----------------------------------------------------------------------------------------------------------+ |
// Fieldset TÉLÉPHONE et EMAIL |
LayoutContainer principalFdTelMail = new LayoutContainer(); |
principalFdTelMail.setLayout(new ColumnLayout()); |
principalFdTelMail.setSize(700, -1); |
LayoutContainer gaucheFdTelMail = new LayoutContainer(); |
gaucheFdTelMail.setLayout(creerFormLayout(60, LabelAlign.LEFT)); |
LayoutContainer droiteFdTelMail = new LayoutContainer(); |
droiteFdTelMail.setLayout(creerFormLayout(60, LabelAlign.LEFT)); |
FieldSet fieldSetTelMail = new FieldSet(); |
fieldSetTelMail.setHeading("Communication"); |
fieldSetTelMail.setCollapsible(true); |
fieldSetTelMail.setLayout(creerFormLayout(null, LabelAlign.LEFT)); |
telChp = new TextField<String>(); |
telChp.setTabIndex(tabIndex++); |
telChp.setFieldLabel("Téléphone fixe"); |
gaucheFdTelMail.add(telChp, new FormData("95%")); |
faxChp = new TextField<String>(); |
faxChp.setTabIndex(tabIndex++); |
faxChp.setFieldLabel("Fax"); |
droiteFdTelMail.add(faxChp, new FormData("95%")); |
emailChp = new TextField<String>(); |
emailChp.setTabIndex(tabIndex++); |
emailChp.setFieldLabel("Courriel"); |
emailChp.setToolTip("Saisir le courriel de l'organisation, pas de courriel individuel. Ex. : accueil@organisation.org"); |
gaucheFdTelMail.add(emailChp, new FormData("95%")); |
urlChp = new TextField<String>(); |
urlChp.setTabIndex(tabIndex++); |
urlChp.setFieldLabel("Site web"); |
droiteFdTelMail.add(urlChp, new FormData("95%")); |
principalFdTelMail.add(gaucheFdTelMail, new ColumnData(.5)); |
principalFdTelMail.add(droiteFdTelMail, new ColumnData(.5)); |
fieldSetTelMail.add(principalFdTelMail); |
identificationOnglet.add(fieldSetTelMail); |
return identificationOnglet; |
} |
public void obtenirListeRegionParPays(String strPays) { |
mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays); |
} |
private void mettreAJourRegion() { |
//Met à jour la combo box en sélectionnant la valeur enregistrée pour la personne |
if (identification.get("ce_truk_region") != null && comboRegion.getStore().getCount() > 0) { |
Valeur valeurRegion = comboRegion.getStore().findModel("id_valeur", identification.get("ce_truk_region")); |
if (valeurRegion!=null) { |
comboRegion.setValue(valeurRegion); |
} else if (identification.get("ce_truk_region").toString().startsWith("AUTRE##")) { |
comboRegion.setRawValue(identification.get("ce_truk_region").toString().replaceFirst("^AUTRE##", "")); |
} |
} |
} |
private native String getTemplatePays() /*-{ |
return [ |
'<tpl for=".">', |
'<div class="x-combo-list-item">{nom} ({abreviation})</div>', |
'</tpl>' |
].join(""); |
}-*/; |
private void peuplerCasesACocher(String donnees, CheckBoxGroup groupeCac, TextField<String> champAutre) { |
String[] valeurs = donnees.split(";;"); |
for (int i = 0; i < valeurs.length; i++) { |
if (valeurs[i].startsWith("AUTRE##")) { |
champAutre.setValue(valeurs[i].replaceFirst("^AUTRE##", "")); |
} else { |
//TODO : check : List<CheckBox> cases = groupeCac.getAll(); |
List<Field<?>> cases = groupeCac.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 void peuplerBoutonsRadio(String valeur, RadioGroup groupeBr) { |
//List<Radio> boutons = groupeBr.getAll(); |
List<Field<?>> boutons = groupeBr.getAll(); |
String id = valeur+"_"+groupeBr.getName().replace("_grp", ""); |
for (int i = 0; i < boutons.size(); i++) { |
if (boutons.get(i).getId().equals(id)) { |
((Radio) boutons.get(i)).setValue(true); |
} |
} |
} |
private String creerChaineDenormalisee(List<CheckBox> liste) { |
String identifiants = ""; |
if (liste != null) { |
int taille = liste.size(); |
for (int i = 0; i < taille; i++) { |
CheckBox cac = liste.get(i); |
if (cac.isEnabled()) { |
identifiants = identifiants.concat(";;"+cac.getData("id")); |
} |
} |
identifiants.replaceFirst("^;;", ""); |
} |
return identifiants; |
} |
public void afficherChampSupplementaire(Radio radioBtn) { |
//GWT.log("Nom btn : "+radioBtn.getName()+" - Nom group : "+radioBtn.getGroup().getName(), null); |
// Valeur du bouton radio déclenchant l'affichage des composants cachés |
String valeurPourAfficher = "oui"; |
// Construction de la liste des composants à afficher/cacher |
String radioGroupeNom = radioBtn.getGroup().getName(); |
ArrayList<Object> composants = new ArrayList<Object>(); |
if (radioGroupeNom.equals("action_mark_grp")) { |
composants.add(actionTrukCp); |
} else if (radioGroupeNom.equals("future_action_mark_grp")) { |
composants.add(futureActionChp); |
} else if (radioGroupeNom.equals("sans_motif_acces_mark_grp")) { |
composants.add(sansMotifAccesChp); |
} else if (radioGroupeNom.equals("avec_motif_acces_mark_grp")) { |
composants.add(avecMotifAccesChp); |
} else if (radioGroupeNom.equals("recherche_mark_grp")) { |
composants.add(provenanceRechercheTrukCp); |
composants.add(typeRechercheTrukCp); |
} else if (radioGroupeNom.equals("formation_mark_grp")) { |
composants.add(formationChp); |
} else if (radioGroupeNom.equals("collection_commune_mark_grp")) { |
composants.add(collectionAutreTrukCp); |
} else if (radioGroupeNom.equals("restauration_mark_grp")) { |
composants.add(opRestauTrukCp); |
} else if (radioGroupeNom.equals("traitement_mark_grp")) { |
composants.add(traitementTrukCp); |
} else if (radioGroupeNom.equals("echantillon_acquisition_mark_grp")) { |
composants.add(traitementAcquisitionMarkRGrpChp); |
} else if (radioGroupeNom.equals("traitement_acquisition_mark_grp")) { |
composants.add(traitementAcquisitionMarkLabel); |
composants.add(poisonTraitementTrukCp); |
composants.add(insecteTraitementTrukCp); |
} else if (radioGroupeNom.equals("materiel_conservation_ce_grp")) { |
composants.add(autreMaterielTrukCp); |
valeurPourAfficher = "non"; |
} |
// Nous affichons/cachons les composant de la liste |
final int nbreComposants = composants.size(); |
//GWT.log("Id : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax, null); |
//Window.alert("Radio grp nom : "+radioGroupeNom+" - Id btn : "+radioBtn.getId()+" - Class : "+radioBtn.getClass().toString()+"- Taille : "+tailleMax); |
for (int i = 0; i < nbreComposants; i++) { |
// En fonction du type de bouton cliquer, on affiche ou cache les champs |
String type = radioBtn.getBoxLabel().toLowerCase(); |
//GWT.log(type, null); |
if (radioBtn.getValue() == true) { |
if (type.equals(valeurPourAfficher)) { |
((Component) composants.get(i)).show(); |
} else { |
((Component) composants.get(i)).hide(); |
} |
} |
// Si on a à faire à un ContentPanel, on l'actualise pour déclencher l'affichage |
if (composants.get(i) instanceof ContentPanel) { |
((ContentPanel) composants.get(i)).layout(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
try { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(listeValeurs); |
} else if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
rafraichirProjetListe(projets); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} catch (Exception e) { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e); |
} |
controlerFermetureApresRafraichissement(); |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
if (info.getType().equals("modif_structure")) { |
Info.display("Modification d'une institution", info.toString()); |
} else if (info.getType().equals("ajout_structure")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String structureId = (String) info.getDonnee(0); |
Info.display("Ajout d'une Institution", "L'intitution '"+structureId+"' a bien été ajoutée"); |
// Suite à la récupération de l'id de l'institution nouvellement ajoutée nous ajoutons le personnel |
mediateur.ajouterStructureAPersonne(this, structureId, personnelAjoute); |
} else { |
Info.display("Ajout d'une Institution", info.toString()); |
} |
} else if (info.getType().equals("modif_structure_a_personne")) { |
Info.display("Modification du Personnel", info.toString()); |
GWT.log("Decompte:"+decompteRafraichissementPersonnel, null); |
testerLancementRafraichirPersonnel(); |
} else if (info.getType().equals("suppression_structure_a_personne")) { |
Info.display("Suppression du Personnel", info.toString()); |
GWT.log("Decompte:"+decompteRafraichissementPersonnel, null); |
testerLancementRafraichirPersonnel(); |
} else if (info.getType().equals("ajout_structure_a_personne")) { |
Info.display("Ajout du Personnel", info.toString()); |
GWT.log("Decompte:"+decompteRafraichissementPersonnel, null); |
testerLancementRafraichirPersonnel(); |
} else if (info.getType().equals("selection_structure")) { |
Info.display("Modification d'une institution", info.toString()); |
String titre = i18nC.titreModifFormStructurePanneau(); |
if (info.getDonnee(0) != null) { |
identification = (Structure) info.getDonnee(0); |
if (onglets.getSelectedItem().equals(identificationOnglet)) { |
peuplerStructureIdentification(); |
} |
// Composition du titre |
titre += " - ID : "+identification.getId(); |
} |
if (info.getDonnee(1) != null) { |
conservation = (StructureConservation) info.getDonnee(1); |
if (onglets.getSelectedItem().equals(conservationOnglet)) { |
peuplerStructureConservation(); |
} |
} |
if (info.getDonnee(2) != null) { |
valorisation = (StructureValorisation) info.getDonnee(2); |
if (valorisation != null) { |
if (onglets.getSelectedItem().equals(valorisationOnglet)) { |
peuplerStructureValorisation(); |
} |
} |
} |
panneauFormulaire.setHeading(titre); |
} else if (info.getType().equals("liste_structure_a_personne")) { |
if (info.getDonnee(0) != null) { |
personnel = (StructureAPersonneListe) info.getDonnee(0); |
peuplerStructurePersonnel(); |
personnelOnglet.layout(); |
Info.display("Chargement du Personnel", "ok"); |
// Remise à zéro des modification dans la liste du personnel |
personnelModifie = new StructureAPersonneListe(); |
personnelAjoute = new StructureAPersonneListe(); |
personnelSupprime = new StructureAPersonneListe(); |
} |
} else if (info.getType().equals("liste_personne")) { |
if (info.getDonnee(0) != null) { |
PersonneListe personnes = (PersonneListe) info.getDonnee(0); |
List<Personne> liste = personnes.toList(); |
personneExistanteMagazin.removeAll(); |
personneExistanteMagazin.add(liste); |
personneExistanteCombo.setStore(personneExistanteMagazin); |
personneExistanteCombo.expand(); |
} |
} |
} |
public void rafraichirValeurListe(ValeurListe listeValeurs) { |
List<Valeur> liste = listeValeurs.toList(); |
// Test pour savoir si la liste contient des éléments |
if (liste.size() > 0) { |
if (listeValeurs.getId().equals(config.getListeId("stpr"))) { |
magazinLstpr.removeAll(); |
magazinLstpr.add(liste); |
comboLstpr.setStore(magazinLstpr); |
} |
if (listeValeurs.getId().equals(config.getListeId("stpu"))) { |
magazinLstpu.removeAll(); |
magazinLstpu.add(liste); |
comboLstpu.setStore(magazinLstpu); |
} |
if (listeValeurs.getId().equals(config.getListeId("statut"))) { |
magazinLiStatut.removeAll(); |
magazinLiStatut.add(liste); |
comboLiStatut.setStore(magazinLiStatut); |
} |
if (listeValeurs.getId().equals(config.getListeId("fonction"))) { |
// FIXME : le store ne contient pas tout le temps les données, chose étrange. |
// On stocke donc les données dans une variables de la classe pour recharger le store si besoin. |
fonctionsListe = liste; |
fonctionsMagazin.removeAll(); |
fonctionsMagazin.add(liste); |
fonctionsCombo.setStore(fonctionsMagazin); |
} |
if (listeValeurs.getId().equals(config.getListeId("pays"))) { |
magazinPays.removeAll(); |
magazinPays.add(liste); |
comboPays.setStore(magazinPays); |
} |
if (listeValeurs.getId().equals(config.getListeId("region"))) { |
magazinRegion.removeAll(); |
magazinRegion.add(liste); |
comboRegion.setStore(magazinRegion); |
mettreAJourRegion(); |
} |
if (listeValeurs.getId().equals(config.getListeId("localStockage"))) { |
localStockageAutreChp = new TextField<String>(); |
creerChoixMultipleCac(localStockageTrukCp, localStockageTrukCacGrpChp, listeValeurs, localStockageAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("meubleStockage"))) { |
meubleStockageAutreChp = new TextField<String>(); |
creerChoixMultipleCac(meubleStockageTrukCp, meubleStockageTrukCacGrpChp, listeValeurs, meubleStockageAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("parametreStockage"))) { |
parametreStockageAutreChp = new TextField<String>(); |
creerChoixMultipleCac(parametreStockageTrukCp, parametreStockageTrukCacGrpChp, listeValeurs, parametreStockageAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("autreCollection"))) { |
if (collectionAutreTrukCp != null && collectionAutreTrukCp.getItemByItemId("collectionAutreTrukCacGrpChp") == null) { |
collectionAutreTrukCacGrpChp.setId("collectionAutreTrukCacGrpChp"); |
collectionAutreAutreChp = new TextField<String>(); |
creerChoixMultipleCac(collectionAutreTrukCp, collectionAutreTrukCacGrpChp, listeValeurs, collectionAutreAutreChp); |
} |
if (autreCollectionTrukCp != null && autreCollectionTrukCp.getItemByItemId("autreCollectionTrukCacGrpChp") == null) { |
autreCollectionTrukCacGrpChp.setId("autreCollectionTrukCacGrpChp"); |
autreCollectionAutreChp = new TextField<String>(); |
creerChoixMultipleCac(autreCollectionTrukCp, autreCollectionTrukCacGrpChp, listeValeurs, autreCollectionAutreChp); |
} |
} |
if (listeValeurs.getId().equals(config.getListeId("opRestau"))) { |
opRestauAutreChp = new TextField<String>(); |
creerChoixMultipleCac(opRestauTrukCp, opRestauTrukCacGrpChp, listeValeurs, opRestauAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("onep"))) { |
creerChoixUniqueBoutonRadio(materielConservationCeRGrpChp, listeValeurs); |
materielConservationCp.add(materielConservationCeRGrpChp); |
materielConservationCp.layout(); |
} |
if (listeValeurs.getId().equals(config.getListeId("autreMateriel"))) { |
autreMaterielAutreChp = new TextField<String>(); |
creerChoixMultipleCac(autreMaterielTrukCp, autreMaterielTrukCacGrpChp, listeValeurs, autreMaterielAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("poisonTraitement"))) { |
poisonTraitementAutreChp = new TextField<String>(); |
creerChoixMultipleCac(poisonTraitementTrukCp, poisonTraitementTrukCacGrpChp, listeValeurs, poisonTraitementAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("insecteTraitement"))) { |
if (traitementTrukCp != null && traitementTrukCp.getItemByItemId("traitementTrukCacGrpChp") == null) { |
traitementTrukCacGrpChp.setId("traitementTrukCacGrpChp"); |
traitementAutreChp = new TextField<String>(); |
creerChoixMultipleCac(traitementTrukCp, traitementTrukCacGrpChp, listeValeurs, traitementAutreChp); |
} |
if (insecteTraitementTrukCp != null && insecteTraitementTrukCp.getItemByItemId("insecteTraitementTrukCacGrpChp") == null) { |
insecteTraitementTrukCacGrpChp.setId("insecteTraitementTrukCacGrpChp"); |
insecteTraitementAutreChp = new TextField<String>(); |
creerChoixMultipleCac(insecteTraitementTrukCp, insecteTraitementTrukCacGrpChp, listeValeurs, insecteTraitementAutreChp); |
} |
} |
if (listeValeurs.getId().equals(config.getListeId("actionValorisation"))) { |
actionAutreChp = new TextField<String>(); |
creerChoixMultipleCac(actionTrukCp, actionTrukCacGrpChp, listeValeurs, actionAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("continentEtFr"))) { |
provenanceRechercheAutreChp = new TextField<String>(); |
creerChoixMultipleCac(provenanceRechercheTrukCp, provenanceRechercheTrukCacGrpChp, listeValeurs, provenanceRechercheAutreChp); |
} |
if (listeValeurs.getId().equals(config.getListeId("typeRecherche"))) { |
typeRechercheAutreChp = new TextField<String>(); |
creerChoixMultipleCac(typeRechercheTrukCp, typeRechercheTrukCacGrpChp, listeValeurs, typeRechercheAutreChp); |
} |
//GWT.log("La liste #"+listeValeurs.getId()+" a été reçue!", null); |
} else { |
GWT.log("La liste #"+listeValeurs.getId()+" ne contient aucune valeurs!", null); |
} |
} |
private void rafraichirProjetListe(ProjetListe projets) { |
List<Projet> liste = projets.toList(); |
projetsMagazin.removeAll(); |
projetsMagazin.add(liste); |
projetsCombo.setStore(projetsMagazin); |
} |
private void testerLancementRafraichirPersonnel() { |
decompteRafraichissementPersonnel--; |
if (decompteRafraichissementPersonnel == 0) { |
// Nous rechargeons la liste du Personnel |
rafraichirPersonnel(); |
} |
} |
private void rafraichirPersonnel() { |
decompteRafraichissementPersonnel = 0; |
if (mode.equals(MODE_MODIFIER)) { |
initialiserGrillePersonnelEnModification(); |
} else if (mode.equals(MODE_AJOUTER)) { |
initialiserGrillePersonnelEnAjout(); |
} |
} |
private void rafraichirPersonneExistante(String nom) { |
mediateur.selectionnerPersonneParNomComplet(this, null, nom+"%"); |
} |
private void ajouterMembreAGrillePersonnel(StructureAPersonne personnel) { |
grillePersonnel.stopEditing(); |
personnelGrilleMagazin.insert(personnel, 0); |
grillePersonnel.startEditing(0, 0); |
} |
private void initialiserGrillePersonnelEnAjout() { |
personnelGrilleMagazin.removeAll(); |
StructureAPersonne conservateurDesCollections = new StructureAPersonne(StructureAPersonne.FONCTION_CONSERVATEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(conservateurDesCollections); |
StructureAPersonne directeurDuPersonnel = new StructureAPersonne(StructureAPersonne.FONCTION_DIRECTEUR, StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(directeurDuPersonnel); |
personnelOnglet.layout(); |
} |
private void initialiserGrillePersonnelEnModification() { |
mediateur.selectionnerStructureAPersonne(this, identification.getId(), StructureAPersonne.ROLE_EQUIPE); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureVue.java |
---|
New file |
0,0 → 1,56 |
package org.tela_botanica.client.vues.structure; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
import com.google.gwt.core.client.GWT; |
public class StructureVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private StructureListeVue panneauInstitutionListe = null; |
private StructureDetailVue panneauInstitutionDetail = null; |
public StructureVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
panneauInstitutionListe = new StructureListeVue(mediateur); |
add(panneauInstitutionListe, new BorderLayoutData(LayoutRegion.CENTER)); |
panneauInstitutionDetail = new StructureDetailVue(mediateur); |
BorderLayoutData dispositionSud = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
dispositionSud.setSplit(true); |
dispositionSud.setMargins(new Margins(5, 0, 0, 0)); |
add(panneauInstitutionDetail, dispositionSud); |
} |
public void rafraichir(Object nouvellesDonnees) { |
// Nous passons l'objet aux méthodes rafraichir des panneaux composant le panneau principal Structure |
if (nouvellesDonnees instanceof Structure) { |
panneauInstitutionDetail.rafraichir(nouvellesDonnees); |
} else if (nouvellesDonnees instanceof StructureListe) { |
panneauInstitutionListe.rafraichir(nouvellesDonnees); |
mediateur.desactiverChargement(); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("liste_structure_a_personne")) { |
panneauInstitutionDetail.rafraichir(nouvellesDonnees); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/structure/StructureListeVue.java |
---|
New file |
0,0 → 1,200 |
package org.tela_botanica.client.vues.structure; |
import java.util.ArrayList; |
import java.util.List; |
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.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.user.client.Window; |
public class StructureListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Grid<Structure> grille = null; |
private ListStore<Structure> store = null; |
private Button modifier; |
private Button supprimer; |
private Button ajouter; |
private BarrePaginationVue pagination = null; |
public StructureListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = mediateur.i18nC; |
setHeading(i18nC.titreStructureListe()); |
setLayout(new FitLayout()); |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicAjouterStructure(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicModifierStructure(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
clicSupprimerStructure(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(new ColumnConfig("ville", "Ville", 150)); |
colonnes.add(new ColumnConfig("nom", "Nom", 450)); |
ColumnModel modeleDeColonne = new ColumnModel(colonnes); |
GridSelectionModel<Structure> modeleDeSelection = new GridSelectionModel<Structure>(); |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Structure>() { |
public void selectionChanged(SelectionChangedEvent<Structure> event) { |
Structure structureSelectionnee = (Structure) event.getSelectedItem(); |
clicListe(structureSelectionnee); |
} |
}); |
store = new ListStore<Structure>(); |
store.sort("ville", SortDir.ASC); |
grille = new Grid<Structure>(store, modeleDeColonne); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("nom"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new StructureListe(), mediateur); |
setBottomComponent(pagination); |
} |
private void clicListe(Structure structure) { |
if (structure != null && store.getCount() > 0) { |
mediateur.clicListeStructure(structure); |
} |
} |
private void clicSupprimerStructure(List<Structure> structuresASupprimer) { |
mediateur.clicSupprimerStructure(this, structuresASupprimer); |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
if (nbreElementDuMagazin == 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof StructureListe) { |
StructureListe structures = (StructureListe) nouvellesDonnees; |
pagination.setlistePaginable(structures); |
pagination.rafraichir(structures.getPageTable()); |
if (structures != null) { |
List<Structure> liste = structures.toList(); |
store.removeAll(); |
store.add(liste); |
gererEtatActivationBouton(); |
mediateur.actualiserPanneauCentral(); |
grille.fireEvent(Events.ViewReady); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("suppression_structure")) { |
// Affichage d'un message d'information |
Info.display(i18nC.suppressionStructure(), info.toString().replaceAll("\n", "<br />")); |
List<Structure> selectionStructure = grille.getSelectionModel().getSelectedItems(); |
if (info.toString().replaceAll("\n", "").equals("OK")) { |
mediateur.supprimerStructureAPersonne(this, selectionStructure); |
} |
// Suppression des structures sélectionnées de la grille |
final int taille = selectionStructure.size(); |
for (int i = 0; i < taille; i++) { |
store.remove(selectionStructure.get(i)); |
} |
gererEtatActivationBouton(); |
} else if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getType().equals("suppression_structure_a_personne")) { |
// Affichage d'un message d'information |
Info.display(i18nC.suppressionStructureAPersonne(), info.toString().replaceAll("\n", "<br />")); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
layout(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/DetailVue.java |
---|
New file |
0,0 → 1,303 |
package org.tela_botanica.client.vues; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.Iterator; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.configuration.Configuration; |
import org.tela_botanica.client.i18n.Constantes; |
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.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
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.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.HtmlContainer; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public abstract class DetailVue extends LayoutContainer implements Rafraichissable { |
protected Mediateur mediateur = null; |
protected Constantes i18nC = null; |
protected HashMap<String, Valeur> ontologie = null; |
protected boolean ontologieChargementOk = false; |
private HashMap<Integer, String> ontologiesEnAttenteDeReception = null; |
protected ProjetListe projets = null; |
protected boolean projetsChargementOk = false; |
protected String sautLigneTpl = null; |
public DetailVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
initialiserSautLigneTpl(); |
ontologie = new HashMap<String, Valeur>(); |
ontologieChargementOk = false; |
ontologiesEnAttenteDeReception = new HashMap<Integer, String>(); |
chargerProjets(); |
setLayout(new FitLayout()); |
setBorders(false); |
setScrollMode(Scroll.AUTO); |
} |
private void initialiserSautLigneTpl() { |
sautLigneTpl = "<br />\n"; |
} |
private void chargerProjets() { |
mediateur.selectionnerProjet(this, null); |
} |
protected String construireTxtProjet(String idProjet) { |
String chaineARetourner = idProjet; |
if (projets != null) { |
Projet projet = projets.get(idProjet); |
if (projet != null) { |
String nomDuProjet = projet.getNom(); |
if (!nomDuProjet.equals("")) { |
chaineARetourner = nomDuProjet; |
} |
} |
} |
return chaineARetourner; |
} |
protected String construireTxtTruck(String chaineAAnalyser) { |
ArrayList<String> termes = new ArrayList<String>(); |
if ((chaineAAnalyser != null) && (!chaineAAnalyser.trim().equals(""))) { |
String[] valeurs = chaineAAnalyser.split(aDonnee.SEPARATEUR_VALEURS); |
int nbreValeurs = valeurs.length; |
if (nbreValeurs > 0) { |
for (int i = 0; i < nbreValeurs; i++) { |
String valeur = valeurs[i]; |
String valeurFormatee = formaterValeurTruck(valeur); |
termes.add(valeurFormatee); |
} |
} |
} |
String chaineARetourner = formaterTableauDeTxt(termes); |
return chaineARetourner; |
} |
private String formaterValeurTruck(String valeur) { |
String chaineARetourner = ""; |
if (valeur.matches("^[^#]+##[^$]+$")) { |
String[] cleValeur = valeur.split(aDonnee.SEPARATEUR_TYPE_VALEUR); |
chaineARetourner = (UtilString.isEmpty(cleValeur[1]) || cleValeur[1].equals("null") ? aDonnee.VALEUR_NULL : cleValeur[1]) +" "+formaterParenthese(cleValeur[0]); |
} else if (!valeur.equals("")) { |
chaineARetourner = valeur; |
} else { |
GWT.log("Valeur truck posant problème :"+valeur, null); |
} |
return chaineARetourner; |
} |
protected String formaterParenthese(String chaineAAfficher) { |
if (!chaineAAfficher.equals("")) { |
chaineAAfficher = "("+chaineAAfficher+")"; |
} |
return chaineAAfficher; |
} |
protected String formaterTableauDeTxt(ArrayList<String> tableauDeTxt) { |
String chaineAAfficher = ""; |
int tailleDuTableau = tableauDeTxt.size(); |
if (tailleDuTableau > 0) { |
int indexAvtDernier = tailleDuTableau - 1; |
for (int i = 0; i < tailleDuTableau; i++) { |
String mot = tableauDeTxt.get(i); |
if (i != indexAvtDernier) { |
chaineAAfficher += mot+", "; |
} else { |
chaineAAfficher += nettoyerPointFinal(mot)+"."; |
} |
} |
} |
return UtilString.ucFirst(chaineAAfficher); |
} |
protected String nettoyerPointFinal(String mot) { |
mot = mot.replaceAll("[.]$", ""); |
return mot; |
} |
protected String formaterContenu(String template, Params parametres) { |
String cHtml = Format.substitute(template, parametres); |
Params cssParams = new Params(); |
cssParams.set("css_lien_ext", ComposantClass.LIEN_EXTERNE); |
cssParams.set("css_corps", ComposantClass.DETAIL_CORPS_CONTENU); |
cssParams.set("css_label", ComposantClass.LABEL); |
cssParams.set("css_indentation", ComposantClass.INDENTATION); |
cssParams.set("css_fieldset", ComposantClass.FIELDSET); |
cssParams.set("css_clear", ComposantClass.CLEAR); |
cHtml = Format.substitute(cHtml, cssParams); |
return cHtml; |
} |
protected void afficherOnglet(String template, Params parametres, TabItem onglet) { |
String cHtml = formaterContenu(template, parametres); |
HtmlContainer corpsConteneurDuHtml = new HtmlContainer(cHtml); |
onglet.removeAll(); |
onglet.add(corpsConteneurDuHtml); |
} |
protected String formaterAutre(String chaineAAfficher) { |
if (!chaineAAfficher.equals("")) { |
chaineAAfficher = " ["+i18nC.autres()+" : "+chaineAAfficher+"]"; |
} |
return chaineAAfficher; |
} |
protected String formaterOuiNon(String chaineAFormater) { |
String txtARetourner = ""; |
if (chaineAFormater.equals("0")) { |
txtARetourner = i18nC.non(); |
} else if (chaineAFormater.equals("1")) { |
txtARetourner = i18nC.oui(); |
} |
return txtARetourner; |
} |
protected String formaterSautDeLigne(String chaineAFormater) { |
String txtARetourner = chaineAFormater.replaceAll("\n", sautLigneTpl); |
return txtARetourner; |
} |
protected void lancerChargementListesValeurs(String[] listesCodes) { |
Configuration configuration = (Configuration) Registry.get(RegistreId.CONFIG); |
for (int i = 0; i < listesCodes.length ; i++) { |
String code = listesCodes[i]; |
ontologiesEnAttenteDeReception.put(configuration.getListeId(code), code); |
mediateur.obtenirListeValeurEtRafraichir(this, code); |
} |
} |
protected void receptionerListeValeurs(ValeurListe listeValeursReceptionnee) { |
mettreAJourOntologieEnAttenteDeReception(listeValeursReceptionnee); |
ajouterListeValeursAOntologie(listeValeursReceptionnee); |
} |
protected void mettreAJourOntologieEnAttenteDeReception(ValeurListe listeValeursReceptionnee) { |
ontologiesEnAttenteDeReception.remove(listeValeursReceptionnee.getId()); |
if (ontologiesEnAttenteDeReception.size() == 0) { |
ontologieChargementOk = true; |
} |
} |
protected void ajouterListeValeursAOntologie(ValeurListe listeValeursReceptionnee) { |
Iterator<String> it = listeValeursReceptionnee.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
Valeur valeur = listeValeursReceptionnee.get(cle); |
if (valeur != null) { |
ontologie.put(cle, valeur); |
} |
} |
} |
public String construireTxtListeOntologie(String chaineAAnalyser) { |
return construireTxtListeOntologie(chaineAAnalyser, true, true, false); |
} |
public String construireTxtListeOntologie(String chaineAAnalyser, boolean valeurEstOntologie, boolean typeEstOntologie, boolean donneeEstOntologie) { |
ArrayList<String> termes = new ArrayList<String>(); |
ArrayList<String> autres = new ArrayList<String>(); |
chaineAAnalyser = chaineAAnalyser.trim(); |
if (!UtilString.isEmpty(chaineAAnalyser)) { |
String[] valeurs = chaineAAnalyser.split(aDonnee.SEPARATEUR_VALEURS); |
int nbreValeurs = valeurs.length; |
if (nbreValeurs > 0) { |
for (int i = 0; i < nbreValeurs; i++) { |
String valeur = valeurs[i]; |
// VALEUR SANS TYPE |
// La valeur sans type est une entrée de l'ontologie |
if (valeurEstOntologie && valeur.matches("^[0-9]+$")) { |
if (valeur.equals("0")) { |
valeur = ""; |
} else if (ontologie != null) { |
Valeur valeurOntologie = ontologie.get(valeur); |
if (valeurOntologie != null) { |
valeur = valeurOntologie.getNom(); |
} |
} |
} |
// VALEUR AVEC TYPE |
// Type : AUTRE |
String valeurTypeAutre = aDonnee.TYPE_AUTRE+aDonnee.SEPARATEUR_TYPE_VALEUR; |
if (valeur.matches("^"+valeurTypeAutre+".+$")) { |
String txtAutre = valeur.replaceFirst("^"+valeurTypeAutre, ""); |
if (!txtAutre.equals("")) { |
autres.add(txtAutre); |
} |
valeur = ""; |
} |
// Type correspondant à une entrée de l'ontologie |
if (typeEstOntologie) { |
String valeurTypeOntologie = "[0-9]+"+aDonnee.SEPARATEUR_TYPE_VALEUR; |
if (valeur.matches("^"+valeurTypeOntologie+".+$")) { |
String type = valeur.substring(0, valeur.indexOf(aDonnee.SEPARATEUR_TYPE_VALEUR)); |
if (ontologie != null && ontologie.get(type) != null) { |
Valeur valeurOntologie = ontologie.get(type); |
valeur = valeur.replaceFirst("^"+type, valeurOntologie.getNom()+": "); |
} |
} |
} |
// Donnée correspondant à une entrée de l'ontologie |
if (donneeEstOntologie) { |
String donneeOntologie = aDonnee.SEPARATEUR_TYPE_VALEUR+"[0-9]+"; |
if (valeur.matches("^.+"+donneeOntologie+"$")) { |
String donnee = valeur.substring(valeur.indexOf(aDonnee.SEPARATEUR_TYPE_VALEUR), valeur.length()); |
donnee = donnee.replaceFirst("^"+aDonnee.SEPARATEUR_TYPE_VALEUR, ""); |
if (ontologie != null && ontologie.get(donnee) != null) { |
Valeur valeurOntologie = ontologie.get(donnee); |
valeur = valeur.replaceFirst(donnee+"$", valeurOntologie.getNom()); |
} |
} |
} |
// Nettoyage final |
valeur = valeur.replaceFirst(aDonnee.SEPARATEUR_TYPE_VALEUR, ""); |
if (!UtilString.isEmpty(valeur)) { |
termes.add(valeur); |
} |
} |
} |
} |
String chaineTermes = formaterTableauDeTxt(termes); |
String chaineAutres = formaterTableauDeTxt(autres); |
String chaineARetourner = chaineTermes+formaterAutre(chaineAutres); |
return chaineARetourner; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetVue.java |
---|
New file |
0,0 → 1,71 |
package org.tela_botanica.client.vues.projet; |
import org.tela_botanica.client.Mediateur; |
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.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.util.Debug; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
import com.google.gwt.core.client.GWT; |
public class ProjetVue extends LayoutContainer implements Rafraichissable { |
private ProjetListeVue panneauProjetListe; |
private ProjetDetailVue panneauProjetDetail; |
private Mediateur mediateur = null; |
public ProjetVue(Mediateur mediateurCourant) { |
super(); |
mediateur = mediateurCourant; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
panneauProjetListe = new ProjetListeVue(mediateur); |
this.add(panneauProjetListe, new BorderLayoutData(LayoutRegion.CENTER)); |
panneauProjetDetail = new ProjetDetailVue(mediateur); |
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
southData.setSplit(true); |
southData.setMargins(new Margins(5, 0, 0, 0)); |
this.add(panneauProjetDetail, southData); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Projet) { |
panneauProjetDetail.rafraichir((Projet) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof ProjetListe) { |
panneauProjetListe.rafraichir((ProjetListe) nouvellesDonnees); |
mediateur.desactiverChargement(); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
// Affichage des éventuels messages de déboguage ou d'alerte |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log(info.getMessages().toString(), null); |
} |
// Traitement en fonction des types d'information |
if (info.getType().equals("liste_projet")) { |
GWT.log("Une liste de projets a été reçue", null); |
panneauProjetListe.rafraichir((ProjetListe) info.getDonnee(0)); |
} else { |
panneauProjetListe.rafraichir(info); |
} |
} else if (nouvellesDonnees instanceof ValeurListe) { |
panneauProjetDetail.rafraichir(nouvellesDonnees); |
} else { |
if (nouvellesDonnees != null) { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
layout(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetListeVue.java |
---|
New file |
0,0 → 1,225 |
package org.tela_botanica.client.vues.projet; |
import java.util.ArrayList; |
import java.util.Arrays; |
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.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.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class ProjetListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Grid<Projet> grille = null; |
private ListStore<Projet> store = null; |
private ColumnModel modeleDesColonnes = null; |
private BarrePaginationVue pagination = null; |
private Button ajouter; |
private Button modifier; |
private Button supprimer; |
public ProjetListeVue(Mediateur mediateurCourant) { |
super(); |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
setLayout(new FitLayout()); |
setHeading("Projets"); |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicAjouterProjet(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicModifierProjet(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicSupprimerProjet(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste |
colonnes.add(new ColumnConfig("id_projet", i18nC.id(), 20)); |
colonnes.add(new ColumnConfig("nom", i18nC.nom(), 200)); |
colonnes.add(new ColumnConfig("abreviation", i18nC.projetAbreviation(), 200)); |
colonnes.add(new ColumnConfig("resume", i18nC.projetResume(), 300)); |
colonnes.add(new ColumnConfig("url", i18nC.projetUrl(), 200)); |
colonnes.add(new ColumnConfig("mot_cles", i18nC.projetMotsCles(), 280)); |
modeleDesColonnes = new ColumnModel(colonnes); |
GridSelectionModel<Projet> modeleDeSelection = new GridSelectionModel<Projet>(); |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Projet>() { |
public void selectionChanged(SelectionChangedEvent<Projet> event) { |
Projet projet = (Projet) event.getSelectedItem(); |
clicListe(projet); |
} |
}); |
store = new ListStore<Projet>(); |
store.sort("id_projet", SortDir.ASC); |
grille = new Grid<Projet>(store, modeleDesColonnes); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("nom"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){ |
@Override |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new StructureListe(), mediateur); |
setBottomComponent(pagination); |
} |
public ListStore<Projet> getStore() { |
return store; |
} |
private void clicListe(Projet projet) { |
mediateur.clicListeProjet(projet); |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin <= 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (mediateur.getUtilisateur().isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
pagination.setlistePaginable(projets); |
pagination.rafraichir(projets.getPageTable()); |
if (projets != null) { |
List<Projet> projetsListe = projets.toList(); |
store.removeAll(); |
if (mediateur.getProjetId() != null) { |
String projetIdSelectionne = mediateur.getProjetId(); |
Iterator<Projet> it = projetsListe.iterator(); |
while (it.hasNext()) { |
Projet projetCourant = it.next(); |
if (projetCourant.getId().equals(projetIdSelectionne)) { |
store.add(projetCourant); |
} |
} |
} else { |
store.add(projetsListe); |
} |
mediateur.actualiserPanneauCentral(); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getType().equals("suppression_projet")) { |
String message = info.toString(); |
if (info.getDonnee(0) != null) { |
message = (String) info.getDonnee(0); |
} |
String idsNonSuppr = info.getDonnee(1).toString(); |
if (!UtilString.isEmpty(idsNonSuppr)) { |
message = "Les projets " + idsNonSuppr + " n'ont pas été supprimés car ils sont liés à d'autres éléments"; |
} |
Info.display(i18nC.projetTitreSuppression(), message); |
supprimerProjetsSelectionnees(Arrays.asList(idsNonSuppr.split(","))); |
gererEtatActivationBouton(); |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
layout(); |
} |
public void supprimerProjetsSelectionnees(List<String> idsNonSuppr) { |
List<Projet> selPub = grille.getSelectionModel().getSelectedItems(); |
for (Iterator<Projet> it = selPub.iterator(); it.hasNext();) { |
Projet projetCourant = it.next(); |
if (!idsNonSuppr.contains(projetCourant.getId().toString())) { |
grille.getStore().remove(projetCourant); |
} |
} |
//Mettre à jour les filtres |
mediateur.mettreFiltreAJour(grille.getStore().getModels()); |
layout(true); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetDetailVue.java |
---|
New file |
0,0 → 1,289 |
package org.tela_botanica.client.vues.projet; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.DetailVue; |
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.Html; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class ProjetDetailVue extends DetailVue implements Rafraichissable { |
private String enteteTpl = null; |
private String contenuTpl = null; |
private String indexationTpl = null; |
private ContentPanel panneauPrincipal = null; |
private Html entete = null; |
private Html contenu = null; |
private final String listeValeurIndexationDureeId = "dureesIndexation"; |
private final int listeValeurIndexationDureeInt = 1072; |
private final String listeValeurIndexationFrequenceId = "frequencesIndexation"; |
private final int listeValeurIndexationFrequenceInt = 1073; |
private final String listeLanguesId = "langues"; |
private final int listeLanguesInt = 1071; |
private Projet projet = null; |
private boolean projetChargementOk = false; |
private ValeurListe valeurListeIndexationDuree = null; |
private boolean listeIndexationDureeChargee = false; |
private ValeurListe valeurListeIndexationFrequence = null; |
private boolean listeIndexationFrequenceChargee = false; |
private ValeurListe valeurListeLangue = null; |
private boolean listeLangueChargee = false; |
public ProjetDetailVue(Mediateur mediateurCourant) { |
super(mediateurCourant); |
initialiserTousLesTpl(); |
panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(false); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
panneauPrincipal.setTopComponent(entete); |
contenu = new Html(); |
panneauPrincipal.add(contenu); |
add(panneauPrincipal); |
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId); |
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId); |
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeLanguesId); |
} |
private void initialiserTousLesTpl() { |
initialiserEnteteHtmlTpl(); |
initialiserGeneralTpl(); |
initialiserIndexationTpl(); |
} |
private void initialiserEnteteHtmlTpl() { |
enteteTpl = |
"<div id='{css_id}'>"+ |
" <h1>{projet}</h1>"+ |
" <h2>{abreviation} <span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" + |
"</div>"; |
} |
private void initialiserGeneralTpl() { |
contenuTpl = |
"<div class='{css_corps}'>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_info_generale}</h2>"+ |
" <span class='{css_label}'>{i18n_nom} :</span> {nom}<br />"+ |
" <span class='{css_label}'>{i18n_abreviation} :</span> {abreviation}<br />"+ |
" <span class='{css_label}'>{i18n_resume} :</span> {resume}<br />"+ |
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+ |
" <span class='{css_label}'>{i18n_url} :</span> <a class='{css_lien_ext}' href='{url}' onclick='window.open(this.href); return false;'>{url}</a><br />"+ |
" </div>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_complement}</h2>"+ |
" <span class='{css_label}'>{i18n_mot_cles} :</span> {mot_cles}<br />"+ |
" <span class='{css_label}'>{i18n_citation} :</span> {citation}<br />"+ |
" <span class='{css_label}'>{i18n_licence} :</span> {licence}<br />"+ |
" <span class='{css_label}'>{i18n_langue} :</span> {langue}<br />"+ |
" </div>"+ |
" <hr class='{css_clear}'/>"+ |
" <div class='{css_fieldset}'>"+ |
" <h2>{i18n_titre_indexation}</h2>"+ |
" <span class='{css_label}'>{i18n_mark_public} :</span> {mark_public}<br />"+ |
" {indexation}"+ |
" </div>"+ |
"</div>"; |
} |
private void initialiserIndexationTpl() { |
indexationTpl = |
" <span class='{css_label}'>{i18n_indexation_heure} :</span> {indexation_heure}<br />"+ |
" <span class='{css_label}'>{i18n_indexation_duree} :</span> {indexation_duree}<br />"+ |
" <span class='{css_label}'>{i18n_indexation_frequence} :</span> {indexation_frequence}<br />"; |
} |
public void afficherDetail() { |
if (projet != null) { |
afficherEntete(); |
afficherDetailProjet(); |
} |
layout(); |
} |
private void afficherEntete() { |
Params enteteParams = new Params(); |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE); |
enteteParams.set("css_meta", ComposantClass.META); |
enteteParams.set("i18n_id", i18nC.id()); |
enteteParams.set("id", projet.getId()); |
enteteParams.set("guid", getGuid()); |
enteteParams.set("projet", construireTxtProjet(projet.getId())); |
enteteParams.set("abreviation", projet.getAbreviation()); |
GWT.log("entete généré", null); |
String eHtml = Format.substitute(enteteTpl, enteteParams); |
entete.getElement().setInnerHTML(eHtml); |
} |
public String getGuid() { |
String guid = "URN:tela-botanica.org:"; |
guid += "coel"+projet.getId()+":"; |
guid += "pro"+projet.getId(); |
return guid; |
} |
public void afficherDetailProjet() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_titre_info_generale", i18nC.projetTitreInfoGenerale()); |
contenuParams.set("i18n_nom", i18nC.nom()); |
contenuParams.set("nom", projet.getNom()); |
contenuParams.set("i18n_abreviation", i18nC.projetAbreviation()); |
contenuParams.set("abreviation", projet.getAbreviation()); |
contenuParams.set("i18n_resume", i18nC.projetResume()); |
contenuParams.set("resume", projet.getResume()); |
contenuParams.set("i18n_description", i18nC.projetDescription()); |
contenuParams.set("description", projet.getDescription()); |
contenuParams.set("i18n_url", i18nC.projetUrl()); |
contenuParams.set("url", projet.getUrl()); |
contenuParams.set("i18n_titre_complement", i18nC.projetTitreComplement()); |
contenuParams.set("i18n_mot_cles", i18nC.projetMotsCles()); |
contenuParams.set("mot_cles", projet.getMotsCles()); |
contenuParams.set("i18n_citation", i18nC.projetCitation()); |
contenuParams.set("citation", projet.getCitation()); |
contenuParams.set("i18n_licence", i18nC.projetLicence()); |
contenuParams.set("licence", projet.getLicence()); |
contenuParams.set("i18n_langue", i18nC.projetLangue()); |
contenuParams.set("langue", obtenirValeurLangue(projet.getLangue())); |
contenuParams.set("i18n_titre_indexation", i18nC.projetTitreIndexation()); |
contenuParams.set("i18n_mark_public", i18nC.projetMarkPublic()); |
contenuParams.set("mark_public", obtenirValeurPublic(projet.getMarkPublic())); |
contenuParams.set("indexation", creerIndexation()); |
String gHtml = formaterContenu(contenuTpl, contenuParams); |
contenu.getElement().setInnerHTML(gHtml); |
} |
private String corrigerIndexationHeure(String heureMinuteSecondeEnBdd) { |
String heureMinute = ""; |
if (!UtilString.isEmpty(heureMinuteSecondeEnBdd)) { |
heureMinute = heureMinuteSecondeEnBdd.replaceAll(":00$", ""); |
} |
return heureMinute; |
} |
private String creerIndexation() { |
String html = ""; |
if (projet.getMarkPublic().equals("1")) { |
Params indexationParams = new Params(); |
indexationParams.set("i18n_indexation_heure", i18nC.projetIndexationHeure()); |
indexationParams.set("indexation_heure", corrigerIndexationHeure(projet.getIndexationHeure())); |
indexationParams.set("i18n_indexation_duree", i18nC.projetIndexationDuree()); |
indexationParams.set("indexation_duree", obtenirValeurIndexationDuree(projet.getIndexationDuree())); |
indexationParams.set("i18n_indexation_frequence", i18nC.projetIndexationFrequence()); |
indexationParams.set("indexation_frequence", obtenirValeurIndexationFrequence(projet.getIndexationFreq())); |
html = Format.substitute(indexationTpl, indexationParams); |
} |
return html; |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Projet) { |
projet = (Projet) nouvellesDonnees; |
projetChargementOk = true; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
projets = (ProjetListe) nouvellesDonnees; |
projetsChargementOk = true; |
} else if(nouvellesDonnees instanceof ValeurListe) { |
ValeurListe nValeurListe = (ValeurListe)nouvellesDonnees; |
if (nValeurListe.getId() == listeValeurIndexationDureeInt) { |
valeurListeIndexationDuree = (ValeurListe)nouvellesDonnees; |
listeIndexationDureeChargee = true; |
} |
if (nValeurListe.getId() == listeValeurIndexationFrequenceInt) { |
valeurListeIndexationFrequence = (ValeurListe)nouvellesDonnees; |
listeIndexationFrequenceChargee = true; |
} |
if (nValeurListe.getId() == listeLanguesInt) { |
valeurListeLangue = (ValeurListe)nouvellesDonnees; |
listeLangueChargee = true; |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (avoirDonneesChargees()) { |
afficherDetail(); |
} |
} |
private boolean avoirDonneesChargees() { |
boolean ok = false; |
if (projetsChargementOk && projetChargementOk && listeIndexationDureeChargee && listeIndexationFrequenceChargee && listeLangueChargee) { |
ok = true; |
} |
return ok; |
} |
private String obtenirValeurIndexationDuree(String id) { |
if (valeurListeIndexationDuree.get(id) != null) { |
return valeurListeIndexationDuree.get(id).getNom(); |
} |
return ""; |
} |
private String obtenirValeurIndexationFrequence(String id) { |
if (valeurListeIndexationFrequence.get(id) != null) { |
return valeurListeIndexationFrequence.get(id).getNom(); |
} |
return ""; |
} |
private String obtenirValeurLangue(String id) { |
if (valeurListeLangue.get(id) != null) { |
return valeurListeLangue.get(id).getNom(); |
} |
return ""; |
} |
private String obtenirValeurPublic(String ouiNon) { |
if (ouiNon.equals("1")) { |
return i18nC.oui(); |
} |
return i18nC.non(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetForm.java |
---|
New file |
0,0 → 1,448 |
package org.tela_botanica.client.vues.projet; |
import java.util.ArrayList; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilArray; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
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.Info; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.form.CheckBox; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
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; |
public class ProjetForm extends Formulaire implements Rafraichissable { |
private Projet projet; |
private String listeValeurIndexationDureeId = "dureesIndexation"; |
private String listeValeurIndexationFrequenceId = "frequencesIndexation"; |
private String listeLanguesId = "langues"; |
private FieldSet generalitesFieldset = null; |
private TextField<String> nomChp = null; |
private TextField<String> abreviationChp = null; |
private TextArea descriptionChp = null; |
private TextArea resumeChp = null; |
private TextField<String> urlChp = null; |
private FieldSet complementFieldset = null; |
private TextField<String> motsClesChp = null; |
private TextField<String> citationChp = null; |
private TextField<String> licenceChp = null; |
private ChampComboBoxListeValeurs langueChp = null; |
private CheckBox markPublicChp = null; |
private FieldSet indexationFieldset = null; |
private TextField<String> indexationHeureChp = null; |
private ChampComboBoxListeValeurs indexationDureeChp = null; |
private ChampComboBoxListeValeurs indexationFrequenceChp = null; |
private boolean formulaireValideOk = false; |
private boolean projetValideOk = false; |
private Rafraichissable vueExterneARafraichirApresValidation = null; |
public ProjetForm(Mediateur mediateurCourrant, String projetId) { |
initialiserProjetForm(mediateurCourrant, projetId); |
} |
public ProjetForm(Mediateur mediateurCourrant, String projetId, Rafraichissable vueARafraichirApresValidation) { |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation; |
initialiserProjetForm(mediateurCourrant, projetId); |
} |
private void initialiserProjetForm(Mediateur mediateurCourant, String projetId) { |
projet = new Projet(); |
projet.setId(projetId); |
String modeDeCreation = (projet.getId().isEmpty() ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourant, modeDeCreation, MenuApplicationId.PROJET); |
panneauFormulaire.setLayout(new FlowLayout()); |
genererTitreFormulaire(); |
creerZoneGeneralites(); |
panneauFormulaire.add(generalitesFieldset); |
creerZoneComplement(); |
panneauFormulaire.add(complementFieldset); |
creerZoneIndexation(); |
panneauFormulaire.add(indexationFieldset); |
creerTabIndex(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerProjet(this, projetId); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.projetTitreFormAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.projetTitreFormModif(); |
if (projet != null) { |
titre += " - "+i18nC.id()+": "+projet.getId(); |
} |
} |
panneauFormulaire.setHeading(titre); |
} |
private void creerZoneGeneralites() { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(100); |
// Fieldset Infos Générales |
generalitesFieldset = new FieldSet(); |
generalitesFieldset.setHeading(i18nC.projetTitreInfoGenerale()); |
generalitesFieldset.setCollapsible(true); |
generalitesFieldset.setLayout(layout); |
nomChp = new TextField<String>(); |
nomChp.setName("cpu"); |
nomChp.setFieldLabel(i18nC.projetNom()); |
nomChp.addStyleName(ComposantClass.OBLIGATOIRE); |
nomChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
generalitesFieldset.add(nomChp, new FormData(450, 0)); |
abreviationChp = new TextField<String>(); |
abreviationChp.setFieldLabel(i18nC.projetAbreviation()); |
abreviationChp.addStyleName(ComposantClass.OBLIGATOIRE); |
abreviationChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
generalitesFieldset.add(abreviationChp, new FormData(450, 0)); |
descriptionChp = new TextArea(); |
descriptionChp.setFieldLabel(i18nC.projetDescription()); |
descriptionChp.addStyleName(ComposantClass.OBLIGATOIRE); |
descriptionChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
generalitesFieldset.add(descriptionChp, new FormData(450, 0)); |
resumeChp = new TextArea(); |
resumeChp.setFieldLabel(i18nC.projetResume()); |
resumeChp.addStyleName(ComposantClass.OBLIGATOIRE); |
resumeChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
generalitesFieldset.add(resumeChp, new FormData(450, 0)); |
urlChp = new TextField<String>(); |
urlChp.setFieldLabel(i18nC.projetUrl()); |
generalitesFieldset.add(urlChp, new FormData(450, 0)); |
} |
private void creerZoneComplement() { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(100); |
// Fieldset Complément |
complementFieldset = new FieldSet(); |
complementFieldset.setHeading(i18nC.projetTitreComplement()); |
complementFieldset.setCollapsible(true); |
complementFieldset.setLayout(layout); |
motsClesChp = new TextField<String>(); |
motsClesChp.setFieldLabel(i18nC.projetMotsCles()); |
complementFieldset.add(motsClesChp, new FormData(450, 0)); |
citationChp = new TextField<String>(); |
citationChp.setFieldLabel(i18nC.projetCitation()); |
complementFieldset.add(citationChp, new FormData(450, 0)); |
licenceChp = new TextField<String>(); |
licenceChp.setFieldLabel(i18nC.projetLicence()); |
complementFieldset.add(licenceChp, new FormData(450, 0)); |
langueChp = new ChampComboBoxListeValeurs(i18nC.projetLangue(), listeLanguesId); |
complementFieldset.add(langueChp, new FormData(200, 0)); |
markPublicChp = new CheckBox(); |
markPublicChp.setFieldLabel(i18nC.projetMarkPublic()); |
markPublicChp.addListener(Events.Change, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
if (markPublicChp.getValue()) { |
indexationFieldset.show(); |
} else { |
indexationFieldset.hide(); |
} |
} |
}); |
complementFieldset.add(markPublicChp); |
} |
private void creerZoneIndexation() { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(100); |
// Fieldset Indexation |
indexationFieldset = new FieldSet(); |
indexationFieldset.setHeading(i18nC.projetTitreIndexation()); |
indexationFieldset.setCollapsible(true); |
indexationFieldset.setLayout(layout); |
indexationFieldset.hide(); |
indexationFieldset.addListener(Events.Hide, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
indexationHeureChp.clear(); |
indexationFrequenceChp.clear(); |
indexationDureeChp.clear(); |
} |
}); |
indexationHeureChp = new TextField<String>(); |
indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure()); |
indexationHeureChp.setToolTip(i18nC.projetMessageHeureMinute()); |
indexationFieldset.add(indexationHeureChp, new FormData(80, 0)); |
indexationFrequenceChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationFrequence(), listeValeurIndexationFrequenceId); |
indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0)); |
indexationDureeChp = new ChampComboBoxListeValeurs(i18nC.projetIndexationDuree(), listeValeurIndexationDureeId); |
indexationFieldset.add(indexationDureeChp, new FormData(80, 0)); |
} |
private void creerTabIndex() { |
nomChp.setTabIndex(1); |
abreviationChp.setTabIndex(2); |
descriptionChp.setTabIndex(3); |
resumeChp.setTabIndex(4); |
urlChp.setTabIndex(5); |
motsClesChp.setTabIndex(6); |
citationChp.setTabIndex(7); |
licenceChp.setTabIndex(8); |
langueChp.setTabIndex(9); |
markPublicChp.setTabIndex(10); |
indexationHeureChp.setTabIndex(11); |
indexationFrequenceChp.setTabIndex(12); |
indexationDureeChp.setTabIndex(13); |
nomChp.focus(); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
if (etreValide()) { |
initialiserValidation(); |
repandreRafraichissement(); |
controlerFermetureApresRafraichissement(); |
} |
} |
private void rafraichirInformation(Information info) { |
final String type = info.getType(); |
// Gestion des problèmes |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
Debug.log("MESSAGES:\n"+info.getMessages().toString()); |
} |
// Gestion des actions |
if (type.equals("selection_projet")) { |
if (info.getDonnee(0) != null) { |
projet = (Projet) info.getDonnee(0); |
} |
peuplerFormulaire(); |
genererTitreFormulaire(); |
} |
if (type.equals("ajout_projet") || type.equals("modif_projet")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
projetValideOk = true; |
String projetId = (String) info.getDonnee(0); |
if (vueExterneARafraichirApresValidation != null) { |
projet.setId(projetId); |
} |
} |
} |
// Gestion des messages |
if (type.equals("selection_projet")) { |
Info.display(i18nC.projetTitreFormModif(), info.toString()); |
} else if (type.equals("modif_projet")) { |
Info.display(i18nC.projetTitreFormModif(), info.toString()); |
} else if (type.equals("ajout_projet")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String projetId = (String) info.getDonnee(0); |
Info.display(i18nC.projetTitreFormAjout(), "Le projet '"+projetId+"' a bien été ajouté"); |
} else { |
Info.display(i18nC.projetTitreFormAjout(), info.toString()); |
} |
} |
} |
private Boolean etreValide() { |
Boolean valide = false; |
if (formulaireValideOk && projetValideOk) { |
valide = true; |
} |
return valide; |
} |
private void initialiserValidation() { |
formulaireValideOk = false; |
projetValideOk = false; |
} |
private void repandreRafraichissement() { |
if (vueExterneARafraichirApresValidation != null) { |
String type = "projet_modifie"; |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
type = "projet_ajoute"; |
} |
Information info = new Information(type); |
info.setDonnee(0, projet); |
vueExterneARafraichirApresValidation.rafraichir(info); |
} |
} |
public boolean soumettreFormulaire() { |
formulaireValideOk = verifierFormulaire(); |
if (formulaireValideOk) { |
Projet projetCollecte = collecterProjet(); |
if (projetCollecte != null) { |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
mediateur.ajouterProjet(this, projetCollecte); |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.modifierProjet(this, projetCollecte); |
} |
} |
} |
return formulaireValideOk; |
} |
public boolean verifierFormulaire() { |
boolean valide = true; |
ArrayList<String> messages = new ArrayList<String>(); |
String titre = nomChp.getValue(); |
if (titre == null || titre.equals("")) { |
messages.add(i18nC.projetMessageNom()); |
} |
String abr = abreviationChp.getValue(); |
if (abr == null || abr.equals(i18nC.projetMessageAbreviation())) { |
messages.add(i18nC.projetMessageAbreviation()); |
} |
String desc = descriptionChp.getValue(); |
if (desc == null || desc.equals(i18nC.projetMessageDescription())) { |
messages.add(i18nC.projetDescription()); |
} |
String resume = resumeChp.getValue(); |
if (resume == null || resume.equals(i18nC.projetMessageResume())) { |
messages.add(i18nC.projetMessageResume()); |
} |
String uri = urlChp.getValue(); |
if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) { |
messages.add(i18nC.messageUrlNonValide()); |
} |
if (markPublicChp.getValue()) { |
String heure = indexationHeureChp.getValue(); |
if (!UtilString.isEmpty(heure) && !heure.matches(Pattern.heureMinute)) { |
messages.add(i18nC.projetMessageHeureMinute()); |
} |
} |
if (messages.size() != 0) { |
String[] tableauDeMessages = {}; |
tableauDeMessages = messages.toArray(tableauDeMessages); |
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null); |
valide = false; |
} |
return valide; |
} |
private void peuplerFormulaire() { |
nomChp.setValue(projet.getNom()); |
abreviationChp.setValue(projet.getAbreviation()); |
descriptionChp.setValue(projet.getDescription()); |
resumeChp.setValue(projet.getResume()); |
urlChp.setValue(projet.getUrl()); |
motsClesChp.setValue(projet.getMotsCles()); |
citationChp.setValue(projet.getCitation()); |
licenceChp.setValue(projet.getLicence()); |
langueChp.peupler(projet.getLangue()); |
if (projet.getMarkPublic().equals("1")) { |
markPublicChp.setValue(true); |
String[] heureTab = projet.getIndexationHeure().split(":"); |
if (heureTab.length > 1) { |
String heure = heureTab[0]+":"+heureTab[1]; |
if (heure.matches(Pattern.heureMinute)) { |
indexationHeureChp.setValue(heure); |
} |
} |
indexationFrequenceChp.peupler(projet.getIndexationFreq()); |
indexationDureeChp.peupler(projet.getIndexationDuree()); |
} else { |
markPublicChp.setValue(false); |
} |
doLayout(true); |
} |
private Projet collecterProjet() { |
Projet projetCollecte = (Projet) projet.cloner(new Projet()); |
projetCollecte.setNom(nomChp.getValue()); |
projetCollecte.setAbreviation(abreviationChp.getValue()); |
projetCollecte.setDescription(descriptionChp.getValue()); |
projetCollecte.setResume(resumeChp.getValue()); |
projetCollecte.setUrl(urlChp.getValue()); |
projetCollecte.setMotsCles(motsClesChp.getValue()); |
projetCollecte.setCitation(citationChp.getValue()); |
projetCollecte.setLicence(licenceChp.getValue()); |
projetCollecte.setLangue(langueChp.getValeur()); |
String markPublic = (markPublicChp.getValue()) ? "1" : "0"; |
projetCollecte.setMarkPublic(markPublic); |
projetCollecte.setIndexationHeure(indexationHeureChp.getValue()); |
projetCollecte.setIndexationFreq(indexationFrequenceChp.getValeur()); |
projetCollecte.setIndexationDuree(indexationDureeChp.getValeur()); |
Projet projetARetourner = null; |
if (!projetCollecte.comparer(projet)) { |
projetARetourner = projet = projetCollecte; |
Debug.log(projetARetourner.toString()); |
} |
return projetARetourner; |
} |
public void reinitialiserFormulaire() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.afficherFormProjet(projet.getId()); |
} else { |
mediateur.afficherFormProjet(null); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireListeVue.java |
---|
New file |
0,0 → 1,321 |
package org.tela_botanica.client.vues.commentaire; |
import java.util.ArrayList; |
import java.util.HashMap; |
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.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.MenuApplicationId; |
import org.tela_botanica.client.modeles.Utilisateur; |
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.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.commentaire.CommentaireListe; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.GroupingStore; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; |
import com.extjs.gxt.ui.client.widget.grid.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.GroupColumnData; |
import com.extjs.gxt.ui.client.widget.grid.GroupingView; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.menu.Menu; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class CommentaireListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Grid<Commentaire> grille = null; |
private GroupingStore<Commentaire> store = null; |
private ColumnModel modeleDesColonnes = null; |
private Button ajouter; |
private Button modifier; |
private Button supprimer; |
private BarrePaginationVue pagination = null; |
private CommentaireListe commentaires = null; |
protected boolean commentairesChargementOk = false; |
protected HashMap<String, Valeur> ontologie = null; |
protected boolean ontologieChargementOk = false; |
public CommentaireListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
setLayout(new FitLayout()); |
setHeading(i18nC.menuCommentaire()); |
// Gestion de l'ontologie |
ontologie = new HashMap<String, Valeur>(); |
mediateur.obtenirListeValeurEtRafraichir(this, "typeCommentaireCollection"); |
// Gestion de la barre d'outil |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicAjouterCommentaire(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicModifierCommentaire(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicSupprimerCommentaire(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
// Gestion de la grille |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste |
colonnes.add(new ColumnConfig("_collection_nom_", i18nC.commentaireCollection(), 150)); |
colonnes.add(creerColonneType()); |
colonnes.add(new ColumnConfig("_titre_", i18nC.commentaireTitre(), 150)); |
colonnes.add(new ColumnConfig("_ponderation_", i18nC.commentairePonderation(), 30)); |
colonnes.add(creerColonneAcces()); |
modeleDesColonnes = new ColumnModel(colonnes); |
GridSelectionModel<Commentaire> modeleDeSelection = new GridSelectionModel<Commentaire>(); |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Commentaire>() { |
public void selectionChanged(SelectionChangedEvent<Commentaire> event) { |
Commentaire commentaire = (Commentaire) event.getSelectedItem(); |
clicListe(commentaire); |
} |
}); |
store = new GroupingStore<Commentaire>(); |
//store.sort("cmhl_date_modification", SortDir.ASC); |
store.groupBy("_collection_nom_"); |
store.setRemoteGroup(false); |
GroupingView vueDeGroupe = new GroupingView(); |
vueDeGroupe.setShowGroupedColumn(false); |
vueDeGroupe.setForceFit(true); |
vueDeGroupe.setAutoFill(true); |
vueDeGroupe.setGroupRenderer(new GridGroupRenderer() { |
@Override |
public String render(GroupColumnData data) { |
String f = modeleDesColonnes.getColumnById(data.field).getHeader(); |
String l = data.models.size() == 1 ? i18nC.commentaireSingulier() : i18nC.commentairePluriel(); |
return f + ": " + data.group + " (" + data.models.size() + " " + l + ")"; |
} |
}); |
grille = new Grid<Commentaire>(store, modeleDesColonnes); |
grille.setView(vueDeGroupe); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("_titre_"); |
grille.setSelectionModel(modeleDeSelection); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){ |
@Override |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new StructureListe(), mediateur); |
setBottomComponent(pagination); |
} |
private ColumnConfig creerColonneType() { |
GridCellRenderer<Commentaire> typeRendu = new GridCellRenderer<Commentaire>() { |
@Override |
public String render(Commentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Commentaire> store, Grid<Commentaire> grid) { |
// FIXME : créer une classe Ontologie qui mixe le code ci-dessous et tout ce qui concerne l'ontologie dans DetailVue |
String type = ""; |
String[] valeurs = model.getCollectionACommentaire().getType().split(aDonnee.SEPARATEUR_VALEURS); |
int nbreValeurs = valeurs.length; |
int indexAvtDernier = nbreValeurs - 1; |
if (nbreValeurs > 0) { |
for (int i = 0; i < nbreValeurs; i++) { |
String valeur = valeurs[i]; |
if (valeur.matches("^[0-9]+$")) { |
if (valeur.equals("0")) { |
valeur = ""; |
} else if (ontologie != null) { |
Valeur valeurOntologie = ontologie.get(valeur); |
if (valeurOntologie != null) { |
valeur = valeurOntologie.getNom(); |
} |
} |
} |
if (i != indexAvtDernier) { |
type += valeur+", "; |
} else { |
type += valeur; |
} |
} |
} |
model.set("_type_", type); |
return type; |
} |
}; |
ColumnConfig typeColonne = new ColumnConfig("_type_", i18nC.commentaireType(), 100); |
typeColonne.setRenderer(typeRendu); |
return typeColonne; |
} |
private ColumnConfig creerColonneAcces() { |
GridCellRenderer<Commentaire> accesRendu = new GridCellRenderer<Commentaire>() { |
@Override |
public String render(Commentaire model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Commentaire> store, Grid<Commentaire> grid) { |
String acces = (model.etrePublic() ? i18nC.donneePublic() : i18nC.donneePrivee()); |
model.set("_public_", acces); |
return acces; |
} |
}; |
ColumnConfig accesColonne = new ColumnConfig("_public_", i18nC.commentairePublic(), 30); |
accesColonne.setRenderer(accesRendu); |
return accesColonne; |
} |
private void clicListe(Commentaire commentaire) { |
if (commentaire != null && store.getCount() > 0) { |
mediateur.clicListeCommentaire(commentaire); |
} |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin <= 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof CommentaireListe) { |
commentaires = (CommentaireListe) nouvellesDonnees; |
pagination.setlistePaginable(commentaires); |
pagination.rafraichir(commentaires.getPageTable()); |
commentairesChargementOk = true; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees; |
Iterator<String> it = listeValeursReceptionnee.keySet().iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
Valeur valeur = listeValeursReceptionnee.get(cle); |
if (valeur != null) { |
ontologie.put(cle, valeur); |
} |
} |
ontologieChargementOk = true; |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getType().equals("suppression_commentaire")) { |
String message = info.toString(); |
if (info.getDonnee(0) != null) { |
message = (String) info.getDonnee(0); |
} |
Info.display(i18nC.commentaireTitreSuppression(), message); |
supprimerCommentairesSelectionnees(); |
gererEtatActivationBouton(); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (etrePretAAfficherListe()) { |
chargerListe(); |
} |
layout(); |
} |
private boolean etrePretAAfficherListe() { |
boolean ok = false; |
if (commentairesChargementOk && ontologieChargementOk) { |
ok = true; |
} |
return ok; |
} |
private void chargerListe() { |
if (commentaires != null) { |
List<Commentaire> liste = commentaires.toList(); |
store.removeAll(); |
store.add(liste); |
mediateur.actualiserPanneauCentral(); |
} |
} |
private void supprimerCommentairesSelectionnees() { |
// FIXME : le code ci-dessous ne marche pas avec la GroupingView, nous utilisons le rechargement du menu à la place |
/* |
List<Commentaire> commentairesSelectionnees = grille.getSelectionModel().getSelectedItems(); |
Iterator<Commentaire> it = commentairesSelectionnees.iterator(); |
while (it.hasNext()) { |
Commentaire commentaireASupprimer = it.next(); |
Debug.log(commentaireASupprimer.getId()); |
grille.getStore().remove(commentaireASupprimer); |
} |
layout(true); |
*/ |
mediateur.clicMenu(MenuApplicationId.COMMENTAIRE); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireDetailVue.java |
---|
New file |
0,0 → 1,158 |
package org.tela_botanica.client.vues.commentaire; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.vues.DetailVue; |
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.Html; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class CommentaireDetailVue extends DetailVue implements Rafraichissable { |
private String enteteTpl = null; |
private String contenuTpl = null; |
private ContentPanel panneauPrincipal = null; |
private Html entete = null; |
private Html contenu = null; |
private Commentaire commentaire = null; |
private boolean commentaireChargementOk = false; |
public CommentaireDetailVue(Mediateur mediateurCourant) { |
super(mediateurCourant); |
initialiserTousLesTpl(); |
chargerOntologie(); |
panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(false); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
panneauPrincipal.setTopComponent(entete); |
contenu = new Html(); |
panneauPrincipal.add(contenu); |
add(panneauPrincipal); |
} |
private void initialiserTousLesTpl() { |
initialiserEnteteHtmlTpl(); |
initialiserGeneralTpl(); |
} |
private void initialiserEnteteHtmlTpl() { |
enteteTpl = |
"<div id='{css_id}'>"+ |
" <h1>{titre}</h1>"+ |
" <h2>{collection}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" + |
"</div>"; |
} |
private void initialiserGeneralTpl() { |
contenuTpl = |
"<div class='{css_corps}'>"+ |
" <span class='{css_label}'>{i18n_type} :</span> {type}<br />"+ |
" <span class='{css_label}'>{i18n_public} :</span> {public}<br />"+ |
" <span class='{css_label}'>{i18n_ponderation} :</span> {ponderation}<br />"+ |
" <span class='{css_label}'>{i18n_texte} :</span>"+ |
" {texte}"+ |
"</div>"; |
} |
private void chargerOntologie() { |
String[] listesCodes = {"typeCommentaireCollection"}; |
lancerChargementListesValeurs(listesCodes); |
} |
public void afficherDetail() { |
if (commentaire != null) { |
afficherEntete(); |
afficherDetailCommentaire(); |
} |
layout(); |
} |
private void afficherEntete() { |
Params enteteParams = new Params(); |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE); |
enteteParams.set("css_meta", ComposantClass.META); |
enteteParams.set("i18n_id", i18nC.id()); |
enteteParams.set("collection", commentaire.getCollection().getNom()); |
enteteParams.set("titre", commentaire.getTitre()); |
enteteParams.set("id", commentaire.getId()); |
enteteParams.set("guid", getGuid()); |
enteteParams.set("projet", construireTxtProjet(commentaire.getIdProjet())); |
String eHtml = Format.substitute(enteteTpl, enteteParams); |
entete.getElement().setInnerHTML(eHtml); |
} |
public String getGuid() { |
String guid = "URN:tela-botanica.org:"; |
guid += "coel"+commentaire.getIdProjet()+":"; |
guid += "com"+commentaire.getId(); |
return guid; |
} |
public void afficherDetailCommentaire() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_type", i18nC.commentaireType()); |
contenuParams.set("i18n_public", i18nC.commentairePublic()); |
contenuParams.set("i18n_ponderation", i18nC.commentairePonderation()); |
contenuParams.set("i18n_texte", i18nC.commentaireTexte()); |
String type = construireTxtListeOntologie(commentaire.getCollectionACommentaire().getType()); |
contenuParams.set("type", type); |
contenuParams.set("ponderation", commentaire.getPonderation()); |
contenuParams.set("public", (commentaire.etrePublic() ? "public" : "privé")); |
contenuParams.set("texte", commentaire.getTexte()); |
String gHtml = formaterContenu(contenuTpl, contenuParams); |
contenu.getElement().setInnerHTML(gHtml); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Commentaire) { |
commentaire = (Commentaire) nouvellesDonnees; |
commentaireChargementOk = true; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
projets = (ProjetListe) nouvellesDonnees; |
projetsChargementOk = true; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees; |
receptionerListeValeurs(listeValeursReceptionnee); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (avoirDonneesChargees()) { |
afficherDetail(); |
} |
} |
private boolean avoirDonneesChargees() { |
boolean ok = false; |
if (projetsChargementOk && commentaireChargementOk) { |
ok = true; |
} |
return ok; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireForm.java |
---|
New file |
0,0 → 1,317 |
package org.tela_botanica.client.vues.commentaire; |
import java.util.ArrayList; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.composants.ChampSliderPourcentage; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilArray; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
import com.extjs.gxt.ui.client.widget.form.CheckBox; |
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.TextArea; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
import com.extjs.gxt.ui.client.widget.form.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.FormLayout; |
public class CommentaireForm extends Formulaire implements Rafraichissable { |
private Commentaire commentaire; |
private ComboBox<Projet> projetsCombo = null; |
private TextField<String> titreChp; |
private TextArea texteChp; |
private ChampSliderPourcentage ponderationChp; |
private CheckBox publicChp; |
private static boolean formulaireValideOk = false; |
private static boolean commentaireValideOk = false; |
public CommentaireForm(Mediateur mediateurCourrant, String commentaireId) { |
initialiserCommentaireForm(mediateurCourrant, commentaireId); |
} |
public CommentaireForm(Mediateur mediateurCourrant, String commentaireId, Rafraichissable vueARafraichirApresValidation) { |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation; |
initialiserCommentaireForm(mediateurCourrant, commentaireId); |
} |
private void initialiserCommentaireForm(Mediateur mediateurCourrant, String commentaireId) { |
initialiserValidation(); |
commentaire = new Commentaire(); |
commentaire.setId(commentaireId); |
String modeDeCreation = (UtilString.isEmpty(commentaire.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COMMENTAIRE); |
panneauFormulaire.setLayout(new FormLayout()); |
genererTitreFormulaire(); |
creerChamps(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerCommentaire(this, commentaireId); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.commentaireTitreFormAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.commentaireTitreFormModif(); |
if (commentaire != null) { |
titre += " - "+i18nC.id()+": "+commentaire.getId(); |
} |
} |
panneauFormulaire.setHeading(titre); |
} |
private void creerChamps() { |
projetsCombo = new ComboBox<Projet>(); |
projetsCombo.setTabIndex(tabIndex++); |
projetsCombo.setFieldLabel(i18nC.projetChamp()); |
projetsCombo.setDisplayField("nom"); |
projetsCombo.setTriggerAction(TriggerAction.ALL); |
projetsCombo.setStore(new ListStore<Projet>()); |
projetsCombo.setEmptyText(i18nC.txtListeProjetDefaut()); |
projetsCombo.setEditable(false); |
projetsCombo.setForceSelection(true); |
projetsCombo.setAllowBlank(false); |
projetsCombo.setValidator(new Validator() { |
@Override |
public String validate(Field<?> champ, String valeurAValider) { |
String retour = null; |
if (UtilString.isEmpty(valeurAValider) |
|| projetsCombo.getStore().findModel("nom", valeurAValider) == null) { |
champ.setValue(null); |
retour = i18nC.selectionnerValeur(); |
} |
return retour; |
} |
}); |
projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
projetsCombo.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
panneauFormulaire.add(projetsCombo, new FormData(450, 0)); |
mediateur.selectionnerProjet(this, null); |
titreChp = new TextField<String>(); |
titreChp.setFieldLabel(i18nC.commentaireTitre()); |
titreChp.setAllowBlank(false); |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE); |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
titreChp.addListener(Events.Invalid, creerEcouteurChampObligatoire()); |
panneauFormulaire.add(titreChp, new FormData(450, 0)); |
texteChp = new TextArea(); |
texteChp.setFieldLabel(i18nC.commentaireTexte()); |
panneauFormulaire.add(texteChp, new FormData(450, 250)); |
ponderationChp = new ChampSliderPourcentage(i18nC.commentairePonderation()); |
panneauFormulaire.add(ponderationChp, new FormData(450, 0)); |
publicChp = new CheckBox(); |
publicChp.setFieldLabel(i18nC.donneePublic()); |
panneauFormulaire.add(publicChp, new FormData(50, 0)); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Commentaire) { |
// Si on a reçu les details d'une publication |
rafraichirCommentaire((Commentaire) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(projets, projetsCombo); |
setValeurComboProjets(); |
} else if (nouvellesDonnees instanceof Information) { |
rafraichirInformation((Information) nouvellesDonnees); |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
if (etreValide()) { |
initialiserValidation(); |
repandreRafraichissement(); |
controlerFermetureApresRafraichissement(); |
} |
} |
private void rafraichirCommentaire(Commentaire commentaireRecu) { |
commentaire = commentaireRecu; |
peuplerFormulaire(); |
genererTitreFormulaire(); |
} |
private String getValeurComboProjets() { |
String valeur = ""; |
if (projetsCombo.getValue() != null && projetsCombo.isValid()) { |
valeur = projetsCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboProjets() { |
if (projetsCombo.getStore() != null ) { |
if (mode.equals(Formulaire.MODE_MODIFIER) && commentaire != null) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", commentaire.getIdProjet())); |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", mediateur.getProjetId())); |
} |
} |
} |
private void rafraichirInformation(Information info) { |
// Gestion des messages d'erreur |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
Debug.log("MESSAGES:\n"+info.getMessages().toString()); |
} |
// Gestion des actions |
String type = info.getType(); |
if (type.equals("ajout_commentaire") || type.equals("modif_commentaire")) { |
commentaireValideOk = true; |
} |
if (info.getType().equals("ajout_commentaire")) { |
if (vueExterneARafraichirApresValidation != null) { |
String noteId = (String) info.getDonnee(0); |
commentaire.setId(noteId); |
} |
} |
// Gestion des messages |
if (info.getType().equals("modif_commentaire")) { |
Info.display("Modification d'une note", info.toString()); |
} else if (info.getType().equals("ajout_commentaire")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String noteId = (String) info.getDonnee(0); |
Info.display("Ajout d'une note", "La note '"+noteId+"' a bien été ajoutée"); |
} else { |
Info.display("Ajout d'une note", info.toString()); |
} |
} |
} |
private Boolean etreValide() { |
Boolean valide = false; |
Debug.log("formulaire"+formulaireValideOk+" - Commentaire :"+commentaireValideOk); |
if (formulaireValideOk && commentaireValideOk) { |
valide = true; |
} |
return valide; |
} |
private void initialiserValidation() { |
formulaireValideOk = false; |
commentaireValideOk = false; |
} |
private void repandreRafraichissement() { |
if (vueExterneARafraichirApresValidation != null) { |
String type = "commentaire_modifiee"; |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
type = "commentaire_ajoutee"; |
} |
Information info = new Information(type); |
info.setDonnee(0, commentaire); |
vueExterneARafraichirApresValidation.rafraichir(info); |
} |
} |
public boolean soumettreFormulaire() { |
formulaireValideOk = verifierFormulaire(); |
if (formulaireValideOk) { |
soumettreCommentaire(); |
} |
return formulaireValideOk; |
} |
private void soumettreCommentaire() { |
Commentaire commentaireCollectee = collecterCommentaire(); |
if (commentaireCollectee != null) { |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
mediateur.ajouterCommentaire(this, commentaireCollectee); |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.modifierCommentaire(this, commentaireCollectee); |
} |
} |
} |
public boolean verifierFormulaire() { |
boolean valide = true; |
ArrayList<String> messages = new ArrayList<String>(); |
String titre = titreChp.getValue(); |
if (titre == null || titre.equals("")) { |
messages.add(i18nC.commentaireMessageTitre()); |
} |
if (UtilString.isEmpty(getValeurComboProjets())) { |
String selectionDe = i18nC.articleUn()+" "+i18nC.projetSingulier(); |
String pour = i18nC.articleLa()+" "+i18nC.commentaireSingulier(); |
messages.add(i18nM.selectionObligatoire(selectionDe, pour)); |
} |
if (messages.size() != 0) { |
String[] tableauDeMessages = {}; |
tableauDeMessages = messages.toArray(tableauDeMessages); |
MessageBox.alert(i18nC.erreurSaisieTitre(), UtilArray.implode(tableauDeMessages, "<br />"), null); |
valide = false; |
} |
return valide; |
} |
private void peuplerFormulaire() { |
setValeurComboProjets(); |
titreChp.setValue(commentaire.getTitre()); |
texteChp.setValue(commentaire.getTexte()); |
ponderationChp.peupler(commentaire.getPonderation()); |
boolean acces = (commentaire.etrePublic() ? true : false); |
publicChp.setValue(acces); |
} |
private Commentaire collecterCommentaire() { |
Commentaire commentaireCollectee = (Commentaire) commentaire.cloner(new Commentaire()); |
commentaireCollectee.setIdProjet(getValeurComboProjets()); |
String titre = titreChp.getValue(); |
commentaireCollectee.setTitre(titre); |
String texte = texteChp.getValue(); |
commentaireCollectee.setTexte(texte); |
String ponderation = ponderationChp.getValeur(); |
commentaireCollectee.setPonderation(ponderation); |
String acces = (publicChp.getValue() ? "1" : "0"); |
commentaireCollectee.setPublic(acces); |
Commentaire commentaireARetourner = null; |
if (!commentaireCollectee.comparer(commentaire)) { |
commentaireARetourner = commentaire = commentaireCollectee; |
} |
return commentaireARetourner; |
} |
public void reinitialiserFormulaire() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.afficherFormPublication(commentaire.getId()); |
} else { |
mediateur.afficherFormPublication(null); |
} |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/commentaire/CommentaireVue.java |
---|
New file |
0,0 → 1,51 |
package org.tela_botanica.client.vues.commentaire; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.commentaire.Commentaire; |
import org.tela_botanica.client.modeles.commentaire.CommentaireListe; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
import com.google.gwt.core.client.GWT; |
public class CommentaireVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private CommentaireListeVue panneauListe; |
private CommentaireDetailVue panneauDetail; |
public CommentaireVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
panneauListe = new CommentaireListeVue(mediateur); |
add(panneauListe, new BorderLayoutData(LayoutRegion.CENTER)); |
panneauDetail = new CommentaireDetailVue(mediateur); |
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
southData.setSplit(true); |
southData.setMargins(new Margins(5, 0, 0, 0)); |
add(panneauDetail, southData); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Commentaire) { |
panneauDetail.rafraichir(nouvellesDonnees); |
} else if (nouvellesDonnees instanceof CommentaireListe) { |
panneauListe.rafraichir(nouvellesDonnees); |
mediateur.desactiverChargement(); |
} else if (nouvellesDonnees instanceof Information) { |
panneauListe.rafraichir(nouvellesDonnees); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/MenuVue.java |
---|
New file |
0,0 → 1,76 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.i18n.Constantes; |
import org.tela_botanica.client.modeles.Menu; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.GXT; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.TreePanelEvent; |
import com.extjs.gxt.ui.client.store.TreeStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel; |
public class MenuVue extends ContentPanel { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private TreePanel<Menu> arbreMenus; |
private TreeStore<Menu> menuStore; |
public MenuVue(Mediateur mediateurCourrant) { |
mediateur = mediateurCourrant; |
i18nC = Mediateur.i18nC; |
setHeading(i18nC.titreMenu()); |
setLayout(new FitLayout()); |
setLayoutOnChange(true); |
construireMenu(); |
afficherMenu(); |
} |
private void construireMenu() { |
menuStore = new TreeStore<Menu>(); |
Menu accueilMenu = new Menu(i18nC.menuAccueil(), MenuApplicationId.ACCUEIL); |
Menu projetMenu = new Menu(i18nC.menuProjet(), MenuApplicationId.PROJET); |
Menu menuInstitution = new Menu(i18nC.menuStructure(), MenuApplicationId.STRUCTURE); |
Menu menuCollections = new Menu(i18nC.menuCollection(), MenuApplicationId.COLLECTION); |
Menu menuPersonnes = new Menu(i18nC.menuPersonne(), MenuApplicationId.PERSONNE); |
Menu menuPublications = new Menu(i18nC.menuPublication(), MenuApplicationId.PUBLICATION); |
Menu menuCommentaires = new Menu(i18nC.menuCommentaire(), MenuApplicationId.COMMENTAIRE); |
menuStore.add(accueilMenu, false); |
menuStore.add(projetMenu, false); |
menuStore.add(menuInstitution, false); |
menuStore.add(menuCollections, false); |
menuStore.add(menuPersonnes, false); |
menuStore.add(menuPublications, false); |
menuStore.add(menuCommentaires, false); |
} |
private void afficherMenu() { |
arbreMenus = new TreePanel<Menu>(menuStore); |
arbreMenus.getStyle().setLeafIcon(GXT.IMAGES.tree_folder()); |
arbreMenus.setDisplayProperty("nom"); |
arbreMenus.setHeight("100%"); |
arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){ |
public void handleEvent(TreePanelEvent<Menu> tpe) { |
Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem(); |
mediateur.clicMenu(menuCourant.getCode()); |
} |
}); |
add(arbreMenus); |
} |
public void selectionMenu(String code) { |
arbreMenus.getSelectionModel().select(menuStore.findModel("code", code), false); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/BarrePaginationVue.java |
---|
New file |
0,0 → 1,486 |
package org.tela_botanica.client.vues; |
import java.util.Iterator; |
import java.util.LinkedList; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.i18n.Constantes; |
import org.tela_botanica.client.i18n.ErrorMessages; |
import org.tela_botanica.client.images.Images; |
import org.tela_botanica.client.interfaces.ListePaginable; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.util.UtilString; |
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.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
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.SimpleComboBox; |
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; |
import com.google.gwt.i18n.client.Dictionary; |
public class BarrePaginationVue extends ToolBar implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private ErrorMessages i18nM = null; |
public int valeur = 0; |
private ListePaginable listePaginable = null; |
private Button prevPage, suivPage, premierePage, dernierePage, rafraichir; |
private int pageCourante, nbElement = 0; |
private int taillePage = Integer.valueOf(((Dictionary) Dictionary.getDictionary("configuration")).get("nbElementsPage")); |
private int pageTotale = 1; |
private Text page, surTotalPage, afficherNbElem, nbElemParPage, intervalleElements; |
private TextField<String> champPage = new TextField<String>(); |
private SimpleComboBox selecteurTaillePage = new SimpleComboBox(); |
private Text labelFiltre; |
private TextField<String> filtre; |
private Button annulerFiltre; |
private boolean filtreActive = false; |
private String termeRecherche = ""; |
private LinkedList<Integer> intervallePages = new LinkedList<Integer>(); |
private ListStore storeIntervalle = new ListStore() ; |
private String labelElement; |
private int taillePageDefaut = 50; |
public ListePaginable getlistePaginable() { |
return listePaginable; |
} |
public void setlistePaginable(ListePaginable listePaginable) { |
this.listePaginable = listePaginable; |
} |
/*************************************************************************** |
* constructeur sans argument (privé car ne doit pas être utilisé) |
*/ |
@SuppressWarnings("unused") |
private BarrePaginationVue() { |
super(); |
} |
/** |
* constructeur avec paramètres |
* |
* @param im |
* le médiateur à associer à la barre |
*/ |
public BarrePaginationVue(ListePaginable listePaginableCourante, Mediateur mediateurCourant) { |
super(); |
listePaginable = listePaginableCourante; |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
i18nM = Mediateur.i18nM; |
intervallePages.add(10); |
intervallePages.add(20); |
intervallePages.add(50); |
intervallePages.add(100); |
intervallePages.add(200); |
premierePage = new Button(); |
premierePage.setIcon(Images.ICONES.resultsetFirst()); |
add(premierePage); |
prevPage = new Button(); |
prevPage.setIcon(Images.ICONES.resultsetPrevious()); |
add(prevPage); |
add(new SeparatorToolItem()); |
page = new Text(i18nC.page()); |
page.setStyleAttribute("padding", "0 5px 0 5px"); |
add(page); |
champPage.setValue(String.valueOf(pageCourante+1)); |
champPage.setStyleAttribute("text-align","right"); |
champPage.setWidth(30); |
add(champPage); |
surTotalPage = new Text(i18nC.sur() + " " + pageTotale); |
surTotalPage.setStyleAttribute("padding-left", "5px"); |
add(surTotalPage); |
//Séparation |
add(new SeparatorToolItem()); |
suivPage = new Button(); |
suivPage.setIcon(Images.ICONES.resultsetNext()); |
add(suivPage); |
dernierePage = new Button(); |
dernierePage.setIcon(Images.ICONES.resultsetLast()); |
add(dernierePage); |
//Séparation |
add(new SeparatorToolItem()); |
rafraichir = new Button(); |
rafraichir.setIcon(Images.ICONES.rafraichir()); |
add(rafraichir); |
//Séparation |
add(new SeparatorToolItem()); |
afficherNbElem = new Text(i18nC.afficher()); |
afficherNbElem.setStyleAttribute("padding", "0 5px 0 5px"); |
add(afficherNbElem); |
selecteurTaillePage.setWidth("40px"); |
setIntervallesPages(); |
add(selecteurTaillePage); |
labelElement = i18nC.elements(); |
nbElemParPage = new Text(labelElement+" "+i18nC.parPage()); |
nbElemParPage.setStyleAttribute("padding-left", "5px"); |
add(nbElemParPage); |
//Séparation |
add(new SeparatorToolItem()); |
labelFiltre = new Text("Recherche rapide : "); |
labelFiltre.setStyleAttribute("padding-right", "5px"); |
add(labelFiltre); |
filtre = new TextField<String>(); |
filtre.setWidth(150); |
this.add(filtre); |
annulerFiltre = new Button(); |
annulerFiltre.setIcon(Images.ICONES.annuler()); |
annulerFiltre.setVisible(false); |
add(annulerFiltre); |
add(new FillToolItem()); |
intervalleElements = new Text(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), |
pageCourante * taillePage, (pageCourante + 1) * taillePage, nbElement)); |
add(intervalleElements); |
// on ajoute les différents listeners |
ajouterListeners(); |
} |
/** |
* Texte nommant les elements pagines (Images, Observation, truc, machin etc...). |
* @param label |
*/ |
public void setLabelElement(String label) { |
this.labelElement = label; |
nbElemParPage.setText(labelElement + " par page "); |
intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), |
pageCourante * taillePage, (pageCourante + 1) * taillePage, nbElement)); |
} |
public void setTaillePageParDefaut(int taille) { |
this.taillePageDefaut = taille; |
selecteurTaillePage.setRawValue(""+taillePageDefaut); |
} |
public void setIntervallesPages() { |
if (!intervallePages.contains(taillePage)) { |
intervallePages.add(taillePage); |
} |
Iterator<Integer> itIntervallePages = intervallePages.iterator(); |
while (itIntervallePages.hasNext()) { |
selecteurTaillePage.add(itIntervallePages.next()); |
} |
selecteurTaillePage.setSimpleValue(taillePage); |
} |
/** |
* Change l'état de la barre de pagination a actif ou inactif |
* @param etat actif ou inactif |
*/ |
private void changerEtatBarre(boolean etat) { |
premierePage.setEnabled(etat); |
prevPage.setEnabled(etat); |
suivPage.setEnabled(etat); |
dernierePage.setEnabled(etat); |
champPage.setEnabled(etat); |
selecteurTaillePage.setEnabled(etat); |
page.setEnabled(etat); |
surTotalPage.setEnabled(etat); |
afficherNbElem.setEnabled(etat); |
nbElemParPage.setEnabled(etat); |
annulerFiltre.setVisible(!etat); |
} |
/** |
* ajoute les différents listeners nécessaires au bon fonctionnement des |
* éléments de la barre de pagination |
*/ |
@SuppressWarnings("unchecked") |
private void ajouterListeners() { |
premierePage.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
pageCourante = 0; |
rafraichirNumeroPage(); |
listePaginable.changerNumeroPage(pageCourante); |
} |
}); |
// boutons suivants et précédents |
prevPage.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
// si la page courante n'est pas la première |
if (pageCourante > 0) { |
// on décrémente la page courante de 1 |
pageCourante--; |
// on rafraichit l'affichage |
rafraichirNumeroPage(); |
// et on notifie le médiateur de l'évenement |
listePaginable.changerNumeroPage(pageCourante); |
} |
} |
}); |
suivPage.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
// si la page courante n'est pas la dernière |
if (pageCourante < pageTotale - 1) { |
// on incrémente la page courante de 1 |
pageCourante++; |
// on rafraichit l'affichage |
rafraichirNumeroPage(); |
// et on notifie le médiateur de l'évenement |
listePaginable.changerNumeroPage(pageCourante); |
} |
} |
}); |
dernierePage.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
pageCourante = pageTotale; |
rafraichirNumeroPage(); |
listePaginable.changerNumeroPage(pageCourante); |
} |
}); |
rafraichir.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
listePaginable.changerNumeroPage(pageCourante); |
} |
}); |
annulerFiltre.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
filtre.setValue(""); |
termeRecherche = ""; |
filtreActive = false; |
listePaginable.changerNumeroPage(pageCourante); |
labelFiltre.setStyleAttribute("font-weight", "normal"); |
changerEtatBarre(true); |
} |
}); |
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"); |
listePaginable.changerNumeroPage(pageCourante); |
changerEtatBarre(true); |
} else { |
changerEtatBarre(false); |
listePaginable.filtrerParNom(termeRecherche); |
labelFiltre.setStyleAttribute("font-weight", "bold"); |
filtreActive = true; |
} |
} |
} |
}); |
champPage.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
// on teste si la touche entrée a été pressée |
if (ce.getKeyCode() == KeyCodes.KEY_ENTER) { |
int nouvellePage = pageCourante; |
// on teste avec parseInt si la valeur entrée est un entier |
try { |
nouvellePage = Integer.parseInt(champPage.getRawValue()); |
} catch (NumberFormatException nfe) { |
// si ce n'est pas le cas alors on remet le numéro de page correct |
rafraichirNumeroPage(); |
champPage.focus(); |
return; |
} |
// si la conversion reussit on verifie s'il est nécessaire |
// de changer de page |
// et si la nouvelle est comprise dans l'intervalle des |
// pages existantes (0..pageTotale) |
if (nouvellePage != pageCourante + 1 && nouvellePage > 0 |
&& nouvellePage <= pageTotale) { |
// le cas échéant, on charge la nouvelle page et on |
// notifie le médiateur |
changerPageCourante(nouvellePage - 1); |
listePaginable.changerNumeroPage(pageCourante); |
} else { |
// sinon on reaffiche l'ancien numero de page sans rien |
// changer |
rafraichirNumeroPage(); |
champPage.focus(); |
} |
} |
} |
}); |
// pour éviter de se compliquer la vie, on filtre tous les charactères |
// non numériques |
champPage.addKeyListener(new KeyListener() { |
public void componentKeyDown(ComponentEvent ce) { |
// FIXME : si c'est un numerique |
/*if (Character.isDigit((char) e.getCharCode())) { |
// on laisse passer |
return; |
}*/ |
// si c'est la touche entrée ou backspace (valider ou effacer) |
if (ce.getKeyCode() == KeyCodes.KEY_ENTER |
|| ce.getKeyCode() == KeyCodes.KEY_BACKSPACE) { |
// on laisse passer |
return; |
} else { |
// sinon on remet le numero de page correct et on annule l'évenement |
rafraichirNumeroPage(); |
ce.stopEvent(); |
} |
} |
}); |
// listener pour la selection dans la combobox |
selecteurTaillePage.addSelectionChangedListener(new SelectionChangedListener() { |
public void selectionChanged(SelectionChangedEvent e) { |
SimpleComboBox comboBox = (SimpleComboBox) e.getSource(); |
String nouvelleTaillePageString = comboBox.getRawValue(); |
int nouvelleTaillePage = Integer.parseInt(nouvelleTaillePageString); |
changerTaillePage(nouvelleTaillePage); |
rafraichirNumeroPage(); |
} |
}); |
} |
/** |
* Met à jour les affichage sur les numéros de pages et d'intervalle |
* d'éléments à partir des variables de classes |
*/ |
public void rafraichirNumeroPage() { |
if (filtreActive == true) { |
intervalleElements.setText("<b><i>Recherche active : </i></b>" + termeRecherche); |
} else { |
surTotalPage.setText(" sur " + pageTotale); |
if (nbElement == 0) { |
champPage.setValue("" + (0)); |
// on met simplement à jour l'intervalle qui contient toujours le |
// même nombre d'éléments |
intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), 0,0,0)); |
} else { |
champPage.setValue("" + (pageCourante + 1)); |
// si la page n'est pas la dernière |
if (pageCourante + 1 != pageTotale) { |
// sauf pour la dernière page qui contient souvent moins |
// d'élements que le nombre d'élements par page |
intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
(pageCourante + 1) * taillePage, nbElement)); |
} else { |
// on met simplement à jour l'intervalle qui contient toujours |
// le même nombre d'éléments |
intervalleElements.setText(i18nM.elementsAffiches(UtilString.ucFirst(labelElement), pageCourante * taillePage, |
nbElement, nbElement)); |
} |
} |
} |
} |
/** |
* Met à jour la page en cours |
* |
* @param nouvellePageCourante |
* la nouvelle page en cours |
*/ |
public void changerPageCourante(int nouvellePageCourante) { |
pageCourante = nouvellePageCourante; |
} |
/** |
* Envoie au médiateur une demande pour modifier la taille de la page (qui |
* va à son tour faire les modifications nécessaires) |
* |
* @param nouvelleTaillePage |
* la nouvelle taille de page (élement appartenant au tableau |
* renvoyé par getNbPages()) |
*/ |
public void changerTaillePage(int nouvelleTaillePage) { |
if (nouvelleTaillePage != taillePage) { |
listePaginable.changerTaillePage(nouvelleTaillePage); |
} |
} |
/** |
* Selectionne la valeur correspond à celle passée en paramètre dans la |
* combobox (si elle existe) |
* |
* @param nouvelleTaillePage |
* la nouvelle taille de page |
*/ |
public void selectionnerTaillePage(int nouvelleTaillePage) { |
selecteurTaillePage.setRawValue("" + nouvelleTaillePage); |
} |
@Override |
public void rafraichir(Object nouvelleDonnees) { |
// si on reçoit un tableau de int |
if (nouvelleDonnees instanceof int[]) { |
int[] page = (int[]) nouvelleDonnees; |
// le premier élement est le nombre de pages totales |
pageTotale = page[0]; |
// le second la page en cours |
pageCourante = page[1]; |
// le troisième la taille de la page |
taillePage = page[2]; |
// et le dernier le nombre total d'éléments |
nbElement = page[3]; |
// si la page courante dépasse la page totale (cas normalement |
// improbable car géré en amont) |
// on met le numéro de page à la page courante -1 (car la page |
// courante est comptée à partir |
// de zéro) |
if (pageCourante >= pageTotale && pageCourante != 0) { |
pageCourante = pageTotale - 1; |
// le cas échéant on en notifie le médiateur |
listePaginable.changerNumeroPage(pageCourante); |
} |
} |
// enfin on rafraichit les informations affichées à partir des nouvelles |
// variables de classes mises à jour |
rafraichirNumeroPage(); |
layout(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/accueil/Applette.java |
---|
New file |
0,0 → 1,81 |
package org.tela_botanica.client.vues.accueil; |
import org.tela_botanica.client.util.Debug; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.event.IconButtonEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.widget.button.ToolButton; |
import com.extjs.gxt.ui.client.widget.custom.Portlet; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
abstract public class Applette extends Portlet { |
private ToolButton epingleBouton = null; |
private ToolButton configurationBouton = null; |
private ToolButton fermetureBouton = null; |
protected void initialiserApplette() { |
initialiserApplette(null); |
} |
protected void initialiserApplette(String titre) { |
setLayout(new FitLayout()); |
setHeight(250); |
setCollapsible(true); |
setAnimCollapse(true); |
setScrollMode(Scroll.AUTO); |
setTitre(titre); |
configurationBouton = new ToolButton("x-tool-gear"); |
getHeader().addTool(configurationBouton); |
epingleBouton = getBoutonEpingle(); |
getHeader().addTool(epingleBouton); |
fermetureBouton = getBoutonFermeture(); |
getHeader().addTool(fermetureBouton); |
} |
private ToolButton getBoutonEpingle() { |
ToolButton bouton = new ToolButton("x-tool-pin", new SelectionListener<IconButtonEvent>() { |
@Override |
public void componentSelected(IconButtonEvent ce) { |
setEpingler(!isPinned()); |
} |
}); |
return bouton; |
} |
private ToolButton getBoutonFermeture() { |
ToolButton bouton = new ToolButton("x-tool-close", new SelectionListener<IconButtonEvent>() { |
@Override |
public void componentSelected(IconButtonEvent ce) { |
removeFromParent(); |
} |
}); |
return bouton; |
} |
public void setTitre(String titre) { |
if (titre != null) { |
setHeading(titre); |
} |
} |
public void setEpingler(boolean epingler) { |
if (epingler) { |
epingleBouton.setStyleName("x-tool-unpin x-tool"); |
setPinned(true); |
} else { |
epingleBouton.setStyleName("x-tool-pin x-tool"); |
setPinned(false); |
} |
Debug.log(epingleBouton.getStyleName()); |
layout(); |
} |
protected void ajouterConfigurationListener(SelectionListener<IconButtonEvent> configurationListener) { |
configurationBouton.addSelectionListener(configurationListener); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/accueil/AppletteStatistique.java |
---|
New file |
0,0 → 1,102 |
package org.tela_botanica.client.vues.accueil; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.configuration.Configuration; |
import org.tela_botanica.client.modeles.InterneValeur; |
import org.tela_botanica.client.vues.Formulaire; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.event.IconButtonEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.event.WindowEvent; |
import com.extjs.gxt.ui.client.event.WindowListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
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.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
public class AppletteStatistique extends Applette { |
private String baseUrl = ((Configuration) Registry.get(RegistreId.CONFIG)).getServiceBaseUrl(); |
public AppletteStatistique() { |
initialiserAppletteStatistique(null); |
} |
public AppletteStatistique(String contenu) { |
initialiserAppletteStatistique(contenu); |
} |
private void initialiserAppletteStatistique(String contenu) { |
String titre = "Statistiques des collections"; |
initialiserApplette(titre); |
SelectionListener<IconButtonEvent> configurationListener = new SelectionListener<IconButtonEvent>() { |
@Override |
public void componentSelected(IconButtonEvent ce) { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeaderVisible(false); |
panneau.setLayout(Formulaire.creerFormLayout(350, LabelAlign.TOP)); |
ListStore<InterneValeur> appletteStore = new ListStore<InterneValeur>(); |
appletteStore.add(new InterneValeur("NombreDonnees", "Nombre de données")); |
appletteStore.add(new InterneValeur("TypeDepot", "Types de dépôt des collections")); |
appletteStore.add(new InterneValeur("NombreCollectionParStructure", "Nombre de collections par institution")); |
final ComboBox<InterneValeur> applettesCombo = new ComboBox<InterneValeur>(); |
applettesCombo.setFieldLabel("Veuillez sélectionner le type d'applette"); |
applettesCombo.setForceSelection(true); |
applettesCombo.setTriggerAction(TriggerAction.ALL); |
applettesCombo.setDisplayField("nom"); |
applettesCombo.setStore(appletteStore); |
applettesCombo.setEditable(false); |
applettesCombo.setWidth(300); |
panneau.add(applettesCombo); |
final Dialog configurationFenetre = new Dialog(); |
configurationFenetre.setHeading("Configuration de l'applette"); |
configurationFenetre.setButtons(Dialog.OK); |
configurationFenetre.setSize(350, 150); |
configurationFenetre.setPlain(true); |
configurationFenetre.setModal(true); |
configurationFenetre.setBlinkModal(true); |
configurationFenetre.setLayout(new FitLayout()); |
configurationFenetre.setHideOnButtonClick(true); |
configurationFenetre.addWindowListener(new WindowListener(){ |
public void windowHide(WindowEvent we) { |
String abreviation = applettesCombo.getValue().getAbr(); |
attribuerContenu(abreviation); |
} |
}); |
configurationFenetre.add(panneau); |
configurationFenetre.show(); |
} |
}; |
ajouterConfigurationListener(configurationListener); |
attribuerContenu(contenu); |
} |
private void attribuerContenu(String abreviation) { |
if (abreviation == null) { |
abreviation = "NombreDonnees"; |
} |
setData("contenu", abreviation); |
String url = baseUrl+"CoelStatistique/"+abreviation; |
HtmlContainer conteneurHtml = new HtmlContainer(); |
conteneurHtml.setUrl(url); |
conteneurHtml.recalculate(); |
removeAll(); |
add(conteneurHtml); |
layout(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/accueil/AccueilVue.java |
---|
New file |
0,0 → 1,251 |
package org.tela_botanica.client.vues.accueil; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.TreeMap; |
import org.tela_botanica.client.Mediateur; |
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.util.Debug; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.custom.Portal; |
import com.extjs.gxt.ui.client.widget.custom.Portlet; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.xml.client.Document; |
import com.google.gwt.xml.client.Element; |
import com.google.gwt.xml.client.Node; |
import com.google.gwt.xml.client.NodeList; |
import com.google.gwt.xml.client.XMLParser; |
public class AccueilVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Portal portail = null; |
private static boolean enregistrementEnCours = false; |
public AccueilVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
setLayout(new FitLayout()); |
ContentPanel panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeading("Accueil"); |
panneauPrincipal.setBorders(false); |
ToolBar barreOutils = new ToolBar(); |
Button ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
ajouterPortlet(); |
} |
}); |
barreOutils.add(ajouter); |
Button enregistrer = new Button("Enregistrer"); |
enregistrer.setIcon(Images.ICONES.appliquer()); |
enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
if (enregistrementEnCours == false) { |
enregistrerParametres(); |
} else { |
Info.display(i18nC.accueilEnregistrement(), i18nC.accueilEnregistrementEnCours()); |
} |
} |
}); |
barreOutils.add(enregistrer); |
panneauPrincipal.setTopComponent(barreOutils); |
portail = creerPortail(); |
panneauPrincipal.add(portail); |
chargerParametres(); |
add(panneauPrincipal); |
mediateur.desactiverChargement(); |
} |
private Portal creerPortail() { |
Portal portail = new Portal(3); |
portail.setBorders(true); |
portail.setStyleAttribute("backgroundColor", "white"); |
portail.setShadow(true); |
portail.setColumnWidth(0, .33); |
portail.setColumnWidth(1, .33); |
portail.setColumnWidth(2, .33); |
return portail; |
} |
// INFO: Les items d'une classse portal correspondent aux colonnes. Pour vider une Portal, il faut donc vider les éléments de chaque item du Portal. |
private void viderPortail() { |
portail.getItem(0).removeAll(); |
portail.getItem(1).removeAll(); |
portail.getItem(2).removeAll(); |
} |
private void chargerParametres() { |
viderPortail(); |
Debug.log("Nbre aplletes c0 :"+portail.getItem(0).getItemCount()); |
Debug.log("Charger:"+mediateur.getUtilisateur().getParametre()); |
Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre()); |
NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil"); |
int nbreAccueilNoeud = listeAccueilNoeud.getLength(); |
// Récupération du noeud accueil |
Node accueilNoeud = null; |
if (nbreAccueilNoeud == 0) { |
ajouterPortlet(); |
} else if (nbreAccueilNoeud == 1) { |
accueilNoeud = listeAccueilNoeud.item(0); |
// Lecture des noeuds "applette" |
NodeList listeAppletteNoeud = accueilNoeud.getChildNodes(); |
int nbreAppletteNoeud = listeAppletteNoeud.getLength(); |
TreeMap<String, HashMap<String, String>> tableApplettes = new TreeMap<String, HashMap<String, String>>(); |
for (int i = 0; i < nbreAppletteNoeud ; i++) { |
Element appletteNoeud = (Element) listeAppletteNoeud.item(i); |
int colonne = Integer.parseInt(appletteNoeud.getAttribute("colonne")); |
int index = Integer.parseInt(appletteNoeud.getAttribute("index")); |
HashMap<String, String> infoApplette = new HashMap<String, String>(); |
infoApplette.put("reduite", appletteNoeud.getAttribute("reduite")); |
infoApplette.put("epingle", appletteNoeud.getAttribute("epingle")); |
infoApplette.put("type", appletteNoeud.getAttribute("type")); |
infoApplette.put("colonne", appletteNoeud.getAttribute("colonne")); |
infoApplette.put("index", appletteNoeud.getAttribute("index")); |
infoApplette.put("contenu", appletteNoeud.getAttribute("contenu")); |
tableApplettes.put(colonne+"-"+index, infoApplette); |
} |
Iterator<String> it = tableApplettes.keySet().iterator(); |
while (it.hasNext()) { |
String id = it.next(); |
HashMap<String, String> infoApplette = tableApplettes.get(id); |
boolean reduite = (infoApplette.get("reduite") != null && infoApplette.get("reduite").equals("true")) ? true : false; |
boolean epingle = (infoApplette.get("epingle") != null && infoApplette.get("epingle").equals("true")) ? true : false; |
int index = Integer.parseInt(infoApplette.get("index")); |
int colonne = Integer.parseInt(infoApplette.get("colonne")); |
ajouterPortlet(reduite, epingle, infoApplette.get("type"), colonne, index, infoApplette.get("contenu")); |
} |
} |
Debug.log("Nbre aplletes c0 :"+portail.getItem(0).getItemCount()); |
layout(); |
} |
private void enregistrerParametres() { |
ArrayList<Portlet> applettes = getPortlets(); |
Iterator<Portlet> it = applettes.iterator(); |
Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre()); |
NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil"); |
int nbreAccueilNoeud = listeAccueilNoeud.getLength(); |
// Suppression des noeuds "accueil" existant car il ne devrait y en avoir qu'un |
if (nbreAccueilNoeud > 1) { |
for (int i = 0; i < nbreAccueilNoeud ; i++) { |
paramXml.getDocumentElement().removeChild(listeAccueilNoeud.item(i)); |
} |
nbreAccueilNoeud = 0; |
} |
// Création du nouveau noeud accueil |
Node accueilNoeud = null; |
Element accueilElement = paramXml.createElement("accueil"); |
if (nbreAccueilNoeud == 0) { |
accueilNoeud = paramXml.getDocumentElement().appendChild(accueilElement); |
} else if (nbreAccueilNoeud == 1) { |
accueilNoeud = listeAccueilNoeud.item(0); |
paramXml.getDocumentElement().replaceChild(accueilElement, accueilNoeud); |
accueilNoeud = paramXml.getElementsByTagName("accueil").item(0); |
} |
// Ajout des noeuds "applette" au noeud "accueil" |
while (it.hasNext()) { |
Portlet applette = it.next(); |
String reduite = (applette.isCollapsed() ? "true" : "false"); |
String epingle = (applette.isPinned() ? "true" : "false"); |
String index = Integer.toString(portail.getPortletIndex(applette)); |
String colonne = Integer.toString(portail.getPortletColumn(applette)); |
String contenu = applette.getData("contenu"); |
Element appletteElement = paramXml.createElement("applette"); |
appletteElement.setAttribute("reduite", reduite); |
appletteElement.setAttribute("epingle", epingle); |
appletteElement.setAttribute("type", "statistique"); |
appletteElement.setAttribute("colonne", colonne); |
appletteElement.setAttribute("index", index); |
appletteElement.setAttribute("contenu", contenu); |
accueilNoeud.appendChild(appletteElement); |
} |
Debug.log("Enregistrer:"+paramXml.toString()); |
enregistrementEnCours = true; |
mediateur.getUtilisateur().setParametre(paramXml.toString()); |
mediateur.modifierUtilisateur(); |
} |
private ArrayList<Portlet> getPortlets() { |
ArrayList<Portlet> applettes = new ArrayList<Portlet>(); |
for (int i = 0; i < 3; i++) { |
int nbreApplette = portail.getItem(i).getItemCount(); |
if (nbreApplette > 0) { |
for (int j = 0; j < nbreApplette; j++) { |
applettes.add((Portlet) portail.getItem(i).getItem(j)); |
} |
} |
} |
return applettes; |
} |
private void ajouterPortlet() { |
ajouterPortlet(false, false, "statistique", 0, 0, null); |
} |
private void ajouterPortlet(boolean reduite, boolean epingle, String type, int colonne, int index, String contenu) { |
Debug.log("Ajout:"+reduite+"-"+epingle+"-"+type+"-"+colonne+"-"+index+"-"+contenu); |
Applette applette = null; |
if (type.equals("statistique")) { |
applette = new AppletteStatistique(contenu); |
} |
if (reduite) { |
applette.collapse(); |
} |
portail.insert(applette, index, colonne); |
applette.setEpingler(epingle); |
layout(); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
String type = info.getType(); |
if (type.equals("maj_utilisateur")) { |
if (enregistrementEnCours == true) { |
enregistrementEnCours = false; |
Info.display(i18nC.accueilEnregistrement(), i18nC.accueilEnregistrementSucces()); |
} else { |
chargerParametres(); |
Info.display(i18nC.accueil(), i18nC.accueilChargementSucces()); |
} |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationVue.java |
---|
New file |
0,0 → 1,55 |
package org.tela_botanica.client.vues.publication; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.util.Debug; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
import com.google.gwt.core.client.GWT; |
public class PublicationVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private PublicationListeVue panneauPublicationListe; |
private PublicationDetailVue panneauPublicationDetail; |
public PublicationVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
panneauPublicationListe = new PublicationListeVue(mediateur); |
add(panneauPublicationListe, new BorderLayoutData(LayoutRegion.CENTER)); |
panneauPublicationDetail = new PublicationDetailVue(mediateur); |
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
southData.setSplit(true); |
southData.setMargins(new Margins(5, 0, 0, 0)); |
add(panneauPublicationDetail, southData); |
setId(ComposantId.PANNEAU_PUBLICATION_LISTE); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Publication) { |
panneauPublicationDetail.rafraichir(nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PublicationListe) { |
panneauPublicationListe.rafraichir(nouvellesDonnees); |
mediateur.desactiverChargement(); |
} else if (nouvellesDonnees instanceof Information) { |
panneauPublicationListe.rafraichir(nouvellesDonnees); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationListeVue.java |
---|
New file |
0,0 → 1,237 |
package org.tela_botanica.client.vues.publication; |
import java.util.ArrayList; |
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.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.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; |
import com.extjs.gxt.ui.client.widget.grid.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.user.client.Window; |
public class PublicationListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private Grid<Publication> grille = null; |
private ListStore<Publication> store = null; |
private ColumnModel modeleDesColonnes = null; |
private Button ajouter; |
private Button modifier; |
private Button supprimer; |
private BarrePaginationVue pagination = null; |
public PublicationListeVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
setLayout(new FitLayout()); |
setHeading(i18nC.menuPublication()); |
// Gestion de la barre d'outil |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicAjouterPublication(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicModifierPublication(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
mediateur.clicSupprimerPublication(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
// Gestion de la grille |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
// ATTENTION : les noms des colonnes doivent correspondre aux noms variables de la classe utilisée dans la liste |
colonnes.add(new ColumnConfig("fmt_auteur", i18nC.publicationAuteurs(), 200)); |
colonnes.add(new ColumnConfig("titre", i18nC.publicationTitre(), 150)); |
colonnes.add(new ColumnConfig("collection", i18nC.publicationRevueCollection(), 110)); |
colonnes.add(creerColonneEditeur()); |
colonnes.add(creerColonneAnneePublication()); |
colonnes.add(new ColumnConfig("indication_nvt", i18nC.publicationNvt(), 35)); |
colonnes.add(new ColumnConfig("fascicule", i18nC.publicationFascicule(), 35)); |
colonnes.add(new ColumnConfig("truk_pages", i18nC.publicationPage(), 35)); |
modeleDesColonnes = new ColumnModel(colonnes); |
GridSelectionModel<Publication> modeleDeSelection = new GridSelectionModel<Publication>(); |
modeleDeSelection.addSelectionChangedListener(new SelectionChangedListener<Publication>() { |
public void selectionChanged(SelectionChangedEvent<Publication> event) { |
Publication publication = (Publication) event.getSelectedItem(); |
clicListe(publication); |
} |
}); |
store = new ListStore<Publication>(); |
store.sort("titre", SortDir.ASC); |
grille = new Grid<Publication>(store, modeleDesColonnes); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("titre"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.setSelectionModel(modeleDeSelection); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){ |
@Override |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new StructureListe(), mediateur); |
setBottomComponent(pagination); |
} |
private ColumnConfig creerColonneEditeur() { |
GridCellRenderer<Publication> editeurRendu = new GridCellRenderer<Publication>() { |
@Override |
public String render(Publication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Publication> store, Grid<Publication> grid) { |
String editeur = model.getNomEditeur(); |
model.set("_editeur_", editeur); |
return editeur; |
} |
}; |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", i18nC.publicationEditeur(), 135); |
editeurColonne.setRenderer(editeurRendu); |
return editeurColonne; |
} |
private ColumnConfig creerColonneAnneePublication() { |
GridCellRenderer<Publication> datePublicationRendu = new GridCellRenderer<Publication>() { |
@Override |
public String render(Publication model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<Publication> store, Grid<Publication> grid) { |
String annee = model.getAnneeParution(); |
model.set("_annee_", annee); |
return annee; |
} |
}; |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", i18nC.publicationDateParution(), 75); |
datePublicationColonne.setRenderer(datePublicationRendu); |
return datePublicationColonne; |
} |
private void clicListe(Publication publication) { |
if (publication != null && store.getCount() > 0) { |
mediateur.clicListePublication(publication); |
} |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin <= 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof PublicationListe) { |
PublicationListe publications = (PublicationListe) nouvellesDonnees; |
pagination.setlistePaginable(publications); |
pagination.rafraichir(publications.getPageTable()); |
if (publications != null) { |
List<Publication> liste = publications.toList(); |
store.removeAll(); |
store.add(liste); |
mediateur.actualiserPanneauCentral(); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getType().equals("suppression_publication")) { |
String message = info.toString(); |
if (info.getDonnee(0) != null) { |
message = (String) info.getDonnee(0); |
} |
Info.display(i18nC.publicationTitreSuppression(), message); |
supprimerPublicationsSelectionnees(); |
gererEtatActivationBouton(); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
layout(); |
} |
private void supprimerPublicationsSelectionnees() { |
List<Publication> publicationsSelectionnees = grille.getSelectionModel().getSelectedItems(); |
Iterator<Publication> it = publicationsSelectionnees.iterator(); |
while (it.hasNext()) { |
grille.getStore().remove(it.next()); |
} |
layout(true); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationDetailVue.java |
---|
New file |
0,0 → 1,162 |
package org.tela_botanica.client.vues.publication; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.ComposantId; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.vues.DetailVue; |
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.Html; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class PublicationDetailVue extends DetailVue implements Rafraichissable { |
private String enteteTpl = null; |
private String contenuTpl = null; |
private ContentPanel panneauPrincipal = null; |
private Html entete = null; |
private Html contenu = null; |
private Publication publication = null; |
private boolean publicationChargementOk = false; |
public PublicationDetailVue(Mediateur mediateurCourant) { |
super(mediateurCourant); |
initialiserTousLesTpl(); |
panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(false); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
panneauPrincipal.setTopComponent(entete); |
contenu = new Html(); |
panneauPrincipal.add(contenu); |
add(panneauPrincipal); |
} |
private void initialiserTousLesTpl() { |
initialiserEnteteHtmlTpl(); |
initialiserGeneralTpl(); |
} |
private void initialiserEnteteHtmlTpl() { |
enteteTpl = |
"<div id='{css_id}'>"+ |
" <h1>{titre}</h1>"+ |
" <h2>{auteurs} ({annee})<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" + |
"</div>"; |
} |
private void initialiserGeneralTpl() { |
contenuTpl = |
"<div class='{css_corps}'>"+ |
" <span class='{css_label}'>{i18n_nom_complet} :</span> {nom_complet}<br />"+ |
" <span class='{css_label}'>{i18n_auteurs} :</span> {auteurs}<br />"+ |
" <span class='{css_label}'>{i18n_titre} :</span> {titre}<br />"+ |
" <span class='{css_label}'>{i18n_collection} :</span> {collection}<br />"+ |
" <span class='{css_label}'>{i18n_editeur} :</span> {editeur}<br />"+ |
" <span class='{css_label}'>{i18n_annee} :</span> {annee}<br />"+ |
" <span class='{css_label}'>{i18n_nvt} :</span> {nvt}<br />"+ |
" <span class='{css_label}'>{i18n_fascicule} :</span> {fascicule}<br />"+ |
" <span class='{css_label}'>{i18n_pages} :</span> {pages}<br />"+ |
"</div>"; |
} |
public void afficherDetail() { |
if (publication != null) { |
afficherEntete(); |
afficherDetailPublication(); |
} |
layout(); |
} |
private void afficherEntete() { |
Params enteteParams = new Params(); |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE); |
enteteParams.set("css_meta", ComposantClass.META); |
enteteParams.set("i18n_id", i18nC.id()); |
enteteParams.set("titre", publication.getTitre()); |
enteteParams.set("auteurs", publication.getAuteur()); |
enteteParams.set("annee", publication.getAnneeParution()); |
enteteParams.set("id", publication.getId()); |
enteteParams.set("guid", getGuid()); |
enteteParams.set("projet", construireTxtProjet(publication.getIdProjet())); |
GWT.log("entete généré", null); |
String eHtml = Format.substitute(enteteTpl, enteteParams); |
entete.getElement().setInnerHTML(eHtml); |
} |
public String getGuid() { |
String guid = "URN:tela-botanica.org:"; |
guid += "coel"+publication.getIdProjet()+":"; |
guid += "pub"+publication.getId(); |
return guid; |
} |
public void afficherDetailPublication() { |
Params contenuParams = new Params(); |
contenuParams.set("i18n_nom_complet", i18nC.publicationNomComplet()); |
contenuParams.set("i18n_auteurs", i18nC.publicationAuteurs()); |
contenuParams.set("i18n_titre", i18nC.publicationTitre()); |
contenuParams.set("i18n_collection", i18nC.publicationRevueCollection()); |
contenuParams.set("i18n_editeur", i18nC.publicationEditeur()); |
contenuParams.set("i18n_annee", i18nC.publicationDateParution()); |
contenuParams.set("i18n_nvt", i18nC.publicationNvt()); |
contenuParams.set("i18n_fascicule", i18nC.publicationFascicule()); |
contenuParams.set("i18n_pages", i18nC.publicationPage()); |
contenuParams.set("nom_complet", publication.getNomComplet()); |
contenuParams.set("auteurs", publication.getAuteur()); |
contenuParams.set("titre", publication.getTitre()); |
contenuParams.set("collection", publication.getCollection()); |
contenuParams.set("editeur", publication.getNomEditeur()); |
contenuParams.set("annee", publication.getAnneeParution()); |
contenuParams.set("nvt", publication.getIndicationNvt()); |
contenuParams.set("fascicule", publication.getFascicule()); |
contenuParams.set("pages", publication.getPages()); |
String gHtml = formaterContenu(contenuTpl, contenuParams); |
contenu.getElement().setInnerHTML(gHtml); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Publication) { |
publication = (Publication) nouvellesDonnees; |
publicationChargementOk = true; |
} else if (nouvellesDonnees instanceof ProjetListe) { |
projets = (ProjetListe) nouvellesDonnees; |
projetsChargementOk = true; |
GWT.log("projets recu", null); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (avoirDonneesChargees()) { |
afficherDetail(); |
} |
} |
private boolean avoirDonneesChargees() { |
boolean ok = false; |
if (projetsChargementOk && publicationChargementOk) { |
ok = true; |
} |
return ok; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/publication/PublicationForm.java |
---|
New file |
0,0 → 1,821 |
package org.tela_botanica.client.vues.publication; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
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.MenuApplicationId; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.structure.Structure; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilArray; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.HorizontalPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.MessageBox; |
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.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.TextField; |
import com.extjs.gxt.ui.client.widget.form.Validator; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.FormLayout; |
import com.google.gwt.core.client.GWT; |
public class PublicationForm extends Formulaire implements Rafraichissable { |
private Publication publication; |
private PersonneListe auteursInitialListe = null; |
private static boolean publicationAPersonneListeChargementOk = false; |
private PublicationAPersonneListe auteursAjoutes = null; |
private PublicationAPersonneListe auteursSupprimes = null; |
private FieldSet auteursFieldset = null; |
private ComboBox<Projet> projetsCombo = null; |
private ArrayList<ComboBox<Personne>> auteurComboboxListe = null; |
private LayoutContainer conteneurChamps; |
private ListStore<Personne> auteursStorePartage = null; |
private static boolean auteurStorePartageChargementOk = false; |
private FieldSet generalitesFieldset = null; |
private TextField<String> titreChp = null; |
private TextField<String> collectionChp = null; |
private TextField<String> uriChp = null; |
private FieldSet editionFieldset = null; |
private ComboBox<Structure> editeurCombobox = null; |
private TextField<String> datePublicationChp = null; |
private TextField<String> tomeChp = null; |
private TextField<String> fasciculeChp = null; |
private TextField<String> pagesChp = null; |
private String idStructureEdition = ""; |
private static boolean formulaireValideOk = false; |
private static boolean publicationValideOk = false; |
private static boolean auteursValideOk = false; |
private static boolean publicationOk = false; |
private static boolean attenteAjoutAuteursOk = true; |
private static boolean attenteSuppressionAuteursOk = true; |
public PublicationForm(Mediateur mediateurCourrant, String publicationId) { |
initialiserPublicationForm(mediateurCourrant, publicationId); |
} |
public PublicationForm(Mediateur mediateurCourrant, String publicationId, Rafraichissable vueARafraichirApresValidation) { |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation; |
initialiserPublicationForm(mediateurCourrant, publicationId); |
} |
private void initialiserPublicationForm(Mediateur mediateurCourrant, String publicationId) { |
auteursInitialListe = new PersonneListe(); |
initialiserValidation(); |
initialiserAffichageAuteurs(); |
publication = new Publication(); |
publication.setId(publicationId); |
String modeDeCreation = (UtilString.isEmpty(publication.getId()) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PUBLICATION); |
panneauFormulaire.setLayout(new FlowLayout()); |
genererTitreFormulaire(); |
creerZoneAuteurs(); |
panneauFormulaire.add(auteursFieldset); |
creerZoneGeneralites(); |
panneauFormulaire.add(generalitesFieldset); |
creerZoneEdition(); |
panneauFormulaire.add(editionFieldset); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateurCourrant.selectionnerPublication(this, publicationId); |
mediateurCourrant.selectionnerPublicationAPersonne(this, publicationId, null, PublicationAPersonne.ROLE_AUTEUR); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.publicationTitreFormAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.publicationTitreFormModif(); |
if (publication != null) { |
titre += " - "+i18nC.id()+": "+publication.getId(); |
} |
} |
panneauFormulaire.setHeading(titre); |
} |
private void creerZoneAuteurs() { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(200); |
// Fieldset Auteur |
auteursFieldset = new FieldSet(); |
auteursFieldset.setHeading(i18nC.publicationAuteursTitre()); |
auteursFieldset.setCollapsible(true); |
auteursFieldset.setLayout(layout); |
Debug.log("Dans creerZoneAuteurs"); |
auteurComboboxListe = new ArrayList<ComboBox<Personne>>(0); |
auteursStorePartage = new ListStore<Personne>(); |
mediateur.clicObtenirListeAuteurs(this); |
creerChampsAuteur(); |
} |
private void creerChampsAuteur() { |
auteursFieldset.removeAll(); |
conteneurChamps = new LayoutContainer(); |
Button ajouterAuteurBouton = new Button(i18nC.publicationAuteurBoutonAjouter()); |
ajouterAuteurBouton.setIcon(Images.ICONES.ajouter()); |
ajouterAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent be) { |
creerChampAuteurEtBoutonSupprimer(null); |
} |
}); |
auteursFieldset.add(conteneurChamps); |
auteursFieldset.add(ajouterAuteurBouton); |
auteursFieldset.layout(); |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
creerChampAuteurEtBoutonSupprimer(null); |
} |
} |
public void creerChampAuteurEtBoutonSupprimer(Personne auteur) { |
final HorizontalPanel panneauHorizontal = new HorizontalPanel(); |
LayoutContainer panneauChampTxt = new LayoutContainer(); |
panneauChampTxt.setLayout(new FormLayout()); |
final ComboBox<Personne> auteursSaisisComboBox = creerComboBoxAuteursSaisis(); |
if (auteur != null) { |
auteursSaisisComboBox.setValue(auteur); |
auteursSaisisComboBox.validate(); |
} |
auteurComboboxListe.add(auteursSaisisComboBox); |
auteursSaisisComboBox.setFieldLabel(i18nC.publicationAuteurSingulier()+" "+auteurComboboxListe.size()); |
panneauChampTxt.add(auteursSaisisComboBox, new FormData(300, 0)); |
panneauHorizontal.add(panneauChampTxt); |
Button supprimerAuteurBouton = new Button(); |
supprimerAuteurBouton.setIcon(Images.ICONES.supprimer()); |
supprimerAuteurBouton.setToolTip(i18nC.supprimer()); |
supprimerAuteurBouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent be) { |
auteurComboboxListe.remove(auteursSaisisComboBox); |
conteneurChamps.remove(panneauHorizontal); |
int numeroAuteurs = 1; |
for (Iterator<ComboBox<Personne>> it = auteurComboboxListe.iterator(); it.hasNext();) { |
it.next().setFieldLabel(i18nC.publicationAuteurSingulier()+" "+numeroAuteurs); |
numeroAuteurs++; |
} |
auteursFieldset.layout(); |
} |
}); |
panneauHorizontal.add(supprimerAuteurBouton); |
conteneurChamps.add(panneauHorizontal); |
auteursFieldset.layout(); |
} |
private ComboBox<Personne> creerComboBoxAuteursSaisis() { |
ListStore<Personne> auteursStore = new ListStore<Personne>(); |
auteursStore.add(auteursStorePartage.getModels()); |
ComboBox<Personne> comboBox = new ComboBox<Personne>(); |
comboBox.setEmptyText(i18nC.chercherPersonneSaisi()); |
comboBox.setEditable(true); |
comboBox.setAllowBlank(false); |
comboBox.setForceSelection(true); |
comboBox.setDisplayField("fmt_nom_complet"); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setStore(auteursStore); |
comboBox.addStyleName(ComposantClass.OBLIGATOIRE); |
comboBox.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
return comboBox; |
} |
private void creerZoneGeneralites() { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(200); |
// Fieldset Infos Générales |
generalitesFieldset = new FieldSet(); |
generalitesFieldset.setHeading("Informations générales"); |
generalitesFieldset.setCollapsible(true); |
generalitesFieldset.setLayout(layout); |
projetsCombo = new ComboBox<Projet>(); |
projetsCombo.setTabIndex(tabIndex++); |
projetsCombo.setFieldLabel(i18nC.projetChamp()); |
projetsCombo.setDisplayField("nom"); |
projetsCombo.setForceSelection(true); |
projetsCombo.setValidator(new Validator() { |
@Override |
public String validate(Field<?> field, String value) { |
String retour = null; |
if (field.getRawValue().equals("")) { |
field.setValue(null); |
} else if (projetsCombo.getStore().findModel("nom", field.getRawValue()) == null) { |
String contenuBrut = field.getRawValue(); |
field.setValue(null); |
field.setRawValue(contenuBrut); |
retour = "Veuillez sélectionner une valeur ou laisser le champ vide"; |
} |
return retour; |
} |
}); |
projetsCombo.setTriggerAction(TriggerAction.ALL); |
projetsCombo.setStore(new ListStore<Projet>()); |
projetsCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
projetsCombo.addListener(Events.Valid, Formulaire.creerEcouteurChampObligatoire()); |
generalitesFieldset.add(projetsCombo, new FormData(450, 0)); |
mediateur.selectionnerProjet(this, null); |
titreChp = new TextField<String>(); |
titreChp.setName("cpu"); |
titreChp.setFieldLabel("Titre de l'article ou de l'ouvrage"); |
titreChp.addStyleName(ComposantClass.OBLIGATOIRE); |
titreChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
generalitesFieldset.add(titreChp, new FormData(450, 0)); |
collectionChp = new TextField<String>(); |
collectionChp.setFieldLabel("Intitulé de la revue ou de la collection"); |
generalitesFieldset.add(collectionChp, new FormData(450, 0)); |
uriChp = new TextField<String>(); |
uriChp.setFieldLabel("URL de la publication"); |
generalitesFieldset.add(uriChp, new FormData(450, 0)); |
} |
private void creerZoneEdition() { |
FormLayout layout = new FormLayout(); |
layout.setLabelWidth(200); |
// Fieldset Edition |
editionFieldset = new FieldSet(); |
editionFieldset.setHeading("Édition"); |
editionFieldset.setCollapsible(true); |
editionFieldset.setLayout(layout); |
ListStore<Structure> editeurStore = new ListStore<Structure>(); |
editeurCombobox = new ComboBox<Structure>(); |
editeurCombobox.setEmptyText("Sélectionner un éditeur..."); |
editeurCombobox.setFieldLabel("Éditeur de la publication"); |
editeurCombobox.setDisplayField("nom"); |
editeurCombobox.setStore(editeurStore); |
editeurCombobox.setEditable(true); |
editeurCombobox.setTriggerAction(TriggerAction.ALL); |
editionFieldset.add(editeurCombobox, new FormData(450, 0)); |
mediateur.clicObtenirListeEditeurs(this); |
datePublicationChp = new TextField<String>(); |
datePublicationChp.setMaxLength(4); |
datePublicationChp.setMinLength(4); |
datePublicationChp.setFieldLabel("Année de publication"); |
datePublicationChp.addStyleName(ComposantClass.OBLIGATOIRE); |
datePublicationChp.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
editionFieldset.add(datePublicationChp, new FormData(40, 0)); |
tomeChp = new TextField<String>(); |
tomeChp.setFieldLabel("Série de la revue ou tome"); |
editionFieldset.add(tomeChp, new FormData(75, 0)); |
fasciculeChp = new TextField<String>(); |
fasciculeChp.setFieldLabel("Fascicule de la revue"); |
editionFieldset.add(fasciculeChp, new FormData(75, 0)); |
pagesChp = new TextField<String>(); |
pagesChp.setFieldLabel("Pages"); |
pagesChp.setToolTip("Fomat : NBRE ou NBRE-NBRE. ('NBRE' correspond à une suite de chiffres arabes ou romains ou à un point d'interrogation '?' dans le cas d'une donnée inconnue)"); |
editionFieldset.add(pagesChp, new FormData(100, 0)); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Publication) { |
// Si on a reçu les details d'une publication |
rafraichirPublication((Publication) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof StructureListe) { |
// Si on a reçu une liste des editeurs |
rafraichirListeEditeurs((StructureListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) { |
rafraichirListeAuteurs((PublicationAPersonneListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof Information) { |
rafraichirInformation((Information) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
Formulaire.rafraichirComboBox(projets, projetsCombo); |
setValeurComboProjets(); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
if (etrePretAAfficherAuteurs()) { |
afficherAuteurs(); |
initialiserAffichageAuteurs(); |
} |
if (etreValide()) { |
initialiserValidation(); |
repandreRafraichissement(); |
controlerFermetureApresRafraichissement(); |
} |
} |
private void miseAJourAuteursInitialListe() { |
Iterator<String> clesAjoutees = auteursAjoutes.keySet().iterator(); |
while (clesAjoutees.hasNext()) { |
Personne auteurAjoute = auteursAjoutes.get(clesAjoutees.next()).getPersonne(); |
auteursInitialListe.put(auteurAjoute.getId(), auteurAjoute); |
} |
Iterator<String> clesSupprimees = auteursSupprimes.keySet().iterator(); |
while (clesSupprimees.hasNext()) { |
Personne auteurSupprime = auteursSupprimes.get(clesSupprimees.next()).getPersonne(); |
auteursInitialListe.remove(auteurSupprime.getId()); |
} |
} |
private void rafraichirPublication(Publication publi) { |
publicationOk = true; |
publication = publi; |
peuplerFormulaire(); |
genererTitreFormulaire(); |
} |
private void rafraichirListeEditeurs(StructureListe editeurs) { |
editeurCombobox.getStore().removeAll(); |
editeurCombobox.getStore().add((List<Structure>) editeurs.toList()); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
editeurCombobox.setValue((Structure) editeurs.get(idStructureEdition)); |
} |
editeurCombobox.expand(); |
} |
private void rafraichirListeAuteurs(PublicationAPersonneListe auteurs) { |
Iterator<String> it = auteurs.keySet().iterator(); |
while (it.hasNext()) { |
Personne auteur = auteurs.get(it.next()).getPersonne(); |
auteursInitialListe.put(auteur.getId(), auteur); |
} |
publicationAPersonneListeChargementOk = true; |
} |
private void rafraichirInformation(Information info) { |
String type = info.getType(); |
if (type.equals("ajout_publication") || type.equals("modif_publication")) { |
publicationValideOk = true; |
if (vueExterneARafraichirApresValidation != null) { |
publication.setId((String) info.getDonnee(0)); |
} |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
attenteAjoutAuteursOk = true; |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR); |
} |
} |
if (info.getType().equals("liste_personne")) { |
PersonneListe listePersonneAuteur = (PersonneListe) info.getDonnee(0); |
List<Personne> liste = listePersonneAuteur.toList(); |
auteursStorePartage.removeAll(); |
auteursStorePartage.add(liste); |
Debug.log("Reception nouvelle liste auteurs"); |
auteurStorePartageChargementOk = true; |
} else if (info.getType().equals("ajout_publication_a_personne")) { |
attenteAjoutAuteursOk = false; |
GWT.log("attenteAjoutAuteursOk", null); |
} else if (info.getType().equals("suppression_publication_a_personne")) { |
attenteSuppressionAuteursOk = false; |
GWT.log("attenteSuppressionAuteursOk", null); |
} else if (info.getType().equals("modif_publication")) { |
Info.display("Modification d'une publication", info.toString()); |
} else if (info.getType().equals("ajout_publication")) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String publicationId = (String) info.getDonnee(0); |
Info.display("Ajout d'une publication", "La publication '"+publicationId+"' a bien été ajoutée"); |
if (vueExterneARafraichirApresValidation != null) { |
publication.setId(publicationId); |
} |
} else { |
Info.display("Ajout d'une publication", info.toString()); |
} |
} |
if (avoirAuteursMiseAJourCorrectement()) { |
Debug.log("Mise à jour liste auteur"); |
miseAJourAuteursInitialListe(); |
initialiserAuteurs(); |
auteursValideOk = true; |
} |
} |
private boolean avoirAuteursMiseAJourCorrectement() { |
boolean ok = false; |
if (attenteAjoutAuteursOk == false && attenteSuppressionAuteursOk == false) { |
ok = true; |
} |
return ok; |
} |
private void afficherAuteurs() { |
Iterator<String> itap = auteursInitialListe.keySet().iterator(); |
while (itap.hasNext()) { |
creerChampAuteurEtBoutonSupprimer(auteursInitialListe.get(itap.next())); |
} |
} |
private void initialiserAffichageAuteurs() { |
publicationOk = false; |
auteurStorePartageChargementOk = false; |
publicationAPersonneListeChargementOk = false; |
} |
private boolean etrePretAAfficherAuteurs() { |
boolean ok = false; |
if (publicationOk && auteurStorePartageChargementOk && publicationAPersonneListeChargementOk) { |
ok = true; |
} |
return ok; |
} |
private Boolean etreValide() { |
Boolean valide = false; |
//Debug.log("formulaire"+formulaireValideOk+" - Publication :"+publicationValideOk+" - Auteurs :"+auteursValideOk, null); |
if (formulaireValideOk && publicationValideOk && auteursValideOk) { |
valide = true; |
} |
return valide; |
} |
private void initialiserValidation() { |
formulaireValideOk = false; |
publicationValideOk = false; |
initialiserAuteurs(); |
auteursValideOk = false; |
} |
private void initialiserAuteurs() { |
attenteAjoutAuteursOk = true; |
auteursAjoutes = new PublicationAPersonneListe(); |
attenteSuppressionAuteursOk = true; |
auteursSupprimes = new PublicationAPersonneListe(); |
} |
private void repandreRafraichissement() { |
if (vueExterneARafraichirApresValidation != null) { |
String type = "publication_modifiee"; |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
type = "publication_ajoutee"; |
} |
Information info = new Information(type); |
info.setDonnee(0, publication); |
vueExterneARafraichirApresValidation.rafraichir(info); |
} |
} |
public boolean soumettreFormulaire() { |
formulaireValideOk = verifierFormulaire(); |
if (formulaireValideOk) { |
soumettrePublication(); |
soumettreAuteurs(); |
} |
return formulaireValideOk; |
} |
private void soumettrePublication() { |
Publication publicationCollectee = collecterPublication(); |
if (publicationCollectee != null) { |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
mediateur.ajouterPublication(this, publicationCollectee); |
} else if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.modifierPublication(this, publicationCollectee); |
} |
} |
} |
private void soumettreAuteurs() { |
attenteAjoutAuteursOk = false; |
attenteSuppressionAuteursOk = false; |
PersonneListe personnesInitiales = auteursInitialListe; |
PersonneListe personnesActuelles = new PersonneListe(); |
if (auteurComboboxListe != null) { |
Iterator<ComboBox<Personne>> itcp = auteurComboboxListe.iterator(); |
while (itcp.hasNext()) { |
ComboBox<Personne> combobox = itcp.next(); |
Personne personne = combobox.getValue(); |
if (personne != null) { |
personnesActuelles.put(personne.getId(), personne); |
} else { |
Debug.log("Etre valide :"+combobox.isValid()+" - "+combobox.getRawValue()); |
} |
} |
} |
// Auteurs ajoutés |
Iterator<String> clesActuelles = personnesActuelles.keySet().iterator(); |
while (clesActuelles.hasNext()) { |
String idActuel = clesActuelles.next(); |
if (personnesInitiales.size() == 0 || personnesInitiales.get(idActuel) == null) { |
Personne personne = personnesActuelles.get(idActuel); |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
publicationAAuteur.setIdPublication(publication.getId()); |
} |
publicationAAuteur.setPersonne(personne); |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR); |
auteursAjoutes.put(publicationAAuteur.getId(), publicationAAuteur); |
attenteAjoutAuteursOk = true; |
} |
} |
// Auteurs supprimés |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
Iterator<String> clesInitiales = personnesInitiales.keySet().iterator(); |
while (clesInitiales.hasNext()) { |
String idInitial = clesInitiales.next(); |
if (personnesActuelles.size() == 0 || personnesActuelles.get(idInitial) == null) { |
Personne personne = personnesInitiales.get(idInitial); |
PublicationAPersonne publicationAAuteur = new PublicationAPersonne(); |
publicationAAuteur.setIdPublication(publication.getId()); |
publicationAAuteur.setPersonne(personne); |
publicationAAuteur.setIdRole(PublicationAPersonne.ROLE_AUTEUR); |
auteursSupprimes.put(publicationAAuteur.getId(), publicationAAuteur); |
attenteSuppressionAuteursOk = true; |
} |
} |
} |
// Execution de les mise à jour pour le mode MODIFICATION |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (auteursAjoutes != null && auteursAjoutes.size() != 0) { |
mediateur.ajouterPublicationAPersonne(this, publication.getId(), auteursAjoutes, PublicationAPersonne.ROLE_AUTEUR); |
} |
if (auteursSupprimes != null && auteursSupprimes.size() != 0) { |
mediateur.supprimerPublicationAPersonne(this, auteursSupprimes); |
} |
} |
Debug.log("personnesInitiales:"+personnesInitiales.size()+" - personnesActuelles :"+personnesActuelles.size()+" - auteursSupprimes :"+auteursSupprimes.size()+" - auteursAjoutes :"+auteursAjoutes.size()); |
} |
public boolean verifierFormulaire() { |
boolean valide = true; |
ArrayList<String> messages = new ArrayList<String>(); |
boolean auteurErreur = true; |
for (int i = 0; i < auteurComboboxListe.size(); i++) { |
if (auteurComboboxListe.get(i).getValue() != null) { |
auteurErreur = false; |
break; |
} |
} |
if (auteurErreur) { |
messages.add("Veuillez saisir au moins un auteur !"); |
} |
String titre = titreChp.getValue(); |
if (titre == null || titre.equals("")) { |
messages.add("Veuillez saisir le titre de la publication !"); |
} |
String uri = uriChp.getValue(); |
if (uri != null && ! uri.isEmpty() && ! uri.matches(Pattern.url)) { |
messages.add("L'URL saisie n'est pas valide !"); |
} |
String datePublication = datePublicationChp.getRawValue(); |
if (datePublication == null || datePublication.equals("")) { |
messages.add("Veuillez saisir une année de parution !"); |
} else { |
if (!etreDateValide(datePublication)) { |
messages.add("Le format de l'année saisie est incorrect !"); |
} |
} |
String pages = pagesChp.getValue(); |
String valeurPage = "(?:[0-9]+|[IVXLCDM]+|\\?)"; |
if (pages != null && ! pages.matches("^(?:"+valeurPage+"|"+valeurPage+"-"+valeurPage+")$")) { |
messages.add("Le format des pages est incorrect !"); |
} |
if (messages.size() != 0) { |
String[] tableauDeMessages = {}; |
tableauDeMessages = messages.toArray(tableauDeMessages); |
MessageBox.alert("Erreurs de saisies", UtilArray.implode(tableauDeMessages, "<br />"), null); |
valide = false; |
} |
return valide; |
} |
private void peuplerFormulaire() { |
creerChampsAuteur(); |
setValeurComboProjets(); |
titreChp.setValue(publication.getTitre()); |
collectionChp.setValue(publication.getCollection()); |
uriChp.setValue(publication.getURI()); |
datePublicationChp.setValue(reduireDateParAnnee(publication.getDateParution())); |
tomeChp.setValue(publication.getIndicationNvt()); |
fasciculeChp.setValue(publication.getFascicule()); |
pagesChp.setValue(publication.getPages()); |
if (publication.getEditeur().matches("^[0-9]+$")) { |
editeurCombobox.setValue(editeurCombobox.getStore().findModel("id_structure", publication.getEditeur())); |
idStructureEdition = publication.getEditeur(); |
} else { |
editeurCombobox.setRawValue(publication.getEditeur()); |
} |
} |
private Publication collecterPublication() { |
Publication publicationCollectee = (Publication) publication.cloner(new Publication()); |
publicationCollectee.setIdProjet(getValeurComboProjets()); |
publicationCollectee.setAuteur(construireIntituleAuteur()); |
String titre = titreChp.getValue(); |
publicationCollectee.setTitre(titre); |
String collection = collectionChp.getValue(); |
publicationCollectee.setCollection(collection); |
publicationCollectee.setNomComplet(construireNomComplet()); |
String uri = uriChp.getValue(); |
publicationCollectee.setUri(uri); |
String editeur = ""; |
if (editeurCombobox.getValue() != null) { |
editeur = editeurCombobox.getValue().getId(); |
publicationCollectee.setStructureEditeur(editeurCombobox.getValue()); |
} else if (editeurCombobox.getRawValue() != "") { |
editeur = editeurCombobox.getRawValue(); |
} |
publicationCollectee.setEditeur(editeur); |
String anneePublication = datePublicationChp.getRawValue(); |
String datePublication = anneePublication+"-00-00"; |
publicationCollectee.setDateParution(datePublication); |
String tome = tomeChp.getValue(); |
publicationCollectee.setIndicationNvt(tome); |
String fascicule = fasciculeChp.getValue(); |
publicationCollectee.setFascicule(fascicule); |
String pages = pagesChp.getValue(); |
publicationCollectee.setPages(pages); |
Publication publicationARetourner = null; |
if (!publicationCollectee.comparer(publication)) { |
publicationARetourner = publication = publicationCollectee; |
} |
return publicationARetourner; |
} |
private String construireIntituleEditeur() { |
String editeur = ""; |
if (editeurCombobox.getValue() != null) { |
editeur = editeurCombobox.getValue().getNom(); |
} else if (editeurCombobox.getRawValue() != "") { |
editeur = editeurCombobox.getRawValue(); |
} |
return editeur; |
} |
private String construireIntituleAuteur() { |
String inituleAuteur = ""; |
int auteursNombre = auteurComboboxListe.size(); |
for (int i = 0; i < auteursNombre; i++) { |
if (auteurComboboxListe.get(i).getValue() != null) { |
Personne auteur = auteurComboboxListe.get(i).getValue(); |
inituleAuteur += auteur.getNom().toUpperCase()+ " "+auteur.getPrenom(); |
if (i != (auteursNombre - 1)) { |
inituleAuteur += ", "; |
} |
} |
} |
return inituleAuteur; |
} |
private String construireNomComplet() { |
// Intitulé de la publication complet : fmt_auteur, date_parution(année). titre. Editeur (nom), collection, fascicule, indication_nvt. pages. |
String nomComplet = ""; |
String auteurs = construireIntituleAuteur(); |
String annee = datePublicationChp.getRawValue(); |
String titre = titreChp.getValue(); |
String editeur = construireIntituleEditeur(); |
nomComplet += auteurs+", "+annee+". "+titre+"."; |
if (!UtilString.isEmpty(editeur)) { |
nomComplet += " Éditeur "+editeur+"."; |
} |
if (collectionChp.getValue() != null) { |
String revue = collectionChp.getValue(); |
nomComplet += ", "+revue; |
} |
if (fasciculeChp.getValue() != null) { |
String fascicule = fasciculeChp.getValue(); |
nomComplet += ", "+fascicule; |
} |
if (tomeChp.getValue() != null) { |
String tomaison = tomeChp.getValue(); |
nomComplet += ", "+tomaison; |
} |
if (collectionChp.getValue() != null || fasciculeChp.getValue() != null || tomeChp.getValue() != null) { |
nomComplet += "."; |
} |
if (pagesChp.getValue() != null) { |
String pages = pagesChp.getValue(); |
nomComplet += pages+"."; |
} |
return nomComplet; |
} |
public void reinitialiserFormulaire() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.afficherFormPublication(publication.getId()); |
} else { |
mediateur.afficherFormPublication(null); |
} |
} |
private boolean etreDateValide(String anneePublication) { |
boolean valide = true; |
if (!anneePublication.matches("^[0-2][0-9]{3}$")) { |
valide = false; |
} |
return valide; |
} |
private String reduireDateParAnnee(String datePar) { |
if (datePar.matches("^[0-2][0-9]{3}(-[0-9]{2}){2}$")) { |
return datePar.split("-")[0]; |
} else { |
return ""; |
} |
} |
private String getValeurComboProjets() { |
String valeur = ""; |
if (projetsCombo.getValue() != null) { |
valeur = projetsCombo.getValue().getId(); |
} |
return valeur; |
} |
private void setValeurComboProjets() { |
if (projetsCombo.getStore() != null ) { |
if (mode.equals(Formulaire.MODE_MODIFIER) && publication != null) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", publication.getIdProjet())); |
} else if (mode.equals(Formulaire.MODE_AJOUTER)) { |
projetsCombo.setValue(projetsCombo.getStore().findModel("id_projet", mediateur.getProjetId())); |
} |
} |
} |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/ContenuVue.java |
---|
New file |
0,0 → 1,73 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Information; |
import org.tela_botanica.client.modeles.collection.CollectionListe; |
import org.tela_botanica.client.modeles.commentaire.CommentaireListe; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.modeles.structure.StructureListe; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class ContenuVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
public ContenuVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
setLayout(new FitLayout()); |
setBorders(true); |
} |
public Rafraichissable getContenu() { |
Rafraichissable contenuPanneauCentre = null; |
if (getItems() != null && getItems().size() == 1) { |
contenuPanneauCentre = (Rafraichissable) getItem(0); |
} |
return contenuPanneauCentre; |
} |
//+----------------------------------------------------------------------------------------------------------------+ |
// RAFRAICHISSEMENT |
//+----------------------------------------------------------------------------------------------------------------+ |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ProjetListe) { |
mediateur.afficherListeProjets((ProjetListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof StructureListe) { |
mediateur.afficherListeStructures((StructureListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof CollectionListe) { |
mediateur.afficherListeCollections((CollectionListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PersonneListe) { |
mediateur.afficherListePersonnes((PersonneListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PublicationListe) { |
mediateur.afficherListePublication((PublicationListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof CommentaireListe) { |
mediateur.afficherListeCommentaire((CommentaireListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
if (getContenu() != null) { |
getContenu().rafraichir(info); |
} |
} else { |
// Affichage des éventuels messages de déboguage ou d'alerte |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log(info.getMessages().toString(), null); |
} |
// Traitement en fonction des types d'information |
if (info.getType().equals("liste_personne")) { |
mediateur.afficherListePersonnes((PersonneListe) info.getDonnee(0)); |
Info.display("Chargement d'une liste de personnes", ""); |
} |
} |
} |
mediateur.desactiverChargement(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/FormulaireBarreValidation.java |
---|
New file |
0,0 → 1,75 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.images.Images; |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem; |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
public class FormulaireBarreValidation extends ButtonBar { |
private SelectionListener<ButtonEvent> ecouteur = null; |
public static final String CODE_BOUTON_VALIDER = "VA"; |
public static final String CODE_BOUTON_APPLIQUER = "AP"; |
public static final String CODE_BOUTON_ANNULER = "AN"; |
public static final String CODE_BOUTON_REINITIALISER = "RE"; |
public FormulaireBarreValidation(SelectionListener<ButtonEvent> ecouteurCourrant) { |
ecouteur = ecouteurCourrant; |
creerBarreOutilsValidation(); |
} |
private void creerBarreOutilsValidation() { |
this.setAlignment(HorizontalAlignment.LEFT); |
this.add(creerBouton(CODE_BOUTON_REINITIALISER)); |
this.add(new FillToolItem()); |
this.add(creerBouton(CODE_BOUTON_APPLIQUER)); |
this.add(creerBouton(CODE_BOUTON_ANNULER)); |
this.add(creerBouton(CODE_BOUTON_VALIDER)); |
} |
private Button creerBouton(final String code) { |
String nom = getNom(code); |
Button bouton = new Button(nom); |
bouton.setData("code", code); |
bouton.setIcon(getIcone(code)); |
bouton.addSelectionListener(ecouteur); |
return bouton; |
} |
private AbstractImagePrototype getIcone(final String code) { |
AbstractImagePrototype icone = null; |
if (code.equals(CODE_BOUTON_VALIDER)) { |
icone = Images.ICONES.valider(); |
} else if (code.equals(CODE_BOUTON_APPLIQUER)) { |
icone = Images.ICONES.appliquer(); |
} else if (code.equals(CODE_BOUTON_ANNULER)) { |
icone = Images.ICONES.annuler(); |
} else if (code.equals(CODE_BOUTON_REINITIALISER)) { |
icone = Images.ICONES.reinitialiser(); |
} |
return icone; |
} |
private String getNom(final String code) { |
String nom = null; |
if (code.equals(CODE_BOUTON_VALIDER)) { |
nom = Mediateur.i18nC.valider(); |
} else if (code.equals(CODE_BOUTON_APPLIQUER)) { |
nom = Mediateur.i18nC.appliquer(); |
} else if (code.equals(CODE_BOUTON_ANNULER)) { |
nom = Mediateur.i18nC.annuler(); |
} else if (code.equals(CODE_BOUTON_REINITIALISER)) { |
nom = Mediateur.i18nC.reinitialiser(); |
} |
return nom; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/PopupChargement.java |
---|
New file |
0,0 → 1,36 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.i18n.Constantes; |
import org.tela_botanica.client.images.Images; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.layout.TableLayout; |
import com.google.gwt.user.client.ui.Image; |
import com.google.gwt.user.client.ui.PopupPanel; |
public class PopupChargement extends PopupPanel{ |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
public PopupChargement(Mediateur mediateurCourrant) { |
super(); |
mediateur = mediateurCourrant; |
i18nC = mediateur.i18nC; |
LayoutContainer cp = new LayoutContainer(); |
cp.setLayout(new TableLayout(2)); |
Image imageChargement = Images.ICONES.ajaxLoader().createImage(); |
cp.add(imageChargement); |
Text texteChargement = new Text(i18nC.chargement()); |
cp.add(texteChargement); |
add(cp); |
center(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/EnteteVue.java |
---|
New file |
0,0 → 1,270 |
package org.tela_botanica.client.vues; |
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.i18n.ErrorMessages; |
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; |
import com.extjs.gxt.ui.client.Style.Orientation; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.MenuEvent; |
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.HtmlContainer; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.button.SplitButton; |
import com.extjs.gxt.ui.client.widget.layout.RowData; |
import com.extjs.gxt.ui.client.widget.layout.RowLayout; |
import com.extjs.gxt.ui.client.widget.menu.Menu; |
import com.extjs.gxt.ui.client.widget.menu.MenuItem; |
public class EnteteVue extends LayoutContainer implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private ErrorMessages i18nM = null; |
private String identificationInfoTpl = null; |
private String titreTpl = null; |
private HtmlContainer conteneurHtml = null; |
private SelectionListener<ButtonEvent> boutonEcouteur = null; |
private ButtonBar barreBoutons = null; |
private Button identificationBouton = null; |
private SplitButton feedbackBouton = null; |
private SplitButton aideBouton = null; |
private SplitButton applisBouton = null; |
public EnteteVue(Mediateur mediateurCourant) { |
mediateur = mediateurCourant; |
i18nC = Mediateur.i18nC; |
i18nM = Mediateur.i18nM; |
setId(ComposantId.PANNEAU_ENTETE); |
setLayout(new RowLayout(Orientation.HORIZONTAL)); |
initialiserSquelettes(); |
boutonEcouteur = getEcouteurDesBoutons(); |
conteneurHtml = getIdentification(); |
identificationBouton = getBoutonIdentification(); |
feedbackBouton = getBoutonAFeedback(); |
aideBouton = getBoutonAide(); |
applisBouton = getBoutonApplications(); |
barreBoutons = new ButtonBar(); |
barreBoutons.setAlignment(Style.HorizontalAlignment.RIGHT); |
barreBoutons.add(conteneurHtml); |
barreBoutons.add(identificationBouton); |
barreBoutons.add(aideBouton); |
barreBoutons.add(feedbackBouton); |
barreBoutons.add(applisBouton); |
add(getTitre(), new RowData(.20, 1)); |
add(barreBoutons, new RowData(.8, 1)); |
} |
private void initialiserSquelettes() { |
identificationInfoTpl = "<div id='"+ComposantId.DIV_IDENTIFICATION+"'>{0}</div>"; |
titreTpl = "<div id='"+ComposantId.DIV_TITRE+"'>{0}</div>"; |
} |
private HtmlContainer getTitre() { |
HtmlContainer titreConteneurHtml = new HtmlContainer(); |
titreConteneurHtml.setHtml(Format.substitute(titreTpl, Registry.get(RegistreId.APPLI_NOM))); |
return titreConteneurHtml; |
} |
private HtmlContainer getIdentification() { |
HtmlContainer conteneurHtml = new HtmlContainer(); |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme()))); |
return conteneurHtml; |
} |
private SelectionListener<ButtonEvent> getEcouteurDesBoutons() { |
SelectionListener<ButtonEvent> boutonEcouteur = new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent be) { |
Button btn = (Button) be.getComponent(); |
String id = btn.getId(); |
String message = ""; |
if (id.equals(ComposantId.BTN_AIDE) |
|| id.equals(ComposantId.BTN_FEEDBACK) |
|| id.equals(ComposantId.BTN_APPLIS)) { |
btn.showMenu(); |
} else if (id.equals(ComposantId.BTN_CONNEXION)) { |
mediateur.ouvrirIdentification(); |
message = i18nM.chargementFenetre(btn.getText()); |
} else if (id.equals(ComposantId.BTN_DECONNEXION)) { |
mediateur.deconnecterUtilisateur(); |
Utilisateur utilisateurCourant = mediateur.getUtilisateur(); |
message = i18nM.deconnexion(utilisateurCourant.getNomComplet()); |
} else if (id.equals(ComposantId.BTN_APPLIS)) { |
btn.getMenu().show(btn); |
} |
if (!message.equals("")) { |
Info.display(i18nC.chargement(), message); |
} |
} |
}; |
return boutonEcouteur; |
} |
private Button getBoutonIdentification() { |
Button bouton = new Button(i18nC.identification(), boutonEcouteur); |
bouton.setId(ComposantId.BTN_CONNEXION); |
return bouton; |
} |
private SplitButton getBoutonAide() { |
MenuItem menuDoc = new MenuItem(i18nC.doc()); |
menuDoc.addSelectionListener(new SelectionListener<MenuEvent>() { |
@Override |
public void componentSelected(MenuEvent mEvent) { |
mediateur.ouvrirAide(); |
} |
}); |
menuDoc.setId(ComposantId.MENU_DOC); |
menuDoc.setIcon(Images.ICONES.aide()); |
MenuItem menuApropos = new MenuItem(i18nC.apropos()); |
menuApropos.addSelectionListener(new SelectionListener<MenuEvent>() { |
@Override |
public void componentSelected(MenuEvent mEvent) { |
mediateur.ouvrirParametres(); |
} |
}); |
menuApropos.setId(ComposantId.MENU_APROPOS); |
menuApropos.setIcon(Images.ICONES.engrenages()); |
Menu menuAide = new Menu(); |
menuAide.add(menuDoc); |
menuAide.add(menuApropos); |
SplitButton boutonAvecMenus = new SplitButton(i18nC.aide()); |
boutonAvecMenus.setId(ComposantId.BTN_AIDE); |
boutonAvecMenus.setIcon(Images.ICONES.aide()); |
boutonAvecMenus.addSelectionListener(boutonEcouteur); |
boutonAvecMenus.setMenu(menuAide); |
return boutonAvecMenus; |
} |
private SplitButton getBoutonAFeedback() { |
MenuItem menuBogue = new MenuItem(i18nC.bogue()); |
menuBogue.addSelectionListener(new SelectionListener<MenuEvent>() { |
@Override |
public void componentSelected(MenuEvent mEvent) { |
Menu me = (Menu) mEvent.getComponent(); |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BOGUE); |
Info.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getText())); |
mediateur.ouvrirUrlExterne(ComposantId.MENU_BOGUE); |
} |
}); |
menuBogue.setId(ComposantId.MENU_BOGUE); |
menuBogue.setIcon(Images.ICONES.bogue()); |
MenuItem menuCommentaire = new MenuItem(i18nC.remarques()); |
menuCommentaire.addSelectionListener(new SelectionListener<MenuEvent>() { |
@Override |
public void componentSelected(MenuEvent mEvent) { |
Menu me = (Menu) mEvent.getComponent(); |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_COMMENTAIRE); |
Info.display(Mediateur.i18nC.chargement(), i18nM.ouvertureLienExterne(mi.getText())); |
mediateur.ouvrirUrlExterne(ComposantId.MENU_COMMENTAIRE); |
} |
}); |
menuCommentaire.setId(ComposantId.MENU_COMMENTAIRE); |
menuCommentaire.setIcon(Images.ICONES.commentaire()); |
Menu menuFeedback = new Menu(); |
menuFeedback.add(menuBogue); |
menuFeedback.add(menuCommentaire); |
SplitButton boutonAvecMenus = new SplitButton(i18nC.feedback()); |
boutonAvecMenus.setId(ComposantId.BTN_FEEDBACK); |
boutonAvecMenus.addSelectionListener(boutonEcouteur); |
boutonAvecMenus.setMenu(menuFeedback); |
boutonAvecMenus.setIcon(Images.ICONES.flecheDedansDehors()); |
return boutonAvecMenus; |
} |
private SplitButton getBoutonApplications() { |
MenuItem menuCel = new MenuItem(i18nC.cel()); |
menuCel.addSelectionListener(new SelectionListener<MenuEvent>() { |
@Override |
public void componentSelected(MenuEvent mEvent) { |
Menu me = (Menu) mEvent.getComponent(); |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_CEL); |
Info.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getText())); |
mediateur.ouvrirUrlExterne(ComposantId.MENU_CEL); |
} |
}); |
menuCel.setId(ComposantId.MENU_CEL); |
menuCel.setIcon(Images.ICONES.images()); |
MenuItem menuBel = new MenuItem(i18nC.bel()); |
menuBel.addSelectionListener(new SelectionListener<MenuEvent>() { |
@Override |
public void componentSelected(MenuEvent mEvent) { |
Menu me = (Menu) mEvent.getComponent(); |
MenuItem mi = (MenuItem) me.getItemByItemId(ComposantId.MENU_BEL); |
Info.display(i18nC.chargement(), i18nM.ouvertureAppliExterne(mi.getText())); |
mediateur.ouvrirUrlExterne(ComposantId.MENU_BEL); |
} |
}); |
menuBel.setId(ComposantId.MENU_BEL); |
menuBel.setIcon(Images.ICONES.livreOuvert()); |
Menu menu = new Menu(); |
menu.add(menuCel); |
menu.add(menuBel); |
SplitButton boutonAvecMenus = new SplitButton(i18nC.applicationExterne()); |
boutonAvecMenus.setId(ComposantId.BTN_APPLIS); |
boutonAvecMenus.addSelectionListener(boutonEcouteur); |
boutonAvecMenus.setMenu(menu); |
boutonAvecMenus.setIcon(Images.ICONES.flecheBascule()); |
return boutonAvecMenus; |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("maj_utilisateur")) { |
Utilisateur utilisateur = mediateur.getUtilisateur(); |
if (utilisateur.isIdentifie()) { |
if (utilisateur.existeDansAnnuaire()) { |
utilisateur.majUtilisateurInfoAnnuaire(); |
} |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.bienvenue()+utilisateur.getNomComplet()))); |
identificationBouton.setText(i18nC.deconnexion()); |
identificationBouton.setIcon(Images.ICONES.deconnexion()); |
identificationBouton.setId(ComposantId.BTN_DECONNEXION); |
} else { |
conteneurHtml.setHtml(Format.substitute(identificationInfoTpl, (new Params()).add(i18nC.modeAnonyme()))); |
identificationBouton.setText(i18nC.identification()); |
identificationBouton.setIcon(Images.ICONES.connexion()); |
identificationBouton.setId(ComposantId.BTN_CONNEXION); |
} |
} |
} else { |
Debug.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass())); |
} |
layout(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/StatutVue.java |
---|
New file |
0,0 → 1,36 |
package org.tela_botanica.client.vues; |
import org.tela_botanica.client.ComposantId; |
import com.extjs.gxt.ui.client.Style.Orientation; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.Status; |
import com.extjs.gxt.ui.client.widget.layout.RowLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
public class StatutVue extends LayoutContainer { |
private Status barreStatut = null; |
public StatutVue() { |
setLayout(new RowLayout(Orientation.HORIZONTAL)); |
setId(ComposantId.PANNEAU_STATUT); |
ToolBar toolBar = new ToolBar(); |
toolBar.add(new FillToolItem()); |
barreStatut = new Status(); |
toolBar.add(barreStatut); |
add(barreStatut); |
} |
public void showBusy(String message) { |
barreStatut.setBusy(message); |
} |
public void clear() { |
barreStatut.clearStatus(""); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/FiltreVue.java |
---|
New file |
0,0 → 1,104 |
package org.tela_botanica.client.vues; |
import java.util.LinkedList; |
import java.util.List; |
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.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
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.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.google.gwt.core.client.GWT; |
public class FiltreVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null; |
private Constantes i18nC = null; |
private ListStore<Projet> projets = null; |
private ComboBox<Projet> listeProjets; |
private ProjetListe projetsCache = null; |
public FiltreVue(Mediateur mediateurCourrant) { |
mediateur = mediateurCourrant; |
i18nC = Mediateur.i18nC; |
setHeading(i18nC.titreFiltre()); |
setLayout(new FitLayout()); |
setLayoutOnChange(true); |
chargerProjets(); |
initialiserListeProjets(); |
} |
private void chargerProjets() { |
mediateur.selectionnerProjet(this, null); |
} |
private void initialiserListeProjets() { |
// Ajout de la sélection des projets |
listeProjets = new ComboBox<Projet>(); |
projets = new ListStore<Projet>(); |
listeProjets.setStore(projets); |
listeProjets.setEditable(false); |
listeProjets.setDisplayField("nom"); |
listeProjets.setEmptyText(i18nC.txtListeProjetDefaut()); |
listeProjets.setTypeAhead(true); |
listeProjets.setTriggerAction(TriggerAction.ALL); |
// Ajout d'un écouteur pour le changement => enregistre la valeur courante du projet dans le registre |
listeProjets.addSelectionChangedListener(new SelectionChangedListener<Projet>() { |
@Override |
public void selectionChanged(SelectionChangedEvent<Projet> se) { |
mediateur.activerChargement(i18nC.chargement()); |
mediateur.selectionnerProjetCourant(se.getSelectedItem()); |
} |
}); |
add(listeProjets); |
} |
private void afficherListeProjets(List projetsRecus) { |
projets.removeAll(); |
List<Projet> selection = new LinkedList<Projet>(); |
Projet tousProjets = new Projet(); |
tousProjets.set("nom", i18nC.tousProjets()); |
projetsRecus.add(0, tousProjets); |
selection.add(tousProjets); |
projets.add(projetsRecus); |
listeProjets.setStore(projets); |
listeProjets.setSelection(selection); |
layout(); |
} |
@Override |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ProjetListe) { |
projetsCache = (ProjetListe) nouvellesDonnees; |
Registry.register(RegistreId.PROJETS, projetsCache); |
afficherListeProjets(projetsCache.toList()); |
} else if (nouvellesDonnees instanceof List) { |
List<Projet> projets = (List) nouvellesDonnees; |
Registry.register(RegistreId.PROJETS, projets); |
afficherListeProjets(projets); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/Formulaire.java |
---|
New file |
0,0 → 1,330 |
package org.tela_botanica.client.vues; |
import java.util.Iterator; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs; |
import org.tela_botanica.client.configuration.Configuration; |
import org.tela_botanica.client.i18n.Constantes; |
import org.tela_botanica.client.i18n.ErrorMessages; |
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.aDonneeListe; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.HorizontalAlignment; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
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.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.TabItem; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
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.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.Field; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.Radio; |
import com.extjs.gxt.ui.client.widget.form.RadioGroup; |
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.FitLayout; |
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 abstract class Formulaire extends LayoutContainer implements Rafraichissable { |
public static final String MODE_AJOUTER = "AJOUT"; |
public static final String MODE_MODIFIER = "MODIF"; |
public Constantes i18nC = null; |
public ErrorMessages i18nM = null; |
public Mediateur mediateur = null; |
public Configuration config = null; |
public String mode = null; |
public int tabIndex = 100; |
public FormPanel panneauFormulaire = null; |
public ButtonBar barreOutilsValidation = null; |
public String menuIdCourant = null; |
public static Boolean clicBoutonvalidation = false; |
public Rafraichissable vueExterneARafraichirApresValidation = null; |
public FormPanel getFormulaire() { |
return panneauFormulaire; |
} |
public void initialiserFormulaire(Mediateur mediateurCourrant, String modeDeCreation, String idMenuCourrant) { |
// Initialisation de variables |
mode = modeDeCreation; |
mediateur = mediateurCourrant; |
i18nC = Mediateur.i18nC; |
i18nM = Mediateur.i18nM; |
menuIdCourant = idMenuCourrant; |
config = (Configuration) Registry.get(RegistreId.CONFIG); |
// Iniatilisation du layoutContainer |
setLayout(new FitLayout()); |
setBorders(false); |
// Création du panneau du FORMULAIRE GÉNÉRAL |
panneauFormulaire = new FormPanel(); |
panneauFormulaire.setBodyBorder(false); |
panneauFormulaire.setFrame(true); |
panneauFormulaire.setCollapsible(false); |
panneauFormulaire.setButtonAlign(HorizontalAlignment.CENTER); |
panneauFormulaire.setLayout(new FitLayout()); |
if (modeDeCreation.equals(MODE_AJOUTER)) { |
panneauFormulaire.setIcon(Images.ICONES.formAjouter()); |
} else if (modeDeCreation.equals(MODE_AJOUTER)) { |
panneauFormulaire.setIcon(Images.ICONES.formModifier()); |
} |
barreOutilsValidation = new FormulaireBarreValidation(creerEcouteurValidation()); |
panneauFormulaire.setBottomComponent(barreOutilsValidation); |
add(panneauFormulaire); |
} |
public SelectionListener<ButtonEvent> creerEcouteurValidation() { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
soumettreFormulaire(); |
clicBoutonvalidation = true; |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
mediateur.clicMenu(menuIdCourant); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
reinitialiserFormulaire(); |
} |
} |
}; |
return ecouteur; |
} |
public abstract boolean verifierFormulaire(); |
public abstract boolean soumettreFormulaire(); |
public abstract void reinitialiserFormulaire(); |
public TabItem creerOnglet(String nom, String id) { |
TabItem onglet = new TabItem(); |
onglet.setId(id); |
onglet.setText(nom); |
FormulaireOnglet.parametrer(onglet); |
return onglet; |
} |
public void controlerFermetureApresRafraichissement() { |
// Si le bouton Valider a été cliqué, nous affichons la liste des structures |
if (clicBoutonvalidation) { |
fermerFormulaire(); |
} |
} |
public void fermerFormulaire() { |
clicBoutonvalidation = false; |
panneauFormulaire.setEnabled(false); |
mediateur.clicMenu(menuIdCourant); |
} |
/** Méthode simplifiant la création de FormLayout. |
* Chacun des paramètres peut prendre la valeur null pour utiliser la valeur par défaut. |
* |
* @param labelWidth largeur des labels. |
* @param labelAlign alignement des labels |
* @return |
*/ |
public static FormLayout creerFormLayout(Integer labelWidth, LabelAlign labelAlign) { |
FormLayout formLayout = new FormLayout(); |
if (labelWidth != null) { |
formLayout.setLabelWidth(labelWidth); |
} |
if (labelAlign != null) { |
formLayout.setLabelAlign(labelAlign); |
} |
return formLayout; |
} |
/** Méthode simplifiant la création de bouton radio oui/non |
* |
* @param listeNom nom de la liste de valeur |
* @return |
*/ |
public RadioGroup creerChoixUniqueRadioGroupe(String groupeNom, String listeNom) { |
groupeNom += "_grp"; |
// NOTE : il semblerait qu'il faille aussi utiliser setName() pour éviter tout problème... |
RadioGroup radioGroup = new RadioGroup(groupeNom); |
radioGroup.setName(groupeNom); |
if (listeNom.equals("ouiNon")) { |
ValeurListe ouiNonListe = new ValeurListe(); |
ouiNonListe.ajouter(new Valeur("1", i18nC.oui(), "NULL", "NULL")); |
ouiNonListe.ajouter(new Valeur("0", i18nC.non(), "NULL", "NULL")); |
creerChoixUniqueBoutonRadio(radioGroup, ouiNonListe); |
} |
return radioGroup; |
} |
public void creerChoixUniqueBoutonRadio(RadioGroup radioGroupe, ValeurListe listeValeurs) { |
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) { |
Valeur val = listeValeurs.get(it.next()); |
Radio radioBtn = new Radio(); |
radioBtn.setName(radioGroupe.getName().replace("_grp", "")); |
radioBtn.setId(val.getId()+"_"+radioBtn.getName()); |
radioBtn.setBoxLabel(val.getNom()); |
radioBtn.setValueAttribute(val.getId()); |
radioBtn.addListener(Events.Change, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
//Window.alert(((Radio) be.component).getName()); |
afficherChampSupplementaire(((Radio) be.getComponent())); |
} |
}); |
if (! val.getDescription().equals("NULL")) { |
radioBtn.setToolTip(new ToolTipConfig(val.getNom(), val.getDescription())); |
} |
radioGroupe.add(radioBtn); |
} |
} |
public void afficherChampSupplementaire(Radio radioBtn) { |
GWT.log("Vous devez redéfinir la méthode afficherChampSupplementaire(Radio radioBtn) dans votre classe formulaire.", null); |
}; |
/** Méthode simplifiant la création de choix multiple sous forme de case à cocher. |
* Apelle un service retournant la liste des valeurs représentant les cases à cocher. |
* Ajoute ou pas un champ "Autre". |
* |
* @return ContentPanel le panneau contenant les cases à cocher |
*/ |
public static LayoutContainer creerChoixMultipleCp() { |
LayoutContainer conteneur = new LayoutContainer(); |
conteneur.setLayout(creerFormLayout(650, LabelAlign.TOP)); |
return conteneur; |
} |
/** Méthode simplifiant la création de choix multiple sous forme de case à cocher. |
* Apelle un service retournant la liste des valeurs représentant les cases à cocher. |
* Ajoute ou pas un champ "Autre". |
* |
* @param cp panneau conteant le groupe de case à cocher |
* @param cacGroup le groupe de case à cocher |
* @param listeValeurs la liste de valeurs à transformer en case à cocher |
* @param boolAutreChp booléen indiquant si oui ou non le champ autre doit apparaître |
* @return |
*/ |
public static void creerChoixMultipleCac(LayoutContainer cp, final CheckBoxGroup cacGroupe, ValeurListe listeValeurs, final Field<String> autreChp) { |
cp.addListener(Events.Hide, new Listener<BaseEvent>() { |
public void handleEvent(BaseEvent be) { |
cacGroupe.reset(); |
autreChp.setValue(""); |
} |
}); |
cacGroupe.setAutoWidth(true); |
cacGroupe.setStyleAttribute("padding", "3px"); |
cacGroupe.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())); |
} |
cacGroupe.add(cac); |
} |
cp.add(cacGroupe); |
if (autreChp != null) { |
// FIXME : éviter le chevauchement du texte des cases à cocher avec le label "Autre" sur les petits écrans |
LayoutContainer conteneur = new LayoutContainer(); |
conteneur.setLayout(creerFormLayout(50, LabelAlign.TOP)); |
autreChp.setId("autre-"+listeValeurs.getId()); |
autreChp.setFieldLabel("Autre"); |
autreChp.setLabelStyle("font-weight:normal;"); |
conteneur.add(autreChp, new FormData(500, 0)); |
cp.add(conteneur); |
} |
cp.layout(); |
} |
@SuppressWarnings({"unchecked"}) |
public static void rafraichirComboBox(aDonneeListe<?> listeValeurs, ComboBox combo) { |
rafraichirComboBox(listeValeurs, combo, "nom"); |
} |
@SuppressWarnings({"unchecked"}) |
public static void rafraichirComboBox(aDonneeListe<?> listeValeurs, ComboBox combo, String champATrier) { |
List<?> liste = listeValeurs.toList(); |
if (liste.size() > 0) { |
ListStore store = combo.getStore(); |
store.removeAll(); |
store.add(liste); |
store.sort(champATrier, SortDir.ASC); |
combo.setStore(store); |
} |
} |
public static Listener<BaseEvent> creerEcouteurChampObligatoire() { |
return new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
Field<?> champ = null; |
boolean etreVide = true; |
if (be.getSource() instanceof TextField<?>) { |
champ = (TextField<?>) be.getSource(); |
etreVide = (champ.getRawValue().isEmpty()) ? true : false; |
} else if (be.getSource() instanceof TextArea) { |
champ = (TextArea) be.getSource(); |
etreVide = (champ.getRawValue().isEmpty()) ? true : false; |
} else if (be.getSource() instanceof ChampComboBoxListeValeurs) { |
champ = (ChampComboBoxListeValeurs) be.getSource(); |
etreVide = (champ.getValue() == null) ? true : false; |
} else if (be.getSource() instanceof ComboBox<?>) { |
champ = (ComboBox<?>) be.getSource(); |
etreVide = (champ.getValue() == null) ? true : false; |
} |
champ.removeStyleName(ComposantClass.OBLIGATOIRE); |
champ.removeStyleName(ComposantClass.OBLIGATOIRE_OK); |
if (etreVide == false) { |
champ.addStyleName(ComposantClass.OBLIGATOIRE_OK); |
} else { |
champ.addStyleName(ComposantClass.OBLIGATOIRE); |
} |
} |
}; |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneFormPublication.java |
---|
New file |
0,0 → 1,665 |
package org.tela_botanica.client.vues.personne; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.LinkedList; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
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.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonne; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.FenetreForm; |
import org.tela_botanica.client.vues.Formulaire; |
import org.tela_botanica.client.vues.FormulaireBarreValidation; |
import org.tela_botanica.client.vues.FormulaireOnglet; |
import org.tela_botanica.client.vues.publication.PublicationForm; |
import com.extjs.gxt.ui.client.core.XTemplate; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
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.Listener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
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.Info; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
import com.extjs.gxt.ui.client.widget.form.ComboBox; |
import com.extjs.gxt.ui.client.widget.form.FormPanel; |
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.grid.CellEditor; |
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig; |
import com.extjs.gxt.ui.client.widget.grid.ColumnData; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.grid.RowExpander; |
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.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class PersonneFormPublication extends FormulaireOnglet implements Rafraichissable { |
private Personne personneSelectionnee = null; |
private static int idGenere = 1; |
private ContentPanel panneauPrincipal = null; |
private ToolBar barreOutils = null; |
private EditorGrid<PublicationAPersonne> grille; |
private PublicationAPersonneListe publicationsAjoutees = null; |
private PublicationAPersonneListe publicationsSupprimees = null; |
private ComboBox<Publication> publicationsSaisiesComboBox = null; |
private Button publicationsBoutonSupprimer = null; |
private Button publicationsBoutonModifier = null; |
private ComboBox<Valeur> typeRelationCombo = null; |
private List<Valeur> roles = null; |
private PublicationAPersonneListe listePublicationsLiees = new PublicationAPersonneListe(); |
private FenetreForm fenetreFormulaire = null; |
public PersonneFormPublication(Formulaire formulaireCourrant) { |
initialiserOnglet(formulaireCourrant); |
setId("publication"); |
setText(Mediateur.i18nC.collectionPublication()); |
setStyleAttribute("padding", "0"); |
panneauPrincipal = creerPanneauContenantGrille(); |
barreOutils = creerBarreOutilsGrille(); |
panneauPrincipal.setTopComponent(barreOutils); |
grille = creerGrille(); |
panneauPrincipal.add(grille); |
add(panneauPrincipal); |
initialiser(); |
} |
private void initialiser() { |
// Remise à zéro des modification dans la liste des auteurs |
idGenere = 1; |
publicationsAjoutees = new PublicationAPersonneListe(); |
publicationsSupprimees = new PublicationAPersonneListe(); |
// Actualisation de l'état des boutons de la barre d'outils |
actualiserEtatBoutonsBarreOutils(); |
} |
public void mettreAJourPersonne() { |
personneSelectionnee = ((PersonneForm) formulaire).personneSelectionnee; |
//Boucle sur les role pour trouver les publication à personne |
if ((roles != null) && (personneSelectionnee!=null)) { |
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), roles); |
} |
} |
private ContentPanel creerPanneauContenantGrille() { |
ContentPanel panneau = new ContentPanel(); |
panneau.setHeading(i18nC.collectionPublication()+" " + i18nC.personnePublication()); |
panneau.setIcon(Images.ICONES.table()); |
panneau.setLayout(new FitLayout()); |
panneau.setFrame(true); |
return panneau; |
} |
private ToolBar creerBarreOutilsGrille() { |
ToolBar barreOutils = new ToolBar(); |
Button ajouterBouton = creerBoutonAjouter(); |
barreOutils.add(ajouterBouton); |
barreOutils.add(new Text(" ou ")); |
publicationsSaisiesComboBox = creerComboBoxPublicationsSaisis(); |
barreOutils.add(publicationsSaisiesComboBox); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonModifier = creerBoutonModifier(); |
barreOutils.add(publicationsBoutonModifier); |
barreOutils.add(new SeparatorToolItem()); |
publicationsBoutonSupprimer = creerBoutonSupprimer(); |
barreOutils.add(publicationsBoutonSupprimer); |
barreOutils.add(new SeparatorToolItem()); |
Button rafraichirBouton = creerBoutonRafraichir(); |
barreOutils.add(rafraichirBouton); |
return barreOutils; |
} |
private Button creerBoutonAjouter() { |
Button bouton = new Button(i18nC.ajouter()); |
bouton.setIcon(Images.ICONES.vcardAjouter()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_AJOUTER); |
fenetreFormulaire.show(); |
} |
}); |
return bouton; |
} |
private Button creerBoutonModifier() { |
Button bouton = new Button(i18nC.modifier()); |
bouton.setIcon(Images.ICONES.vcardModifier()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
PublicationAPersonne publicationSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(Formulaire.MODE_MODIFIER); |
fenetreFormulaire.show(); |
} |
} |
}); |
return bouton; |
} |
private FenetreForm creerFenetreModaleAvecFormulairePersonne(String mode) { |
String publicationId = null; |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
PublicationAPersonne publicationSaisiSelectionne = grille.getSelectionModel().getSelectedItem(); |
publicationId = publicationSaisiSelectionne.getIdPublication(); |
} |
final FenetreForm fenetre = new FenetreForm(""); |
final PublicationForm formulaire = creerFormulairePublication(fenetre, publicationId); |
fenetre.add(formulaire); |
return fenetre; |
} |
private PublicationForm creerFormulairePublication(final FenetreForm fenetre, final String publicationId) { |
PublicationForm formulairePublication = new PublicationForm(mediateur, publicationId, this); |
FormPanel panneauFormulaire = formulairePublication.getFormulaire(); |
fenetre.setHeading(panneauFormulaire.getHeading()); |
panneauFormulaire.setHeaderVisible(false); |
panneauFormulaire.setTopComponent(null); |
// FIXME : avec GXT-2.1.0 la redéfinition du bottom component ne marche plus. Nous le cachons et en créeons un dans la fenêtre. |
panneauFormulaire.getBottomComponent().hide(); |
SelectionListener<ButtonEvent> ecouteur = creerEcouteurValidationFormulairePublication(fenetre, formulairePublication); |
final ButtonBar barreValidation = new FormulaireBarreValidation(ecouteur); |
fenetre.setBottomComponent(barreValidation); |
return formulairePublication; |
} |
private SelectionListener<ButtonEvent> creerEcouteurValidationFormulairePublication(final FenetreForm fenetre, final PublicationForm formulaire) { |
SelectionListener<ButtonEvent> ecouteur = new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
String code = ((Button) ce.getComponent()).getData("code"); |
if (code.equals(FormulaireBarreValidation.CODE_BOUTON_VALIDER)) { |
if (formulaire.soumettreFormulaire()) { |
fenetre.hide(); |
} |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_APPLIQUER)) { |
formulaire.soumettreFormulaire(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_ANNULER)) { |
fenetre.hide(); |
} else if (code.equals(FormulaireBarreValidation.CODE_BOUTON_REINITIALISER)) { |
fenetreFormulaire.hide(); |
fenetreFormulaire = creerFenetreModaleAvecFormulairePersonne(formulaire.mode); |
fenetreFormulaire.show(); |
} |
} |
}; |
return ecouteur; |
} |
private Button creerBoutonSupprimer() { |
Button bouton = new Button(i18nC.supprimer()); |
bouton.setIcon(Images.ICONES.vcardSupprimer()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
PublicationAPersonne publicationSaisieSelectionnee = grille.getSelectionModel().getSelectedItem(); |
if (publicationSaisieSelectionnee == null) { |
Info.display(i18nC.informationTitreGenerique(), i18nC.selectionnerPublication()); |
} else { |
supprimerDansGrille(publicationSaisieSelectionnee); |
} |
} |
}); |
return bouton; |
} |
private Button creerBoutonRafraichir() { |
Button bouton = new Button(i18nC.rafraichir()); |
bouton.setIcon(Images.ICONES.rafraichir()); |
bouton.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
actualiserGrille(); |
} |
}); |
return bouton; |
} |
private void actualiserGrille() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerPublicationAPersonne(this, null, personneSelectionnee.getId(), "%"); |
} else { |
grille.getStore().removeAll(); |
layout(); |
} |
} |
private ComboBox<Publication> creerComboBoxPublicationsSaisis() { |
ListStore<Publication> publicationsSaisiesStore = new ListStore<Publication>(); |
ComboBox<Publication> comboBox = new ComboBox<Publication>(); |
comboBox.setWidth(400); |
comboBox.setEmptyText(i18nC.chercherPublicationSaisi()); |
comboBox.setTriggerAction(TriggerAction.ALL); |
comboBox.setEditable(true); |
comboBox.setDisplayField("fmt_nom_complet"); |
comboBox.setStore(publicationsSaisiesStore); |
comboBox.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (publicationsSaisiesComboBox.getRawValue() != null && publicationsSaisiesComboBox.getRawValue().length() > 0) { |
if (!ce.isNavKeyPress()) { |
obtenirPublicationsSaisies(publicationsSaisiesComboBox.getRawValue()); |
} |
} |
} |
}); |
comboBox.addListener(Events.Select, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
if (publicationsSaisiesComboBox.getValue() instanceof Publication) { |
Publication publicationSaisieSelectionne = publicationsSaisiesComboBox.getValue(); |
ajouterDansGrille(publicationSaisieSelectionne); |
publicationsSaisiesComboBox.setValue(null); |
} |
} |
}); |
return comboBox; |
} |
private void ajouterDansGrille(Publication publication) { |
ajouterDansGrille(publication, 0); |
} |
private void ajouterDansGrille(Publication publication, int index) { |
if (publication != null) { |
if (!listePublicationsLiees.containsKey(publication.getId())) { |
PublicationAPersonne publicationLiee = new PublicationAPersonne(); |
publicationLiee.setPersonne(personneSelectionnee); |
publicationLiee.setPublicationLiee(publication); |
publicationLiee.setIdPublication(publication.getId()); |
publicationLiee.set("_etat_", aDonnee.ETAT_AJOUTE); |
listePublicationsLiees.put(publication.getId(), publicationLiee); |
// Ajout à la grille |
grille.stopEditing(); |
grille.getStore().insert(publicationLiee, 0); |
grille.startEditing(index, 0); |
grille.getSelectionModel().select(index, false); |
} else { |
Info.display("Information", "La publication choisie existe déjà dans la liste."); |
} |
} |
} |
/** |
* Met à jour la grille avec les informations contenus dans la variable listePublicationsLiees |
*/ |
private void mettreAJourGrille() { |
grille.getStore().removeAll(); |
grille.getStore().add(listePublicationsLiees.toList()); |
} |
private void supprimerDansGrille(PublicationAPersonne publicationLiee) { |
if (publicationLiee != null) { |
// Ajout de la personne supprimée à la liste |
if ((publicationLiee.get("_etat_").equals("") || !publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) |
&& publicationLiee.getId() != null |
&& !publicationLiee.getId().equals("")) { |
Debug.log("Nbre publications supprimées avant:"+publicationsSupprimees.size()); |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
//GWT.log("Publications supprimée : "+publicationLiee.getIdPublication()+" "+publicationLiee.get.getNomComplet(), null); |
Debug.log("Nbre publications supprimées :"+publicationsSupprimees.size()); |
} |
// Suppression de l'enregistrement de la grille |
grille.getStore().remove(publicationLiee); |
} |
} |
private EditorGrid<PublicationAPersonne> creerGrille() { |
ListStore<PublicationAPersonne> storeGrille = new ListStore<PublicationAPersonne>(); |
storeGrille.addListener(Store.Add, new Listener<StoreEvent<PublicationAPersonne>>() { |
public void handleEvent(StoreEvent<PublicationAPersonne> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
storeGrille.addListener(Store.Remove, new Listener<StoreEvent<PublicationAPersonne>>() { |
public void handleEvent(StoreEvent<PublicationAPersonne> ce) { |
actualiserEtatBoutonsBarreOutils(); |
} |
}); |
RowNumberer numeroPlugin = new RowNumberer(); |
numeroPlugin.setHeader("#"); |
XTemplate infoTpl = XTemplate.create("<p>"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationAuteurs()+" :</span> {fmt_auteur}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationTitre()+" :</span> {titre}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationRevueCollection()+" :</span> {collection}<br />"+ |
"<span style='font-weight:bold;'>"+i18nC.publicationEditeur()+" :</span> {_editeur_}"+ |
"</p>"); |
RowExpander expansionPlugin = new RowExpander(); |
expansionPlugin.setTemplate(infoTpl); |
List<ColumnConfig> colonnes = new ArrayList<ColumnConfig>(); |
colonnes.add(expansionPlugin); |
colonnes.add(numeroPlugin); |
typeRelationCombo = new ComboBox<Valeur>(); |
typeRelationCombo.setForceSelection(true); |
typeRelationCombo.setTriggerAction(TriggerAction.ALL); |
typeRelationCombo.setDisplayField("nom"); |
typeRelationCombo.setStore(new ListStore<Valeur>()); |
typeRelationCombo.setEditable(false); |
typeRelationCombo.addStyleName(ComposantClass.OBLIGATOIRE); |
typeRelationCombo.addListener(Events.Select, Formulaire.creerEcouteurChampObligatoire()); |
CellEditor editeurRelation = new CellEditor(typeRelationCombo) { |
@Override |
public Object preProcessValue(Object valeur) { |
Valeur retour = null; |
if (valeur != null ) { |
Debug.log(valeur.toString()); |
if (typeRelationCombo.getStore().findModel("nom", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("nom", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("abr", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("abr", valeur.toString()); |
} else if (typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()) != null) { |
retour = typeRelationCombo.getStore().findModel("id_valeur", valeur.toString()); |
} |
} |
return retour; |
} |
@Override |
public Object postProcessValue(Object valeur) { |
String retour = null; |
if (valeur != null ) { |
if (valeur instanceof Valeur) { |
Valeur valeurOntologie = (Valeur) valeur; |
retour = valeurOntologie.getId(); |
} |
} |
return retour; |
} |
}; |
GridCellRenderer<PublicationAPersonne> relationRendu = new GridCellRenderer<PublicationAPersonne>() { |
@Override |
public String render(PublicationAPersonne modele, String property, ColumnData config, int rowIndex, int colIndex, ListStore<PublicationAPersonne> store, Grid<PublicationAPersonne> grille) { |
// Gestion du texte afficher dans la cellule |
String role = modele.get("_role_"); |
String roleNom = ""; |
if (typeRelationCombo.getStore() != null && role!=null && role.matches("[0-9]+")) { |
roleNom = typeRelationCombo.getStore().findModel("id_valeur", role).getNom(); |
role = typeRelationCombo.getStore().findModel("id_valeur", role).getId(); |
} |
modele.set("_role_", role); |
modele.set("_etat_", aDonnee.ETAT_MODIFIE); |
return roleNom; |
} |
}; |
ColumnConfig typeRelationColonne = new ColumnConfig("_role_", i18nC.typeRelationPersonneCollection(), 75); |
typeRelationColonne.setEditor(editeurRelation); |
typeRelationColonne.setRenderer(relationRendu); |
colonnes.add(typeRelationColonne); |
colonnes.add(new ColumnConfig("fmt_auteur", i18nC.publicationAuteurs(), 150)); |
colonnes.add(new ColumnConfig("titre", i18nC.publicationTitre(), 150)); |
colonnes.add(new ColumnConfig("collection", i18nC.publicationRevueCollection(), 75)); |
colonnes.add(creerColonneEditeur()); |
colonnes.add(creerColonneAnneePublication()); |
colonnes.add(new ColumnConfig("indication_nvt", i18nC.publicationNvt(), 75)); |
colonnes.add(new ColumnConfig("fascicule", i18nC.publicationFascicule(), 75)); |
colonnes.add(new ColumnConfig("truk_pages", i18nC.publicationPage(), 50)); |
GridSelectionModel<PublicationAPersonne> modeleDeSelection = new GridSelectionModel<PublicationAPersonne>(); |
ColumnModel modeleDeColonnes = new ColumnModel(colonnes); |
modeleDeColonnes.getColumn(0).setWidget(Images.ICONES.information().createImage(), "Info"); |
EditorGrid<PublicationAPersonne> grillePublications = new EditorGrid<PublicationAPersonne>(storeGrille, modeleDeColonnes); |
grillePublications.setHeight("100%"); |
grillePublications.setBorders(true); |
grillePublications.setSelectionModel(modeleDeSelection); |
grillePublications.addPlugin(expansionPlugin); |
grillePublications.addPlugin(numeroPlugin); |
grillePublications.getView().setForceFit(true); |
grillePublications.setAutoExpandColumn("titre"); |
grillePublications.setStripeRows(true); |
grillePublications.setTrackMouseOver(true); |
return grillePublications; |
} |
private ColumnConfig creerColonneEditeur() { |
GridCellRenderer<PublicationAPersonne> editeurRendu = new GridCellRenderer<PublicationAPersonne>() { |
@Override |
public String render(PublicationAPersonne model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<PublicationAPersonne> store, Grid<PublicationAPersonne> grid) { |
String editeur = model.getPublicationLiee().getNomEditeur(); |
model.set("_editeur_", editeur); |
return editeur; |
} |
}; |
ColumnConfig editeurColonne = new ColumnConfig("_editeur_", Mediateur.i18nC.publicationEditeur(), 135); |
editeurColonne.setRenderer(editeurRendu); |
return editeurColonne; |
} |
private ColumnConfig creerColonneAnneePublication() { |
GridCellRenderer<PublicationAPersonne> datePublicationRendu = new GridCellRenderer<PublicationAPersonne>() { |
@Override |
public String render(PublicationAPersonne model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<PublicationAPersonne> store, Grid<PublicationAPersonne> grid) { |
String annee = model.getPublicationLiee().getAnneeParution(); |
model.set("_annee_", annee); |
return annee; |
} |
}; |
ColumnConfig datePublicationColonne = new ColumnConfig("_annee_", Mediateur.i18nC.publicationDateParution(), 75); |
datePublicationColonne.setRenderer(datePublicationRendu); |
return datePublicationColonne; |
} |
public void actualiserEtatBoutonsBarreOutils() { |
// Activation des boutons si la grille contient un élément |
if (grille.getStore().getCount() > 0) { |
publicationsBoutonSupprimer.enable(); |
publicationsBoutonModifier.enable(); |
} |
// Désactivation des boutons si la grille ne contient plus d'élément |
if (grille.getStore().getCount() == 0) { |
publicationsBoutonSupprimer.disable(); |
publicationsBoutonModifier.disable(); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
rafraichirInformation(info); |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) { |
Formulaire.rafraichirComboBox(listeValeurs, typeRelationCombo); |
roles = listeValeurs.toList(); |
mettreAJourPersonne(); |
} |
} else if (nouvellesDonnees instanceof PublicationListe) { |
PublicationListe listePublications = (PublicationListe) nouvellesDonnees; |
rafraichirPublicationListe(listePublications); |
} else if (nouvellesDonnees instanceof PublicationAPersonneListe) { |
PublicationAPersonneListe papl = (PublicationAPersonneListe) nouvellesDonnees; |
List<PublicationAPersonne> paplListe = papl.toList(); |
if (paplListe.size()>0){ |
Iterator<PublicationAPersonne> it = paplListe.iterator(); |
while (it.hasNext()) { |
PublicationAPersonne pap = it.next(); |
listePublicationsLiees.put(pap.getPublicationLiee().getId(), pap); |
} |
mettreAJourGrille(); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
private void rafraichirPublicationListe(PublicationListe listePublications) { |
publicationsSaisiesComboBox.getStore().removeAll(); |
publicationsSaisiesComboBox.getStore().add(listePublications.toList()); |
publicationsSaisiesComboBox.expand(); |
} |
public void rafraichirInformation(Information info) { |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log("MESSAGES:\n"+info.getMessages().toString(), null); |
} |
String type = info.getType(); |
if (type.equals("publication_liees")) { |
if (info.getDonnee(0) != null) { |
initialiser(); |
personneSelectionnee.setPublicationsLiees((PublicationAPersonneListe) info.getDonnee(0)); |
peupler(); |
} |
} else if (type.equals("publication_modifiee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
PublicationAPersonne publicationDansGrille = grille.getStore().findModel("id_publication", publication.getId()); |
int index = grille.getStore().indexOf(publicationDansGrille); |
grille.getStore().remove(publicationDansGrille); |
ajouterDansGrille(publication, index); |
} |
} else if (type.equals("publication_ajoutee")) { |
if (info.getDonnee(0) != null) { |
Publication publication = (Publication) info.getDonnee(0); |
ajouterDansGrille(publication); |
} |
} else if (type.equals("suppression_collection_a_publication")) { |
Info.display("Suppression des publications liées à la collection", info.toString()); |
} else if (type.equals("ajout_collection_a_publication")) { |
Info.display("Ajout des publications liées à la collection", info.toString()); |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(info.getClass(), this.getClass()), null); |
} |
} |
public void peupler() { |
grille.getStore().removeAll(); |
grille.getStore().add(personneSelectionnee.getPublicationsLiees().toList()); |
layout(); |
Info.display(i18nC.chargementPublication(), i18nC.ok()); |
} |
public void collecter() { |
if (etreAccede()) { |
int nbrePublication = grille.getStore().getCount(); |
for (int i = 0; i < nbrePublication; i++) { |
PublicationAPersonne publicationLiee = grille.getStore().getAt(i); |
if (publicationLiee.get("_etat_") != null) { |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_MODIFIE)) { |
// Comme il est impossible de modifier les relations nous supprimons l'ancien enregistrement et ajoutons un nouveau avec le nouveau id_role |
publicationsSupprimees.put("id"+idGenere++, publicationLiee); |
PublicationAPersonne relationAAjouter = (PublicationAPersonne) publicationLiee.cloner(new PublicationAPersonne()); |
publicationsAjoutees.put("id"+idGenere++, relationAAjouter); |
Debug.log(publicationLiee.toString()); |
} |
if (publicationLiee.get("_etat_").equals(aDonnee.ETAT_AJOUTE)) { |
publicationsAjoutees.put("id"+idGenere++, publicationLiee); |
Debug.log(publicationLiee.toString()); |
} |
// Initialisation de la grille |
publicationLiee.set("_etat_", ""); |
} |
} |
grille.getStore().commitChanges(); |
} |
} |
public List verifier() { |
List lstMessageErreur = new LinkedList<String>(); |
//Vérifier les roles |
List<PublicationAPersonne> listePublis = grille.getStore().getModels(); |
Iterator<PublicationAPersonne> itPublis = listePublis.iterator(); |
while (itPublis.hasNext()) { |
PublicationAPersonne publi = itPublis.next(); |
if (UtilString.isEmpty((String) publi.get("_role_"))) { |
lstMessageErreur.add("Vous devez choisir le rôle de la relation " + (grille.getStore().indexOf(publi) + 1)); |
} |
} |
return lstMessageErreur; |
} |
public void soumettre() { |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
if (publicationsAjoutees.size() == 0 && publicationsSupprimees.size() == 0) { |
Info.display("Modification des publications liées", "Rien n'a été enregistré car le formulaire n'a pas été modifié."); |
} else { |
// Ajout des relations CollectionAPublication |
if (publicationsAjoutees.size() != 0) { |
//TODO : utiliser le role d'une liste déroulante |
mediateur.ajouterPublicationAPersonne(this, publicationsAjoutees, personneSelectionnee.getId(), null); |
} |
// Suppression des relations CollectionAPublication |
if (publicationsSupprimees.size() != 0) { |
mediateur.supprimerPublicationAPersonne(this, publicationsSupprimees); |
} |
} |
} |
} |
private void obtenirPublicationsSaisies(String nom) { |
mediateur.selectionnerPublicationParNomComplet(this, null, "%"+nom+"%"); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneVue.java |
---|
New file |
0,0 → 1,65 |
package org.tela_botanica.client.vues.personne; |
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.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.util.Debug; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.LayoutRegion; |
import com.extjs.gxt.ui.client.util.Margins; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.LayoutContainer; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; |
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; |
import com.google.gwt.core.client.GWT; |
public class PersonneVue extends LayoutContainer implements Rafraichissable { |
private PersonneListeVue panneauPersonneListe; |
private PersonneDetailVue panneauPersonneDetail; |
private Mediateur mediateur = null; |
public PersonneVue(Mediateur mediateur) { |
this.mediateur = mediateur; |
BorderLayout layout = new BorderLayout(); |
layout.setEnableState(false); |
setLayout(layout); |
panneauPersonneListe = new PersonneListeVue(); |
this.add(panneauPersonneListe, new BorderLayoutData(LayoutRegion.CENTER)); |
panneauPersonneDetail = new PersonneDetailVue(mediateur); |
BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, .5f, 200, 1000); |
southData.setSplit(true); |
southData.setMargins(new Margins(5, 0, 0, 0)); |
this.add(panneauPersonneDetail, southData); |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof Personne) { |
panneauPersonneDetail.rafraichir((Personne) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof PersonneListe) { |
panneauPersonneListe.rafraichir((PersonneListe) nouvellesDonnees); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
// Affichage des éventuels messages de déboguage ou d'alerte |
if (info.getMessages() != null && !info.getMessages().toString().equals("[]")) { |
GWT.log(info.getMessages().toString(), null); |
} |
// Traitement en fonction des types d'information |
if (info.getType().equals("liste_personne")) { |
panneauPersonneListe.rafraichir((PersonneListe) info.getDonnee(0)); |
Info.display("Chargement d'une liste de personnes", ""); |
} else { |
panneauPersonneListe.rafraichir(info); |
} |
} else { |
GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneListeVue.java |
---|
New file |
0,0 → 1,205 |
package org.tela_botanica.client.vues.personne; |
import java.util.ArrayList; |
import java.util.List; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
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.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.vues.BarrePaginationVue; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.SortDir; |
import com.extjs.gxt.ui.client.event.BaseEvent; |
import com.extjs.gxt.ui.client.event.ButtonEvent; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.event.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
import com.extjs.gxt.ui.client.event.SelectionListener; |
import com.extjs.gxt.ui.client.store.ListStore; |
import com.extjs.gxt.ui.client.widget.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.button.Button; |
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.Grid; |
import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
public class PersonneListeVue extends ContentPanel implements Rafraichissable { |
private Mediateur mediateur = null ; |
private Grid<Personne> grille = null; |
private ListStore<Personne> store = null; |
private BarrePaginationVue pagination = null; |
private ColumnModel modeleColonnes = null; |
private Button ajouter = null; |
private Button modifier = null; |
private Button supprimer = null; |
public PersonneListeVue() { |
mediateur = Registry.get(RegistreId.MEDIATEUR); |
setHeading(Mediateur.i18nC.personneListeLabel()); |
setLayout(new FitLayout()); |
//Définition de la barre d'outil |
ToolBar toolBar = new ToolBar(); |
ajouter = new Button(Mediateur.i18nC.ajouter()); |
ajouter.setIcon(Images.ICONES.ajouter()); |
ajouter.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicAjouterPersonne(); |
} |
}); |
toolBar.add(ajouter); |
modifier = new Button(Mediateur.i18nC.modifier()); |
modifier.setIcon(Images.ICONES.formModifier()); |
modifier.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
mediateur.clicModifierPersonne(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(modifier); |
supprimer = new Button(Mediateur.i18nC.supprimer()); |
supprimer.setIcon(Images.ICONES.supprimer()); |
supprimer.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
clicSupprimerPersonne(grille.getSelectionModel().getSelectedItems()); |
} |
}); |
toolBar.add(supprimer); |
setTopComponent(toolBar); |
// Définition des colomnes de la grille: |
List<ColumnConfig> lstColumns = new ArrayList<ColumnConfig>(); |
lstColumns.add(new ColumnConfig("id_personne", "Id", 45)); |
lstColumns.add(new ColumnConfig("nom", "Nom", 100)); |
lstColumns.add(new ColumnConfig("prenom", "Prénom", 100)); |
lstColumns.add(new ColumnConfig("fmt_nom_complet", "Nom Complet", 200)); |
lstColumns.add(new ColumnConfig("code_postal", "Code postal", 100)); |
lstColumns.add(new ColumnConfig("ville", "Ville", 100)); |
lstColumns.add(new ColumnConfig("_courriel_princ_", "Courriel", 200)); |
lstColumns.get(0).setHidden(true); |
lstColumns.get(1).setHidden(true); |
lstColumns.get(2).setHidden(true); |
modeleColonnes = new ColumnModel(lstColumns); |
// Définition de la grille |
GridSelectionModel<Personne> gsmSelectionGrille = new GridSelectionModel<Personne>(); |
gsmSelectionGrille.addSelectionChangedListener(new SelectionChangedListener<Personne>() { |
public void selectionChanged(SelectionChangedEvent<Personne> event) { |
Personne personneSelectionnee = (Personne) event.getSelectedItem(); |
clicListe(personneSelectionnee); |
} |
}); |
store = new ListStore<Personne>(); |
store.sort("fmt_nom_complet", SortDir.ASC); |
grille = new Grid<Personne>(store, modeleColonnes); |
grille.setSelectionModel(gsmSelectionGrille); |
grille.setWidth("100%"); |
grille.setAutoExpandColumn("fmt_nom_complet"); |
grille.getView().setAutoFill(true); |
grille.getView().setForceFit(true); |
grille.addListener(Events.ViewReady, new Listener<BaseEvent>() { |
@Override |
public void handleEvent(BaseEvent be) { |
grille.getStore().sort("fmt_nom_complet", SortDir.ASC); |
grille.getSelectionModel().select(0, false); |
} |
}); |
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){ |
@Override |
public void handleEvent(BaseEvent be) { |
modifier.fireEvent(Events.Select); |
} |
}); |
add(grille); |
// Définition de la barre de pagination |
pagination = new BarrePaginationVue(new PersonneListe(), mediateur); |
setBottomComponent(pagination); |
} |
private void clicListe(Personne personne) { |
if (personne != null && store.getCount() > 0) { |
mediateur.clicListePersonne(personne); |
} |
} |
private void clicSupprimerPersonne(List<Personne> personnesASupprimer) { |
if (store.getCount() > 0) { |
mediateur.clicSupprimerPersonne(this, personnesASupprimer); |
} |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if (nbreElementDuMagazin == 0) { |
supprimer.disable(); |
modifier.disable(); |
} else if (nbreElementDuMagazin > 0) { |
modifier.enable(); |
if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof PersonneListe) { |
PersonneListe listePersonnes = (PersonneListe) nouvellesDonnees; |
pagination.setlistePaginable(listePersonnes); |
pagination.rafraichir(listePersonnes.getPageTable()); |
if (listePersonnes != null) { |
List<Personne> liste = (List<Personne>) listePersonnes.toList(); |
store.removeAll(); |
store.add(liste); |
mediateur.desactiverChargement(); |
mediateur.actualiserPanneauCentral(); |
grille.fireEvent(Events.ViewReady); |
} |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("suppression_personne")) { |
Info.display("Suppression de personne", info.getMessages().toString()); |
pagination.getlistePaginable().recharger(); |
gererEtatActivationBouton(); |
} else if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else { |
Info.display("Erreur", info.getMessages().toString()); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
layout(); |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneDetailVue.java |
---|
New file |
0,0 → 1,368 |
package org.tela_botanica.client.vues.personne; |
import java.util.Collection; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.LinkedList; |
import java.util.MissingResourceException; |
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.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.util.Debug; |
import org.tela_botanica.client.vues.DetailVue; |
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.Html; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.form.FieldSet; |
import com.extjs.gxt.ui.client.widget.form.LabelField; |
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FlowLayout; |
import com.google.gwt.user.client.ui.Image; |
public class PersonneDetailVue extends DetailVue implements Rafraichissable { |
private TabPanel tabPanel; |
private Html entete; |
private TabItem tabIdentite; |
private TabItem tabAdresse; |
private TabItem tabInfosNat; |
private TabItem tabLogos; |
private HashMap hmLabelFieldRegion = new HashMap(); |
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG); |
private boolean ontologieRecue = false; |
private Personne personneAAfficher = null; |
private void chargerOntologie() { |
mediateur.obtenirListeValeurEtRafraichir(this, "pays"); |
mediateur.obtenirListeValeurEtRafraichir(this, "tel"); |
} |
public PersonneDetailVue(Mediateur mediateur) { |
super(mediateur); |
chargerOntologie(); |
mediateur.obtenirListeValeurEtRafraichir(this, "pays"); |
setLayout(new FitLayout()); |
entete = new Html(); |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE); |
ContentPanel panneauPrincipal = new ContentPanel(); |
panneauPrincipal.setLayout(new FitLayout()); |
panneauPrincipal.setHeaderVisible(false); |
panneauPrincipal.setBodyBorder(true); |
panneauPrincipal.setTopComponent(entete); |
tabIdentite = new TabItem(i18nC.personneIdentite()); |
tabIdentite.setLayout(new AnchorLayout()); |
tabIdentite.setScrollMode(Scroll.AUTO); |
tabAdresse = new TabItem(i18nC.personneAdresses()); |
tabAdresse.setLayout(new FitLayout()); |
tabAdresse.setScrollMode(Scroll.AUTO); |
tabInfosNat = new TabItem(i18nC.personneInfoNat()); |
tabInfosNat.setScrollMode(Scroll.AUTO); |
tabLogos = new TabItem(i18nC.personneLogos()); |
tabLogos.setScrollMode(Scroll.AUTO); |
tabLogos.setLayout(new FlowLayout()); |
tabPanel = new TabPanel(); |
tabPanel.setId(ComposantId.ZONE_DETAIL_CORPS); |
tabPanel.setBodyBorder(false); |
tabPanel.add(tabIdentite); |
tabPanel.add(tabAdresse); |
tabPanel.add(tabInfosNat); |
tabPanel.add(tabLogos); |
panneauPrincipal.add(tabPanel); |
add(panneauPrincipal); |
} |
public void afficherDetailPersonne(Personne personne) { |
if (personne != null) { |
String tplEntete = initialiserTplEntete(); |
Params enteteParams = new Params(); |
enteteParams.set("nom", (String) personne.get("fmt_nom_complet")); |
enteteParams.set("mail", (String) personne.getCourrielPrinc()); |
LinkedList lstLogos = (LinkedList) personne |
.getChaineDenormaliseAsMapOrList("truk_logo"); |
if (lstLogos != null && lstLogos.size() > 0) { |
tabLogos.removeAll(); |
String urlLogoPrinc = (String) lstLogos.get(0); |
if (!urlLogoPrinc.trim().equals("")) { |
tplEntete = "<div id='personne-logo-div'><img src='{image}' alt='logo' /></div>" |
+ tplEntete; |
enteteParams.set("image", urlLogoPrinc); |
} |
Iterator<String> itLogo = lstLogos.iterator(); |
while (itLogo.hasNext()) { |
String urlLogoCourant = itLogo.next(); |
Image imgCourante = new Image(urlLogoCourant); |
tabLogos.add(imgCourante); |
} |
tabLogos.enable(); |
} else { |
enteteParams.set("image", ""); |
tabLogos.disable(); |
} |
entete.el().setInnerHtml(Format.substitute(tplEntete, enteteParams)); |
String tplIdentite = initialiserTplIdentite(); |
Params tabIdentiteParams = new Params(); |
tabIdentiteParams.set("nom_complet", personne.getString("fmt_nom_complet")); |
tabIdentiteParams.set("abreviation", personne.getString("abreviation")); |
tabIdentiteParams.set("naissance_date", personne.getNaissanceDate()); |
tabIdentiteParams.set("naissance_lieu", personne.getString("naissance_lieu")); |
String tplDeces = ""; |
if (personne.estDecedee()) { |
tplDeces = " <h2>Décès:</h2>" |
+ " <span><b>" |
+ i18nC.personneDateDeces() |
+ ":</b></span> {deces_date}<br />" |
+ " <span><b>" |
+ i18nC.personneLieuDeces() |
+ ":</b></span> {deces_lieu}<br /><br />"; |
tabIdentiteParams.set("deces_date", personne.getDecesDate()); |
tabIdentiteParams.set("deces_lieu", personne.getString("deces_lieu")); |
} |
Params paramsDeces = new Params(); |
paramsDeces.set("tplDeces", tplDeces); |
tplIdentite = Format.substitute(tplIdentite, paramsDeces); |
tabIdentiteParams.set("description", personne.getString("description")); |
tabInfosNat.removeAll(); |
tabIdentiteParams.set("nom_autre", construireTxtTruck(personne.getString("truk_nom_autre"))); |
tabIdentiteParams.set("abreviation_autre", construireTxtTruck(personne.getString("truk_abreviation_autre"))); |
tplIdentite += construireTxtListeOntologie(personne.getString("truk_telephone")); |
// Courriel :Champ truk de la forme |
// "Adresse@adr.com;; adr2@adr.fr ..." |
LinkedList<String> listeCourriel = (LinkedList<String>) personne |
.getChaineDenormaliseAsMapOrList("truk_courriel"); |
if ((listeCourriel != null) && (listeCourriel.size() > 0)) { |
String strLabelCourriel = "Courriel"; |
if (listeCourriel.size() > 1) { |
strLabelCourriel += "s"; |
} |
String valeurCourriel = ""; |
Iterator<String> itCourriel = listeCourriel.iterator(); |
while (itCourriel.hasNext()) { |
String valeurCourante = itCourriel.next(); |
valeurCourriel += "<br /><a href=\"mailto:" |
+ valeurCourante + "\">" + valeurCourante + "</a>"; |
} |
tplIdentite += valeurCourriel; |
} |
// Url Site Webs |
LinkedList listeUrl = (LinkedList) personne |
.getChaineDenormaliseAsMapOrList("truk_url"); |
if (listeUrl != null && listeUrl.size() > 0) { |
tplIdentite += "<br /><br /><b>Sites web:</b><br /><span style='display:inline-block'>"; |
String strUrl = ""; |
Iterator<String> urlIt = listeUrl.iterator(); |
while (urlIt.hasNext()) { |
String urlCourante = urlIt.next(); |
strUrl += "<a href=\"" + urlCourante + "\">" + urlCourante |
+ "</a> <br/>"; |
} |
tplIdentite += strUrl + "</span><br />"; |
} |
tplIdentite += "</div>"; |
afficherOnglet(tplIdentite, tabIdentiteParams, tabIdentite); |
String tabAdresseTpl = "<div class='{css_corps}'>" |
+ " <div class='{css_fieldset}'>" |
+ " <h2>Adresse personnelle:</h2>" |
+ " <b>Adresse:</b> {adresse01} <br />" |
+ " <b>Complément d'adresse: </b>{adresse02} <br />" |
+ " <b>Boite postale: </b>{boitePostale}<br />" |
+ " <b>Code postal:</b>{codePostal} <br />" |
+ " <b>Région:</b>{region}<br />" |
+ " <span style='uppercase'>{pays}</span><br />" |
+ "</div>"; |
// Adresses : |
Params paramAdresseTpl = new Params(); |
paramAdresseTpl.set("adresse01", (String) personne |
.obtenirValeurChamp("adresse_01")); |
paramAdresseTpl.set("adresse02", (String) personne |
.obtenirValeurChamp("adresse_02")); |
paramAdresseTpl.set("boitePostale", (String) personne |
.obtenirValeurChamp("bp")); |
paramAdresseTpl.set("codePostal", (String) personne |
.obtenirValeurChamp("code_postal")); |
paramAdresseTpl.set("ville", (String) personne |
.obtenirValeurChamp("ville")); |
paramAdresseTpl.set("region", (String) personne |
.obtenirValeurChamp("region")); |
paramAdresseTpl.set("pays", (String) personne |
.obtenirValeurChamp("pays")); |
afficherOnglet(tabAdresseTpl, paramAdresseTpl, tabAdresse); |
tabAdresse.setStyleAttribute("padding", "15px"); |
// Infos naturalistes :Biographie, Spécialité (typé) |
String tplInfosNat = "<div class='{css_corps}'>" |
+ " <div class='{css_fieldset}'>" + " <h2>" |
+ i18nC.personneSpecialite() + "</h1>" |
+ " {specialites}" + " <h2>" |
+ i18nC.personneRecolte() + "</h2>" |
+ " {recoltes}" + " </div>" + "</div>"; |
Params prmInfosNat = new Params(); |
// TODO : replace id region par valeur |
String specialite = construireTxtTruck(personne.getSpecialite()); |
prmInfosNat.set("specialites", specialite); |
String recolte = construireTxtListeOntologie(personne.getString("truk_recolte")); |
prmInfosNat.set("recoltes", recolte); |
afficherOnglet(tplInfosNat, prmInfosNat, tabInfosNat); |
tabAdresse.setStyleAttribute("padding", "15px"); |
changerLabelRegions(); |
layout(); |
} |
} |
public String initialiserTplEntete() { |
return "<div id='{css_id}'>" + "<h1>{nom}</h1>" |
+ "<h2><a href='{mail}'>{mail}</a></h2>" + "</div>"; |
} |
public String initialiserTplIdentite() { |
return "<div class='{css_corps}'>" + " <div class='{css_fieldset}'>" |
+ " <h2>Noms:</h2>" + " <span><b>" |
+ i18nC.personneNomComplet() |
+ ":</b></span> {nom_complet}<br />" |
+ " <span><b>" |
+ i18nC.personneNomAutre() |
+ ":</b></span> {nom_autre}<br />" |
+ " <span><b>" |
+ i18nC.personneAbreviation() |
+ ":</b></span> {abreviation}<br />" |
+ " <span><b>" |
+ i18nC.personneAbreviationAutre() |
+ ":</b></b></span> {abreviation_autre}<br /><br />" |
+ " <h2>Naissance:</h2>" |
+ " <span><b>" |
+ i18nC.personneDateNaissance() |
+ ":</b></span> {naissance_date}<br />" |
+ " <span><b>" |
+ i18nC.personneLieuNaissance() |
+ ":</b></span> {naissance_lieu}<br /><br />" |
+ "{tplDeces}" |
+ " </div>" |
+ "</div>" |
+ "<div class='{css_corps}'>" |
+ " <div class='css_fieldset'> " |
+ " <h2>Description:</h2>" |
+ " {description}<br />" + " </div>" + "<br />"; |
} |
private void changerLabelRegions() { |
Collection<String> colClesComposants = hmLabelFieldRegion.keySet(); |
Iterator<String> itComposants = colClesComposants.iterator(); |
while (itComposants.hasNext()) { |
String region = itComposants.next(); |
mediateur.obtenirValeurEtRafraichir(this, "region", region); |
} |
} |
private void ajouterLabelField(FieldSet fs, String tfLabel, Object tfValue) { |
if ((tfValue != null) && (!tfValue.toString().trim().equals(""))) { |
LabelField tf = new LabelField(); |
tf.setFieldLabel(tfLabel + ":"); |
if ((tfLabel == null) || ("".equals(tfLabel))) { |
tf.setHideLabel(true); |
tf.setStyleAttribute("margin", "0 0 0 105px"); |
} |
tf.setValue(tfValue); |
// Ajout au fieldSet |
fs.add(tf); |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
// Si on a reçu une personne on en affiche les détails |
if (nouvellesDonnees instanceof Personne) { |
personneAAfficher = (Personne) nouvellesDonnees; |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe ontologieReceptionnee = (ValeurListe) nouvellesDonnees; |
ajouterListeValeursAOntologie(ontologieReceptionnee); |
ontologieRecue = true; |
// Remplacer ci-dessous par Ontologie |
ValeurListe listeValeur = (ValeurListe) nouvellesDonnees; |
if (listeValeur.getId().equals(config.getListeId("region"))) { |
Collection colCleListeValeur = listeValeur.keySet(); |
Iterator<String> itLv = colCleListeValeur.iterator(); |
while (itLv.hasNext()) { |
String idRegion = itLv.next(); |
Valeur region = listeValeur.get(idRegion); |
if (region != null) { |
String strRegionId = region.getAbreviation(); |
LinkedList<LabelField> listComposantsRegion = (LinkedList) hmLabelFieldRegion.get(strRegionId); |
for (int i = 0; i < listComposantsRegion.size(); i++) { |
LabelField lfRegion = listComposantsRegion.get(i); |
lfRegion.setFieldLabel(region.getNom()); |
} |
} |
} |
} |
} |
if (ontologieRecue && personneAAfficher != null) { |
afficherDetailPersonne(personneAAfficher); |
} |
} |
} |
/branches/v1.0-syrah/src/org/tela_botanica/client/vues/personne/PersonneForm.java |
---|
New file |
0,0 → 1,1278 |
package org.tela_botanica.client.vues.personne; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.LinkedList; |
import java.util.List; |
import org.tela_botanica.client.ComposantClass; |
import org.tela_botanica.client.Mediateur; |
import org.tela_botanica.client.RegistreId; |
import org.tela_botanica.client.composants.ChampMultiValeurs; |
import org.tela_botanica.client.composants.ChampMultiValeursImage; |
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes; |
import org.tela_botanica.client.composants.HashMapComposants; |
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.Information; |
import org.tela_botanica.client.modeles.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.modeles.personne.PersonneListe; |
import org.tela_botanica.client.modeles.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.modeles.publication.Publication; |
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe; |
import org.tela_botanica.client.modeles.publication.PublicationListe; |
import org.tela_botanica.client.util.Pattern; |
import org.tela_botanica.client.util.UtilString; |
import org.tela_botanica.client.vues.Formulaire; |
import com.extjs.gxt.ui.client.event.Events; |
import com.extjs.gxt.ui.client.Registry; |
import com.extjs.gxt.ui.client.Style.Scroll; |
import com.extjs.gxt.ui.client.Style.VerticalAlignment; |
import com.extjs.gxt.ui.client.binding.FormBinding; |
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.Listener; |
import com.extjs.gxt.ui.client.event.SelectionChangedEvent; |
import com.extjs.gxt.ui.client.event.SelectionChangedListener; |
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.ContentPanel; |
import com.extjs.gxt.ui.client.widget.Info; |
import com.extjs.gxt.ui.client.widget.TabItem; |
import com.extjs.gxt.ui.client.widget.TabPanel; |
import com.extjs.gxt.ui.client.widget.Text; |
import com.extjs.gxt.ui.client.widget.button.Button; |
import com.extjs.gxt.ui.client.widget.button.ButtonBar; |
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.FieldSet; |
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.RadioGroup; |
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.ComboBox.TriggerAction; |
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign; |
import com.extjs.gxt.ui.client.widget.layout.ColumnData; |
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout; |
import com.extjs.gxt.ui.client.widget.layout.FitLayout; |
import com.extjs.gxt.ui.client.widget.layout.FormData; |
import com.extjs.gxt.ui.client.widget.layout.FormLayout; |
import com.extjs.gxt.ui.client.widget.layout.RowLayout; |
import com.extjs.gxt.ui.client.widget.layout.TableData; |
import com.extjs.gxt.ui.client.widget.layout.TableLayout; |
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem; |
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.Widget; |
public class PersonneForm extends Formulaire implements Rafraichissable { |
// VARIABLES |
private TabItem tiIdentite, tiAdresses, tiInfosNat; |
PersonneFormPublication tiPubli; |
private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG); |
protected Personne personneSelectionnee, personneSauvegarde = null; |
//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite |
private HashMapComposants hmIdentite = new HashMapComposants(); |
private HashMapComposants hmAdresse = new HashMapComposants(); |
private HashMapComposants hmInfosNat = new HashMapComposants(); |
private HashMap<String, Valeur> hmCbSelectionnee = new HashMap(); |
private FormData fd100 = new FormData("95%"); |
private Button enregistrer, enregistrerEtRevenir; |
private Personne personne = null; |
private String personneId = null; |
private FormBinding binding = null; |
//Publi |
private ComboBox<Publication> cbPubli; |
private ListStore<Publication> storePubli; |
// CONSTRUCTEUR |
public PersonneForm(Mediateur mediateurCourrant, String personneId) { |
initialiserPersonneForm(mediateurCourrant, personneId); |
} |
public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) { |
vueExterneARafraichirApresValidation = vueARafraichirApresValidation; |
initialiserPersonneForm(mediateurCourrant, personneId); |
} |
private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) { |
personne = new Personne(); |
personne.setId(personneIdCourrant); |
personneId = personneIdCourrant; |
String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER); |
initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE); |
initialiserComposants(); |
genererTitreFormulaire(); |
mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication"); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerPersonne(this, personne, null); |
} |
} |
private void genererTitreFormulaire() { |
String titre = i18nC.personneModeAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId; |
} |
panneauFormulaire.setHeading(titre); |
} |
public void initialiserComposants() { |
personneSelectionnee = new Personne(); |
personneSauvegarde = new Personne(); |
initialiserOnglets(); |
creerComposantsIdentite(); |
creerComposantsAdresse(); |
creerComposantsInfosNat(); |
//creerComposantsPubli(); |
binderPersonne(personneSelectionnee); |
} |
/** |
* Crée les onglets identité, adresse et informations naturaliste |
* |
* */ |
public void initialiserOnglets() { |
//TabPanel |
TabPanel formulaireOnglets = new TabPanel(); |
//Tab 1 : identite |
tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite"); |
tiIdentite.setStyleAttribute("padding", "0"); |
formulaireOnglets.add(tiIdentite); |
//Tab 2 : Adresse |
tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses"); |
formulaireOnglets.add(tiAdresses); |
//Tab 3 : Infos Naturalistes |
tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat"); |
formulaireOnglets.add(tiInfosNat); |
tiPubli = new PersonneFormPublication(this); |
formulaireOnglets.add(tiPubli); |
getFormulaire().add(formulaireOnglets); |
} |
/** |
* Crée les widgets pour l'onglet identité |
* |
* */ |
public void creerComposantsIdentite() { |
// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
left.setStyleAttribute("padding", "15px"); |
LayoutContainer right = new LayoutContainer(); |
right.setLayout(new FormLayout()); |
right.setStyleAttribute("padding", "15px"); |
LayoutContainer main = new LayoutContainer(); |
main.add(left, new ColumnData(.45)); |
main.add(right, new ColumnData(.45)); |
main.setLayout(new ColumnLayout()); |
main.setHeight("100%"); |
main.setScrollMode(Scroll.AUTO); |
// Création des champs |
FormLayout formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.LEFT); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset PROJET |
FieldSet fsProjet = new FieldSet(); |
fsProjet.setHeading(i18nC.menuProjet()); |
fsProjet.setLayout(new FormLayout()); |
ListStore<Projet> storeProjets = new ListStore<Projet>(); |
ComboBox cbProjets = new ComboBox<Projet>(); |
cbProjets.setFieldLabel(i18nC.personneProjet()+ " :"); |
cbProjets.setEmptyText(i18nC.txtListeProjetDefaut()); |
cbProjets.setLabelSeparator(""); |
cbProjets.setDisplayField("nom"); |
cbProjets.setEditable(false); |
cbProjets.setTriggerAction(TriggerAction.ALL); |
cbProjets.setStore(storeProjets); |
cbProjets.setAllowBlank(false); |
cbProjets.addStyleName(ComposantClass.OBLIGATOIRE); |
cbProjets.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
fsProjet.add(cbProjets, new FormData(450, 0)); |
hmIdentite.put("cbProjets", cbProjets); |
mediateur.selectionnerProjet(this, null); |
left.add(fsProjet); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset NOM |
FieldSet fsNoms = new FieldSet(); |
fsNoms.setHeading("Noms"); |
fsNoms.setLayout(formLayout); |
// Nom complet : Affiché que si valeurs saisies |
LabelField nomComplet = new LabelField(); |
nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :"); |
nomComplet.hide(); |
fsNoms.add(nomComplet); |
hmIdentite.put("nomComplet", nomComplet); |
//Préfixe |
ListStore<Valeur> storePrefixe = new ListStore<Valeur>(); |
ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>(); |
cbPrefixe.setStore(storePrefixe); |
cbPrefixe.setDisplayField("nom"); |
cbPrefixe.setEmptyText("Choisissez le préfixe:"); |
cbPrefixe.setFieldLabel("Prefix"); |
fsNoms.add(cbPrefixe); |
hmIdentite.put("cbPrefixe", cbPrefixe); |
mediateur.obtenirListeValeurEtRafraichir(this, "prefixe"); |
//Prénom |
TextField<String> tfPrenom = new TextField<String>(); |
tfPrenom.setFieldLabel("Prénom"); |
tfPrenom.setName("prenom"); |
fsNoms.add(tfPrenom, new FormData(300, 0)); |
hmIdentite.put("tfPrenom", tfPrenom); |
//Nom |
TextField<String> tfNom = new TextField<String>(); |
tfNom.setFieldLabel("Nom"); |
tfNom.setAllowBlank(false); |
tfNom.setName("nom"); |
tfNom.addStyleName(ComposantClass.OBLIGATOIRE); |
tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire()); |
fsNoms.add(tfNom, new FormData(300, 0)); |
hmIdentite.put("tfNom", tfNom); |
//Suffixe |
ListStore<Valeur> storeSuffixe = new ListStore<Valeur>(); |
ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>(); |
cbSuffixe.setStore(storeSuffixe); |
cbSuffixe.setFieldLabel("Suffixe"); |
cbSuffixe.setDisplayField("nom"); |
cbSuffixe.setEmptyText("Choisissez un suffixe:"); |
fsNoms.add(cbSuffixe); |
hmIdentite.put("cbSuffixe", cbSuffixe); |
mediateur.obtenirListeValeurEtRafraichir(this, "suffixes"); |
TextField<String> tfAbreviation = new TextField<String>(); |
tfAbreviation.setFieldLabel("Abréviation"); |
tfAbreviation.setName("abreviation"); |
fsNoms.add(tfAbreviation); |
hmIdentite.put("tfAbreviation", tfAbreviation); |
TableLayout layoutAutreNoms = new TableLayout(2); |
layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP); |
LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms); |
ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150); |
hmIdentite.put("nomAutre", nomAutre); |
autresNoms.add(nomAutre, new TableData("200px", "15px")); |
ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150); |
hmIdentite.put("abreviationAutre", abreviationAutre); |
autresNoms.add(abreviationAutre, new TableData("200px", "15px")); |
fsNoms.add(autresNoms); |
left.add(fsNoms); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset NAISSANCE ET DÉCÈS |
FieldSet fsNaissanceEtDeces = new FieldSet(); |
fsNaissanceEtDeces.setHeading("Naissance et Décès"); |
fsNaissanceEtDeces.setLayout(new ColumnLayout()); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.TOP); |
LayoutContainer containerNaissance = new LayoutContainer(formLayout); |
DateField dfDateNaissance = new DateField(); |
dfDateNaissance.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy")); |
dfDateNaissance.setFieldLabel("Date de naissance"); |
dfDateNaissance.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa»."); |
containerNaissance.add(dfDateNaissance); |
hmIdentite.put("dfDateNaissance", dfDateNaissance); |
// Lieu naissance |
TextField<String> tfLieuNaissance = new TextField<String>(); |
tfLieuNaissance.setFieldLabel("Lieu de naissance"); |
tfLieuNaissance.setName("naissance_lieu"); |
containerNaissance.add(tfLieuNaissance); |
hmIdentite.put("tfLieuNaissance", tfLieuNaissance); |
fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5)); |
left.add(fsNaissanceEtDeces); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.TOP); |
LayoutContainer containerDeces = new LayoutContainer(formLayout); |
Radio rbEstDecedee = new Radio(); |
rbEstDecedee.setId("ce_deces"); |
rbEstDecedee.setBoxLabel("oui"); |
rbEstDecedee.setValueAttribute("1"); |
rbEstDecedee.setId("rbEstD"); |
rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() { |
public void handleEvent(ComponentEvent be) { |
if(((Radio) be.getComponent()).getValue().equals(true)) { |
hmIdentite.getDateField("dfDateDeces").setVisible(true); |
hmIdentite.getTextField("tfLieuDeces").setVisible(true); |
} else { |
DateField dfDateDeces = hmIdentite.getDateField("dfDateDeces"); |
dfDateDeces.setValue(null); |
dfDateDeces.setVisible(false); |
TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces"); |
tfLieuDeces.setValue(null); |
tfLieuDeces.setVisible(false); |
} |
} |
}); |
DateField dfDateDeces = new DateField(); |
dfDateDeces.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy")); |
dfDateDeces.setFormatValue(true); |
dfDateDeces.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa»."); |
dfDateDeces.setFieldLabel("Date de décès"); |
dfDateDeces.setVisible(false); |
containerDeces.add(dfDateDeces); |
hmIdentite.put("dfDateDeces", dfDateDeces); |
TextField<String> tfLieuDeces = new TextField<String>(); |
tfLieuDeces.setFieldLabel("Lieu de décès"); |
tfLieuDeces.setName("deces_lieu"); |
tfLieuDeces.setVisible(false); |
containerDeces.add(tfLieuDeces); |
hmIdentite.put("tfLieuDeces", tfLieuDeces); |
hmIdentite.put("rbEstDecedee", rbEstDecedee); |
Radio rbNestPasDecedee = new Radio(); |
rbNestPasDecedee.setValueAttribute("0"); |
rbNestPasDecedee.setBoxLabel("non"); |
rbNestPasDecedee.setValue(true); |
RadioGroup rbgDeces = new RadioGroup(); |
rbgDeces.setFieldLabel("Est décédée"); |
rbgDeces.add(rbEstDecedee); |
rbgDeces.add(rbNestPasDecedee); |
containerDeces.add(rbgDeces); |
fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5)); |
tiIdentite.add(main); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset CONTACT |
FieldSet fsContact = new FieldSet(); |
fsContact.setHeading("Contact"); |
fsContact.setLayout(new RowLayout()); |
ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100); |
telephones.initialiserType("tel"); |
fsContact.add(telephones, new FormData(450, 0)); |
hmIdentite.put("telephones", telephones); |
ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280); |
courriels.setValidation(Pattern.email, "moi@domaine.fr"); |
fsContact.add(courriels, new FormData(450, 0)); |
hmIdentite.put("courriels", courriels); |
LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout()); |
fsContact.add(lcCourrielContainer); |
hmIdentite.put("lcCourrielContainer", lcCourrielContainer); |
fsContact.add(new Text("")); |
ChampMultiValeurs sites = new ChampMultiValeurs("Sites web"); |
sites.setValeurParDefaut("http://"); |
sites.setValidation(Pattern.url, "http://www.monsite.com"); |
fsContact.add(sites); |
hmIdentite.put("sites", sites); |
right.add(fsContact); |
//+------------------------------------------------------------------------------------------------------------+ |
// Fieldset AUTRES INFOS |
FieldSet fsAutresInfos = new FieldSet(); |
fsAutresInfos.setHeading("Autres informations"); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.LEFT); |
fsAutresInfos.setLayout(formLayout); |
formLayout = new FormLayout(); |
formLayout.setLabelAlign(LabelAlign.TOP); |
LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout); |
ListStore<Valeur> storeSexe = new ListStore<Valeur>(); |
ComboBox<Valeur> cbSexe = new ComboBox<Valeur>(); |
cbSexe.setStore(storeSexe); |
cbSexe.setFieldLabel("Sexe"); |
cbSexe.setDisplayField("nom"); |
cbSexe.setEmptyText("Choisissez le sexe:"); |
cbSexe.setTypeAhead(true); |
cbSexe.setTriggerAction(TriggerAction.ALL); |
FormData fd = new FormData(); |
fd.setWidth(100); |
lcAutreInformations1.add(cbSexe, fd); |
hmIdentite.put("cbSexe", cbSexe); |
mediateur.obtenirListeValeurEtRafraichir(this, "sexe"); |
//Description |
TextArea taDescription = new TextArea(); |
taDescription.setEmptyText("Saisissez une description"); |
taDescription.setFieldLabel("Description"); |
taDescription.setWidth("100%"); |
taDescription.setName("description"); |
lcAutreInformations1.add(taDescription, new FormData(500, 200)); |
hmIdentite.put("taDescription", taDescription); |
fsAutresInfos.add(lcAutreInformations1); |
// Logo |
LayoutContainer lcLogoUrl = new LayoutContainer(); |
hmIdentite.put("lcLogoUrl", lcLogoUrl); |
ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos()); |
logo.setImageHeight("150px"); |
logo.setValeurParDefaut("http://"); |
logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg"); |
logo.setValeurBoutonSupprimer("Supprimer"); |
hmIdentite.put("logos", logo); |
lcLogoUrl.add(logo); |
fsAutresInfos.add(logo); |
LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout()); |
hmIdentite.put("lcAutreInformations2", lcAutreInformations2); |
fsAutresInfos.add(lcAutreInformations2); |
right.add(fsAutresInfos); |
//+------------------------------------------------------------------------------------------------------------+ |
// Ajout des évènements saisi |
KeyListener klNoms = new KeyListener() { |
public void componentKeyUp(ComponentEvent ev) { |
rafraichir(null); |
} |
}; |
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() { |
public void selectionChanged(SelectionChangedEvent se) { |
rafraichir(null); |
} |
}; |
cbPrefixe.addSelectionChangedListener(selectionChange); |
cbPrefixe.addKeyListener(klNoms); |
tfPrenom.addKeyListener(klNoms); |
tfNom.addKeyListener(klNoms); |
cbSuffixe.addSelectionChangedListener(selectionChange); |
} |
public void creerComposantsAdresse() { |
// Gauche |
LayoutContainer left = new LayoutContainer(); |
left.setLayout(new FormLayout()); |
left.setStyleAttribute("padding", "15px"); |
// Droite |
LayoutContainer right = new LayoutContainer(); |
right.setLayout(new FormLayout()); |
// Principal |
LayoutContainer main = new LayoutContainer(); |
main.setLayout(new TableLayout(2)); |
// Ajout au principal |
main.add(left); |
main.add(right); |
TextField<String> tfAdresse1 = new TextField(); |
tfAdresse1.setFieldLabel("Adresse"); |
tfAdresse1.setName("adresse_01"); |
left.add(tfAdresse1, fd100); |
hmAdresse.put("tfAdresse1", tfAdresse1); |
TextField<String> tfAdresse2 = new TextField(); |
tfAdresse2.setFieldLabel("Complément d'adresse"); |
tfAdresse2.setName("adresse_02"); |
left.add(tfAdresse2, fd100); |
hmAdresse.put("tfAdresse2", tfAdresse2); |
ComboBox<Valeur> cbPays = new ComboBox<Valeur>(); |
cbPays.setFieldLabel("Pays"); |
cbPays.setDisplayField("nom"); |
cbPays.setEmptyText("Sélectionnez le pays:"); |
ListStore<Valeur> storePays = new ListStore<Valeur>(); |
cbPays.setStore(storePays); |
right.add(cbPays, fd100); |
hmAdresse.put("cbPays", cbPays); |
SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() { |
public void selectionChanged(SelectionChangedEvent se) { |
// Rafraichir avec le pays sélectionné |
obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString()); |
//mettreAJourRegion(); |
} |
}; |
cbPays.addSelectionChangedListener(selectionChange); |
ComboBox<Valeur> cbRegion = new ComboBox<Valeur>(); |
cbRegion.setFieldLabel("Region"); |
cbRegion.setDisplayField("nom"); |
cbRegion.setEmptyText("Sélectionnez la région:"); |
cbRegion.setVisible(false); |
ListStore<Valeur> storeRegion = new ListStore<Valeur>(); |
cbRegion.setStore(storeRegion); |
right.add(cbRegion, fd100); |
hmAdresse.put("cbRegion", cbRegion); |
TextField<String> tfBoitePostale = new TextField<String>(); |
tfBoitePostale.setFieldLabel("Boite postale"); |
tfBoitePostale.setName("bp"); |
left.add(tfBoitePostale, fd100); |
hmAdresse.put("tfBoitePostale", tfBoitePostale); |
TextField<Integer> tfCodePostal = new TextField<Integer>(); |
tfCodePostal.setFieldLabel("Code postal"); |
tfCodePostal.setName("code_postal"); |
right.add(tfCodePostal, fd100); |
hmAdresse.put("tfCodePostal", tfCodePostal); |
TextField tfVille = new TextField(); |
tfVille.setFieldLabel("Ville"); |
tfVille.setName("ville"); |
right.add(tfVille, fd100); |
hmAdresse.put("tfVille", tfVille); |
// MAJ ComboBox |
mediateur.obtenirListeValeurEtRafraichir(this, "pays"); |
FieldSet fsAdresse = new FieldSet(); |
fsAdresse.setHeading("Adresse personnelle"); |
fsAdresse.add(main); |
tiAdresses.add(fsAdresse); |
} |
public void creerComposantsInfosNat() { |
FormLayout fl = new FormLayout(); |
fl.setLabelAlign(LabelAlign.TOP); |
FieldSet fsInfosNat = new FieldSet(); |
fsInfosNat.setLayout(fl); |
fsInfosNat.setTitle("Informations Naturaliste"); |
TextArea taBiographie = new TextArea(); |
taBiographie.setFieldLabel("Vie et renommée de l'auteur"); |
taBiographie.setWidth("400"); |
taBiographie.setName("biographie"); |
fsInfosNat.add(taBiographie, new FormData(800, 200)); |
ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite()); |
fsInfosNat.add(specialite); |
hmInfosNat.put("specialite", specialite); |
ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte(), 200, 200); |
recolte.initialiserType("pays"); |
hmInfosNat.put("recolte", recolte); |
fsInfosNat.add(recolte); |
tiInfosNat.add(fsInfosNat); |
} |
public void creerComposantsPubli(){ |
//Création des composants de l'onglet publication |
ContentPanel cp = new ContentPanel(); |
cp.setHeading("Publications dont la personne est le sujet"); |
cp.setIcon(Images.ICONES.table()); |
cp.setLayout(new FitLayout()); |
cp.setFrame(true); |
ToolBar toolBar = new ToolBar(); |
Button ajouterPubli = new Button("Ajouter"); |
ajouterPubli.setIcon(Images.ICONES.vcardAjouter()); |
ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
Window.alert("ajout publi"); |
/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE); |
ajouterMembreAGrillePersonnel(membreDuPersonnel);*/ |
} |
}); |
toolBar.add(ajouterPubli); |
toolBar.add(new SeparatorToolItem()); |
Button supprimerPubli = new Button("Supprimer"); |
supprimerPubli.setIcon(Images.ICONES.vcardSupprimer()); |
supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem(); |
if (personne != null) { |
// Ajout de la personne supprimée à la liste |
if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) { |
personnelSupprime.put(personne.getId(), personne); |
} |
// Suppression de l'enregistrement de la grille |
grillePersonnel.getStore().remove(personne); |
// Désactivation du bouton supprimer si la grille contient plus d'élément |
if (grillePersonnel.getStore().getCount() == 0) { |
//TODO : check : Item -> component |
ce.getComponent().disable(); |
} |
}*/ |
Window.alert("supprimer"); |
} |
}); |
toolBar.add(supprimerPubli); |
toolBar.add(new SeparatorToolItem()); |
Button rafraichirPersonnelBtn = new Button("Rafraichir"); |
rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir()); |
rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() { |
@Override |
public void componentSelected(ButtonEvent ce) { |
//rafraichirPersonnel(); |
Window.alert("rafraichir"); |
} |
}); |
toolBar.add(rafraichirPersonnelBtn); |
//Ajout d'une ComboBox |
storePubli = new ListStore<Publication>(); |
storePubli.add(new ArrayList<Publication>()); |
cbPubli = new ComboBox<Publication>(); |
cbPubli.setWidth(200); |
cbPubli.setEmptyText("Chercher une publication existante..."); |
cbPubli.setTriggerAction(TriggerAction.ALL); |
cbPubli.setEditable(true); |
cbPubli.setDisplayField("fmt_nom_complet"); |
cbPubli.setStore(storePubli); |
cbPubli.addKeyListener(new KeyListener() { |
public void componentKeyUp(ComponentEvent ce) { |
if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) { |
rafraichirPublicationsExistante(cbPubli.getRawValue()); |
} |
} |
}); |
toolBar.add(cbPubli); |
toolBar.add(new SeparatorToolItem()); |
cp.setTopComponent(toolBar); |
tiPubli.add(cp); |
} |
public void rafraichirPublicationsExistante(String nomPubli) { |
nomPubli +="%"; |
mediateur.selectionnerPublicationParNomComplet(this, null, nomPubli); |
} |
/** |
* Ajouter le bouton annuler à la barre d'outils donnée |
* |
* @param barreOutils la barre d'outils à modifier |
* */ |
public static void ajouterBoutonAnnuler(ButtonBar barreOutils) { |
// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente |
Button annuler = new Button("Revenir à la liste"); |
annuler.addSelectionListener(new SelectionListener<ButtonEvent>() { |
public void componentSelected(ButtonEvent ce) { |
((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes"); |
} |
}); |
annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER); |
barreOutils.add(annuler); |
} |
public void obtenirListeRegionParPays(String strPays) { |
mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays); |
} |
// RAFRAICHISSEMENT DU PANNEAU |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof PublicationAPersonneListe) { |
Information info = new Information(); |
info.setType("publication_liees"); |
info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees); |
tiPubli.rafraichir(info); |
} else if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees; |
// Créer une liste de valeurs |
List<Valeur> liste = new ArrayList<Valeur>(); |
for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) { |
liste.add(listeValeurs.get(it.next())); |
} |
if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication"))) { |
tiPubli.rafraichir(nouvellesDonnees); |
} else if (listeValeurs.getId().equals(config.getListeId("prefixe"))) { |
remplirCombobox("cbPrefixe", liste, "hmIdentite"); |
} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) { |
remplirCombobox("cbSuffixe", liste, "hmIdentite"); |
} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) { |
//Ajout de la valeur "Inconnu" |
ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe"); |
Valeur inconnu = new Valeur(); |
inconnu.set("nom", "Inconnu"); |
inconnu.set("id", "0"); |
liste.add(0, inconnu); |
remplirCombobox("cbSexe", liste, "hmIdentite"); |
/*List<Valeur> selection = new LinkedList<Valeur>(); |
selection.add(inconnu); |
cbSexe.setSelection(s);*/ |
} else if (listeValeurs.getId().equals(config.getListeId("tel"))) { |
remplirCombobox("cbTelephone", liste, "hmIdentite"); |
//Préselection du tél |
ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone"); |
cbTelephone.setValue(liste.get(1)); |
} else if (listeValeurs.getId().equals(config.getListeId("pays"))) { |
remplirCombobox("cbPays", liste, "hmAdresse"); |
} else if (listeValeurs.getId().equals(config.getListeId("region"))) { |
remplirCombobox("cbRegion", liste, "hmAdresse"); |
mettreAJourRegion(); |
hmAdresse.getComboBox("cbRegion").setVisible(true); |
} |
} else if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
List<Projet> liste = projets.toList(); |
ComboBox cbProjets = hmIdentite.getComboBox("cbProjets"); |
ListStore<Projet> storeProjets= cbProjets.getStore(); |
storeProjets.removeAll(); |
storeProjets.add(liste); |
cbProjets.setStore(storeProjets); |
} else if (nouvellesDonnees instanceof PublicationListe) { |
PublicationListe publicationListe = (PublicationListe) nouvellesDonnees; |
List<Publication> liste = publicationListe.toList(); |
storePubli.removeAll(); |
storePubli.add(liste); |
cbPubli.setStore(storePubli); |
} else if (nouvellesDonnees instanceof Information) { |
Information info = (Information) nouvellesDonnees; |
if (info.getType().equals("ajout_personne")) { |
if (info.getDonnee(0) != null) { |
personneSelectionnee.setId(info.getDonnee(0).toString()); |
GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null); |
Info.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")"); |
repandreRafraichissement(); |
if (clicBoutonvalidation) { |
mediateur.clicMenu(menuIdCourant); |
} |
} else { |
Info.display("Enregistrement", info.getMessages().toString()); |
} |
} else if (info.getType().equals("modification_personne")) { |
Info.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées."); |
repandreRafraichissement(); |
if (clicBoutonvalidation) { |
mediateur.clicMenu(menuIdCourant); |
} |
} else if (info.getType().equals("maj_utilisateur")) { |
gererEtatActivationBouton(); |
} else if (info.getDonnee(0) instanceof PersonneListe) { |
Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values(); |
Iterator itPersonneListe = colPersonneListe.iterator(); |
Personne personne = (Personne) itPersonneListe.next(); |
//TODO : Je vois pas l'intérêt des lignes ci dessous.. |
personneSauvegarde = new Personne(); |
personneSauvegarde = (Personne) personne.cloner(personneSauvegarde); |
binderPersonne(personne); |
mettreAJourPersonne(personne); |
nouvellesDonnees = null; |
} else { |
Info.display("messages", info.getMessages().toString()); |
} |
} |
if (nouvellesDonnees == null) { |
ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe"); |
//Met à jour le nom Complet du formulaire |
String valeurRetour = ""; |
// Prefixe |
String prefixe = ""; |
Valeur valPrefixe = cb.getValue(); |
if (valPrefixe != null) { |
prefixe = valPrefixe.getNom(); |
} else { |
prefixe = (String) cb.getRawValue(); |
} |
// Prénom |
String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue(); |
// Nom |
String nom = (String) hmIdentite.getTextField("tfNom").getValue(); |
// Suffixe |
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe"); |
String suffixe = ""; |
Valeur valSuffixe = cbSuffixe.getValue(); |
if (valSuffixe != null) { |
suffixe = valSuffixe.getNom(); |
} else { |
suffixe = (String) cbSuffixe.getRawValue(); |
} |
// Mettre à jour la valeur |
valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe; |
valeurRetour = valeurRetour.replaceAll("null", ""); |
hmIdentite.getLabelField("nomComplet").setValue(valeurRetour); |
if (!valeurRetour.trim().equals("")) { |
hmIdentite.getLabelField("nomComplet").show(); |
} else { |
hmIdentite.getLabelField("nomComplet").hide(); |
} |
} |
mediateur.masquerPopinChargement(); |
if (this.mode.equals(MODE_AJOUTER)) { |
gererEtatActivationBouton(); |
} |
} |
private void repandreRafraichissement() { |
if (vueExterneARafraichirApresValidation != null) { |
String type = "personne_modifiee"; |
if (mode.equals(Formulaire.MODE_AJOUTER)) { |
type = "personne_ajoutee"; |
} |
Information info = new Information(type); |
info.setDonnee(0, personneSelectionnee); |
vueExterneARafraichirApresValidation.rafraichir(info); |
} |
} |
private void mettreAJourRegion() { |
//Met à jour la combo box en sélectionnant la valeur enregistrée pour la personne |
ComboBox<Valeur> cbRegion = hmAdresse.getComboBoxValeur("cbRegion"); |
if (personneSelectionnee.get("ce_truk_region").toString().startsWith("AUTRE##")) { |
cbRegion.setRawValue(personneSelectionnee.get("ce_truk_region").toString().replaceFirst("^AUTRE##", "")); |
} else if (personneSelectionnee.get("ce_truk_region") != null && cbRegion.getStore().getCount() > 0) { |
Valeur valeurRegion = cbRegion.getStore().findModel("id_valeur", personneSelectionnee.get("ce_truk_region")); |
if (valeurRegion!=null) { |
cbRegion.setValue(valeurRegion); |
} |
} |
} |
private void mettreAJourPersonne(Personne personne) { |
//Mise à jour de la personne |
//Personne personne = (Personne) nouvellesDonnees; |
ComboBox cbProjets = hmIdentite.getComboBox("cbProjets"); |
cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet"))); |
//Prefixe |
String prefixe = personne.get("ce_truk_prefix"); |
ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe"); |
String prefixeCourant = personne.get("ce_truk_prefix"); |
if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null) { |
cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant)); |
} else { |
cbPrefixe.setRawValue(prefixeCourant); |
} |
hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom")); |
hmIdentite.getTextField("tfNom").setValue(personne.get("nom")); |
//Suffixe |
String suffixe = personne.get("ce_truk_suffixe"); |
ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe"); |
String suffixeCourant = personne.get("ce_truk_suffix"); |
if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null) { |
cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant)); |
} else { |
cbSuffixe.setRawValue(suffixeCourant); |
} |
hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre")); |
hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation")); |
hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre")); |
hmIdentite.getDateField("dfDateNaissance").setValue(personne.getDate("naissance_date")); |
hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu")); |
if (personne.estDecedee()) { |
hmIdentite.getDateField("dfDateDeces").setValue(personne.getDate("deces_date")); |
hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu")); |
Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee"); |
rbEstDecede.setValue(true); |
} |
hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone")); |
//Courriel |
hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel()); |
//Sites web |
hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url")); |
// Sexe |
String strSexe = personne.get("ce_sexe"); |
ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe"); |
if (cbSexe.getStore().findModel("id_valeur", strSexe) != null) { |
cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe)); |
} |
hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description")); |
//Logo |
hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo")); |
/*-------------------------------------------------- |
Adresse |
---------------------------------------------------*/ |
// Adresse |
hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01")); |
// Complément |
hmAdresse.getTextField("tfAdresse2").setValue((String) personne.get("adresse_02")); |
//Boite postale |
hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp")); |
//Pays |
String strPays = personne.get("ce_truk_pays"); |
ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays"); |
if (cbPays.getStore().findModel("id_valeur", strPays) != null) { |
cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays)); |
cbPays.fireEvent(Events.OnChange); |
} else { |
cbPays.setRawValue(strPays); |
} |
//Région : doit être chargé après chargement de la liste des régions... |
String strRegion = personne.get("ce_truk_region"); |
if ((strRegion!=null)&&(!strRegion.equals(""))) { |
ComboBox<Valeur> cbRegion = hmAdresse.getComboBoxValeur("cbRegion"); |
System.out.println(cbRegion.getStore().getCount()); |
cbRegion.setVisible(true); |
if (cbRegion.getStore().findModel("id_valeur", strRegion) != null) { |
cbRegion.setValue(cbRegion.getStore().findModel("id_valeur", strRegion)); |
} else { |
cbRegion.setRawValue(strRegion); |
} |
} |
//Cp |
hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal")); |
//Ville |
hmAdresse.getTextField("tfVille").setValue(personne.get("ville")); |
/*-------------------------------------------------------- |
* Infos naturalistes |
* -----------------------------------------------------*/ |
hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite")); |
String tr = personne.getString("truk_recolte"); |
hmInfosNat.getChampMultiValeursMultiTypes("recolte").peupler(tr); |
//Onglet publi |
tiPubli.mettreAJourPersonne(); |
gererEtatActivationBouton(); |
} |
public void remplirCombobox(String idComboBox, List liste, String hashMapId) { |
HashMap hm = null; |
if (hashMapId.equals("hmIdentite")) { |
hm = hmIdentite; |
} else if (hashMapId.equals("hmAdresse")){ |
hm = hmAdresse; |
} else { |
hm = hmInfosNat; |
} |
ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore(); |
store.removeAll(); |
store.add(liste); |
((ComboBox) hm.get(idComboBox)).setStore(store); |
} |
private void gererEtatActivationBouton() { |
/* if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false) { |
enregistrer.setEnabled(false); |
enregistrerEtRevenir.setEnabled(false); |
} else { |
enregistrer.setEnabled(true); |
enregistrerEtRevenir.setEnabled(true); |
}*/ |
} |
public void reinitialiserFormulaire() { |
mediateur.afficherPopinChargement(); |
mettreAJourPersonne(personneSauvegarde); |
mediateur.masquerPopinChargement(); |
} |
public void binderPersonne(Personne personne) { |
binding = new FormBinding(getFormulaire()); |
personneSelectionnee = personne; |
binding.autoBind(); |
binding.bind(personneSelectionnee); |
layout(); |
} |
private String obtenirValeurCombo(String strComboName) { |
String strValeur = ""; |
Valeur valeur; |
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName); |
if (combo == null) { |
combo = hmAdresse.getComboBoxValeur(strComboName); |
} |
strValeur = combo.getRawValue(); |
valeur = combo.getValue(); |
if (valeur != null) { |
strValeur = valeur.getId(); |
} |
return strValeur; |
} |
public boolean soumettreFormulaire() { |
tiPubli.collecter(); |
if (verifierFormulaire()) { |
tiPubli.soumettre(); |
mediateur.enregistrerPersonne(this, personneSelectionnee); |
} |
return true; |
} |
public boolean verifierFormulaire() { |
boolean success = true; |
LinkedList<String> lstMessageErreur = new LinkedList<String>(); |
ComboBox<Projet> cbProjets = hmIdentite.getComboBox("cbProjets"); |
Projet projet = cbProjets.getValue(); |
if (projet == null) { |
lstMessageErreur.add("Le projet n'a pas été renseigné"); |
} else { |
personneSelectionnee.set("ce_projet", projet.getId()); |
} |
String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue(); |
if ((strTfNom == null)||(strTfNom.trim().equals(""))) { |
lstMessageErreur.add("Le nom n'a pas été saisi"); |
} else { |
strTfNom = UtilString.ucFirst(strTfNom); |
personneSelectionnee.set("nom", strTfNom); |
} |
String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue(); |
personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom)); |
//Préparer les données |
ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe"); |
Valeur valeur; |
String strValeur = ""; |
valeur = combo.getValue(); |
if (valeur!=null) { |
personneSelectionnee.set("ce_sexe", valeur.getId()); |
} |
strValeur = obtenirValeurCombo("cbPrefixe"); |
personneSelectionnee.set("ce_truk_prefix", strValeur); |
strValeur = obtenirValeurCombo("cbSuffixe"); |
personneSelectionnee.set("ce_truk_suffix", strValeur); |
String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs(); |
personneSelectionnee.set("truk_nom_autre", nomAutre); |
String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs(); |
personneSelectionnee.set("truk_abreviation_autre", abreviationAutre); |
personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs()); |
//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id |
String strPrefixe = ""; |
combo = hmIdentite.getComboBoxValeur("cbPrefixe"); |
valeur = combo.getValue(); |
if (valeur != null) { |
strPrefixe = valeur.getNom(); |
} else { |
strPrefixe = combo.getRawValue(); |
} |
String strSuffixe = ""; |
combo = hmIdentite.getComboBox("cbSuffixe"); |
valeur = combo.getValue(); |
if (valeur != null) { |
strSuffixe = valeur.getNom() + " "; |
} else { |
strSuffixe = combo.getRawValue() +" "; |
} |
personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe); |
DateField dfDateNaissance = hmIdentite.getDateField("dfDateNaissance"); |
Date naissanceDate = dfDateNaissance.getValue(); |
personneSelectionnee.setNaissanceDate(naissanceDate); |
Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee"); |
if (rbEstDecedee.getValue() == true) { |
DateField dfDecesDate = hmIdentite.getDateField("dfDateDeces"); |
String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue(); |
personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu); |
} else { |
personneSelectionnee.setNonDecedee(); |
} |
strValeur = obtenirValeurCombo("cbPays"); |
personneSelectionnee.set("ce_truk_pays", strValeur); |
strValeur = obtenirValeurCombo("cbRegion"); |
ComboBox<Valeur> cbRegions = hmAdresse.getComboBoxValeur("cbRegion"); |
if (cbRegions.getStore().findModel("id", strValeur) == null) { |
strValeur = "AUTRE##" + strValeur; |
} |
personneSelectionnee.set("ce_truk_region", strValeur); |
personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs()); |
String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs(); |
personneSelectionnee.set("truk_logo", logoUrls); |
personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs()); |
//Infos Naturalistes |
String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs(); |
personneSelectionnee.set("truk_recolte", recolte); |
String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs(); |
personneSelectionnee.set("ce_truk_specialite", specialite); |
lstMessageErreur.addAll(tiPubli.verifier()); |
if (lstMessageErreur.size() != 0) { |
String strMessagesErreur = "<span><br />"; |
Iterator<String> itMessagesErreur = lstMessageErreur.iterator(); |
while (itMessagesErreur.hasNext()) { |
strMessagesErreur += "<br /> - " + itMessagesErreur.next(); |
} |
strMessagesErreur += "</span>"; |
MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null); |
success = false; |
} |
return success; |
} |
} |