/trunk/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(); |
} |
} |
/trunk/src/org/tela_botanica/client/vues/projet/ProjetListeVue.java |
---|
New file |
0,0 → 1,207 |
package org.tela_botanica.client.vues.projet; |
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.projet.Projet; |
import org.tela_botanica.client.modeles.projet.ProjetListe; |
import org.tela_botanica.client.util.Debug; |
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 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); |
} |
public ListStore<Projet> getStore() { |
return store; |
} |
private void clicListe(Projet projet) { |
mediateur.clicListeProjet(projet); |
} |
private void gererEtatActivationBouton() { |
int nbreElementDuMagazin = store.getCount(); |
ajouter.enable(); |
if(!((Utilisateur)Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie()) { |
supprimer.disable(); |
modifier.disable(); |
} else { |
if (nbreElementDuMagazin <= 0) { |
supprimer.disable(); |
modifier.disable(); |
} else { |
supprimer.enable(); |
modifier.enable(); |
} |
} |
} |
public void rafraichir(Object nouvellesDonnees) { |
if (nouvellesDonnees instanceof ProjetListe) { |
ProjetListe projets = (ProjetListe) nouvellesDonnees; |
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); |
} |
Info.display(i18nC.projetTitreSuppression(), message); |
supprimerProjetsSelectionnees(); |
gererEtatActivationBouton(); |
} |
} else { |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null); |
} |
} |
public void supprimerProjetsSelectionnees() { |
List<Projet> selPub = grille.getSelectionModel().getSelectedItems(); |
GWT.log("Le résultat dans supprimer est : "+grille.getSelectionModel().getSelection().size()+" ", null); |
for(Iterator<Projet> it = selPub.iterator(); it.hasNext();) { |
GWT.log("Le résultat dans rafraichir est : "+grille.getSelectionModel().getSelection().size()+" ", null); |
grille.getStore().remove(it.next()); |
} |
layout(true); |
} |
} |
/trunk/src/org/tela_botanica/client/vues/projet/ProjetDetailVue.java |
---|
New file |
0,0 → 1,257 |
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.vues.collection.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 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(); |
} |
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 />"+ |
" </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_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 />"+ |
" <span class='{css_label}'>{i18n_mark_public} :</span> {mark_public}<br />"+ |
" </div>"+ |
"</div>"; |
} |
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_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_indexation_heure", i18nC.projetIndexationHeure()); |
contenuParams.set("indexation_heure", projet.getIndexationHeure()); |
contenuParams.set("i18n_indexation_duree", i18nC.projetIndexationDuree()); |
contenuParams.set("indexation_duree", obtenirValeurIndexationDuree(projet.getIndexationDuree())); |
contenuParams.set("i18n_indexation_frequence", i18nC.projetIndexationFrequence()); |
contenuParams.set("indexation_frequence", obtenirValeurIndexationFrequence(projet.getIndexationFreq())); |
contenuParams.set("i18n_mark_public", i18nC.projetMarkPublic()); |
contenuParams.set("mark_public", obtenirValeurPublic(projet.getMarkPublic())); |
String gHtml = formaterContenu(contenuTpl, contenuParams); |
contenu.getElement().setInnerHTML(gHtml); |
} |
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(); |
} |
} |
/trunk/src/org/tela_botanica/client/vues/projet/ProjetForm.java |
---|
New file |
0,0 → 1,532 |
package org.tela_botanica.client.vues.projet; |
import java.util.ArrayList; |
import java.util.Iterator; |
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.MenuApplicationId; |
import org.tela_botanica.client.modeles.Valeur; |
import org.tela_botanica.client.modeles.ValeurListe; |
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.Style.SortDir; |
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.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 int listeValeurIndexationDureeInt = 1072; |
private String listeValeurIndexationFrequenceId = "frequencesIndexation"; |
private int listeValeurIndexationFrequenceInt = 1073; |
private String listeLanguesId = "langues"; |
private int listeLanguesInt = 1071; |
private ListStore<Valeur> listeIndexationDuree = null; |
private ListStore<Valeur> listeIndexationFrequence = null; |
private ListStore<Valeur> listeLangue = null; |
private ValeurListe valeurListeIndexationDuree = null; |
private ValeurListe valeurListeIndexationFrequence = null; |
private ValeurListe valeurListeLangue = null; |
private boolean listeIndexationDureeChargee = false; |
private boolean listeIndexationFrequenceChargee = false; |
private boolean listeLangueChargee = false; |
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 ComboBox<Valeur> langueChp = null; |
private CheckBox markPublicChp = null; |
private FieldSet indexationFieldset = null; |
private TextField<String> indexationHeureChp = null; |
private ComboBox<Valeur> indexationDureeChp = null; |
private ComboBox<Valeur> 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()); |
actualiserTitreFormulaire(); |
creerZoneGeneralites(); |
panneauFormulaire.add(generalitesFieldset); |
creerZoneComplement(); |
panneauFormulaire.add(complementFieldset); |
creerZoneIndexation(); |
panneauFormulaire.add(indexationFieldset); |
creerTabIndex(); |
if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) { |
mediateur.selectionnerProjet(this, projetId); |
} |
mediateur.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId); |
mediateur.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId); |
mediateur.obtenirListeValeurEtRafraichir(this, listeLanguesId); |
} |
private void actualiserTitreFormulaire() { |
String titre = i18nC.projetTitreFormAjout(); |
if (mode.equals(Formulaire.MODE_MODIFIER)) { |
titre = i18nC.projetTitreFormModif()+" - "+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("Nom"); |
generalitesFieldset.add(nomChp, new FormData(450, 0)); |
abreviationChp = new TextField<String>(); |
abreviationChp.setFieldLabel("Abréviation"); |
generalitesFieldset.add(abreviationChp, new FormData(450, 0)); |
descriptionChp = new TextArea(); |
descriptionChp.setFieldLabel("Description"); |
generalitesFieldset.add(descriptionChp, new FormData(450, 0)); |
resumeChp = new TextArea(); |
resumeChp.setFieldLabel("Résumé"); |
generalitesFieldset.add(resumeChp, new FormData(450, 0)); |
urlChp = new TextField<String>(); |
urlChp.setFieldLabel("URL du projet"); |
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("Mots Clés"); |
complementFieldset.add(motsClesChp); |
citationChp = new TextField<String>(); |
citationChp.setFieldLabel("Citation"); |
complementFieldset.add(citationChp); |
licenceChp = new TextField<String>(); |
licenceChp.setFieldLabel("Licence"); |
complementFieldset.add(licenceChp); |
listeLangue = new ListStore<Valeur>(); |
langueChp = new ComboBox<Valeur>(); |
langueChp.setStore(listeLangue); |
langueChp.setDisplayField("nom"); |
langueChp.setEditable(true); |
langueChp.setForceSelection(true); |
langueChp.setTypeAhead(true); |
langueChp.setFieldLabel("Langue"); |
complementFieldset.add(langueChp); |
markPublicChp = new CheckBox(); |
markPublicChp.setFieldLabel("Public"); |
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); |
indexationHeureChp = new TextField<String>(); |
indexationHeureChp.setFieldLabel(i18nC.projetIndexationHeure()); |
indexationFieldset.add(indexationHeureChp, new FormData(80, 0)); |
// liste 1073 |
listeIndexationFrequence = new ListStore<Valeur>(); |
indexationFrequenceChp = new ComboBox<Valeur>(); |
indexationFrequenceChp.setStore(listeIndexationFrequence); |
indexationFrequenceChp.setDisplayField("nom"); |
indexationFrequenceChp.setEditable(true); |
indexationFrequenceChp.setForceSelection(true); |
indexationFrequenceChp.setTypeAhead(true); |
indexationFrequenceChp.setFieldLabel(i18nC.projetIndexationFrequence()); |
indexationFieldset.add(indexationFrequenceChp, new FormData(120, 0)); |
// liste 1072 |
listeIndexationDuree = new ListStore<Valeur>(); |
indexationDureeChp = new ComboBox<Valeur>(); |
indexationDureeChp.setStore(listeIndexationDuree); |
indexationDureeChp.setDisplayField("nom"); |
indexationDureeChp.setEditable(true); |
indexationDureeChp.setForceSelection(true); |
indexationDureeChp.setTypeAhead(true); |
indexationDureeChp.setFieldLabel(i18nC.projetIndexationDuree()); |
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 if (nouvellesDonnees instanceof ValeurListe) { |
ValeurListe valeursListe = (ValeurListe) nouvellesDonnees; |
rafraichirValeurListe(valeursListe); |
Debug.log("une liste de valeurs est arrivée "+valeursListe.getId()); |
} |
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(); |
actualiserTitreFormulaire(); |
} else if (type.equals("modif_projet") || type.equals("ajout_projet") ) { |
if (info.getDonnee(0) != null && info.getDonnee(0) instanceof String) { |
String projetId = (String) info.getDonnee(0); |
projet.setId(projetId); |
projetValideOk = true; |
} |
} |
// 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 (!UtilString.isEmpty(projet.getId())) { |
info.setMessage("Le projet '"+projet.getId()+"' a bien été ajouté"); |
} |
Info.display(i18nC.projetTitreFormAjout(), info.toString()); |
} |
} |
private void rafraichirValeurListe(ValeurListe valeursListe) { |
if (valeursListe.getId() == listeValeurIndexationDureeInt) { |
valeurListeIndexationDuree = valeursListe; |
for (Iterator<String> it = valeursListe.keySet().iterator(); it.hasNext();) { |
listeIndexationDuree.add(valeursListe.get(it.next())); |
listeIndexationDuree.sort("id_valeur", SortDir.ASC); |
} |
listeIndexationDureeChargee = true; |
if (mode.equals(MODE_MODIFIER)) { |
if (valeurListeIndexationDuree.get(projet.getIndexationDuree()) != null) { |
indexationDureeChp.setValue(valeurListeIndexationDuree.get(projet.getIndexationDuree())); |
indexationDureeChp.validate(); |
} |
} |
indexationDureeChp.expand(); |
} else if (valeursListe.getId() == listeValeurIndexationFrequenceInt) { |
valeurListeIndexationFrequence = valeursListe; |
for (Iterator<String> it = valeursListe.keySet().iterator(); it.hasNext();) { |
listeIndexationFrequence.add(valeursListe.get(it.next())); |
listeIndexationFrequence.sort("id_valeur", SortDir.ASC); |
} |
listeIndexationFrequenceChargee = true; |
if (mode.equals(MODE_MODIFIER)) { |
if (valeurListeIndexationFrequence.get(projet.getIndexationFreq()) != null) { |
indexationFrequenceChp.setValue(valeurListeIndexationFrequence.get(projet.getIndexationFreq())); |
indexationFrequenceChp.validate(); |
} |
} |
indexationFrequenceChp.expand(); |
} else if (valeursListe.getId() == listeLanguesInt) { |
valeurListeLangue = valeursListe; |
for (Iterator<String> it = valeursListe.keySet().iterator(); it.hasNext();) { |
listeLangue.add(valeursListe.get(it.next())); |
listeLangue.sort("id_valeur", SortDir.ASC); |
} |
listeLangueChargee = true; |
if (mode.equals(MODE_MODIFIER)) { |
if (valeurListeLangue.get(projet.getLangue()) != null) { |
langueChp.setValue(valeurListeLangue.get(projet.getLangue())); |
langueChp.validate(); |
} |
} |
} |
} |
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("Veuillez saisir le nom du projet !"); |
} |
String abr = abreviationChp.getValue(); |
if (abr == null || abr.equals("")) { |
messages.add("Veuillez saisir l'abréviation du projet !"); |
} |
String desc = descriptionChp.getValue(); |
if (desc == null || desc.equals("")) { |
messages.add("Veuillez saisir la description du projet !"); |
} |
String resume = resumeChp.getValue(); |
if (resume == null || resume.equals("")) { |
messages.add("Veuillez saisir le résumé du projet !"); |
} |
String uri = urlChp.getValue(); |
if (uri != null && ! uri.trim().isEmpty() && ! uri.matches(Pattern.url)) { |
messages.add("L'URL saisie n'est pas valide !"); |
} |
String heure = indexationHeureChp.getValue(); |
if (!UtilString.isEmpty(heure)) { |
if (!heure.matches(Pattern.heureMinute)) { |
messages.add("L'heureMinute d'indexation saisie n'est pas valide !"); |
} |
} |
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() { |
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.getMarkPublic().equals("1")) { |
markPublicChp.setValue(true); |
} else { |
markPublicChp.setValue(false); |
} |
if (listeLangueChargee) { |
if(valeurListeLangue.get(projet.getLangue()) != null) { |
langueChp.setValue(valeurListeLangue.get(projet.getLangue())); |
langueChp.validate(); |
} |
} |
if (listeIndexationFrequenceChargee) { |
if (valeurListeIndexationFrequence.get(projet.getIndexationFreq()) != null) { |
indexationFrequenceChp.setValue(valeurListeIndexationFrequence.get(projet.getIndexationFreq())); |
indexationFrequenceChp.validate(); |
} |
} |
if (listeIndexationDureeChargee) { |
if (valeurListeIndexationDuree.get(projet.getIndexationDuree()) != null) { |
indexationDureeChp.setValue(valeurListeIndexationDuree.get(projet.getIndexationDuree())); |
indexationDureeChp.validate(); |
} |
} |
String[] heureTab = projet.getIndexationHeure().split(":"); |
if (heureTab.length > 1) { |
String heure = heureTab[0]+":"+heureTab[1]; |
if (heure.matches(Pattern.heureMinute)) { |
indexationHeureChp.setValue(heure); |
} |
} |
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.getValue() != null) { |
projetCollecte.setLangue(langueChp.getValue().getId()); |
} |
String markPublic = (markPublicChp.getValue()) ? "1" : "0"; |
projetCollecte.setMarkPublic(markPublic); |
projetCollecte.setIndexationHeure(indexationHeureChp.getValue()); |
if (indexationFrequenceChp.getValue() != null) { |
projetCollecte.setIndexationFreq(indexationFrequenceChp.getValue().getId()); |
} |
if (indexationDureeChp.getValue() != null) { |
projetCollecte.setIndexationDuree(indexationDureeChp.getValue().getId()); |
} |
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); |
} |
} |
} |