-
Notifications
You must be signed in to change notification settings - Fork 7
/
GxContextMenu.bbj
276 lines (266 loc) · 7.91 KB
/
GxContextMenu.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
rem /**
rem * The package exports a collection of classes to manipulate the grid's context menu
rem */
rem package GxContextMenu
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 java.util.LinkedHashMap
use com.google.gson.JsonArray
use com.google.gson.JsonObject
use com.google.gson.JsonPrimitive
rem /**
rem * A class which represents grid context menu
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxContextMenu
field protected LinkedHashMap Items! = new LinkedHashMap()
rem /**
rem * Add new context menu item
rem *
rem * @param GxContextMenuItemInterface item! the item object
rem */
method public void addItem(GxContextMenuItemInterface item!)
#Items!.put(item!.getId() , item!)
methodend
rem /**
rem * Add a predefined context menu item
rem *
rem * @param BBjString item! the item ID
rem */
method public void addItem(BBjString item!)
#Items!.put(str(System.nanoTime()), item!)
methodend
rem /**
rem * Convert the menu to a JSON string
rem *
rem * @returns String
rem */
method public String toString()
declare JsonArray array!
array! = new JsonArray()
it! = #Items!.entrySet().iterator()
WHILE (it!.hasNext())
next! = it!.next()
value! = next!.getValue()
array!.add(new JsonPrimitive(value!.toString()))
WEND
methodret array!.toString()
methodend
classend
rem /**
rem * A class which represents the default grid context menu
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxDefaultContextMenu extends GxContextMenu
rem /**
rem * Construct the default grid context menu
rem */
method public GxDefaultContextMenu()
#addItem(GxContextMenuItem.COPY())
#addItem(GxContextMenuItem.COPY_WITH_HEADERS())
#addItem(GxContextMenuItem.COPY_WITH_GROUP_HEADERS())
#addItem(GxContextMenuItem.EXPORT())
methodend
classend
rem /**
rem * An interface which defines a menu item
rem *
rem * @author Hyyan Abo Fakher
rem */
interface public GxContextMenuItemInterface
rem /**
rem * Get the menu item ID
rem *
rem * @return BBjString the menu item's id
rem */
method public BBjString getId()
rem /**
rem * Convert the item to String
rem *
rem * @return BBjString
rem */
method public String toString()
interfaceend
rem /**
rem * A class which represents a grid context menu item
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxContextMenuItem implements GxContextMenuItemInterface
rem /**
rem * The item's label
rem */
field public BBjString Label! = null()
rem /**
rem * Optional tooltip for the menu item
rem */
field public BBjString Tooltip! = null()
rem /**
rem * The icon to display beside the icon, either a DOM element or HTML string
rem */
field public BBjString Icon! = null()
rem /**
rem * Additional CSS classes to be applied to the menu item
rem */
field public BBjString CssClasses! = null()
rem /**
rem * if this menu is a submenu, contains a list of submenu item definitions
rem */
field public GxContextMenu SubMenu! = null()
rem /**
rem * The item's ID
rem */
field protected BBjString Id! = null()
rem /**
rem * @return shortcode to separator menu item
rem */
method public static BBjString SEPARATOR()
methodret "separator"
methodend
rem /**
rem * @return shortcode to autoSizeAll menu item
rem */
method public static BBjString AUTO_SIZE_ALL()
methodret "autoSizeAll"
methodend
rem /**
rem * @return shortcode to expandAll menu item
rem */
method public static BBjString EXPAND_ALL()
methodret "expandAll"
methodend
rem /**
rem * @return shortcode to contractAll menu item
rem */
method public static BBjString CONTRACT_ALL()
methodret "contractAll"
methodend
rem /**
rem * @return shortcode to copy menu item
rem */
method public static BBjString COPY()
methodret "copy"
methodend
rem /**
rem * @return shortcode to copyWithHeaders menu item
rem */
method public static BBjString COPY_WITH_HEADERS ()
methodret "copyWithHeaders"
methodend
rem /**
rem * @return shortcode to copyWithGroupHeaders menu item
rem */
method public static BBjString COPY_WITH_GROUP_HEADERS ()
methodret "copyWithGroupHeaders"
methodend
rem /**
rem * @return shortcode to resetColumns menu item
rem */
method public static BBjString RESET_COLUMNS()
methodret "resetColumns"
methodend
rem /**
rem * @return shortcode to export menu item
rem */
method public static BBjString EXPORT()
methodret "export"
methodend
rem /**
rem * @return shortcode to chartRange menu item
rem */
method public static BBjString CHART_RANGE()
methodret "chartRange"
methodend
rem /**
rem * @return shortcode to csvExport menu item
rem */
method public static BBjString CSV_EXPORT()
methodret "csvExport"
methodend
rem /**
rem * @return shortcode to excelExport menu item
rem */
method public static BBjString EXCEL_EXPORT()
methodret "excelExport"
methodend
rem /**
rem * Disable default constructor
rem */
method private GxContextMenuItem()
methodend
rem /**
rem * Construct new Menu item
rem *
rem * @param BBjString id! The item's ID
rem */
method public GxContextMenuItem(BBjString id!)
#Id! = id!
methodend
rem /**
rem * Construct new Menu item
rem *
rem * @param BBjString id! The item's ID
rem * @param BBjString label! The item's name
rem */
method public GxContextMenuItem(BBjString id! ,BBjString label!)
#this!(id!)
#Label! = label!
methodend
rem /**
rem * Construct new Menu item
rem *
rem * @param BBjNumber id! The item's ID
rem * @param BBjString label! The item's name
rem */
method public GxContextMenuItem(BBjNumber id! ,BBjString label!)
#this!(str(id!) , label!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjString getId()
methodret #Id!
methodend
rem /**
rem * Construct an html image to use as an icon
rem *
rem * @param BBjString url$ image url or base64 string
rem * @param BBjNumber width! image width
rem * @param BBjNumber height! image height
rem */
method public void setIcon(BBjString url$,BBjNumber width!,BBjNumber height!)
#setIcon("<img border=0 width=" + str(width!) + " height=" + str(height!) + " src='" + url$ + "' />")
methodend
rem /**
rem * Construct an html image to use as an icon
rem *
rem * @param BBjString url$: image url or base64 string
rem * @param BBjNumber width!: image width
rem */
method public void setIcon(BBjString url$,BBjNumber width!)
#setIcon(url$,width!,width!)
methodend
rem /**
rem * Convert the item to String
rem *
rem * @return BBjString
rem */
method public String toString()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("id",#getId() , err=*next)
json!.addProperty("name",#getLabel() , err=*next)
json!.addProperty("icon",#getIcon() , err=*next)
json!.addProperty("tooltip",#getTooltip() , err=*next)
json!.addProperty("cssClasses",#getCssClasses(), err=*next)
json!.addProperty("subMenu" , #getSubMenu().toString() ,err=*next)
methodret json!.toString()
methodend
classend