View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
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.dom.client.KeyUpEvent;
30  import com.google.gwt.event.dom.client.KeyUpHandler;
31  import com.google.gwt.event.logical.shared.ValueChangeEvent;
32  import com.google.gwt.event.logical.shared.ValueChangeHandler;
33  import com.google.gwt.event.shared.HandlerRegistration;
34  import com.google.gwt.user.client.Window;
35  import com.google.gwt.user.client.ui.HorizontalPanel;
36  import com.google.gwt.user.client.ui.TextArea;
37  
38  /**
39   * This is a description of what this class does - hjohnson don't forget to fill this in. 
40   * 
41   * @author Kuali Student Team (kuali-student@googlegroups.com)
42   *
43   */
44  public class LOPicker extends HorizontalPanel implements HasSelectionChangeHandlers{
45  	KSLabel countLabel = new KSLabel();
46      KSTextArea loTextArea = new KSTextArea(countLabel, 250);
47      VerticalFlowPanel vp = new VerticalFlowPanel();
48      LOCategoryBuilder loCategoryBuilder;
49      Data metaInfoData; // temporary storage of metaInfo data this is needed when LO is updated
50      public LOPicker(String messageGroup, String type, String state, String loRepoKey) {
51          super();
52          loCategoryBuilder = new LOCategoryBuilder(messageGroup, type, state, loRepoKey);
53          loTextArea.removeStyleName("ks-form-module-elements");
54          loTextArea.addStyleName("KS-LOTextArea");
55          countLabel.addStyleName("ks-form-module-elements-help-text");
56          countLabel.addStyleName("loText-count-label");
57          vp.add(loTextArea);
58          vp.add(countLabel);
59          super.add(vp);
60          super.add(loCategoryBuilder);
61          
62          loTextArea.addValueChangeHandler(new ValueChangeHandler<String>(){
63  			public void onValueChange(ValueChangeEvent<String> event) {
64  				fireChangeEvent();
65  			}        	
66          });
67          
68          loCategoryBuilder.addValueChangeHandler(new ValueChangeHandler<List<LoCategoryInfo>>(){
69  			public void onValueChange(
70  					ValueChangeEvent<List<LoCategoryInfo>> event) {
71  				fireChangeEvent();
72  			}        	
73          });
74      }
75      public void setLOCategories(List<LoCategoryInfo> categories){
76          loCategoryBuilder.setValue(categories);
77      }
78      public List<LoCategoryInfo> getLoCategories(){
79          return loCategoryBuilder.getValue();
80      }
81      public String getLOText(){
82          return loTextArea.getText();
83      }
84      public void setLOText(String value){
85          loTextArea.setText(value);
86      }
87      public Data getMetaInfoData() {
88          return metaInfoData;
89      }
90      public void setMetaInfoData(Data metaInfoData) {
91          this.metaInfoData = metaInfoData;
92      }
93  	
94      @Override
95  	public HandlerRegistration addSelectionChangeHandler(SelectionChangeHandler handler) {
96      	return addHandler(handler, SelectionChangeEvent.getType());
97      }
98      
99      public boolean hasChangeHandler(){
100     	return this.getHandlerCount(SelectionChangeEvent.getType()) > 0;
101     }
102 	
103     private void fireChangeEvent(){
104     	SelectionChangeEvent.fire(this);
105     }
106 }