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 org.kuali.student.common.ui.client.widgets.KSButton;
19 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
20
21 import com.google.gwt.event.dom.client.ClickEvent;
22 import com.google.gwt.event.dom.client.ClickHandler;
23 import com.google.gwt.user.client.ui.Widget;
24
25
26
27
28
29
30
31 public abstract class UpdatableMultiplicityComposite extends MultiplicityComposite {
32 protected String addItemLabel;
33 protected String itemLabel;
34 protected boolean readOnly = false;
35
36 public UpdatableMultiplicityComposite(StyleType style){
37 super(style);
38 }
39
40 public UpdatableMultiplicityComposite(StyleType style, boolean readOnly){
41 super(style);
42 this.readOnly=readOnly;
43 }
44
45
46
47
48 @Override
49 public MultiplicityItem getItemDecorator(StyleType style) {
50 org.kuali.student.common.ui.client.configurable.mvc.sections.RemovableItemWithHeader item = new org.kuali.student.common.ui.client.configurable.mvc.sections.RemovableItemWithHeader(style, readOnly);
51 item.setItemLabel(itemLabel + " " + itemCount);
52 return item;
53 }
54
55
56
57
58 public Widget generateAddWidget() {
59
60 if(readOnly){
61 return null;
62 }
63
64 KSButton addWidget;
65 if(style == StyleType.TOP_LEVEL){
66 addWidget = new KSButton(addItemLabel, ButtonStyle.FORM_LARGE);
67 }
68 else{
69 addWidget = new KSButton(addItemLabel, ButtonStyle.FORM_SMALL);
70 }
71 addWidget.addClickHandler(new ClickHandler(){
72 public void onClick(ClickEvent event) {
73 addItem();
74 }
75 });
76 return addWidget;
77 }
78
79
80 public String getAddItemLabel() {
81 return addItemLabel;
82 }
83
84
85 public void setAddItemLabel(String addItemLabel) {
86 this.addItemLabel = addItemLabel;
87 }
88
89 public String getItemLabel() {
90 return itemLabel;
91 }
92
93 public void setItemLabel(String itemLabel) {
94 this.itemLabel = itemLabel;
95 }
96
97
98 }