1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.ui.client.widgets.tabs.impl; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.HashMap; |
20 |
|
import java.util.List; |
21 |
|
import java.util.Map; |
22 |
|
|
23 |
|
import org.kuali.student.common.ui.client.mvc.Callback; |
24 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
25 |
|
import org.kuali.student.common.ui.client.widgets.ClickablePanel; |
26 |
|
import org.kuali.student.common.ui.client.widgets.KSLabel; |
27 |
|
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
28 |
|
import org.kuali.student.common.ui.client.widgets.menus.KSListPanel; |
29 |
|
import org.kuali.student.common.ui.client.widgets.tabs.KSTabPanelAbstract; |
30 |
|
import org.kuali.student.common.ui.client.widgets.tabs.KSTabPanel.TabPanelStyle; |
31 |
|
import org.kuali.student.common.ui.client.widgets.tabs.KSTabPanel.TabPosition; |
32 |
|
|
33 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
34 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
35 |
|
import com.google.gwt.event.dom.client.MouseOutEvent; |
36 |
|
import com.google.gwt.event.dom.client.MouseOutHandler; |
37 |
|
import com.google.gwt.event.dom.client.MouseOverEvent; |
38 |
|
import com.google.gwt.event.dom.client.MouseOverHandler; |
39 |
|
import com.google.gwt.user.client.ui.ComplexPanel; |
40 |
|
import com.google.gwt.user.client.ui.Composite; |
41 |
|
import com.google.gwt.user.client.ui.FlowPanel; |
42 |
|
import com.google.gwt.user.client.ui.HorizontalPanel; |
43 |
|
import com.google.gwt.user.client.ui.Image; |
44 |
|
import com.google.gwt.user.client.ui.Label; |
45 |
|
import com.google.gwt.user.client.ui.SimplePanel; |
46 |
|
import com.google.gwt.user.client.ui.Widget; |
47 |
|
|
|
|
| 0% |
Uncovered Elements: 98 (98) |
Complexity: 26 |
Complexity Density: 0.4 |
|
48 |
|
public class KSTabPanelImpl extends KSTabPanelAbstract{ |
49 |
|
|
50 |
|
private VerticalFlowPanel container = new VerticalFlowPanel(); |
51 |
|
private FlowPanel tabRow = new FlowPanel(); |
52 |
|
|
53 |
|
|
54 |
|
private KSListPanel left = new KSListPanel(); |
55 |
|
private KSListPanel right = new KSListPanel(); |
56 |
|
private SimplePanel content = new SimplePanel(); |
57 |
|
private Tab selectedTab; |
58 |
|
private Map<String, Tab> tabMap = new HashMap<String, Tab>(); |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
|
|
| 0% |
Uncovered Elements: 110 (110) |
Complexity: 33 |
Complexity Density: 0.49 |
|
104 |
|
protected class Tab extends Composite{ |
105 |
|
private boolean selected = false; |
106 |
|
private Widget tab; |
107 |
|
private ClickablePanel tabPanel = new ClickablePanel(); |
108 |
|
private Widget displayContent; |
109 |
|
private int labelIndex = -1; |
110 |
|
private String tabKey = ""; |
111 |
|
private List<Callback<String>> callbacks = new ArrayList<Callback<String>>(); |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
113 |
0
|
public Tab(String key, String label, Image image, Widget displayContent){... |
114 |
0
|
tabKey = key; |
115 |
0
|
HorizontalPanel tabContent = new HorizontalPanel(); |
116 |
0
|
tabContent.add(image); |
117 |
0
|
KSLabel labelWidget = new KSLabel(label); |
118 |
0
|
tabContent.add(labelWidget); |
119 |
0
|
labelIndex = tabContent.getWidgetIndex(labelWidget); |
120 |
0
|
init(tabContent, displayContent); |
121 |
|
|
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
124 |
0
|
public Tab(String key, String label, Widget displayContent){... |
125 |
0
|
tabKey = key; |
126 |
0
|
KSLabel labelWidget = new KSLabel(label); |
127 |
0
|
init(labelWidget, displayContent); |
128 |
|
} |
129 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
130 |
0
|
public Tab(String key, Widget tab, Widget displayContent){... |
131 |
0
|
tabKey = key; |
132 |
0
|
init(tab, displayContent); |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0
|
public void addCallback(Callback<String> callback) {... |
136 |
0
|
callbacks.add(callback); |
137 |
|
} |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
0
|
public void emptyCallbacks(){... |
140 |
0
|
callbacks = new ArrayList<Callback<String>>(); |
141 |
|
} |
142 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
0
|
public String getTabKey() {... |
144 |
0
|
return tabKey; |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
147 |
0
|
public void init(Widget tab, Widget displayContent){... |
148 |
0
|
this.tab = tab; |
149 |
0
|
this.tabPanel.setWidget(tab); |
150 |
0
|
tabPanel.addMouseOverHandler(new MouseOverHandler(){ |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0
|
@Override... |
153 |
|
public void onMouseOver(MouseOverEvent event) { |
154 |
0
|
Tab.this.onMouseOver(); |
155 |
|
|
156 |
|
} |
157 |
|
}); |
158 |
0
|
tabPanel.addClickHandler(new ClickHandler(){ |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
160 |
0
|
@Override... |
161 |
|
public void onClick(ClickEvent event) { |
162 |
0
|
Tab.this.onSelect(); |
163 |
0
|
if(!callbacks.isEmpty()){ |
164 |
0
|
for(Callback<String> callback: callbacks){ |
165 |
0
|
callback.exec(tabKey); |
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
0
|
HistoryManager.logHistoryChange(); |
172 |
|
} |
173 |
|
} |
174 |
|
}); |
175 |
0
|
tabPanel.addMouseOutHandler(new MouseOutHandler(){ |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
0
|
@Override... |
178 |
|
public void onMouseOut(MouseOutEvent event) { |
179 |
0
|
Tab.this.onMouseOut(); |
180 |
|
|
181 |
|
} |
182 |
|
}); |
183 |
0
|
tabPanel.addStyleName("KS-TabPanel-Tab"); |
184 |
0
|
this.initWidget(tabPanel); |
185 |
0
|
this.displayContent = displayContent; |
186 |
|
} |
187 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
188 |
0
|
public void addTabStyleName(String style){... |
189 |
0
|
tabPanel.addStyleName(style); |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 5 |
Complexity Density: 0.38 |
|
192 |
0
|
public void onSelect(){... |
193 |
0
|
KSTabPanelImpl.this.deselectCurrentTab(); |
194 |
0
|
KSTabPanelImpl.this.selectedTab = Tab.this; |
195 |
0
|
selected = true; |
196 |
0
|
this.onMouseOut(); |
197 |
0
|
tabPanel.addStyleName("KS-TabPanel-Tab-Selected"); |
198 |
0
|
if(tab instanceof Label || tab instanceof KSLabel){ |
199 |
0
|
tab.addStyleName("KS-TabPanel-Tab-Label-Selected"); |
200 |
|
} |
201 |
0
|
else if(tab instanceof ComplexPanel){ |
202 |
0
|
if(labelIndex != -1){ |
203 |
0
|
Widget w = ((ComplexPanel) tab).getWidget(labelIndex); |
204 |
0
|
w.addStyleName("KS-TabPanel-Tab-Label-Selected"); |
205 |
|
} |
206 |
|
} |
207 |
0
|
KSTabPanelImpl.this.content.clear(); |
208 |
0
|
KSTabPanelImpl.this.content.setWidget(displayContent); |
209 |
|
|
210 |
|
|
211 |
|
} |
212 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
213 |
0
|
public void onDeselect(){... |
214 |
0
|
selected = false; |
215 |
0
|
tabPanel.removeStyleName("KS-TabPanel-Tab-Selected"); |
216 |
0
|
if(tab instanceof Label || tab instanceof KSLabel){ |
217 |
0
|
tab.removeStyleName("KS-TabPanel-Tab-Label-Selected"); |
218 |
|
} |
219 |
0
|
else if(tab instanceof ComplexPanel){ |
220 |
0
|
if(labelIndex != -1){ |
221 |
0
|
Widget w = ((ComplexPanel) tab).getWidget(labelIndex); |
222 |
0
|
w.removeStyleName("KS-TabPanel-Tab-Label-Selected"); |
223 |
|
} |
224 |
|
} |
225 |
|
} |
226 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.75 |
|
227 |
0
|
public void onMouseOver(){... |
228 |
0
|
if(!selected){ |
229 |
0
|
tabPanel.addStyleName("KS-TabPanel-Tab-Hover"); |
230 |
0
|
if(tab instanceof Label || tab instanceof KSLabel){ |
231 |
0
|
tab.addStyleName("KS-TabPanel-Tab-Label-Hover"); |
232 |
|
} |
233 |
0
|
else if(tab instanceof ComplexPanel){ |
234 |
0
|
if(labelIndex != -1){ |
235 |
0
|
Widget w = ((ComplexPanel) tab).getWidget(labelIndex); |
236 |
0
|
w.addStyleName("KS-TabPanel-Tab-Label-Hover"); |
237 |
|
} |
238 |
|
} |
239 |
|
} |
240 |
|
} |
241 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
242 |
0
|
public void onMouseOut(){... |
243 |
0
|
tabPanel.removeStyleName("KS-TabPanel-Tab-Hover"); |
244 |
0
|
if(tab instanceof Label || tab instanceof KSLabel){ |
245 |
0
|
tab.removeStyleName("KS-TabPanel-Tab-Label-Hover"); |
246 |
|
} |
247 |
0
|
else if(tab instanceof ComplexPanel){ |
248 |
0
|
if(labelIndex != -1){ |
249 |
0
|
Widget w = ((ComplexPanel) tab).getWidget(labelIndex); |
250 |
0
|
w.removeStyleName("KS-TabPanel-Tab-Label-Hover"); |
251 |
|
} |
252 |
|
} |
253 |
|
} |
254 |
|
} |
255 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
256 |
0
|
public KSTabPanelImpl(){... |
257 |
|
|
258 |
|
|
259 |
|
|
260 |
0
|
tabRow.add(left); |
261 |
0
|
tabRow.add(right); |
262 |
0
|
tabRow.addStyleName("KS-TabPanel-TabRow"); |
263 |
0
|
left.addStyleName("KS-TabPanel-Left-Panel"); |
264 |
0
|
right.addStyleName("KS-TabPanel-Right-Panel"); |
265 |
0
|
container.addStyleName("KS-TabPanel-Full"); |
266 |
0
|
content.addStyleName("KS-TabPanel-Content"); |
267 |
0
|
container.add(tabRow); |
268 |
0
|
container.add(content); |
269 |
0
|
this.initWidget(container); |
270 |
|
} |
271 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
272 |
0
|
public KSTabPanelImpl(TabPanelStyle style){... |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
0
|
tabRow.add(left); |
277 |
0
|
tabRow.add(right); |
278 |
0
|
tabRow.addStyleName("KS-TabPanel-TabRow"); |
279 |
0
|
left.addStyleName("KS-TabPanel-Left-Panel"); |
280 |
0
|
right.addStyleName("KS-TabPanel-Right-Panel"); |
281 |
|
|
282 |
0
|
container.addStyleName("KS-TabPanel"); |
283 |
0
|
content.addStyleName("KS-TabPanel-Content"); |
284 |
0
|
container.add(tabRow); |
285 |
0
|
container.add(content); |
286 |
0
|
this.initWidget(container); |
287 |
|
} |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
289 |
0
|
public void setTabPanelStyle(TabPanelStyle style){... |
290 |
0
|
if(style == TabPanelStyle.FULL_PAGE){ |
291 |
0
|
container.setStyleName("KS-TabPanel-Full"); |
292 |
|
} |
293 |
0
|
else if(style == TabPanelStyle.SMALL){ |
294 |
0
|
container.setStyleName("KS-TabPanel-Small"); |
295 |
|
} |
296 |
|
} |
297 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
298 |
0
|
private void deselectCurrentTab() {... |
299 |
0
|
if(selectedTab != null){ |
300 |
0
|
selectedTab.onDeselect(); |
301 |
|
} |
302 |
|
} |
303 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
304 |
0
|
@Override... |
305 |
|
public void selectTab(String key){ |
306 |
0
|
Tab tab = tabMap.get(key); |
307 |
0
|
tab.onSelect(); |
308 |
|
} |
309 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
310 |
0
|
@Override... |
311 |
|
public void removeTab(String key){ |
312 |
0
|
Tab tab = tabMap.get(key); |
313 |
0
|
tab.removeFromParent(); |
314 |
|
} |
315 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
316 |
0
|
private void positionTab(Tab tab, TabPosition position){... |
317 |
0
|
if(position == TabPosition.LEFT){ |
318 |
0
|
tab.addStyleName("KS-TabPanel-Tab-Left"); |
319 |
0
|
left.add(tab); |
320 |
|
} |
321 |
|
else{ |
322 |
0
|
tab.addStyleName("KS-TabPanel-Tab-Right"); |
323 |
0
|
right.add(tab); |
324 |
|
} |
325 |
|
} |
326 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
327 |
0
|
@Override... |
328 |
|
public void addTab(String key, Widget tabWidget, Widget content, TabPosition position){ |
329 |
0
|
Tab tab = new Tab(key, tabWidget, content); |
330 |
0
|
tabMap.put(key, tab); |
331 |
0
|
positionTab(tab, position); |
332 |
|
} |
333 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
334 |
0
|
@Override... |
335 |
|
public void addTab(String key, String label, Widget content, TabPosition position){ |
336 |
0
|
Tab tab = new Tab(key, label, content); |
337 |
0
|
tabMap.put(key, tab); |
338 |
0
|
positionTab(tab, position); |
339 |
|
} |
340 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
341 |
0
|
@Override... |
342 |
|
public void addTab(String key, String label, Image image, Widget content, TabPosition position){ |
343 |
0
|
Tab tab = new Tab(key, label, image, content); |
344 |
0
|
tabMap.put(key, tab); |
345 |
0
|
positionTab(tab, position); |
346 |
|
} |
347 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
348 |
0
|
@Override... |
349 |
|
public void addTab(String key, String label, Image image, Widget content){ |
350 |
0
|
Tab tab = new Tab(key, label, image, content); |
351 |
0
|
tabMap.put(key, tab); |
352 |
0
|
positionTab(tab, TabPosition.LEFT); |
353 |
|
} |
354 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
355 |
0
|
@Override... |
356 |
|
public void addTab(String key, String label, Widget content){ |
357 |
0
|
Tab tab = new Tab(key, label, content); |
358 |
0
|
tabMap.put(key, tab); |
359 |
0
|
positionTab(tab, TabPosition.LEFT); |
360 |
|
} |
361 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
362 |
0
|
@Override... |
363 |
|
public void addTab(String key, Widget tabWidget, Widget content){ |
364 |
0
|
Tab tab = new Tab(key, tabWidget, content); |
365 |
0
|
tabMap.put(key, tab); |
366 |
0
|
positionTab(tab, TabPosition.LEFT); |
367 |
|
} |
368 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
369 |
0
|
@Override... |
370 |
|
public void addStyleName(String style) { |
371 |
0
|
container.addStyleName(style); |
372 |
|
} |
373 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
374 |
0
|
@Override... |
375 |
|
public void addTabCustomCallback(final String key, final Callback<String> callback) { |
376 |
0
|
Tab tab = tabMap.get(key); |
377 |
0
|
if(tab != null){ |
378 |
0
|
tab.addCallback(callback); |
379 |
|
} |
380 |
|
|
381 |
|
} |
382 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
383 |
0
|
@Override... |
384 |
|
public String getSelectedTabKey() { |
385 |
0
|
if(selectedTab != null){ |
386 |
0
|
return selectedTab.getTabKey(); |
387 |
|
} |
388 |
|
else{ |
389 |
0
|
return ""; |
390 |
|
} |
391 |
|
|
392 |
|
} |
393 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
394 |
0
|
@Override... |
395 |
|
public int getTabCount() { |
396 |
0
|
return tabMap.size(); |
397 |
|
} |
398 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
399 |
0
|
@Override... |
400 |
|
public void removeTabCustomCallbacks(String key) { |
401 |
0
|
Tab tab = tabMap.get(key); |
402 |
0
|
if(tab != null){ |
403 |
0
|
tab.emptyCallbacks(); |
404 |
|
} |
405 |
|
|
406 |
|
} |
407 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
408 |
0
|
@Override... |
409 |
|
public boolean hasTabKey(String key) { |
410 |
0
|
return tabMap.containsKey(key); |
411 |
|
} |
412 |
|
|
413 |
|
|
414 |
|
} |