Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1468 Rev 1613
Line 11... Line 11...
11
import org.tela_botanica.client.images.Images;
11
import org.tela_botanica.client.images.Images;
12
import org.tela_botanica.client.interfaces.Rafraichissable;
12
import org.tela_botanica.client.interfaces.Rafraichissable;
13
import org.tela_botanica.client.modeles.Information;
13
import org.tela_botanica.client.modeles.Information;
14
import org.tela_botanica.client.util.Debug;
14
import org.tela_botanica.client.util.Debug;
Line 15... Line -...
15
 
-
 
16
import com.extjs.gxt.ui.client.GXT;
15
 
17
import com.extjs.gxt.ui.client.event.ButtonEvent;
16
import com.extjs.gxt.ui.client.event.ButtonEvent;
18
import com.extjs.gxt.ui.client.event.SelectionListener;
17
import com.extjs.gxt.ui.client.event.SelectionListener;
19
import com.extjs.gxt.ui.client.widget.ContentPanel;
-
 
20
import com.extjs.gxt.ui.client.widget.Info;
18
import com.extjs.gxt.ui.client.widget.ContentPanel;
21
import com.extjs.gxt.ui.client.widget.LayoutContainer;
19
import com.extjs.gxt.ui.client.widget.LayoutContainer;
22
import com.extjs.gxt.ui.client.widget.button.Button;
20
import com.extjs.gxt.ui.client.widget.button.Button;
23
import com.extjs.gxt.ui.client.widget.custom.Portal;
21
import com.extjs.gxt.ui.client.widget.custom.Portal;
24
import com.extjs.gxt.ui.client.widget.custom.Portlet;
22
import com.extjs.gxt.ui.client.widget.custom.Portlet;
Line 72... Line 70...
72
		
70
		
Line 73... Line 71...
73
		panneauPrincipal.setTopComponent(barreOutils);
71
		panneauPrincipal.setTopComponent(barreOutils);
74
		
72
		
75
		portail = creerPortail();
73
		portail = creerPortail();
76
		panneauPrincipal.add(portail);
-
 
77
		
-
 
78
		chargerParametres();
74
		panneauPrincipal.add(portail);
79
 
75
				
80
		add(panneauPrincipal);
76
		add(panneauPrincipal);
Line 81... Line 77...
81
		mediateur.desactiverChargement(this);
77
		mediateur.desactiverChargement(this);
Line 99... Line 95...
99
		portail.getItem(2).removeAll();
95
		portail.getItem(2).removeAll();
100
	}
96
	}
Line 101... Line 97...
101
	
97
	
