Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 499 Rev 553
Line 1... Line 1...
1
package org.tela_botanica.client.vues;
1
package org.tela_botanica.client.vues;
Line 2... Line 2...
2
 
2
 
Line 3... Line 3...
3
import java.util.Iterator;
3
import java.util.Iterator;
4
 
-
 
5
import org.tela_botanica.client.Mediateur;
4
 
6
import org.tela_botanica.client.RegistreId;
5
import org.tela_botanica.client.Mediateur;
7
import org.tela_botanica.client.i18n.Constantes;
6
import org.tela_botanica.client.i18n.Constantes;
8
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.modeles.Menu;
8
import org.tela_botanica.client.modeles.Menu;
10
import org.tela_botanica.client.modeles.MenuApplicationId;
9
import org.tela_botanica.client.modeles.MenuApplicationId;
Line 11... Line 10...
11
import org.tela_botanica.client.modeles.Projet;
10
import org.tela_botanica.client.modeles.Projet;
12
import org.tela_botanica.client.modeles.ProjetListe;
11
import org.tela_botanica.client.modeles.ProjetListe;
13
 
-
 
14
import com.extjs.gxt.ui.client.event.Events;
12
 
15
import com.extjs.gxt.ui.client.Registry;
13
import com.extjs.gxt.ui.client.event.Events;
16
import com.extjs.gxt.ui.client.binder.TreeBinder;
14
import com.extjs.gxt.ui.client.GXT;
17
import com.extjs.gxt.ui.client.event.Listener;
15
import com.extjs.gxt.ui.client.event.Listener;
18
import com.extjs.gxt.ui.client.event.TreeEvent;
16
import com.extjs.gxt.ui.client.event.TreePanelEvent;
19
import com.extjs.gxt.ui.client.store.TreeStore;
17
import com.extjs.gxt.ui.client.store.TreeStore;
20
import com.extjs.gxt.ui.client.widget.ContentPanel;
18
import com.extjs.gxt.ui.client.widget.ContentPanel;
21
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
19
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
22
import com.extjs.gxt.ui.client.widget.tree.Tree;
20
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
23
import com.extjs.gxt.ui.client.widget.tree.TreeItem;
21
import com.google.gwt.core.client.GWT;
24
import com.google.gwt.user.client.ui.ChangeListener;
-
 
Line 25... Line 22...
25
import com.google.gwt.user.client.ui.ClickListener;
22
import com.google.gwt.event.dom.client.ChangeEvent;
Line 26... Line 23...
26
import com.google.gwt.user.client.ui.ListBox;
23
import com.google.gwt.event.dom.client.ChangeHandler;
27
import com.google.gwt.user.client.ui.Widget;
24
import com.google.gwt.user.client.ui.ListBox;
Line 28... Line 25...
28
 
25
 
