1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.wicket.markup.html.form;
20
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
24 import org.apache.commons.lang3.StringUtils;
25 import org.apache.wicket.model.Model;
26
27
28
29
30
31
32 public final class Action<T extends Serializable> implements Serializable {
33
34 private static final long serialVersionUID = -7989237020377623993L;
35
36 private final List<String> realms = new ArrayList<>();
37
38 private final ActionLink<T> link;
39
40 private final ActionLink.ActionType type;
41
42 private String entitlements;
43
44 private boolean onConfirm;
45
46 private boolean visibleLabel;
47
48 private Model<String> label;
49
50 private Model<String> title;
51
52 private Model<String> alt;
53
54 private Model<String> icon;
55
56 private boolean indicator;
57
58 public Action(final ActionLink<T> link, final ActionLink.ActionType type) {
59 this.link = link;
60 this.type = type;
61 this.entitlements = StringUtils.EMPTY;
62 this.onConfirm = false;
63 this.visibleLabel = true;
64 this.label = null;
65 this.title = null;
66 this.alt = null;
67 this.icon = null;
68 this.indicator = true;
69 }
70
71 public String[] getRealms() {
72 return realms.toArray(String[]::new);
73 }
74
75 public void setRealm(final String realm) {
76 this.realms.clear();
77
78 if (realm != null) {
79 this.realms.add(realm);
80 }
81 }
82
83 public void setRealms(final String realm, final List<String> dynRealms) {
84 setRealm(realm);
85
86 if (dynRealms != null) {
87 this.realms.addAll(dynRealms);
88 }
89 }
90
91 public ActionLink<T> getLink() {
92 return link;
93 }
94
95 public ActionLink.ActionType getType() {
96 return type;
97 }
98
99 public String getEntitlements() {
100 return entitlements;
101 }
102
103 public boolean isOnConfirm() {
104 return onConfirm;
105 }
106
107 public Action<T> setEntitlements(final String entitlements) {
108 this.entitlements = entitlements;
109 return this;
110 }
111
112 public Action<T> setOnConfirm(final boolean onConfirm) {
113 this.onConfirm = onConfirm;
114 return this;
115 }
116
117 public Action<T> hideLabel() {
118 this.visibleLabel = false;
119 return this;
120 }
121
122 public Action<T> showLabel() {
123 this.visibleLabel = true;
124 return this;
125 }
126
127 public boolean isVisibleLabel() {
128 return visibleLabel;
129 }
130
131
132
133
134
135
136
137 public Action<T> setLabel(final Model<String> label) {
138 this.label = label;
139 return this;
140 }
141
142 public Model<String> getLabel() {
143 return label;
144 }
145
146
147
148
149
150
151
152 public Action<T> setTitleI(final Model<String> title) {
153 this.title = title;
154 return this;
155 }
156
157 public Model<String> getTitle() {
158 return title;
159 }
160
161
162
163
164
165
166
167 public Action<T> setAlt(final Model<String> alt) {
168 this.alt = alt;
169 return this;
170 }
171
172 public Model<String> getAlt() {
173 return alt;
174 }
175
176
177
178
179
180
181
182 public Action<T> setIcon(final Model<String> icon) {
183 this.icon = icon;
184 return this;
185 }
186
187 public Model<String> getIcon() {
188 return icon;
189 }
190
191
192
193
194
195
196 public Action<T> disableIndicator() {
197 this.indicator = false;
198 return this;
199 }
200
201 public boolean hasIndicator() {
202 return indicator;
203 }
204 }