-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGxStatusBar.bbj
375 lines (356 loc) · 11.8 KB
/
GxStatusBar.bbj
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
rem /**
rem * The module contains a collection of classes to manipulate the grid's statusbar
rem */
rem package GxStatusBar
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <[email protected]>
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use ::BBjGridExWidget/GxLogger.bbj::GxLogger
use java.util.LinkedHashMap
use com.google.gson.JsonArray
use com.google.gson.JsonObject
use com.google.gson.Gson
use java.util.HashSet
rem /**
rem * An interface which defines a status bar component
rem *
REM * @author Hyyan Abo Fakher
rem */
interface public GxStatusBarComponentInterface
rem /**
rem * Get the component name
rem *
rem * @returns BBjString the component name
rem *
rem * @deprecated since version 0.101.0, GxStatusBarComponentInterface.NAME() is deprecated / renamed. Use GxStatusBarComponentInterface.getId() instead.
rem */
method public static BBjString NAME()
rem /**
rem * Get the component id
rem *
rem * @returns BBjString the component unique id
rem */
method public static BBjString getId()
rem /**
rem * Set the component alignment
rem *
rem * @param BBjString alignment$ "right", "left" or "center"
rem */
method public void setAlignment(BBjString alignment!)
rem /**
rem * Get the component alignment
rem *
rem * @returns BBjString the component alignment
rem */
method public BBjString getAlignment()
rem /**
rem * Get the component's JSON representation
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
interfaceend
rem /**
rem * An Abstract implementation for GxStatusBarComponentInterface
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxStatusBarComponent implements GxStatusBarComponentInterface
rem /**
rem * The component alignment
rem */
field public BBjString Alignment! = "left"
rem /**
rem * Constructor
rem *
rem * @param BBjString alignment! "right", "left" or "center"
rem */
method public GxStatusBarComponent(BBjString alignment!)
#Alignment! = alignment!
methodend
rem /**
rem * Get the component's JSON representation
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("statusPanel",#getId())
json!.addProperty("align",#getAlignment())
methodret json!
methodend
classend
rem /**
rem * A statusbar component which provides the selected row count
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxStatusBarSelectedRowCountComponent extends GxStatusBarComponent
rem /**
rem * Constructor
rem *
rem * @param BBjString alignment! "right", "left" or "center"
rem */
method public GxStatusBarSelectedRowCountComponent(BBjString alignment!)
#super!(alignment!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
GxLogger.warn("GxStatusBar","since version 0.101.0, GxStatusBarSelectedRowCountComponent.NAME() is deprecated. use GxStatusBarSelectedRowCountComponent.getId() instead")
methodret GxStatusBarSelectedRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agSelectedRowCountComponent"
methodend
classend
rem /**
rem * A statusbar component which provides the filtered row count.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxStatusBarFilteredRowCountComponent extends GxStatusBarComponent
rem /**
rem * Constructor
rem *
rem * @param BBjString alignment! "right", "left" or "center"
rem */
method public GxStatusBarFilteredRowCountComponent(BBjString alignment!)
#super!(alignment!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
GxLogger.warn("GxStatusBar","since version 0.101.0, GxStatusBarFilteredRowCountComponent.NAME() is deprecated. use GxStatusBarFilteredRowCountComponent.getId() instead")
methodret GxStatusBarFilteredRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agFilteredRowCountComponent"
methodend
classend
rem /**
rem * A statusbar component which provides the total and filtered row count.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxStatusBarTotalAndFilteredRowCountComponent extends GxStatusBarComponent
rem /**
rem * Constructor
rem *
rem * @param BBjString alignment! "right", "left" or "center"
rem */
method public GxStatusBarTotalAndFilteredRowCountComponent(BBjString alignment!)
#super!(alignment!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
GxLogger.warn("GxStatusBar","since version 0.101.0, GxStatusBarTotalAndFilteredRowCountComponent.NAME() is deprecated. use GxStatusBarTotalAndFilteredRowCountComponent.getId() instead")
methodret GxStatusBarTotalAndFilteredRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agTotalAndFilteredRowCountComponent"
methodend
classend
rem /**
rem * A statusbar component which provides the total row count.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxStatusBarTotalRowCountComponent extends GxStatusBarComponent
rem /**
rem * Constructor
rem *
rem * @param BBjString alignment! "right", "left" or "center"
rem */
method public GxStatusBarTotalRowCountComponent(BBjString alignment!)
#super!(alignment!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
GxLogger.warn("GxStatusBar","since version 0.101.0, GxStatusBarTotalRowCountComponent.NAME() is deprecated. use GxStatusBarTotalRowCountComponent.getId() instead")
methodret GxStatusBarTotalRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agTotalRowCountComponent"
methodend
classend
rem /**
rem * A statusbar component which provides aggregations on the selected range.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxStatusBarAggregationComponent extends GxStatusBarComponent
rem /**
rem * agg functions to show on the panel. possible values are: 'count', 'sum', 'min', 'max', 'avg'
rem */
field public HashSet AggFuncs! = new HashSet()
rem /**
rem * Construct new Aggregation Component
rem */
method public GxStatusBarAggregationComponent()
#fillHashSetWithDefault()
methodend
rem /**
rem * Construct new Aggregation Component
rem *
rem * @param BBjString alignment! "right", "left" or "center"
rem */
method public GxStatusBarAggregationComponent(BBjString alignment!)
#super!(alignment!)
#fillHashSetWithDefault()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
GxLogger.warn("GxStatusBar","since version 0.101.0, GxStatusBarAggregationComponent.NAME() is deprecated. use GxStatusBarAggregationComponent.getId() instead")
methodret GxStatusBarAggregationComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agAggregationComponent"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
params! = new JsonObject()
params!.addProperty("aggFuncs" , iff(#getAggFuncs().size() <> 0 ,new Gson().toJson(#getAggFuncs()), null()) ,err=*next)
json! = #super!.getAsJsonObject()
json!.add("statusPanelParams",params!)
methodret json!
methodend
method protected void fillHashSetWithDefault()
#getAggFuncs().add("count")
#getAggFuncs().add("sum")
#getAggFuncs().add("min")
#getAggFuncs().add("max")
#getAggFuncs().add("avg")
methodend
classend
rem /**
rem * GxStatusBar
rem *
rem * Gx status bar manager.
rem * The class can add, remove & hide status bar components
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxStatusBar
rem /**
rem * A map for the registered components
rem */
field protected LinkedHashMap Components! = new LinkedHashMap()
rem /**
rem * The BBjGridExWidget instance
rem */
field protected BBjGridExWidget Widget!
rem /**
rem * Construct new sidebar
rem *
rem * @param BBjGridExWidget widget!
rem */
method public GxStatusBar(BBjGridExWidget widget!)
#Widget! = widget!
methodend
rem /**
rem * Add statusbar component
rem *
rem * @param GxStatusBarComponentInterface component! a statusbar component
rem */
method public void addComponent(GxStatusBarComponentInterface component!)
#Components!.put(component!.getId(),component!)
methodend
rem /**
rem * Get statusbar component
rem *
rem * @param BBjString id! The component id
rem *
rem * @return GxStatusBarComponentInterface The component instance
rem */
method public GxStatusBarComponentInterface getComponent(BBjString id!)
declare auto GxStatusBarComponentInterface c!
c! = #Components!.get(id!)
methodret c!
methodend
rem /**
rem * Remove statusbar component
rem *
rem * @param BBjString id! The component id
rem */
method public void removeComponent(BBjString id!)
#Components!.remove(id!)
methodend
rem /**
rem * Remove statusbar component
rem *
rem * @param GxStatusBarComponentInterface component! a statusbar component
rem */
method public void removeComponent(GxStatusBarComponentInterface component!)
#Components!.remove(component!.getId())
methodend
rem /**
rem * Hide/show statusbar component
rem *
rem * @param BBjString id! The component id
rem * @param BBjNumber visibility! 0 to hide component, 1 to show component
rem */
method public void setComponentVisibility(BBjString id! , BBjNumber visibility!)
scriptKey! = "$gw_wnd.gw_setStatusbarComponentVisibility" + id!
#Widget!.getExecutor().execute(scriptKey!,"$gw_wnd.gw_setStatusbarComponentVisibility('" + #Widget!.getRootId() + "','" + id! + "'," + str(visibility!) + ")")
methodend
rem /**
rem * Hide/show statusbar component
rem *
rem * @param GxStatusBarComponentInterface component! a statusbar component
rem * @param BBjNumber visibility! 0 to hide component, 1 to show component
rem */
method public void setComponentVisibility(GxStatusBarComponentInterface component! , BBjNumber visibility!)
#setComponentVisibility(component!.getId() , visibility!)
methodend
rem /**
rem * Convert the statusbar into a parsable json string
rem *
rem * @returns BBjString
rem */
method public String toString()
declare JsonArray defs!
defs! = new JsonArray()
it! = #Components!.entrySet().iterator()
while it!.hasNext() = BBjAPI.TRUE
defs!.add(it!.next().getValue().getAsJsonObject())
wend
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("statusPanels",str(defs!.toString()))
methodret new Gson().toJson(json!)
methodend
classend