102
	private void chargerParametres() {	
98
	private void chargerParametres() {	
103
		viderPortail();
-
 
104
		
99
		viderPortail();
105
		Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre());
100
		Document paramXml = XMLParser.parse(mediateur.getUtilisateur().getParametre());
106
		NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil");
101
		NodeList listeAccueilNoeud = paramXml.getElementsByTagName("accueil");
Line 107... Line 102...
107
		int nbreAccueilNoeud = listeAccueilNoeud.getLength();
102
		int nbreAccueilNoeud = listeAccueilNoeud.getLength();
108
 
103
 
109
		// Récupération du noeud accueil
104
		// Récupération du noeud accueil
110
		Node accueilNoeud = null;
105
		Node accueilNoeud = null;
111
		if (nbreAccueilNoeud == 0) {		
106
		if (nbreAccueilNoeud == 0) {		
112
			ajouterPortlet();
107
			ajouterPortletsDefaut();
113
		} else if (nbreAccueilNoeud == 1) {
-
 
114
			accueilNoeud = listeAccueilNoeud.item(0);
-
 
115
			
108
		} else if (nbreAccueilNoeud == 1) {
-
 
109
			accueilNoeud = listeAccueilNoeud.item(0);
-
 
110
			NodeList listeAppletteNoeud = accueilNoeud.getChildNodes();
-
 
111
			// un noeud de type vide indique que l'utilisateur a explicité effacé les applettes de la page d'accueil
116
			// Lecture des noeuds "applette"
112
			if(listeAppletteNoeud.getLength() > 0 && !listeAppletteNoeud.item(0).getNodeName().equals("vide")) {		
117
			NodeList listeAppletteNoeud = accueilNoeud.getChildNodes();
113
				// Lecture des noeuds "applette"
118
			int nbreAppletteNoeud = listeAppletteNoeud.getLength();
114
				int nbreAppletteNoeud = listeAppletteNoeud.getLength();
119
			TreeMap<String, HashMap<String, String>> tableApplettes = new TreeMap<String, HashMap<String, String>>(); 				
115
				TreeMap<String, HashMap<String, String>> tableApplettes = new TreeMap<String, HashMap<String, String>>(); 				
120
			for (int i = 0; i < nbreAppletteNoeud ; i++) {
116
				for (int i = 0; i < nbreAppletteNoeud ; i++) {
121
				Element appletteNoeud = (Element) listeAppletteNoeud.item(i);
117
					Element appletteNoeud = (Element) listeAppletteNoeud.item(i);
122
				int colonne = Integer.parseInt(appletteNoeud.getAttribute("colonne"));
118
					int colonne = Integer.parseInt(appletteNoeud.getAttribute("colonne"));
123
				int index = Integer.parseInt(appletteNoeud.getAttribute("index"));
119
					int index = Integer.parseInt(appletteNoeud.getAttribute("index"));
124
				HashMap<String, String> infoApplette = new HashMap<String, String>();
120
					HashMap<String, String> infoApplette = new HashMap<String, String>();
125
				infoApplette.put("reduite", appletteNoeud.getAttribute("reduite"));
121
					infoApplette.put("reduite", appletteNoeud.getAttribute("reduite"));
126
				infoApplette.put("epingle", appletteNoeud.getAttribute("epingle"));
122
					infoApplette.put("epingle", appletteNoeud.getAttribute("epingle"));
127
				infoApplette.put("type", appletteNoeud.getAttribute("type"));
123
					infoApplette.put("type", appletteNoeud.getAttribute("type"));
128
				infoApplette.put("colonne", appletteNoeud.getAttribute("colonne"));
124
					infoApplette.put("colonne", appletteNoeud.getAttribute("colonne"));
129
				infoApplette.put("index", appletteNoeud.getAttribute("index"));
125
					infoApplette.put("index", appletteNoeud.getAttribute("index"));
130
				infoApplette.put("contenu", appletteNoeud.getAttribute("contenu"));
126
					infoApplette.put("contenu", appletteNoeud.getAttribute("contenu"));
131
				tableApplettes.put(colonne+"-"+index, infoApplette);
127
					tableApplettes.put(colonne+"-"+index, infoApplette);
132
			}
128
				}
133
			Iterator<String> it = tableApplettes.keySet().iterator();
129
				Iterator<String> it = tableApplettes.keySet().iterator();
134
			while (it.hasNext()) {
130
				while (it.hasNext()) {
135
				String id = it.next();
131
					String id = it.next();
136
				HashMap<String, String> infoApplette = tableApplettes.get(id);
132
					HashMap<String, String> infoApplette = tableApplettes.get(id);
137
				boolean reduite = (infoApplette.get("reduite") != null && infoApplette.get("reduite").equals("true")) ? true : false;
133
					boolean reduite = (infoApplette.get("reduite") != null && infoApplette.get("reduite").equals("true")) ? true : false;
138
				boolean epingle = (infoApplette.get("epingle") != null && infoApplette.get("epingle").equals("true")) ? true : false;
134
					boolean epingle = (infoApplette.get("epingle") != null && infoApplette.get("epingle").equals("true")) ? true : false;
139
				int index = Integer.parseInt(infoApplette.get("index"));
135
					int index = Integer.parseInt(infoApplette.get("index"));
-
 
136
					int colonne = Integer.parseInt(infoApplette.get("colonne"));			
-
 
137
					ajouterPortlet(reduite, epingle, infoApplette.get("type"), colonne, index, infoApplette.get("contenu"));				
-
 
138
				}
140
				int colonne = Integer.parseInt(infoApplette.get("colonne"));			
139
			} else if(listeAppletteNoeud.getLength() == 0) {
141
				ajouterPortlet(reduite, epingle, infoApplette.get("type"), colonne, index, infoApplette.get("contenu"));				
140
				ajouterPortletsDefaut();
142
			}
141
			}
143
		}
142
		}
Line 170... Line 169...
170
			accueilNoeud = listeAccueilNoeud.item(0);
169
			accueilNoeud = listeAccueilNoeud.item(0);
171
			paramXml.getDocumentElement().replaceChild(accueilElement, accueilNoeud);
170
			paramXml.getDocumentElement().replaceChild(accueilElement, accueilNoeud);
172
			accueilNoeud = paramXml.getElementsByTagName("accueil").item(0);
171
			accueilNoeud = paramXml.getElementsByTagName("accueil").item(0);
173
		}
