Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 277 Rev 328
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.Collection;
2
 
Line 4... Line 3...
4
import java.util.Iterator;
3
import java.util.Iterator;
5
 
4
 
6
import org.tela_botanica.client.Mediateur;
5
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.RegistreId;
6
import org.tela_botanica.client.RegistreId;
-
 
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.modeles.Menu;
9
import org.tela_botanica.client.modeles.Menu;
9
import org.tela_botanica.client.modeles.MenuApplicationId;
Line 10... Line 10...
10
import org.tela_botanica.client.modeles.Projet;
10
import org.tela_botanica.client.modeles.Projet;
11
import org.tela_botanica.client.modeles.ProjetListe;
11
import org.tela_botanica.client.modeles.ProjetListe;
-
 
12
 
12
 
13
import com.extjs.gxt.ui.client.Events;
13
import com.extjs.gxt.ui.client.Events;
14
import com.extjs.gxt.ui.client.Registry;
14
import com.extjs.gxt.ui.client.Registry;
15
import com.extjs.gxt.ui.client.binder.TreeBinder;
15
import com.extjs.gxt.ui.client.event.Listener;
16
import com.extjs.gxt.ui.client.event.Listener;
16
import com.extjs.gxt.ui.client.event.TreeEvent;
17
import com.extjs.gxt.ui.client.event.TreeEvent;
17
import com.extjs.gxt.ui.client.util.TreeBuilder;
18
import com.extjs.gxt.ui.client.store.TreeStore;
18
import com.extjs.gxt.ui.client.widget.ContentPanel;
19
import com.extjs.gxt.ui.client.widget.ContentPanel;
19
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
20
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
Line 24... Line 25...
24
import com.google.gwt.user.client.ui.ListBox;
25
import com.google.gwt.user.client.ui.ListBox;
25
import com.google.gwt.user.client.ui.Widget;
26
import com.google.gwt.user.client.ui.Widget;
Line 26... Line 27...
26
 
27
 
Line 27... Line 28...
27
public class MenuPanneauVue extends ContentPanel implements Rafraichissable {
28
public class MenuPanneauVue extends ContentPanel implements Rafraichissable {
28
 
29
 
29
	private Tree tree;
30
	private Tree arbreMenus;
30
	private ListBox listeProjets;
31
	private ListBox listeProjets;
-
 
32
	private boolean estListeProjetsInitialise = false;
Line 31... Line 33...
31
	private boolean listeProjetsInitialise = false;
33
	private ProjetListe projetsCache = null;
32
	private ProjetListe projetsCache = null;
34
	private TreeStore<Menu> menuStore;
33
	
35
	
34
	public MenuPanneauVue() {
36
	public MenuPanneauVue() {
35
		setBodyBorder(false);
37
		setBodyBorder(false);
36
		setLayoutOnChange(true);
38
		setLayoutOnChange(true);
Line 37... Line 39...
37
		setHeading("Menu");
39
		setHeading("Menu");
38
		setLayout(new FlowLayout());
-
 
39
	}
-
 
40
 
40
		setLayout(new FlowLayout());
41
	public void rafraichir(Object nouvelleDonnees) {
41
	}
42
		if (nouvelleDonnees instanceof Menu) {
42
 
43
			afficherMenu((Menu) nouvelleDonnees);
43
	public void rafraichir(Object nouvelleDonnees) {
44
		} else if (nouvelleDonnees instanceof ProjetListe) {
44
		if (nouvelleDonnees instanceof ProjetListe) {
Line 45... Line 45...
45
			projetsCache = (ProjetListe) nouvelleDonnees;
45
			projetsCache = (ProjetListe) nouvelleDonnees;
46
			afficherProjets();
46
			afficherProjets();
47
		}
47
		}
48
	}
48
	}
49
 
49
 
50
	private void afficherProjets()	{
50
	private void afficherProjets()	{
51
		Iterator it = projetsCache.values().iterator();
51
		Iterator<Projet> it = projetsCache.values().iterator();
Line 52... Line 52...
52
		while (it.hasNext())	{
52
		while (it.hasNext())	{
Line 53... Line 53...
53
			Projet projetCourant = (Projet) it.next();
53
			Projet projetCourant = it.next();
54
			listeProjets.addItem(projetCourant.getNom(), projetCourant.getId());
54
			listeProjets.addItem(projetCourant.getNom(), projetCourant.getId());
55
		}
55
		}
56
	}
56
	}
57
	
57
	
Line 58... Line 58...
58
	private void afficherMenu(Menu menu) {
58
	private void afficherMenu() {
59
		
59
		
60
		// Greg : ajout de la sélection des projets
60
		// Greg : ajout de la sélection des projets
61
		listeProjets = new ListBox(false);
61
		listeProjets = new ListBox(false);
62
		listeProjets.setWidth("100%");
62
		listeProjets.setWidth("100%");
63
		listeProjets.addItem("Choisisez un projet...", "NULL");
63
		listeProjets.addItem("Choisisez un projet...", "NULL");
64
		add(listeProjets);
64
		add(listeProjets);
65
		
65
		
66
		// Ajout d'un écouteur pour le clic => chargement de la liste des projets
66
		// Ajout d'un écouteur pour le clic => chargement de la liste des projets
Line 80... Line 80...
80
	    	  // TODO : récupérer la valeur passé par l'évenement et enregistrer dans le registre
80
	    	  // TODO : récupérer la valeur passé par l'évenement et enregistrer dans le registre
81
	    	  ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).selectionnerProjetCourant(projetsCache.get(listeProjets.getValue(listeProjets.getSelectedIndex())));	    	  
81
	    	  ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).selectionnerProjetCourant(projetsCache.get(listeProjets.getValue(listeProjets.getSelectedIndex())));	    	  
82
	      }
82
	      }
