Subversion Repositories eFlore/Applications.coel

Rev

Rev 1865 | Go to most recent revision | Details | Compare with Previous | 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 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);
1639 aurelien 51
	    menuStore.add(accueilMenu, menuInstitution, true);
52
	    menuStore.add(accueilMenu, menuCollections, true);
53
	    menuStore.add(accueilMenu, menuPersonnes, true);
54
	    menuStore.add(accueilMenu, menuPublications, true);
55
	    menuStore.add(accueilMenu, menuCommentaires, true);
1608 delphine 56
 
60 jpm 57
	}
277 jp_milcent 58
 
553 jp_milcent 59
	private void afficherMenu() {
60
		arbreMenus = new TreePanel<Menu>(menuStore);
1608 delphine 61
		arbreMenus.getStyle().setNodeCloseIcon(null);
62
		arbreMenus.getStyle().setNodeOpenIcon(null);
553 jp_milcent 63
		arbreMenus.setDisplayProperty("nom");
64
		arbreMenus.setHeight("100%");
1633 aurelien 65
		arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
553 jp_milcent 66
			public void handleEvent(TreePanelEvent<Menu> tpe) {
67
				Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem();
791 jpm 68
				mediateur.clicMenu(menuCourant.getCode());
553 jp_milcent 69
			}
70
		});
71
 
72
		add(arbreMenus);
1608 delphine 73
		arbreMenus.setAutoExpand(true);
328 jp_milcent 74
	}
75
 
791 jpm 76
	public void selectionMenu(String code) {
77
		arbreMenus.getSelectionModel().select(menuStore.findModel("code", code), false);
982 jpm 78
	}
277 jp_milcent 79
}