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.common.ui.client.configurable.mvc.multiplicity;
17  
18  import com.google.gwt.event.dom.client.ClickEvent;
19  import com.google.gwt.event.dom.client.ClickHandler;
20  import com.google.gwt.user.client.ui.FlowPanel;
21  import com.google.gwt.user.client.ui.Label;
22  import com.google.gwt.user.client.ui.Widget;
23  
24  /**
25   * This wraps a widget item
26   *
27   * @author Kuali Student Team
28   */
29  public class RemovableItem extends MultiplicityItem {
30      private boolean loaded = false;
31  
32      protected FlowPanel itemPanel = new FlowPanel();
33  
34      public RemovableItem(){
35          initWidget(itemPanel);
36      }
37  
38      public void onLoad(){
39      }
40  
41      private Widget generateRemoveWidget() {
42          ClickHandler ch = new ClickHandler() {
43              public void onClick(ClickEvent event) {
44                  getRemoveCallback().exec(RemovableItem.this);
45              }
46          };
47  
48          itemPanel.addStyleName("KS-Multiplicity-Item");
49          Label deleteLabel = new Label("Delete");
50          deleteLabel.addStyleName("KS-Multiplicity-Link-Label");
51          deleteLabel.addClickHandler(ch);
52  
53          return deleteLabel;
54      }
55  
56      /**
57       * @see org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityItem#clear()
58       */
59      @Override
60      public void clear() {
61          loaded = false;
62      }
63  
64      /**
65       * @see org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityItem#redraw()
66       */
67      @Override
68      public void redraw() {
69          Widget item = getItemWidget();
70          if (!loaded){
71  
72              itemPanel.add(item);
73              itemPanel.add(generateRemoveWidget());
74              loaded = true;
75          }
76  //redraw() removed
77  /*        if (item instanceof Section){
78              ((Section)item).redraw();
79          }*/
80      }
81  
82  }