1
2
3
4
5
6
7
8
9
10
11
12
13
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
26
27
28
29
30
31
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
62
63 @Override
64 public void clear() {
65 loaded = false;
66 }
67
68
69
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
81
82
83
84 }
85
86 }