Subversion Repositories eFlore/Applications.coel

Rev

Rev 851 | Rev 860 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 851 Rev 858
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line -...
2
 
-
 
3
import java.util.HashMap;
-
 
4
 
2
 
-
 
3
import org.tela_botanica.client.Mediateur;
5
import org.tela_botanica.client.Mediateur;
4
import org.tela_botanica.client.composants.ChampComboBoxListeValeurs;
6
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.modeles.Collection;
6
import org.tela_botanica.client.modeles.Collection;
8
import org.tela_botanica.client.modeles.Information;
7
import org.tela_botanica.client.modeles.Information;
9
import org.tela_botanica.client.modeles.MenuApplicationId;
8
import org.tela_botanica.client.modeles.MenuApplicationId;
Line -... Line 9...
-
 
9
import org.tela_botanica.client.modeles.Valeur;
10
import org.tela_botanica.client.modeles.Valeur;
10
 
11
 
11
import com.extjs.gxt.ui.client.event.BaseEvent;
12
import com.extjs.gxt.ui.client.event.ButtonEvent;
12
import com.extjs.gxt.ui.client.event.ButtonEvent;
13
import com.extjs.gxt.ui.client.event.ComponentEvent;
13
import com.extjs.gxt.ui.client.event.ComponentEvent;
14
import com.extjs.gxt.ui.client.event.Events;
14
import com.extjs.gxt.ui.client.event.Events;
-
 
15
import com.extjs.gxt.ui.client.event.Listener;
15
import com.extjs.gxt.ui.client.event.Listener;
16
import com.extjs.gxt.ui.client.event.SelectionListener;
16
import com.extjs.gxt.ui.client.event.SelectionListener;
17
import com.extjs.gxt.ui.client.store.StoreEvent;
17
import com.extjs.gxt.ui.client.store.ListStore;
18
import com.extjs.gxt.ui.client.store.StoreListener;
18
import com.extjs.gxt.ui.client.widget.Info;
19
import com.extjs.gxt.ui.client.widget.Info;
19
import com.extjs.gxt.ui.client.widget.TabItem;
20
import com.extjs.gxt.ui.client.widget.TabItem;
20
import com.extjs.gxt.ui.client.widget.TabPanel;
21
import com.extjs.gxt.ui.client.widget.TabPanel;
-
 
22
import com.extjs.gxt.ui.client.widget.button.Button;
-
 
23
import com.extjs.gxt.ui.client.widget.form.FieldSet;
-
 
24
import com.extjs.gxt.ui.client.widget.form.TextField;
21
import com.extjs.gxt.ui.client.widget.button.Button;
25
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
Line 22... Line 26...
22
import com.extjs.gxt.ui.client.widget.form.ComboBox;
26
import com.extjs.gxt.ui.client.widget.layout.FormData;
Line 23... Line 27...
23
import com.google.gwt.core.client.GWT;
27
import com.google.gwt.core.client.GWT;
24
 
28
 
