| 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 | 0 | public class LOPicker extends HorizontalPanel implements HasSelectionChangeHandlers{ |
| 41 | 0 | KSLabel countLabel = new KSLabel(); |
| 42 | |
KSTextArea loTextArea; |
| 43 | 0 | VerticalFlowPanel vp = new VerticalFlowPanel(); |
| 44 | |
LOCategoryBuilder loCategoryBuilder; |
| 45 | |
Data metaInfoData; |
| 46 | |
public LOPicker(String messageGroup, String type, String state, String loRepoKey, int maxLength) { |
| 47 | 0 | super(); |
| 48 | 0 | this.loTextArea = new KSTextArea(countLabel, maxLength); |
| 49 | 0 | loCategoryBuilder = new LOCategoryBuilder(messageGroup, type, state, loRepoKey); |
| 50 | 0 | loTextArea.removeStyleName("ks-form-module-elements"); |
| 51 | 0 | loTextArea.addStyleName("KS-LOTextArea"); |
| 52 | 0 | countLabel.addStyleName("ks-form-module-elements-help-text"); |
| 53 | 0 | countLabel.addStyleName("loText-count-label"); |
| 54 | 0 | vp.add(loTextArea); |
| 55 | 0 | vp.add(countLabel); |
| 56 | 0 | super.add(vp); |
| 57 | 0 | super.add(loCategoryBuilder); |
| 58 | |
|
| 59 | 0 | loTextArea.addValueChangeHandler(new ValueChangeHandler<String>(){ |
| 60 | |
public void onValueChange(ValueChangeEvent<String> event) { |
| 61 | 0 | fireChangeEvent(); |
| 62 | 0 | } |
| 63 | |
}); |
| 64 | |
|
| 65 | 0 | loCategoryBuilder.addValueChangeHandler(new ValueChangeHandler<List<LoCategoryInfo>>(){ |
| 66 | |
public void onValueChange( |
| 67 | |
ValueChangeEvent<List<LoCategoryInfo>> event) { |
| 68 | 0 | fireChangeEvent(); |
| 69 | 0 | } |
| 70 | |
}); |
| 71 | 0 | } |
| 72 | |
public void setLOCategories(List<LoCategoryInfo> categories){ |
| 73 | 0 | loCategoryBuilder.setValue(categories); |
| 74 | 0 | } |
| 75 | |
public List<LoCategoryInfo> getLoCategories(){ |
| 76 | 0 | return loCategoryBuilder.getValue(); |
| 77 | |
} |
| 78 | |
public String getLOText(){ |
| 79 | 0 | return this.loTextArea.getText(); |
| 80 | |
} |
| 81 | |
public void setLOText(String value){ |
| 82 | 0 | this.loTextArea.setText(value); |
| 83 | 0 | } |
| 84 | |
public Data getMetaInfoData() { |
| 85 | 0 | return metaInfoData; |
| 86 | |
} |
| 87 | |
public void setMetaInfoData(Data metaInfoData) { |
| 88 | 0 | this.metaInfoData = metaInfoData; |
| 89 | 0 | } |
| 90 | |
|
| 91 | |
@Override |
| 92 | |
public HandlerRegistration addSelectionChangeHandler(SelectionChangeHandler handler) { |
| 93 | 0 | return addHandler(handler, SelectionChangeEvent.getType()); |
| 94 | |
} |
| 95 | |
|
| 96 | |
public boolean hasChangeHandler(){ |
| 97 | 0 | return this.getHandlerCount(SelectionChangeEvent.getType()) > 0; |
| 98 | |
} |
| 99 | |
|
| 100 | |
private void fireChangeEvent(){ |
| 101 | 0 | SelectionChangeEvent.fire(this); |
| 102 | 0 | } |
| 103 | |
@Override |
| 104 | |
protected void onEnsureDebugId(String baseID) { |
| 105 | 0 | super.onEnsureDebugId(baseID); |
| 106 | 0 | loTextArea.ensureDebugId(baseID); |
| 107 | 0 | loCategoryBuilder.ensureDebugId(baseID); |
| 108 | 0 | } |
| 109 | |
|
| 110 | |
|
| 111 | |
} |