Subversion Repositories eFlore/Applications.coel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1414 → Rev 1415

/trunk/src/org/tela_botanica/client/vues/projet/ProjetDetailVue.java
New file
0,0 → 1,300
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.synchronisation.Sequenceur;
import org.tela_botanica.client.util.Debug;
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.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;
 
private Sequenceur sequenceur;
public ProjetDetailVue(Mediateur mediateurCourant, Sequenceur sequenceur) {
super(mediateurCourant);
this.sequenceur = sequenceur;
initialiserTousLesTpl();
panneauPrincipal = new ContentPanel();
panneauPrincipal.setLayout(new FitLayout());
panneauPrincipal.setHeaderVisible(false);
panneauPrincipal.setBodyBorder(false);
panneauPrincipal.setScrollMode(Scroll.AUTO);
entete = new Html();
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
panneauPrincipal.setTopComponent(entete);
contenu = new Html();
panneauPrincipal.add(contenu);
add(panneauPrincipal);
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId, sequenceur);
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId, sequenceur);
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeLanguesId, sequenceur);
}
 
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());
 
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) {
if (Mediateur.DEBUG) System.out.println("|| ProjetDetailVue > Réception d'un Projet");
projet = (Projet) nouvellesDonnees;
projetChargementOk = true;
} else if (nouvellesDonnees instanceof ProjetListe) {
if (Mediateur.DEBUG) System.out.println("|| ProjetDetailVue > Réception d'une ProjetListe");
projets = (ProjetListe) nouvellesDonnees;
projetsChargementOk = true;
} else if(nouvellesDonnees instanceof ValeurListe) {
if (Mediateur.DEBUG) System.out.println("|| ProjetDetailVue > Réception d'une 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();
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetDetailVue.java:r1136-1368
/trunk/src/org/tela_botanica/client/vues/projet/ProjetForm.java
New file
0,0 → 1,482
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.composants.ChampComboBoxRechercheTempsReelPaginable;
import org.tela_botanica.client.composants.InfoLogger;
import org.tela_botanica.client.composants.pagination.ProxyValeur;
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.projet.Projet;
import org.tela_botanica.client.synchronisation.Sequenceur;
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.Style.Scroll;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelType;
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 ChampComboBoxRechercheTempsReelPaginable 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 Sequenceur sequenceur = new Sequenceur();
 
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());
panneauFormulaire.setScrollMode(Scroll.AUTO);
genererTitreFormulaire();
creerZoneGeneralites();
panneauFormulaire.add(generalitesFieldset);
creerZoneComplement();
panneauFormulaire.add(complementFieldset);
creerZoneIndexation();
panneauFormulaire.add(indexationFieldset);
creerTabIndex();
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
mediateur.selectionnerProjet(this, projetId, null);
}
}
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));
ModelType modelTypesLangues = new ModelType();
modelTypesLangues.setRoot("valeurs");
modelTypesLangues.setTotalName("nbElements");
modelTypesLangues.addField("cmlv_nom");
modelTypesLangues.addField("cmlv_id_valeur");
modelTypesLangues.addField("cmlv_abreviation");
modelTypesLangues.addField("cmlv_description");
String displayNameLangues = "cmlv_nom";
String nomListeTypes = "langues";
ProxyValeur<ModelData> proxyLangues = new ProxyValeur<ModelData>(nomListeTypes, sequenceur);
langueChp = new ChampComboBoxRechercheTempsReelPaginable(proxyLangues, modelTypesLangues, displayNameLangues);
langueChp.setWidth(100,300);
langueChp.getCombo().setTabIndex(tabIndex++);
langueChp.getCombo().setFieldLabel(i18nC.projetLangue());
langueChp.getCombo().setForceSelection(true);
complementFieldset.add(langueChp, new FormData(300, 0));
markPublicChp = new CheckBox();
markPublicChp.setFieldLabel(i18nC.projetMarkPublic());
markPublicChp.addListener(Events.Change, new Listener<BaseEvent>() {
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>() {
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();
controlerFermeture();
}
}
 
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")) {
InfoLogger.display(i18nC.projetTitreFormModif(), info.toString());
} else if (type.equals("modif_projet")) {
InfoLogger.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);
InfoLogger.display(i18nC.projetTitreFormAjout(), "Le projet '"+projetId+"' a bien été ajouté");
} else {
InfoLogger.display(i18nC.projetTitreFormAjout(), info.toString(), true);
}
}
}
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());
if (projet.getLangue().matches("[0-9]+")) {
langueChp.getCombo().setValue(langueChp.getStore().findModel("cmlv_id_valeur", projet.getLangue()));
} else {
langueChp.getCombo().setRawValue(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());
if (langueChp.getValeur() != null) {
Valeur valeur = new Valeur(langueChp.getValeur());
projetCollecte.setLangue(valeur.getId());
} else {
projetCollecte.setLangue("");
}
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;
}
return projetARetourner;
}
public void reinitialiserFormulaire() {
if (mode.equals(Formulaire.MODE_MODIFIER)) {
mediateur.afficherFormProjet(projet.getId());
} else {
mediateur.afficherFormProjet(null);
}
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetForm.java:r1136-1368
/trunk/src/org/tela_botanica/client/vues/projet/ProjetVue.java
New file
0,0 → 1,73
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.synchronisation.Sequenceur;
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;
private Sequenceur sequenceur = new Sequenceur();
 
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, sequenceur);
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);
sequenceur.enfilerRafraichissement(panneauProjetDetail, (Projet) nouvellesDonnees);
} else if (nouvellesDonnees instanceof ProjetListe) {
panneauProjetListe.rafraichir((ProjetListe) 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_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();
}
 
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetVue.java:r1136-1368
/trunk/src/org/tela_botanica/client/vues/projet/ProjetListeVue.java
New file
0,0 → 1,224
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.composants.InfoLogger;
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>() {
public void handleEvent(BaseEvent be) {
grille.getSelectionModel().select(0, false);
}
});
grille.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
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";
}
InfoLogger.display(i18nC.projetTitreSuppression(), message, true);
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);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet/ProjetListeVue.java:r1136-1368
/trunk/src/org/tela_botanica/client/vues/projet/.
New file
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/vues/projet:r1136-1291