1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.element;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.rice.krad.uif.component.Component;
23
24
25
26
27
28
29
30
31
32
33
34
35 public class DropdownMenu extends ContentElementBase {
36 private static final long serialVersionUID = -1759659012620124641L;
37
38 private String dropdownToggleText;
39 private Message dropdownToggle;
40
41 private boolean renderToggleCaret;
42 private boolean renderToggleButton;
43
44 private List<MenuAction> menuActions;
45
46 public DropdownMenu() {
47 super();
48
49 renderToggleCaret = true;
50 }
51
52
53
54
55
56 @Override
57 public void performApplyModel(Object model, Component parent) {
58 super.performApplyModel(model, parent);
59
60 if (StringUtils.isNotBlank(dropdownToggleText) && StringUtils.isBlank(dropdownToggle.getMessageText())) {
61 dropdownToggle.setMessageText(dropdownToggleText);
62 }
63 }
64
65
66
67
68 @Override
69 public List<Component> getComponentsForLifecycle() {
70 List<Component> components = super.getComponentsForLifecycle();
71
72 components.add(dropdownToggle);
73 components.addAll(menuActions);
74
75 return components;
76 }
77
78
79
80
81
82
83
84
85
86
87
88
89 public String getDropdownToggleText() {
90 return dropdownToggleText;
91 }
92
93
94
95
96 public void setDropdownToggleText(String dropdownToggleText) {
97 this.dropdownToggleText = dropdownToggleText;
98 }
99
100
101
102
103
104
105
106 public Message getDropdownToggle() {
107 return dropdownToggle;
108 }
109
110
111
112
113 public void setDropdownToggle(Message dropdownToggle) {
114 this.dropdownToggle = dropdownToggle;
115 }
116
117
118
119
120
121
122 public boolean isRenderToggleCaret() {
123 return renderToggleCaret;
124 }
125
126
127
128
129 public void setRenderToggleCaret(boolean renderToggleCaret) {
130 this.renderToggleCaret = renderToggleCaret;
131 }
132
133
134
135
136
137
138 public boolean isRenderToggleButton() {
139 return renderToggleButton;
140 }
141
142
143
144
145 public void setRenderToggleButton(boolean renderToggleButton) {
146 this.renderToggleButton = renderToggleButton;
147 }
148
149
150
151
152
153
154
155
156
157
158
159 public List<MenuAction> getMenuActions() {
160 return menuActions;
161 }
162
163
164
165
166 public void setMenuActions(List<MenuAction> menuActions) {
167 this.menuActions = menuActions;
168 }
169
170
171
172
173 @Override
174 protected <T> void copyProperties(T component) {
175 super.copyProperties(component);
176
177 DropdownMenu dropdownCopy = (DropdownMenu) component;
178
179 if (this.dropdownToggle != null) {
180 dropdownCopy.setDropdownToggle((Message) this.dropdownToggle.copy());
181 }
182 dropdownCopy.setDropdownToggleText(this.dropdownToggleText);
183
184 dropdownCopy.setRenderToggleCaret(this.renderToggleCaret);
185 dropdownCopy.setRenderToggleButton(this.renderToggleButton);
186
187 if (this.menuActions != null) {
188 List<MenuAction> optionsCopy = new ArrayList<MenuAction>();
189
190 for (MenuAction action : this.menuActions) {
191 optionsCopy.add((MenuAction) action.copy());
192 }
193 dropdownCopy.setMenuActions(optionsCopy);
194 }
195 }
196 }