172
		}
Line -... Line 173...
-
 
173
		
-
 
174
		// si il existe des applettes ouvertes
174
		
175
		if(it.hasNext()) {
175
		// Ajout des noeuds "applette" au noeud "accueil"
176
			// Ajout des noeuds "applette" au noeud "accueil"
176
		while (it.hasNext()) {
177
			while (it.hasNext()) {
177
			Portlet applette = it.next();
178
				Portlet applette = it.next();
178
			String reduite = (applette.isCollapsed() ? "true" : "false");
179
				String reduite = (applette.isCollapsed() ? "true" : "false");
179
			String epingle = (applette.isPinned() ? "true" : "false");
180
				String epingle = (applette.isPinned() ? "true" : "false");
180
			String index = Integer.toString(portail.getPortletIndex(applette));
181
				String index = Integer.toString(portail.getPortletIndex(applette));
181
			String colonne = Integer.toString(portail.getPortletColumn(applette));
182
				String colonne = Integer.toString(portail.getPortletColumn(applette));
182
			String contenu = applette.getData("contenu");
183
				String contenu = applette.getData("contenu");
183
			
184
				
184
			Element appletteElement = paramXml.createElement("applette");
185
				Element appletteElement = paramXml.createElement("applette");
185
			appletteElement.setAttribute("reduite", reduite);
186
				appletteElement.setAttribute("reduite", reduite);
186
			appletteElement.setAttribute("epingle", epingle);
187
				appletteElement.setAttribute("epingle", epingle);
187
			appletteElement.setAttribute("type", "statistique");
188
				appletteElement.setAttribute("type", "statistique");
188
			appletteElement.setAttribute("colonne", colonne);
189
				appletteElement.setAttribute("colonne", colonne);
189
			appletteElement.setAttribute("index", index);
190
				appletteElement.setAttribute("index", index);
190
			appletteElement.setAttribute("contenu", contenu);
191
				appletteElement.setAttribute("contenu", contenu);
191
			
192
				
-
 
193
				accueilNoeud.appendChild(appletteElement);
-
 
194
			}
-
 
195
		} else {
-
 
196
			// sinon ajout d'un noeud vide
-
 
197
			Element videElement = paramXml.createElement("vide");
192
			accueilNoeud.appendChild(appletteElement);
198
			accueilNoeud.appendChild(videElement);
Line 193... Line 199...
193
		}
199
		}
194
		
200
		
195
		enregistrementEnCours = true;
201
		enregistrementEnCours = true;
Line 225... Line 231...
225
		portail.insert(applette, index, colonne);		
231
		portail.insert(applette, index, colonne);		
226
		applette.setEpingler(epingle);	
232
		applette.setEpingler(epingle);	
227
		layout();
233
		layout();
228
	}
234
	}
Line -... Line 235...
-
 
235
	
-
 
236
	private void ajouterPortletsDefaut() {
-
 
237
		//TODO créer une énum des différents types de portlet puis faire une boucle
-
 
238
		// dessus
-
 
239
		Applette applette = new AppletteStatistique(mediateur, "NombreDonnees");
-
 
240
		portail.insert(applette, 0, 0);		
-
 
241
		applette.setEpingler(true);	
-
 
242
		
-
 
243
		applette = new AppletteStatistique(mediateur, "MesDonnees");
-
 
244
		portail.insert(applette, 0, 1);	
-
 
245
		
-
 
246
		applette = new AppletteStatistique(mediateur, "TypeDepot");
-
 
247
		portail.insert(applette, 0, 2);	
-
 
248
		
-
 
249
		applette = new AppletteStatistique(mediateur, "NombreCollectionParStructure");
-
 
250
		portail.insert(applette, 1, 0);	
-
 
251
		layout();
-
 
252
	}
229
	
253
	
230
	public void rafraichir(Object nouvellesDonnees) {	
254
	public void rafraichir(Object nouvellesDonnees) {	
231
		if (nouvellesDonnees instanceof Information) {
255
		if (nouvellesDonnees instanceof Information) {
232
			Information info = (Information) nouvellesDonnees;
256
			Information info = (Information) nouvellesDonnees;
233
			String type = info.getType(); 
257
			String type = info.getType();