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 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
58
59 @Override
60 public void clear() {
61 loaded = false;
62 }
63
64
65
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
77
78
79
80 }
81
82 }