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.sections; |
17 | |
|
18 | |
import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle; |
19 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityItem; |
20 | |
import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityComposite.StyleType; |
21 | |
|
22 | |
import com.google.gwt.event.dom.client.ClickEvent; |
23 | |
import com.google.gwt.event.dom.client.ClickHandler; |
24 | |
import com.google.gwt.user.client.ui.FlowPanel; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class RemovableItemWithHeader extends MultiplicityItem{ |
30 | |
|
31 | |
private MultiplicityHeader header; |
32 | 0 | private FlowPanel layout = new FlowPanel(); |
33 | 0 | private FlowPanel body = new FlowPanel(); |
34 | |
private StyleType style; |
35 | |
private String itemLabel; |
36 | 0 | private boolean readOnly=false; |
37 | 0 | private boolean loaded = false; |
38 | |
|
39 | |
|
40 | |
public void isReadOnly(boolean readOnly){ |
41 | 0 | this.readOnly=readOnly; |
42 | 0 | } |
43 | |
|
44 | |
public void setReadOnly(boolean readOnly) { |
45 | 0 | this.readOnly = readOnly; |
46 | 0 | } |
47 | |
|
48 | 0 | public RemovableItemWithHeader(StyleType style){ |
49 | 0 | this.style = style; |
50 | 0 | this.initWidget(layout); |
51 | |
|
52 | 0 | } |
53 | |
|
54 | 0 | public RemovableItemWithHeader(StyleType style, boolean readOnly){ |
55 | 0 | this.style = style; |
56 | 0 | this.readOnly = readOnly; |
57 | 0 | this.initWidget(layout); |
58 | |
|
59 | 0 | } |
60 | |
|
61 | |
@Override |
62 | |
public void clear() { |
63 | 0 | loaded = false; |
64 | |
|
65 | 0 | } |
66 | |
|
67 | |
public void setItemLabel(String itemLabel) { |
68 | 0 | this.itemLabel = itemLabel; |
69 | 0 | } |
70 | |
|
71 | |
@Override |
72 | |
public void redraw() { |
73 | 0 | if (!loaded){ |
74 | 0 | layout.clear(); |
75 | 0 | if(style == StyleType.TOP_LEVEL){ |
76 | 0 | SectionTitle title = SectionTitle.generateH4Title(itemLabel); |
77 | 0 | title.addStyleName("ks-form-bordered-header-title"); |
78 | 0 | header = new MultiplicityHeader(title, readOnly); |
79 | 0 | header.setStyleName("ks-form-bordered-header"); |
80 | 0 | layout.setStyleName("ks-form-bordered"); |
81 | 0 | body.setStyleName("ks-form-bordered-body"); |
82 | 0 | } |
83 | 0 | else if(style == StyleType.SUB_LEVEL){ |
84 | 0 | SectionTitle title = SectionTitle.generateH5Title(itemLabel); |
85 | 0 | title.addStyleName("ks-form-course-format-activity-header-title"); |
86 | 0 | header = new MultiplicityHeader(title, readOnly); |
87 | 0 | header.setStyleName("ks-form-course-format-activity-header"); |
88 | 0 | layout.setStyleName("ks-form-course-format-activity"); |
89 | |
} |
90 | |
|
91 | |
|
92 | 0 | if(!readOnly){ |
93 | 0 | header.addDeleteHandler(new ClickHandler() { |
94 | |
public void onClick(ClickEvent event) { |
95 | 0 | getRemoveCallback().exec(RemovableItemWithHeader.this); |
96 | 0 | } |
97 | |
}); |
98 | |
} |
99 | |
|
100 | 0 | layout.add(header); |
101 | 0 | body.add(this.getItemWidget()); |
102 | 0 | layout.add(body); |
103 | |
} |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | 0 | } |
110 | |
|
111 | |
} |