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;
1633 aurelien 17
import com.google.gwt.user.client.Window;
60 jpm 18
 
982 jpm 19
public class MenuVue extends ContentPanel {
149 gduche 20
 
423 jp_milcent 21
	private Mediateur mediateur = null;
22
	private Constantes i18nC = null;
23
 
553 jp_milcent 24
	private TreePanel<Menu> arbreMenus;
328 jp_milcent 25
	private TreeStore<Menu> menuStore;
277 jp_milcent 26
 
444 jp_milcent 27
	public MenuVue(Mediateur mediateurCourrant) {
423 jp_milcent 28
		mediateur = mediateurCourrant;
919 jpm 29
		i18nC = Mediateur.i18nC;
423 jp_milcent 30
 
1680 raphael 31
		setHeadingHtml(i18nC.titreMenu());
982 jpm 32
		setLayout(new FitLayout());
60 jpm 33
		setLayoutOnChange(true);
553 jp_milcent 34
 
35
		construireMenu();
36
		afficherMenu();
60 jpm 37
	}
38
 
328 jp_milcent 39
	private void construireMenu() {
40
		menuStore = new TreeStore<Menu>();
60 jpm 41
 
423 jp_milcent 42
		Menu accueilMenu = new Menu(i18nC.menuAccueil(), MenuApplicationId.ACCUEIL);
43
		Menu projetMenu = new Menu(i18nC.menuProjet(), MenuApplicationId.PROJET);
44
	    Menu menuInstitution = new Menu(i18nC.menuStructure(), MenuApplicationId.STRUCTURE);
45
	    Menu menuCollections = new Menu(i18nC.menuCollection(), MenuApplicationId.COLLECTION);
46
	    Menu menuPersonnes = new Menu(i18nC.menuPersonne(), MenuApplicationId.PERSONNE);
47
	    Menu menuPublications = new Menu(i18nC.menuPublication(), MenuApplicationId.PUBLICATION);
985 jpm 48
	    Menu menuCommentaires = new Menu(i18nC.menuCommentaire(), MenuApplicationId.COMMENTAIRE);
60 jpm 49
 
1608 delphine 50
 
328 jp_milcent 51
	    menuStore.add(accueilMenu, false);
1608 delphine 52
	    menuStore.add(accueilMenu, projetMenu, true);
1639 aurelien 53
	    menuStore.add(accueilMenu, menuInstitution, true);
54
	    menuStore.add(accueilMenu, menuCollections, true);
55
	    menuStore.add(accueilMenu, menuPersonnes, true);
56
	    menuStore.add(accueilMenu, menuPublications, true);
57
	    menuStore.add(accueilMenu, menuCommentaires, true);
1608 delphine 58
 
60 jpm 59
	}
277 jp_milcent 60
 
553 jp_milcent 61
	private void afficherMenu() {
62
		arbreMenus = new TreePanel<Menu>(menuStore);
1608 delphine 63
		arbreMenus.getStyle().setNodeCloseIcon(null);
64
		arbreMenus.getStyle().setNodeOpenIcon(null);
553 jp_milcent 65
		arbreMenus.setDisplayProperty("nom");
66
		arbreMenus.setHeight("100%");
1633 aurelien 67
		arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
553 jp_milcent 68
			public void handleEvent(TreePanelEvent<Menu> tpe) {
69
				Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem();
791 jpm 70
				mediateur.clicMenu(menuCourant.getCode());
553 jp_milcent 71
			}
72
		});
73
 
74
		add(arbreMenus);
1608 delphine 75
		arbreMenus.setAutoExpand(true);
328 jp_milcent 76
	}
77
 
791 jpm 78
	public void selectionMenu(String code) {
79
		arbreMenus.getSelectionModel().select(menuStore.findModel("code", code), false);
982 jpm 80
	}
277 jp_milcent 81
}