1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.lum.common.client.lo;
17
18 import java.util.List;
19
20 import org.kuali.student.common.assembly.data.Data;
21 import org.kuali.student.common.ui.client.widgets.KSLabel;
22 import org.kuali.student.common.ui.client.widgets.KSTextArea;
23 import org.kuali.student.common.ui.client.widgets.layout.VerticalFlowPanel;
24 import org.kuali.student.common.ui.client.widgets.list.HasSelectionChangeHandlers;
25 import org.kuali.student.common.ui.client.widgets.list.SelectionChangeEvent;
26 import org.kuali.student.common.ui.client.widgets.list.SelectionChangeHandler;
27 import org.kuali.student.lum.lo.dto.LoCategoryInfo;
28
29 import com.google.gwt.event.logical.shared.ValueChangeEvent;
30 import com.google.gwt.event.logical.shared.ValueChangeHandler;
31 import com.google.gwt.event.shared.HandlerRegistration;
32 import com.google.gwt.user.client.ui.HorizontalPanel;
33
34
35
36
37
38
39
40 public class LOPicker extends HorizontalPanel implements HasSelectionChangeHandlers{
41 KSLabel countLabel = new KSLabel();
42 KSTextArea loTextArea;
43 VerticalFlowPanel vp = new VerticalFlowPanel();
44 LOCategoryBuilder loCategoryBuilder;
45 Data metaInfoData;
46 public LOPicker(String messageGroup, String type, String state, String loRepoKey, int maxLength) {
47 super();
48 this.loTextArea = new KSTextArea(countLabel, maxLength);
49 loCategoryBuilder = new LOCategoryBuilder(messageGroup, type, state, loRepoKey);
50 loTextArea.removeStyleName("ks-form-module-elements");
51 loTextArea.addStyleName("KS-LOTextArea");
52 countLabel.addStyleName("ks-form-module-elements-help-text");
53 countLabel.addStyleName("loText-count-label");
54 vp.add(loTextArea);
55 vp.add(countLabel);
56 super.add(vp);
57 super.add(loCategoryBuilder);
58
59 loTextArea.addValueChangeHandler(new ValueChangeHandler<String>(){
60 public void onValueChange(ValueChangeEvent<String> event) {
61 fireChangeEvent();
62 }
63 });
64
65 loCategoryBuilder.addValueChangeHandler(new ValueChangeHandler<List<LoCategoryInfo>>(){
66 public void onValueChange(
67 ValueChangeEvent<List<LoCategoryInfo>> event) {
68 fireChangeEvent();
69 }
70 });
71 }
72 public void setLOCategories(List<LoCategoryInfo> categories){
73 loCategoryBuilder.setValue(categories);
74 }
75 public List<LoCategoryInfo> getLoCategories(){
76 return loCategoryBuilder.getValue();
77 }
78 public String getLOText(){
79 return this.loTextArea.getText();
80 }
81 public void setLOText(String value){
82 this.loTextArea.setText(value);
83 }
84 public Data getMetaInfoData() {
85 return metaInfoData;
86 }
87 public void setMetaInfoData(Data metaInfoData) {
88 this.metaInfoData = metaInfoData;
89 }
90
91 @Override
92 public HandlerRegistration addSelectionChangeHandler(SelectionChangeHandler handler) {
93 return addHandler(handler, SelectionChangeEvent.getType());
94 }
95
96 public boolean hasChangeHandler(){
97 return this.getHandlerCount(SelectionChangeEvent.getType()) > 0;
98 }
99
100 private void fireChangeEvent(){
101 SelectionChangeEvent.fire(this);
102 }
103 @Override
104 protected void onEnsureDebugId(String baseID) {
105 super.onEnsureDebugId(baseID);
106 loTextArea.ensureDebugId(baseID);
107 loCategoryBuilder.ensureDebugId(baseID);
108 }
109
110
111 }