1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.ui.client.widgets.buttongroups; |
17 | |
|
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.HashMap; |
21 | |
import java.util.List; |
22 | |
import java.util.Map; |
23 | |
|
24 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
25 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
26 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum; |
27 | |
import org.kuali.student.common.ui.client.widgets.buttonlayout.ButtonLayout; |
28 | |
|
29 | |
import com.google.gwt.user.client.ui.Composite; |
30 | |
import com.google.gwt.user.client.ui.Widget; |
31 | |
|
32 | 0 | public abstract class ButtonGroup<T extends ButtonEnum> extends Composite{ |
33 | 0 | private List<Callback<T>> callbacks = new ArrayList<Callback<T>>(); |
34 | 0 | protected Map<T, KSButton> buttonMap = new HashMap<T, KSButton>(); |
35 | |
protected ButtonLayout layout; |
36 | |
|
37 | |
public void addCallback(Callback<T> callback) { |
38 | 0 | callbacks.add(callback); |
39 | 0 | } |
40 | |
|
41 | |
public List<Callback<T>> getCallbacks() { |
42 | 0 | return callbacks; |
43 | |
} |
44 | |
|
45 | |
protected void sendCallbacks(T type){ |
46 | 0 | for(Callback<T> c: getCallbacks()){ |
47 | 0 | c.exec(type); |
48 | |
} |
49 | 0 | } |
50 | |
|
51 | |
public void setButtonText(T key, String text){ |
52 | 0 | buttonMap.get(key).setText(text); |
53 | 0 | } |
54 | |
|
55 | |
public KSButton getButton(T key){ |
56 | 0 | return buttonMap.get(key); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
public void setContent(Widget content){ |
69 | 0 | layout.setContent(content); |
70 | 0 | } |
71 | |
} |