Line 25... Line 29...
25
public class CollectionForm extends Formulaire implements Rafraichissable {
29
public class CollectionForm extends Formulaire implements Rafraichissable {
26
 
-
 
Line 27... Line 30...
27
	private Collection collection = null;
30
 
28
	private Collection collectionCollectee = null;
31
	private Collection collection = null;
29
 
32
	private Collection collectionCollectee = null;
30
	private HashMap<String,ComboBox<Valeur>> champsCbv = new HashMap<String,ComboBox<Valeur>>();
33
 
31
	private HashMap<String,ListStore<Valeur>> champsLsv = new HashMap<String,ListStore<Valeur>>();
34
	private ChampComboBoxListeValeurs typesCollectionCombo = null;
32
	
35
	
33
	private TabPanel onglets = null;
-
 
34
	private TabItem generalOnglet = null;
36
	private TabPanel onglets = null;
-
 
37
	private TabItem generalOnglet = null;
Line 35... Line 38...
35
	private TabItem auteurOnglet = null;
38
	private TabItem auteurOnglet = null;
36
	private TabItem publicationOnglet = null;
39
	private TabItem publicationOnglet = null;
-
 
40
	private TabItem descriptionOnglet = null;
-
 
41
	private TabItem contenuOnglet = null;
-
 
42
	private TabItem inventaireOnglet = null;
-
 
43
	private TextField<String> nomChp = null;
-
 
44
	
-
 
45
	public CollectionForm(Mediateur mediateurCourrant, String modeDeCreation) {
-
 
46
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION);
-
 
47
		creerFieldsetPrincipal();
-
 
48
	}
-
 
49
	
-
 
50
	private void creerFieldsetPrincipal() {
-
 
51
		FieldSet principalFieldSet = new FieldSet();
-
 
52
		principalFieldSet.setHeading("Info");
-
 
53
		principalFieldSet.setCollapsible(true);
-
 
54
		principalFieldSet.setLayout(Formulaire.creerFormLayout(150, LabelAlign.LEFT));
-
 
55
		
-
 
56
		nomChp  = new TextField<String>();
-
 
57
		nomChp.setTabIndex(tabIndex++);
-
 
58
		nomChp.setFieldLabel(i18nC.nomCollection());
-
 
59
		nomChp.setAllowBlank(false);
-
 
60
		nomChp.getMessages().setBlankText(i18nC.champObligatoire());
-
 
61
		principalFieldSet.add(nomChp, new FormData(450, 0));
37
	private TabItem descriptionOnglet = null;
62
		
-
 
63
		typesCollectionCombo = new ChampComboBoxListeValeurs(i18nC.typeCollectionNcd(), "typeCollectionNcd", tabIndex++);
-
 
64
		typesCollectionCombo.setValeurDefaut(Valeur.COLLECTION_NCD_HERBIER);
38
	private TabItem contenuOnglet = null;
65
		typesCollectionCombo.addListener(Events.Select, new Listener<BaseEvent>() {
39
	private TabItem documentOnglet = null;
66
			@Override
-
 
67
			public void handleEvent(BaseEvent be) {
-
 
68
				Valeur valeur = typesCollectionCombo.getValue();
40
	private TabItem inventaireOnglet = null;
69
				panneauFormulaire.remove(onglets);
-
 
70
				mediateur.activerChargement("");
-
 
71
				if (valeur != null && valeur.getId().equals(Valeur.COLLECTION_NCD_HERBIER)) {
-
 
72
					onglets = creerOngletsHerbier();
-
 
73
					panneauFormulaire.add(onglets);
-
 
74
				} else {
-
 
75
					onglets = creerOngletsDefaut();
-
 
76
					panneauFormulaire.add(onglets);
-
 
77
				}
-
 
78
				mediateur.desactiverChargement();
-
 
79
				panneauFormulaire.layout();
-
 
80
			}
-
 
81
		});
-
 
82
		principalFieldSet.add(typesCollectionCombo, new FormData(150, 0));
-
 
83
		typesCollectionCombo.fireEvent(Events.Select);
-
 
84
		
-
 
85
		panneauFormulaire.setTopComponent(principalFieldSet);
-
 
86
	}
-
 
87
	
-
 
88
	protected TabPanel creerOngletsDefaut() {
-
 
89
		TabPanel ongletsCollectionDefaut = new TabPanel();
-
 
90
		
41
	
91
		// Onlget formulaire GENERAL
Line 42... Line 92...
42
	public CollectionForm(Mediateur mediateurCourrant, String modeDeCreation) {
92
		ongletsCollectionDefaut.add(creerOngletGeneral());
43
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.COLLECTION);
93
		
44
		// Création des onglets
94
		// Onlget formulaire AUTEUR
45
		onglets = creerOnglets();
95
		ongletsCollectionDefaut.add(creerOngletAuteur());
Line 46... Line 96...
46
		// Ajout des onglets au formulaire général
96
 
47
		panneauFormulaire.add(onglets);
97
		return ongletsCollectionDefaut;
Line 48... Line 98...
48
	}
98
	}
49
	
99
	
