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