1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.custom.navmenu;
20
21 import javax.faces.model.SelectItem;
22 import java.util.List;
23 import java.util.Arrays;
24 import java.util.ArrayList;
25
26
27
28
29
30
31
32 public class NavigationMenuItem extends SelectItem {
33 private static final long serialVersionUID = 2801735314476639024L;
34 private String _icon;
35 private String _action;
36 private String _actionListener;
37 private boolean _open;
38 private boolean _active;
39 boolean _split;
40 private boolean rendered = true;
41 private List _navigationMenuItems = null;
42 private String _target;
43 private String _disabledStyle;
44 private String _disabledStyleClass;
45 private String _externalLink;
46 private String _activeOnViewIds;
47
48
49 public NavigationMenuItem()
50 {
51 super();
52 }
53
54 public NavigationMenuItem(String label, String action) {
55 super(label, label);
56 _action = action;
57 _icon = null;
58 _split = false;
59 }
60
61 public NavigationMenuItem(String label, String action, String icon, boolean split) {
62 super(label, label);
63 _action = action;
64 _icon = icon;
65 _split = split;
66 }
67
68 public NavigationMenuItem(Object value,
69 String label,
70 String description,
71 boolean disabled,
72 String action,
73 String icon,
74 boolean split) {
75 super(value, label, description, disabled);
76 _action = action;
77 _icon = icon;
78 _split = split;
79 }
80
81 public NavigationMenuItem(Object value,
82 String label,
83 String description,
84 boolean disabled,
85 boolean rendered,
86 String action,
87 String icon,
88 boolean split) {
89 this(value, label, description, disabled, action, icon, split);
90 this.rendered = rendered;
91 }
92
93 public NavigationMenuItem(Object value,
94 String label,
95 String description,
96 boolean disabled,
97 boolean rendered,
98 String action,
99 String icon,
100 boolean split,
101 String target) {
102 this(value, label, description, disabled, rendered, action, icon, split);
103 this.setTarget(target);
104 }
105
106 public boolean isRendered() {
107 return rendered;
108 }
109
110 public String getActiveOnViewIds() {
111 return _activeOnViewIds;
112 }
113
114 public void setActiveOnViewIds(String activeOnViewIds) {
115 _activeOnViewIds = activeOnViewIds;
116 }
117
118
119 public String getAction() {
120 return _action;
121 }
122
123 public void setAction(String action) {
124 _action = action;
125 }
126
127 public boolean isSplit() {
128 return _split;
129 }
130
131 public void setSplit(boolean split) {
132 _split = split;
133 }
134
135 public String getIcon() {
136 return _icon;
137 }
138
139 public void setIcon(String icon) {
140 _icon = icon;
141 }
142
143
144
145
146
147
148 public boolean isOpen() {
149 return _open;
150 }
151
152 public void setOpen(boolean open) {
153 _open = open;
154 }
155
156 public boolean isActive() {
157 return _active;
158 }
159
160 public void setActive(boolean active) {
161 _active = active;
162 }
163
164 public String getActionListener() {
165 return _actionListener;
166 }
167
168 public void setActionListener(String actionListener) {
169 _actionListener = actionListener;
170 }
171
172 public String getTarget() {
173 return _target;
174 }
175
176 public void setTarget(String target) {
177 _target = target;
178 }
179
180 public String getDisabledStyle() {
181 return _disabledStyle;
182 }
183
184 public void setDisabledStyle(String disabledStyle) {
185 _disabledStyle = disabledStyle;
186 }
187
188 public String getDisabledStyleClass() {
189 return _disabledStyleClass;
190 }
191
192 public void setDisabledStyleClass(String disabledStyleClass) {
193 _disabledStyleClass = disabledStyleClass;
194 }
195
196 public String getExternalLink() {
197 return _externalLink;
198 }
199
200 public void setExternalLink(String externalLink) {
201 _externalLink = externalLink;
202 }
203
204
205
206
207
208
209
210
211
212 public NavigationMenuItem[] getNavigationMenuItems() {
213 if (_navigationMenuItems == null) {
214 return new NavigationMenuItem[0];
215 }
216 return (NavigationMenuItem[]) _navigationMenuItems.toArray(
217 new NavigationMenuItem[_navigationMenuItems.size()]);
218 }
219
220
221
222
223 public void setNavigationMenuItems(NavigationMenuItem[] navigationMenuItems) {
224 _navigationMenuItems = Arrays.asList(navigationMenuItems);
225 }
226
227
228
229
230 public void setNavigationMenuItems(List list) {
231 _navigationMenuItems = list;
232 }
233
234
235
236
237
238
239
240
241
242 public void add(NavigationMenuItem navigationMenuItem) {
243 if (_navigationMenuItems == null)
244 _navigationMenuItems = new ArrayList();
245 _navigationMenuItems.add(navigationMenuItem);
246 }
247 }