Subversion Repositories eFlore/Applications.coel

Rev

Rev 985 | Rev 1369 | 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;
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
 
328 jp_milcent 49
	    menuStore.add(accueilMenu, false);
50
	    menuStore.add(projetMenu, false);
51
	    menuStore.add(menuInstitution, false);
52
	    menuStore.add(menuCollections, false);
53
	    menuStore.add(menuPersonnes, false);
54
	    menuStore.add(menuPublications, false);
985 jpm 55
	    menuStore.add(menuCommentaires, false);
60 jpm 56
	}
277 jp_milcent 57
 
553 jp_milcent 58
	private void afficherMenu() {
59
		arbreMenus = new TreePanel<Menu>(menuStore);
60
		arbreMenus.getStyle().setLeafIcon(GXT.IMAGES.tree_folder());
61
		arbreMenus.setDisplayProperty("nom");
62
		arbreMenus.setHeight("100%");
63
		arbreMenus.addListener(Events.OnClick, new Listener<TreePanelEvent<Menu>>(){
64
			public void handleEvent(TreePanelEvent<Menu> tpe) {
65
				Menu menuCourant = arbreMenus.getSelectionModel().getSelectedItem();
791 jpm 66
				mediateur.clicMenu(menuCourant.getCode());
553 jp_milcent 67
			}
68
		});
69
 
70
		add(arbreMenus);
328 jp_milcent 71
	}
72
 
791 jpm 73
	public void selectionMenu(String code) {
74
		arbreMenus.getSelectionModel().select(menuStore.findModel("code", code), false);
982 jpm 75
	}
277 jp_milcent 76
}