Toolbar.java
7.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.apache.sling.commons.json.io.JSONWriter
*/
package com.day.cq.wcm.api.components;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.commons.json.io.JSONWriter;
public class Toolbar
implements List<Item> {
private final List<Item> items;
public Toolbar() {
this.items = new LinkedList<Item>();
}
public /* varargs */ Toolbar(Item ... items) {
this.items = new LinkedList<Item>();
this.items.addAll(Arrays.asList(items));
}
public Toolbar(Collection<? extends Item> items) {
this.items = new LinkedList<Item>();
this.items.addAll(items);
}
public Toolbar(Toolbar toolbar) {
this.items = toolbar == null ? Collections.emptyList() : Collections.unmodifiableList(toolbar);
}
public void write(JSONWriter writer, String key) throws JSONException {
if (key != null) {
writer.key(key);
}
writer.array();
for (Item item : this.items) {
item.write(writer);
}
writer.endArray();
}
@Override
public int size() {
return this.items.size();
}
@Override
public boolean isEmpty() {
return this.items.isEmpty();
}
@Override
public boolean contains(Object o) {
return this.items.contains(o);
}
@Override
public Iterator<Item> iterator() {
return this.items.iterator();
}
@Override
public Object[] toArray() {
return this.items.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return this.items.toArray(a);
}
@Override
public boolean add(Item o) {
return this.items.add(o);
}
@Override
public boolean remove(Object o) {
return this.items.remove(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return this.items.containsAll(c);
}
@Override
public boolean addAll(Collection<? extends Item> c) {
return this.items.addAll(c);
}
@Override
public boolean addAll(int index, Collection<? extends Item> c) {
return this.items.addAll(index, c);
}
@Override
public boolean removeAll(Collection<?> c) {
return this.items.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return this.items.retainAll(c);
}
@Override
public void clear() {
this.items.clear();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
Toolbar toolbar = (Toolbar)o;
return this.items == null ? toolbar.items == null : this.items.equals(toolbar.items);
}
@Override
public int hashCode() {
return this.items.hashCode();
}
@Override
public Item get(int index) {
return this.items.get(index);
}
@Override
public Item set(int index, Item element) {
return this.items.set(index, element);
}
@Override
public void add(int index, Item element) {
this.items.add(index, element);
}
@Override
public Item remove(int index) {
return this.items.remove(index);
}
@Override
public int indexOf(Object o) {
return this.items.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return this.items.lastIndexOf(o);
}
@Override
public ListIterator<Item> listIterator() {
return this.items.listIterator();
}
@Override
public ListIterator<Item> listIterator(int index) {
return this.items.listIterator(index);
}
@Override
public List<Item> subList(int fromIndex, int toIndex) {
return this.items.subList(fromIndex, toIndex);
}
public static class Separator
implements Item {
@Override
public void write(JSONWriter writer) throws JSONException {
writer.object();
writer.key("xtype").value((Object)"tbseparator");
writer.endObject();
}
}
public static class Label
implements Item {
private final String text;
public Label(String text) {
this.text = text;
}
@Override
public void write(JSONWriter writer) throws JSONException {
writer.object();
writer.key("xtype").value((Object)"tbtext");
writer.key("text").value((Object)this.text);
writer.endObject();
}
}
public static class Button
extends JSONObject
implements Item {
public Button(String text, String handler) {
this(text, handler, false, null);
}
public Button(String text, String handler, boolean disabled, String tooltip) {
try {
this.put("xtype", (Object)"button");
this.put("text", (Object)text);
this.put("handler", (Object)handler);
if (tooltip != null) {
this.put("tooltip", (Object)tooltip);
}
if (disabled) {
this.put("disabled", true);
}
}
catch (JSONException var5_5) {
// empty catch block
}
}
public Button setText(String text) {
try {
this.put("text", (Object)text);
}
catch (JSONException var2_2) {
// empty catch block
}
return this;
}
public Button setHandler(String handler) {
try {
this.put("handler", (Object)handler);
}
catch (JSONException var2_2) {
// empty catch block
}
return this;
}
public Button setTooltip(String tooltip) {
try {
this.put("tooltip", (Object)tooltip);
}
catch (JSONException var2_2) {
// empty catch block
}
return this;
}
public Button setDisabled(boolean disabled) {
try {
this.put("disabled", disabled);
}
catch (JSONException var2_2) {
// empty catch block
}
return this;
}
@Override
public void write(JSONWriter writer) throws JSONException {
writer.value((Object)this);
}
}
public static class Custom
extends JSONObject
implements Item {
@Override
public void write(JSONWriter writer) throws JSONException {
writer.value((Object)this);
}
}
public static interface Item {
public void write(JSONWriter var1) throws JSONException;
}
}