-
Notifications
You must be signed in to change notification settings - Fork 7
/
GxSidebar.bbj
387 lines (373 loc) · 12.6 KB
/
GxSidebar.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
376
377
378
379
380
381
382
383
384
385
386
387
rem /**
rem * The package contains a collection of classes to manipulate the grid's sidebar
rem */
rem package GxSidebar
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 com.google.gson.JsonParser
use com.google.gson.JsonArray
use com.google.gson.JsonObject
use com.google.gson.JsonElement
use com.google.gson.Gson
use java.util.LinkedHashMap
use ::BBjGridExWidget/GxLogger.bbj::GxLogger
rem /**
rem * A interface which defines a grid toolpanel
rem *
rem * @author Hyyan Abo Fakher
rem */
interface public GxToolpanelInterface
rem /**
rem * Get the toolbar unique name
rem *
rem * @return BBjString The toolbar name
rem *
rem * @deprecated since version 0.101.0, GxToolpanelInterface.ID() is deprecated. use GxToolpanelInterface.getId() instead
rem */
method public static BBjString ID()
rem /**
rem * Get the toolbar unique name
rem *
rem * @return BBjString The toolbar name
rem */
method public static BBjString getId()
rem /**
rem * Get a json representation for the toolpanel
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
interfaceend
rem /**
rem * An abstract class which represents a toolpanel which can be attached to a sidebar
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxToolpanel implements GxToolpanelInterface
rem /**
rem * The default label of the toolpanel
rem */
field public BBjString Label! = null()
rem /**
rem * The key of the icon to be used as a graphical aid beside the label in the sidebar.
rem *
rem * @see https://www.ag-grid.com/javascript-grid-icons/
rem */
field protected BBjString Icon! = null()
rem /**
rem * Construct new toolpanel
rem *
rem * @param BBjString label! the toolpanel label
rem */
method public GxToolpanel(BBjString label!)
#Label! = label!
methodend
rem /**
rem * Construct new toolpanel
rem *
rem * @param BBjString label! the toolpanel label
rem * @param BBjString icon! the toolpanel icon
rem */
method public GxToolpanel(BBjString label! , BBjString icon!)
#this!(label!)
#Icon! = icon!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("id",#getId(), err=*next)
json!.addProperty("labelKey",#getLabel() , err=*next)
json!.addProperty("labelDefault",#getLabel() , err=*next)
json!.addProperty("iconKey",#getIcon() , err=*next)
methodret json!
methodend
classend
rem /**
rem * Columns Toolpanel
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxColumnsToolpanel extends GxToolpanel
rem /**
rem * suppress Expand / Collapse all widget.
rem */
field public BBjNumber SuppressColumnExpandAll! = null()
rem /**
rem * suppress Select / Un-select all widget.
rem */
field public BBjNumber SuppressColumnSelectAll! = null()
rem /**
rem * suppress Column Filter section.
rem */
field public BBjNumber SuppressColumnFilter! = null()
rem /**
rem * suppress Pivot Mode section.
rem */
field public BBjNumber SuppressPivotMode! = null()
rem /**
rem * suppress Column Labels (Pivot) section.
rem */
field public BBjNumber SuppressPivots! = null()
rem /**
rem * suppress Values section
rem */
field public BBjNumber SuppressValues! = null()
rem /**
rem * Suppress Row Groups section.
rem */
field public BBjNumber SuppressRowGroups! = null()
rem /**
rem * Suppress updating the layout of columns as they are rearranged in the grid
rem */
field public BBjNumber SuppressSyncLayoutWithGrid! = null()
rem /**
rem * Suppress Column Move section
rem */
field public BBjNumber SuppressColumnMove! = null()
rem /**
rem * By default, column groups start expanded. Pass true to default to contracted groups
rem */
field public BBjNumber ContractColumnSelection! = null()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString ID()
GxLogger.warn("GxSidebar","since version 0.101.0, GxColumnsToolpanel.ID() is deprecated. use GxColumnsToolpanel.getId() instead")
methodret GxColumnsToolpanel.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agColumnsToolPanel"
methodend
rem /**
rem * Construct new columns toolpanel
rem */
method public GxColumnsToolpanel()
#super!("columns","columns")
methodend
rem /**
rem * Construct new toolpanel
rem *
rem * @param BBjString label! the toolpanel label
rem */
method public GxColumnsToolpanel(BBjString label!)
#super!(label!)
methodend
rem /**
rem * Construct new toolpanel
rem *
rem * @param BBjString label! the toolpanel label
rem * @param BBjString icon! the toolpanel icon
rem */
method public GxColumnsToolpanel(BBjString label! , BBjString icon!)
#super!(label! , icon!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
declare JsonObject params!
json! = #super!.getAsJsonObject()
params! = new JsonObject()
params!.addProperty("suppressRowGroups",#SuppressRowGroups!.booleanValue(), err=*next)
params!.addProperty("suppressValues",#SuppressValues!.booleanValue(), err=*next)
params!.addProperty("suppressPivots",#SuppressPivots!.booleanValue(), err=*next)
params!.addProperty("suppressPivotMode",#SuppressPivotMode!.booleanValue(), err=*next)
params!.addProperty("suppressColumnFilter",#SuppressColumnFilter!.booleanValue(), err=*next)
params!.addProperty("suppressColumnSelectAll",#SuppressColumnSelectAll!.booleanValue(), err=*next)
params!.addProperty("suppressColumnExpandAll",#SuppressColumnExpandAll!.booleanValue(), err=*next)
params!.addProperty("suppressSyncLayoutWithGrid",#SuppressSyncLayoutWithGrid!.booleanValue(), err=*next)
params!.addProperty("suppressColumnMove",#SuppressColumnMove!.booleanValue(), err=*next)
params!.addProperty("contractColumnSelection",#ContractColumnSelection!.booleanValue(), err=*next)
json!.addProperty("toolPanel",#getId(), err=*next)
json!.add("toolPanelParams",params!)
methodret json!
methodend
classend
rem /**
rem * A class which represents the filters toolpanel
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxFiltersToolpanel extends GxToolpanel
rem /**
rem * To suppress the Filter Search
rem */
field public BBjNumber SuppressFilterSearch! = null()
rem /**
rem * Suppress updating the layout of columns as they are rearranged in the grid
rem */
field public BBjNumber SuppressSyncLayoutWithGrid! = null()
rem /**
rem * To suppress Expand / Collapse All
rem */
field public BBjNumber suppressExpandAll! = null()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString ID()
GxLogger.warn("GxSidebar","since version 0.101.0, GxFiltersToolpanel.ID() is deprecated. use GxFiltersToolpanel.getId() instead")
methodret GxFiltersToolpanel.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agFiltersToolPanel"
methodend
rem /**
rem * Construct new filters toolpanel
rem */
method public GxFiltersToolpanel()
#super!("filters","filters")
#setIcon("filter")
methodend
rem /**
rem * Construct new filters toolpanel
rem *
rem * @param BBjString label! the toolpanel label
rem */
method public GxFiltersToolpanel(BBjString label!)
#super!(label!)
methodend
rem /**
rem * Construct new filters toolpanel
rem *
rem * @param BBjString label! the toolpanel label
rem * @param BBjString icon! the toolpanel icon
rem */
method public GxFiltersToolpanel(BBjString label! , BBjString icon!)
#super!(label! , icon!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("toolPanel",#getId())
params! = new JsonObject()
params!.addProperty("suppressFilterSearch",#SuppressFilterSearch!.booleanValue(), err=*next)
params!.addProperty("suppressSyncLayoutWithGrid",#SuppressSyncLayoutWithGrid!.booleanValue(), err=*next)
params!.addProperty("suppressExpandAll",#SuppressExpandAll!.booleanValue(), err=*next)
json!.add("toolPanelParams",params!)
methodret json!
methodend
classend
rem /**
rem * The class manages the grid sidebar and its toolpanels
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxSidebar
rem /**
rem * The id of the default panel
rem */
field public BBjString DefaultToolpanel$
rem /**
rem * When true, the sidebar will be hidden on the first draw, visible otherwise. default is false
rem */
field public BBjNumber HiddenByDefault! = 0
rem /**
rem * A map for the registered toolpanels
rem */
field public LinkedHashMap Toolpanels! = new LinkedHashMap()
rem /**
rem * The BBjGridExWidget instance
rem */
field protected BBjGridExWidget Widget!
rem /**
rem * Disable default constructor
rem */
method private GxSidebar()
methodend
rem /**
rem * Construct new sidebar
rem *
rem * @param BBjGridExWidget widget!
rem */
method public GxSidebar(BBjGridExWidget widget!)
#Widget! = widget!
methodend
rem /**
rem * Set Visible
rem *
rem * Enable / Disable the grid sidebar
rem */
method public void setVisible(BBjNumber visible!)
scriptKey! = "$gw_wnd.gw_setSideBarVisible"
#Widget!.getExecutor().execute(scriptKey!,"$gw_wnd.gw_setSideBarVisible('" + #Widget!.getRootId() + "'," + str(visible!) + ")")
methodend
rem /**
rem * Open toolpanel
rem *
rem * Open the given toolpanel
rem *
rem * @param BBjString id$ the toolpanel id
rem */
method public void openToolpanel(BBjString id!)
scriptKey! = "$gw_wnd.gw_openToolpanel"
#Widget!.getExecutor().execute(scriptKey!,"$gw_wnd.gw_openToolpanel('" + #Widget!.getRootId() + "','" + str(id!) + "')")
methodend
rem /**
rem * Close toolpanel
rem *
rem * Close the given toolpanel
rem *
rem * @param BBjString id$ the toolpanel id
rem */
method public void closeToolpanel(BBjString id!)
scriptKey! = "$gw_wnd.gw_closeToolpanel"
#Widget!.getExecutor().execute(scriptKey!,"$gw_wnd.gw_closeToolpanel('" + #Widget!.getRootId() + "','" + str(id!) + "')")
methodend
rem /**
rem * Convert the sidebar into json object
rem *
rem * @returns JsonObject
rem */
method public JsonObject getAsJsonObject()
declare JsonArray toolpanelsJson!
declare JsonObject json!
toolpanelsJson! = new JsonArray()
it! = #Toolpanels!.entrySet().iterator()
while it!.hasNext()
o! = it!.next().getValue()
toolpanelsJson!.add(o!.getAsJsonObject())
wend
json! = new JsonObject()
json!.addProperty("toolPanels",toolpanelsJson!.toString())
json!.addProperty("defaultToolPanel",#DefaultToolpanel$)
json!.addProperty("hiddenByDefault",#getHiddenByDefault(),err=*next)
methodret json!
methodend
classend
rem /**
rem * A class to define the default implementation of the grid sidebar
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxDefaultSidebar extends GxSidebar
rem /**
rem * Construct the default grid sidebar
rem *
rem * @param BBjGridExWidget widget!
rem */
method public GxDefaultSidebar(BBjGridExWidget widget!)
#super!(widget!)
#getToolpanels().put(GxColumnsToolpanel.getId() , new GxColumnsToolpanel())
#getToolpanels().put(GxFiltersToolpanel.getId() , new GxFiltersToolpanel())
rem #setDefaultToolpanel(GxColumnsToolpanel.getId())
methodend
classend