1 | |
package org.kuali.student.common.ui.client.widgets.field.layout.button; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.HashMap; |
5 | |
import java.util.List; |
6 | |
import java.util.Map; |
7 | |
|
8 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
9 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
10 | |
import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations.ButtonEnum; |
11 | |
|
12 | 0 | public abstract class ButtonGroup<T extends ButtonEnum> extends ButtonLayout{ |
13 | 0 | private List<Callback<T>> callbacks = new ArrayList<Callback<T>>(); |
14 | 0 | protected Map<T, KSButton> buttonMap = new HashMap<T, KSButton>(); |
15 | |
|
16 | |
public void addCallback(Callback<T> callback) { |
17 | 0 | callbacks.add(callback); |
18 | 0 | } |
19 | |
|
20 | |
public List<Callback<T>> getCallbacks() { |
21 | 0 | return callbacks; |
22 | |
} |
23 | |
|
24 | |
protected void sendCallbacks(T type){ |
25 | 0 | for(Callback<T> c: getCallbacks()){ |
26 | 0 | c.exec(type); |
27 | |
} |
28 | 0 | } |
29 | |
|
30 | |
public void setButtonText(T key, String text){ |
31 | 0 | buttonMap.get(key).setText(text); |
32 | 0 | } |
33 | |
|
34 | |
public KSButton getButton(T key){ |
35 | 0 | return buttonMap.get(key); |
36 | |
} |
37 | |
} |