1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.ui.client.widgets.search; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.LinkedHashMap; |
20 |
|
import java.util.List; |
21 |
|
|
22 |
|
import org.kuali.student.common.assembly.data.LookupMetadata; |
23 |
|
import org.kuali.student.common.ui.client.application.Application; |
24 |
|
import org.kuali.student.common.ui.client.mvc.Callback; |
25 |
|
import org.kuali.student.common.ui.client.widgets.KSLabel; |
26 |
|
import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel; |
27 |
|
|
28 |
|
import com.google.gwt.event.dom.client.ChangeEvent; |
29 |
|
import com.google.gwt.event.dom.client.ChangeHandler; |
30 |
|
import com.google.gwt.user.client.ui.Composite; |
31 |
|
import com.google.gwt.user.client.ui.ListBox; |
32 |
|
import com.google.gwt.user.client.ui.SimplePanel; |
33 |
|
import com.google.gwt.user.client.ui.Widget; |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 9 |
Complexity Density: 0.39 |
|
35 |
|
public class SwappablePanel extends Composite{ |
36 |
|
private VerticalFlowPanel panel = new VerticalFlowPanel(); |
37 |
|
private ListBox panelSelector = new ListBox(); |
38 |
|
private LinkedHashMap<String, Widget> panelMap = new LinkedHashMap<String, Widget>(); |
39 |
|
private SimplePanel content = new SimplePanel(); |
40 |
|
|
41 |
|
|
42 |
|
private KSLabel searchForLabel = new KSLabel(Application.getApplicationContext().getMessage("swappablePanelSearchBy")); |
43 |
|
private List<Callback<LookupMetadata>> lookupChangedCallbacks = new ArrayList<Callback<LookupMetadata>>(); |
44 |
|
private LinkedHashMap<String, LookupMetadata> searchLookups = new LinkedHashMap<String, LookupMetadata>(); |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
46 |
0
|
public SwappablePanel(LinkedHashMap<String, Widget> panelMap){... |
47 |
0
|
this.panelMap = panelMap; |
48 |
0
|
drawPanel(); |
49 |
0
|
panelSelector.addChangeHandler(new ChangeHandler(){ |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
51 |
0
|
@Override... |
52 |
|
public void onChange(ChangeEvent event) { |
53 |
0
|
int i = panelSelector.getSelectedIndex(); |
54 |
0
|
Widget p = SwappablePanel.this.panelMap.get(panelSelector.getItemText(i)); |
55 |
0
|
content.setWidget(p); |
56 |
0
|
if (lookupChangedCallbacks != null && |
57 |
|
searchLookups != null) { |
58 |
0
|
LookupMetadata selectedLookup = SwappablePanel.this.searchLookups.get( |
59 |
|
panelSelector.getItemText(i)); |
60 |
0
|
for (Callback<LookupMetadata> callback : lookupChangedCallbacks) { |
61 |
0
|
callback.exec(selectedLookup); |
62 |
|
} |
63 |
|
} |
64 |
|
} |
65 |
|
}); |
66 |
|
|
67 |
0
|
this.initWidget(panel); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
70 |
0
|
private void drawPanel(){... |
71 |
0
|
panel.add(searchForLabel); |
72 |
0
|
panel.add(panelSelector); |
73 |
0
|
panel.add(content); |
74 |
|
|
75 |
0
|
boolean contentSet = false; |
76 |
0
|
for (String text : panelMap.keySet()) { |
77 |
0
|
panelSelector.addItem(text); |
78 |
0
|
if (!contentSet) { |
79 |
0
|
content.setWidget(panelMap.get(text)); |
80 |
0
|
contentSet = true; |
81 |
|
} |
82 |
|
} |
83 |
|
} |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0
|
public void addLookupChangedCallback(Callback<LookupMetadata> callback) {... |
86 |
0
|
lookupChangedCallbacks.add(callback); |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
0
|
public LinkedHashMap<String, LookupMetadata> getSearchLookups() {... |
90 |
0
|
return searchLookups; |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0
|
public void setSearchLookups(LinkedHashMap<String, LookupMetadata> searchLookups) {... |
94 |
0
|
this.searchLookups = searchLookups; |
95 |
|
} |
96 |
|
|
97 |
|
} |