83
	    });
83
	    });
Line 84... Line 84...
84
		
84
		
85
		tree = new Tree();
85
		arbreMenus = new Tree();
86
		tree.getStyle().setLeafIconStyle("tree-folder");
86
		arbreMenus.getStyle().setLeafIconStyle("tree-folder");
Line 87... Line 87...
87
		tree.addListener(Events.OnClick, new Listener<TreeEvent>(){
87
		arbreMenus.addListener(Events.OnClick, new Listener<TreeEvent>(){
88
 
88
 
-
 
89
			public void handleEvent(TreeEvent be) {
89
			public void handleEvent(TreeEvent be) {
90
				TreeItem f = arbreMenus.getSelectedItem();
90
				TreeItem f = tree.getSelectedItem();
91
				Menu menuSelectionne = (Menu) f.getModel();
Line 91... Line 92...
91
				selectionMenu(f.getText());
92
				selectionMenu(menuSelectionne);
-
 
93
			}
-
 
94
			
-
 
95
		});
92
			}
96
		
-
 
97
		TreeBinder<Menu> binder = new TreeBinder<Menu>(arbreMenus, menuStore);
Line 93... Line 98...
93
			
98
		binder.setAutoLoad(true);  
94
		});
99
		binder.setDisplayProperty("nom");
Line 95... Line 100...
95
		TreeBuilder.buildTree(tree, menu);
100
		binder.init();
-
 
101
				
96
				
102
		add(arbreMenus);
97
		add(tree);
103
	}
Line 98... Line 104...
98
	}
104
	
99
	
105
	private void selectionMenu(Menu menuSelectionne) {
Line 100... Line 106...
100
	private void selectionMenu(String s) {
106
		String codeMenuSelectionne = menuSelectionne.getCode();
101
		((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu(s);
107
		((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu(codeMenuSelectionne);
102
	}
108
	}
103
	
109
	
104
	public Menu listerMenu() {
110
	private void construireMenu() {
105
		Menu menus = new Menu();
111
		menuStore = new TreeStore<Menu>();
106
		
-
 
107
		Menu accueilMenu = new Menu("Accueil");
-
 
108
		Menu projetMenu = new Menu("Projets");
-
 
109
	    Menu menuInstitution = new Menu("Institutions");
-
 
110
	    Menu menuCollections = new Menu("Collections");
-
 
111
	    Menu menuPersonnes = new Menu("Personnes");
-
 
112
	    Menu menuPublications = new Menu("Publications");
-
 
Line -... Line 112...
-
 
112
		
-
 
113
		Menu accueilMenu = new Menu("Accueil", MenuApplicationId.ACCUEIL);
-
 
114
		Menu projetMenu = new Menu("Projets", MenuApplicationId.PROJET);
-
 
115
	    Menu menuInstitution = new Menu("Institutions", MenuApplicationId.STRUCTURE);
-
 
116
	    Menu menuCollections = new Menu("Collections", MenuApplicationId.COLLECTION);
-
 
117
	    Menu menuPersonnes = new Menu("Personnes", MenuApplicationId.PERSONNE);
-
 
118
	    Menu menuPublications = new Menu("Publications", MenuApplicationId.PUBLICATION);
-
 
119
	    
-
 
120
	    menuStore.add(accueilMenu, false);
113
	    
121
	    menuStore.add(projetMenu, false);
-
 
122
	    menuStore.add(menuInstitution, false);
114
	    menus.add(accueilMenu);
123
	    menuStore.add(menuCollections, false);
Line 115... Line 124...
115
	    menus.add(projetMenu);
124
	    menuStore.add(menuPersonnes, false);
116
	    menus.add(menuInstitution);
125
	    menuStore.add(menuPublications, false);
117
	    menus.add(menuCollections);
126
	}