1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.widget.client.impl;
26
27 import java.util.ArrayList;
28
29 import org.utgenome.gwt.widget.client.Icon;
30 import org.utgenome.gwt.widget.client.NowLoadingIcon;
31 import org.utgenome.gwt.widget.client.Switch;
32 import org.utgenome.gwt.widget.client.TrackButtonListener;
33 import org.utgenome.gwt.widget.client.TrackFrame;
34 import org.utgenome.gwt.widget.client.UTGBDesignFactory;
35
36 import com.google.gwt.event.dom.client.ClickEvent;
37 import com.google.gwt.event.dom.client.ClickHandler;
38 import com.google.gwt.user.client.ui.HorizontalPanel;
39
40
41
42
43
44
45
46
47 public class IconSetPanel extends HorizontalPanel {
48
49 private final TrackFrame parentTrackPanel;
50
51 private int visibleButtonFlag = TrackFrame.BUTTON_ALL;
52
53
54 private NowLoadingIcon loadButton;
55 private Icon configButton;
56 private Switch adjustHightButton;
57 private Switch minimizeButton;
58 private Icon closeButton;
59
60
61 private ArrayList<TrackButtonListener> buttonListenerList = new ArrayList<TrackButtonListener>();
62
63 public IconSetPanel(TrackFrame parentTrackPanel) {
64 this.parentTrackPanel = parentTrackPanel;
65
66
67 UTGBDesignFactory iconFactory = new UTGBDesignFactory();
68
69 loadButton = iconFactory.getNowLoadingIcon();
70 configButton = iconFactory.getConfigButton();
71 adjustHightButton = iconFactory.getAdjustHightSwitch();
72 minimizeButton = iconFactory.getOpenHideSwith();
73 closeButton = iconFactory.getCloseButton();
74
75 loadButton.addClickHandler(new ClickHandler() {
76 public void onClick(ClickEvent event) {
77 fireOnClickReloadButton();
78 }
79 });
80 configButton.addClickHandler(new ClickHandler() {
81 public void onClick(ClickEvent arg0) {
82 fireOnClickConfigButton();
83 }
84 });
85 adjustHightButton.addClickHandler(new ClickHandler() {
86 public void onClick(ClickEvent arg0) {
87 fireOnClickAdjustHightButton();
88 }
89 });
90 minimizeButton.addClickHandler(new ClickHandler() {
91 public void onClick(ClickEvent arg0) {
92 fireOnClickMinimizeButton();
93 }
94 });
95
96 closeButton.addClickHandler(new ClickHandler() {
97 public void onClick(ClickEvent arg0) {
98 fireOnClickCloseButton();
99 }
100 });
101
102 drawWidget();
103 }
104
105 private void drawWidget() {
106 this.clear();
107
108 this.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
109
110 if ((visibleButtonFlag & TrackFrame.BUTTON_RELOAD) != 0)
111 this.add(loadButton);
112 if ((visibleButtonFlag & TrackFrame.BUTTON_CONFIG) != 0)
113 this.add(configButton);
114 if ((visibleButtonFlag & TrackFrame.BUTTON_ADJUSTHEIGHT) != 0)
115 this.add(adjustHightButton);
116 if ((visibleButtonFlag & TrackFrame.BUTTON_MINIMIZE) != 0)
117 this.add(minimizeButton);
118 if ((visibleButtonFlag & TrackFrame.BUTTON_CLOSE) != 0)
119 this.add(closeButton);
120
121 }
122
123 private void fireOnClickReloadButton() {
124 for (TrackButtonListener listener : buttonListenerList)
125 listener.onClickReloadButton(parentTrackPanel);
126 }
127
128 private void fireOnClickConfigButton() {
129 for (TrackButtonListener listener : buttonListenerList)
130 listener.onClickConfigButton(parentTrackPanel);
131 }
132
133 private void fireOnClickAdjustHightButton() {
134 for (TrackButtonListener listener : buttonListenerList)
135 listener.onClickAdjustHightButton(parentTrackPanel);
136 }
137
138 private void fireOnClickMinimizeButton() {
139 for (TrackButtonListener listener : buttonListenerList)
140 listener.onClickMinimizeButton(parentTrackPanel);
141 }
142
143 private void fireOnClickCloseButton() {
144 for (TrackButtonListener listener : buttonListenerList)
145 listener.onClickCloseButton(parentTrackPanel);
146 }
147
148 public void addTrackButtonListener(TrackButtonListener listener) {
149 buttonListenerList.add(listener);
150 }
151
152 public void setVisible(int buttonType, boolean visible) {
153 if (visible)
154 visibleButtonFlag |= buttonType;
155 else
156 visibleButtonFlag &= ~buttonType;
157
158 drawWidget();
159 }
160
161 public void setLoading(boolean rotate) {
162 loadButton.setLoading(rotate);
163
164 }
165
166 }