Subversion Repositories eFlore/Applications.coel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
60 jpm 1
package org.tela_botanica.client.vues;
2
 
149 gduche 3
 
60 jpm 4
import org.tela_botanica.client.Mediateur;
423 jp_milcent 5
import org.tela_botanica.client.i18n.Constantes;
60 jpm 6
import org.tela_botanica.client.modeles.Menu;
328 jp_milcent 7
import org.tela_botanica.client.modeles.MenuApplicationId;
60 jpm 8
 
499 jp_milcent 9
import com.extjs.gxt.ui.client.event.Events;
553 jp_milcent 10
import com.extjs.gxt.ui.client.GXT;
60 jpm 11
import com.extjs.gxt.ui.client.event.Listener;
553 jp_milcent 12
import com.extjs.gxt.ui.client.event.TreePanelEvent;
328 jp_milcent 13
import com.extjs.gxt.ui.client.store.TreeStore;
60 jpm 14
import com.extjs.gxt.ui.client.widget.ContentPanel;
982 jpm 15
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
553 jp_milcent 16
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
60 jpm 17
 
982 jpm 18
public class MenuVue extends ContentPanel {
149 gduche 19
 
423 jp_milcent 20
	private Mediateur mediateur = null;
21
	private Constantes i18nC = null;
22
 
553 jp_milcent 23
	private TreePanel<Menu> arbreMenus;
328 jp_milcent 24
	private TreeStore<Menu> menuStore;
277 jp_milcent 25
 
444 jp_milcent 26
	public MenuVue(Mediateur mediateurCourrant) {
423 jp_milcent 27
		mediateur = mediateurCourrant;
919 jpm 28
		i18nC = Mediateur.i18nC;
423 jp_milcent 29
 
553 jp_milcent 30
		setHeading(i18nC.titreMenu());
982 jpm 31
		setLayout(new FitLayout());
60 jpm 32
		setLayoutOnChange(true);
553 jp_milcent 33
 
34
		construireMenu();
35
		afficherMenu();
60 jpm 36
	}
37
 
328 jp_milcent 38
	private void construireMenu() {
39
		menuStore = new TreeStore<Menu>();
60 jpm 40
 
423 jp_milcent 41
		Menu accueilMenu = new Menu(i18nC.menuAccueil(), MenuApplicationId.ACCUEIL);
42
		Menu projetMenu = new Menu(i18nC.menuProjet(), MenuApplicationId.PROJET);
43
	    Menu menuInstitution = new Menu(i18nC.menuStructure(), MenuApplicationId.STRUCTURE);
44
	    Menu menuCollections = new Menu(i18nC.menuCollection(), MenuApplicationId.COLLECTION);
45
	    Menu menuPersonnes = new Menu(i18nC.menuPersonne(), MenuApplicationId.PERSONNE);
46
	    Menu menuPublications = new Menu(i18nC.menuPublication(), MenuApplicationId.PUBLICATION);
985 jpm 47
	    Menu menuCommentaires = new Menu(i18nC.menuCommentaire(), MenuApplicationId.COMMENTAIRE);
60 jpm 48
 
1608 delphine 49
 
328 jp_milcent 50
	    menuStore.add(accueilMenu, false);
1608 delphine 51
	    menuStore.add(accueilMenu, projetMenu, true);
52
	    menuStore.add(projetMenu, menuCommentaires, true);
53
	    menuStore.add(projetMenu, menuInstitution, true);
54
	    menuStore.add(menuInstitution, menuCollections, true);
55
	    menuStore.add(menuCollections, menuPersonnes, true);
56
	    menuStore.add(menuPersonnes, menuPublications, true);
57
 
60 jpm 58
	}
277 jp_milcent 59
 
553 jp_milcent 60
	private void afficherMenu() {
61
		arbreMenus = new TreePanel<Menu>(menuStore);
1608 delphine 62
		arbreMenus.getStyle().setNodeCloseIcon(null);
63
		arbreMenus.getStyle().setNodeOpenIcon(null);
553 jp_milcent 64
		arbreMenus.setDisplayProperty("nom");
65
		arbreMenus.setHeight("100%");
1608 delphine 66
;		arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
553 jp_milcent 67
			public void handleEvent(TreePanelEvent<Menu> tpe) {
68
				Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem();
791 jpm 69
				mediateur.clicMenu(menuCourant.getCode());
553 jp_milcent 70
			}
71
		});
72
 
73
		add(arbreMenus);
1608 delphine 74
		arbreMenus.setAutoExpand(true);
328 jp_milcent 75
	}
76
 
791 jpm 77
	public void selectionMenu(String code) {
78
		arbreMenus.getSelectionModel().select(menuStore.findModel("code", code), false);
982 jpm 79
	}
277 jp_milcent 80
}