1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.ui.client.widgets.list; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import org.kuali.student.common.dto.Idable; |
22 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
23 | |
import org.kuali.student.common.ui.client.mvc.HasWidgetReadyCallback; |
24 | |
|
25 | |
import com.google.gwt.event.dom.client.HasBlurHandlers; |
26 | |
import com.google.gwt.event.dom.client.HasFocusHandlers; |
27 | |
import com.google.gwt.event.shared.HandlerRegistration; |
28 | |
import com.google.gwt.user.client.ui.Composite; |
29 | |
import com.google.gwt.user.client.ui.HasName; |
30 | |
import com.google.gwt.user.client.ui.Widget; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 0 | public abstract class KSSelectItemWidgetAbstract extends Composite implements HasName, HasFocusHandlers, HasBlurHandlers, HasSelectionChangeHandlers, HasWidgetReadyCallback{ |
41 | 0 | private ListItems listItems = null; |
42 | |
private String name; |
43 | |
private List<Callback<Widget>> widgetReadyCallbacks; |
44 | 0 | private boolean initialized = false; |
45 | |
|
46 | |
public ListItems getListItems() { |
47 | 0 | return listItems; |
48 | |
} |
49 | |
|
50 | |
public <T extends Idable> void setListItems(ListItems listItems) { |
51 | 0 | this.listItems = listItems; |
52 | 0 | } |
53 | |
|
54 | |
public abstract void redraw(); |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public HandlerRegistration addSelectionChangeHandler(SelectionChangeHandler selectionHandler){ |
63 | 0 | return addHandler(selectionHandler,SelectionChangeEvent.getType()); |
64 | |
} |
65 | |
|
66 | |
protected void fireChangeEvent(boolean userInitiated){ |
67 | 0 | SelectionChangeEvent.fire(this, userInitiated); |
68 | 0 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
public abstract void selectItem(String id); |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public abstract void deSelectItem(String id); |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public abstract List<String> getSelectedItems(); |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
public String getSelectedItem(){ |
100 | 0 | String selectedItem = null; |
101 | 0 | List<String> selectedItems = getSelectedItems(); |
102 | 0 | if (selectedItems != null && selectedItems.size() > 0){ |
103 | 0 | selectedItem = selectedItems.get(0); |
104 | |
} |
105 | 0 | return selectedItem; |
106 | |
} |
107 | |
|
108 | |
public String getName() { |
109 | 0 | return this.name; |
110 | |
} |
111 | |
|
112 | |
public void setName(String name) { |
113 | 0 | this.name = name; |
114 | 0 | } |
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public void setMultipleSelect(boolean isMultipleSelect){ |
121 | 0 | throw new UnsupportedOperationException(); |
122 | |
} |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public boolean isMultipleSelect(){ |
130 | 0 | return false; |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public void setColumnSize(int col){ |
138 | 0 | throw new UnsupportedOperationException(); |
139 | |
} |
140 | |
|
141 | |
public abstract void onLoad(); |
142 | |
|
143 | |
public abstract void setEnabled(boolean b); |
144 | |
|
145 | |
public abstract boolean isEnabled(); |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public abstract void clear(); |
153 | |
|
154 | |
@Override |
155 | |
public void addWidgetReadyCallback(Callback<Widget> callback) { |
156 | 0 | if (widgetReadyCallbacks == null){ |
157 | 0 | widgetReadyCallbacks = new ArrayList<Callback<Widget>>(); |
158 | |
} |
159 | 0 | widgetReadyCallbacks.add(callback); |
160 | 0 | } |
161 | |
|
162 | |
@Override |
163 | |
public void setInitialized(boolean initialized) { |
164 | 0 | this.initialized = initialized; |
165 | 0 | if (initialized){ |
166 | |
|
167 | 0 | while (widgetReadyCallbacks != null && widgetReadyCallbacks.size() > 0){ |
168 | 0 | Callback<Widget> callback = widgetReadyCallbacks.remove(0); |
169 | 0 | callback.exec(this); |
170 | 0 | } |
171 | |
} |
172 | 0 | } |
173 | |
|
174 | |
@Override |
175 | |
public boolean isInitialized() { |
176 | 0 | return initialized; |
177 | |
} |
178 | |
} |