Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
913 jpm 1
package org.tela_botanica.client.vues.accueil;
2
 
3
import org.tela_botanica.client.util.Debug;
4
 
5
import com.extjs.gxt.ui.client.Style.Scroll;
6
import com.extjs.gxt.ui.client.event.IconButtonEvent;
7
import com.extjs.gxt.ui.client.event.SelectionListener;
8
import com.extjs.gxt.ui.client.widget.button.ToolButton;
9
import com.extjs.gxt.ui.client.widget.custom.Portlet;
10
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
11
 
12
abstract public class Applette extends Portlet {
13
 
14
	private ToolButton epingleBouton = null;
15
	private ToolButton configurationBouton = null;
16
	private ToolButton fermetureBouton = null;
17
 
18
	protected void initialiserApplette() {
19
		initialiserApplette(null);
20
	}
21
 
22
	protected void initialiserApplette(String titre) {
23
		setLayout(new FitLayout());
24
		setHeight(250);
25
		setCollapsible(true);
26
		setAnimCollapse(true);
27
		setScrollMode(Scroll.AUTO);
28
		setTitre(titre);
29
 
30
		configurationBouton  = new ToolButton("x-tool-gear");
31
		getHeader().addTool(configurationBouton);
32
 
33
		epingleBouton  = getBoutonEpingle();
34
		getHeader().addTool(epingleBouton);
35
 
36
		fermetureBouton = getBoutonFermeture();
37
		getHeader().addTool(fermetureBouton);
38
	}
39
 
40
	private ToolButton getBoutonEpingle() {
41
		ToolButton bouton = new ToolButton("x-tool-pin", new SelectionListener<IconButtonEvent>() {
42
			@Override
43
			public void componentSelected(IconButtonEvent ce) {
44
				setEpingler(!isPinned());
45
			}
46
		});
47
		return bouton;
48
	}
49
 
50
	private ToolButton getBoutonFermeture() {
51
		ToolButton bouton = new ToolButton("x-tool-close", new SelectionListener<IconButtonEvent>() {
52
			@Override
53
			public void componentSelected(IconButtonEvent ce) {
54
				removeFromParent();
55
			}
56
		});
57
		return bouton;
58
	}
59
 
60
	public void setTitre(String titre) {
61
		if (titre != null) {
62
			setHeading(titre);
63
		}
64
	}
65
 
66
	public void setEpingler(boolean epingler) {
67
		if (epingler) {
68
			epingleBouton.setStyleName("x-tool-unpin x-tool");
69
			setPinned(true);
70
		} else {
71
			epingleBouton.setStyleName("x-tool-pin x-tool");
72
			setPinned(false);
73
		}
74
		Debug.log(epingleBouton.getStyleName());
75
		layout();
76
	}
77
 
78
	protected void ajouterConfigurationListener(SelectionListener<IconButtonEvent> configurationListener) {
79
		configurationBouton.addSelectionListener(configurationListener);
80
	}
81
}