29
public class MenuVue extends ContentPanel implements Rafraichissable {
26
public class MenuVue extends ContentPanel implements Rafraichissable {
30
 
-
 
31
	private Mediateur mediateur = null;
27
 
32
	private Constantes i18nC = null;
28
	private Mediateur mediateur = null;
Line 33... Line 29...
33
	
29
	private Constantes i18nC = null;
34
	private Tree arbreMenus;
30
	
35
	private ListBox listeProjets;
31
	private TreePanel<Menu> arbreMenus;
Line -... Line 32...
-
 
32
	private ListBox listeProjets;
36
	private boolean estListeProjetsInitialise = false;
33
	private ProjetListe projetsCache = null;
37
	private ProjetListe projetsCache = null;
34
	private TreeStore<Menu> menuStore;
38
	private TreeStore<Menu> menuStore;
-
 
39
	
-
 
Line 40... Line -...
40
	public MenuVue(Mediateur mediateurCourrant) {
-
 
41
		mediateur = mediateurCourrant;
-
 
42
		i18nC = mediateur.i18nC;
-
 
43
		
35
	
44
		setLayout(new FlowLayout());
-
 
45
		setLayoutOnChange(true);
-
 
46
		setHeading(i18nC.titreMenu());
-
 
47
	}
-
 
48
 
-
 
49
	public void rafraichir(Object nouvelleDonnees) {
-
 
50
		if (nouvelleDonnees instanceof ProjetListe) {
-
 
51
			projetsCache = (ProjetListe) nouvelleDonnees;
-
 
52
			afficherProjets();
-
 
53
		}
-
 
54
	}
-
 
55
 
-
 
56
	private void afficherProjets()	{
-
 
57
		Iterator<Projet> it = projetsCache.values().iterator();
-
 
58
		while (it.hasNext())	{
-
 
59
			Projet projetCourant = it.next();
-
 
60
			listeProjets.addItem(projetCourant.getNom(), projetCourant.getId());
36
	public MenuVue(Mediateur mediateurCourrant) {
61
		}
-
 
62
	}
-
 
63
	
-
 
64
	private void afficherMenu() {
-
 
65
		// Ajout de la sélection des projets
-
 
66
		listeProjets = new ListBox(false);
-
 
67
		listeProjets.setWidth("100%");
-
 
68
		listeProjets.addItem(i18nC.txtListeProjetDefaut(), "NULL");
-
 
69
		add(listeProjets);
-
 
70
		
-
 
71
		// Ajout d'un écouteur pour le clic => chargement de la liste des projets
-
 
72
	    listeProjets.addClickListener(new ClickListener() {
-
 
73
	      public void onClick(Widget sender) {
-
 
74
	    	  if(!estListeProjetsInitialise) {
-
 
75
	    		  chargerProjets();
-
 
76
	    		  estListeProjetsInitialise = true;
-
 
77
	    	  }
-
 
78
	      }
-
 
Line 79... Line -...
79
	    });
-
 
80
	    
-
 
81
	    // Ajout d'un écouteur pour le changement => enregistre la valeur courante du projet dans le registre
-
 
82
	    listeProjets.addChangeListener(new ChangeListener() {
-
 
83
	      public void onChange(Widget sender) {
-
 
84
	    	  // TODO : récupérer la valeur passé par l'évenement et enregistrer dans le registre
-
 
85
	    	  mediateur.selectionnerProjetCourant(projetsCache.get(listeProjets.getValue(listeProjets.getSelectedIndex())));	    	  
-
 
86
	      }
-
 
87
	    });
-
 
88
		
-
 
89
		arbreMenus = new Tree();
-
 
90
		arbreMenus.getStyle().setLeafIconStyle("tree-folder");
-
 
91
		arbreMenus.addListener(Events.OnClick, new Listener<TreeEvent>(){
-
 
92
			public void handleEvent(TreeEvent be) {
37
		mediateur = mediateurCourrant;
93
				TreeItem f = arbreMenus.getSelectedItem();
-
 
94
				Menu menuSelectionne = (Menu) f.getModel();
38
		i18nC = mediateur.i18nC;
95
				selectionMenu(menuSelectionne);
-
 
96
			}
-
 
97
		});
-
 
98
		
-
 
99
		TreeBinder<Menu> binder = new TreeBinder<Menu>(arbreMenus, menuStore);
-
 
100
		binder.setAutoLoad(true);  
39
		
101
		binder.setDisplayProperty("nom");
40
		setHeading(i18nC.titreMenu());
102
		binder.init();
41
		setLayout(new FlowLayout());
103
				
42
		setLayoutOnChange(true);
Line 104... Line 43...
104
		add(arbreMenus);
43
 
105
	}
44
		chargerProjets();
Line 125... Line 64...
125
	    menuStore.add(menuCollections, false);
64
	    menuStore.add(menuCollections, false);
126
	    menuStore.add(menuPersonnes, false);
65
	    menuStore.add(menuPersonnes, false);
127
	    menuStore.add(menuPublications, false);
66
	    menuStore.add(menuPublications, false);
128
	}
67
	}
Line 129... Line 68...
129
	
68
	
-
 
69
	private void afficherMenu() {
-
 
70
		arbreMenus = new TreePanel<Menu>(menuStore);
-
 
71
		arbreMenus.getStyle().setLeafIcon(GXT.IMAGES.tree_folder());
-
 
72
		arbreMenus.setDisplayProperty("nom");
-
 
73
		arbreMenus.setHeight("100%");
-
 
74
		arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
-
 
75
			public void handleEvent(TreePanelEvent<Menu> tpe) {
130
	public void chargerMenus() {
76
				Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem();
-
 
77
				selectionMenu(menuCourant);
-
 
78
			}
-
 
79
		});
131
		construireMenu();
80
		
-
 
81
		add(arbreMenus);
-
 
82
	}
-
 
83
	
-
 
84
	private void selectionMenu(Menu menuSelectionne) {
-
 
85
		String codeMenuSelectionne = menuSelectionne.getCode();
132
		afficherMenu();
86
		mediateur.clicMenu(codeMenuSelectionne);
Line 133... Line 87...
133
	}
87
	}
134
	
88
	
135
	private void chargerProjets() {
89
	private void chargerProjets() {
Line -... Line 90...
-
 
90
		mediateur.selectionnerProjets(this);
-
 
91
	}
-
 
92
	
-
 
93
	private void ajouterProjetsAListe()	{
-
 
94
		Iterator<Projet> it = projetsCache.values().iterator();
-
 
95
		while (it.hasNext())	{
-
 
96
			Projet projetCourant = it.next();
-
 
97
			listeProjets.addItem(projetCourant.getNom(), projetCourant.getId());
-
 
98
		}
-
 
99
	}
-
 
100
	
-
 
101
	private void afficherListeProjets() {
-
 
102
		// Ajout de la sélection des projets
-
 
103
		listeProjets = new ListBox(false);
-
 
104
		listeProjets.setWidth("100%");
-
 
105
		listeProjets.addItem(i18nC.txtListeProjetDefaut(), "NULL");
-
 
106
		add(listeProjets);
-
 
107
		
-
 
108
	    // Ajout d'un écouteur pour le changement => enregistre la valeur courante du projet dans le registre
-
 
109
	    listeProjets.addChangeHandler(new ChangeHandler() {
-
 
110
			@Override
-
 
111
			public void onChange(ChangeEvent event) {
-
 
112
				mediateur.activerChargement(i18nC.chargement());
-
 
113
				mediateur.selectionnerProjetCourant(projetsCache.get(listeProjets.getValue(listeProjets.getSelectedIndex())));
-
 
114
			}
-
 
115
		});
-
 
116
	}
-
 
117
	
-
 
118
	public void rafraichir(Object nouvellesDonnees) {
-
 
119
		if (nouvellesDonnees instanceof ProjetListe) {
-
 
120
			projetsCache = (ProjetListe) nouvellesDonnees;
-
 
121
			ajouterProjetsAListe();
-
 
122
		} else {
136
		((Mediateur) Registry.get(RegistreId.MEDIATEUR)).selectionnerProjets(this);
123
			GWT.log(mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
137
	}
124
		}