Line 50... Line 100...
50
	protected TabPanel creerOnglets() {
100
	protected TabPanel creerOngletsHerbier() {
51
		TabPanel ongletsCollection = new TabPanel();
101
		TabPanel ongletsCollectionHerbier = new TabPanel();
Line 52... Line 102...
52
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) 
102
		// NOTE : pour faire apparaître les scrollBar il faut définir la hauteur du panneau d'onglets à 100% (autoHeight ne semble pas fonctionner) 
53
		ongletsCollection.setHeight("100%");
103
		ongletsCollectionHerbier.setHeight("100%");
Line 54... Line 104...
54
		
104
		
55
		// Onlget formulaire GENERAL
105
		// Onlget formulaire GENERAL
56
		ongletsCollection.add(creerOngletGeneral());
-
 
57
		
-
 
58
		// Onlget formulaire AUTEUR
-
 
Line 59... Line 106...
59
		ongletsCollection.add(creerOngletAuteur());
106
		ongletsCollectionHerbier.add(creerOngletGeneral());
60
		
107
		
Line 61... Line 108...
61
		// Onlget formulaire PUBLICATION
108
		// Onlget formulaire AUTEUR
62
		ongletsCollection.add(creerOngletPublication());
109
		ongletsCollectionHerbier.add(creerOngletAuteur());
Line 63... Line 110...
63
		
110
		
64
		// Onlget formulaire DESCRIPTION
111
		// Onlget formulaire PUBLICATION
Line 65... Line 112...
65
		ongletsCollection.add(creerOngletDescription());
112
		ongletsCollectionHerbier.add(creerOngletPublication());
66
		
113
		
67
		// Onlget formulaire CONTENU
114
		// Onlget formulaire DESCRIPTION
Line 98... Line 145...
98
		descriptionOnglet = new CollectionFormDescription(this);
145
		descriptionOnglet = new CollectionFormDescription(this);
99
		return descriptionOnglet;
146
		return descriptionOnglet;
100
	}
147
	}
Line 101... Line 148...
101
	
148
	
102
	private TabItem creerOngletContenu() {
149
	private TabItem creerOngletContenu() {
103
		contenuOnglet = creerOnglet(i18nC.collectionContenu(), "contenu");
-
 
104
		contenuOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
-
 
105
			public void handleEvent(ComponentEvent be) {  
-
 
106
				//peuplerOngletContenu();
-
 
107
				contenuOnglet.layout();
-
 
108
			}  
-
 
109
		});
-
 
110
		
150
		contenuOnglet = new CollectionFormContenu(this);
111
		return contenuOnglet;
151
		return contenuOnglet;
Line 112... Line -...
112
	}
-
 
113
	
-
 
114
	private TabItem creerOngletDocument() {
-
 
115
		documentOnglet = creerOnglet(i18nC.collectionDocument(), "document");
-
 
116
		documentOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
-
 
117
			public void handleEvent(ComponentEvent be) {  
-
 
118
				//peuplerOngletDocument();
-
 
119
				documentOnglet.layout();
-
 
120
			}  
-
 
121
		});
-
 
122
		
-
 
123
		return documentOnglet;
-
 
124
	}
152
	}
125
	
153
	
126
	private TabItem creerOngletInventaire() {
154
	private TabItem creerOngletInventaire() {
127
		inventaireOnglet = creerOnglet(i18nC.collectionInventaire(), "inventaire");
155
		inventaireOnglet = creerOnglet(i18nC.collectionInventaire(), "inventaire");
128
		inventaireOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
156
		inventaireOnglet.addListener(Events.Select, new Listener<ComponentEvent>() {  
Line 134... Line 162...
134
		
162
		
135
		return inventaireOnglet;
163
		return inventaireOnglet;
Line 136... Line 164...
136
	}
164
	}
137
	
-
 
138
	public void rafraichir(Object nouvellesDonnees) {
165
	
139
		try {
166
	public void rafraichir(Object nouvellesDonnees) {
140
			if (nouvellesDonnees instanceof Information) {
167
		if (nouvellesDonnees instanceof Information) {
141
				Information info = (Information) nouvellesDonnees;
168
			Information info = (Information) nouvellesDonnees;
142
				rafraichirInformation(info);
169
			rafraichirInformation(info);
143
			} else {
-
 
144
				GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
-
 
145
			}
-
 
146
		} catch (Exception e) {
170
		} else {
-
 
171
			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
147
			GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), e);
172
		}
148
		}
173
		
Line 149... Line 174...
149
		controlerFermetureApresRafraichissement();
174
		controlerFermetureApresRafraichissement();
150
	}
175
	}
Line 165... Line 190...
165
			actualiserTitrePanneau();
190
			actualiserTitrePanneau();
166
		}
191
		}
167
	}
192
	}
Line 168... Line 193...
168
	
193
	
169
	private void actualiserPeuplementOnglet() {
194
	private void actualiserPeuplementOnglet() {
170
		onglets.setSelection(onglets.getSelectedItem());
195
		// TODO : déclencher le peuplement de l'onglet courant
Line 171... Line 196...
171
	}
196
	}
172
 
197
 
173
	private void actualiserTitrePanneau() {
198
	private void actualiserTitrePanneau() {