-
Notifications
You must be signed in to change notification settings - Fork 7
/
BBjGridExWidgetRenderers.bbj
254 lines (239 loc) · 8.42 KB
/
BBjGridExWidgetRenderers.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
rem package BBjGridExWidget.Renderers
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <eu@basis.com>
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
use com.google.gson.JsonObject
use ::BBjGridExWidget/BBjGridExWidgetExpressions.bbj::BBjGridExWidgetExpressionInterface
use ::BBjGridExWidget/BBjGridExWidgetExpressions.bbj::BBjGridExWidgetExpression
REM /**
REM * BBjGridExWidgetRendererInterface
REM *
REM * @author Hyyan Abo Fakher
REM */
interface public BBjGridExWidgetRendererInterface
rem /**
rem * A constant which holds the client renderer real name
rem */
method public static BBjString RENDERER_NAME()
rem /**
rem * Convert the renderer defintion to Json Object
rem *
rem * @return JsonOobject The renderer as JsonObject
rem */
method public JsonObject getAsJsonObject()
interfaceend
rem /**
rem * The class reprensets a boolean cell renderer
rem *
REM * @author Hyyan Abo Fakher
rem */
class public BBjGridExWidgetRendererBoolean implements BBjGridExWidgetRendererInterface
rem /**
rem * HTML string which defines how to render true values.
rem */
field public BBjString TrueValue! = "✔"
rem /**
rem * HTML string which defines how to render false values
rem */
field public BBjString FalseValue! = "✘"
rem /**
rem * A special html string which uses the switch button to show true/false values
rem */
method public static BBjString SWITCH_RENDERER()
methodret "switch"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString RENDERER_NAME()
methodret "BasicBooleansRenderer"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("RENDERER_TRUE" , #getTrueValue(),err=*next)
json!.addProperty("RENDERER_FALSE" , #getFalseValue(),err=*next)
methodret json!
methodend
classend
rem /**
rem * The class can render a custom html using lodash string templates.
rem *
rem * Inside the template you will have access to the <i>params</i> object
rem * which contains value , valueFormatted , ...
rem *
rem * Use This render if you want to render the data with a custom html.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public BBjGridExWidgetRendererCustomHTML implements BBjGridExWidgetRendererInterface
rem /**
rem * String template which will be complied in the client.<br>
rem * <pre>
rem * <code>
rem * <%= '<strong style=\'color:red\'>' + (params.valueFormatted || '') + '</strong>' %>
rem * </code>
rem * </pre>
rem */
field public BBjString Template! = null()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString RENDERER_NAME()
methodret "GWCustomHTMLTemplateRenderer"
methodend
rem /**
rem * Construct new BBjGridExWidgetRendererCustomHTML
rem *
rem * @param BBjString template! The string tempatle
rem *
rem * i.e
rem * <pre>
rem * <code>
rem * <%= '<strong style=\'color:red\'>' + (params.valueFormatted || '') + '</strong>' %>
rem * </code>
rem * </pre>
rem */
method public BBjGridExWidgetRendererCustomHTML(BBjString template!)
#Template! = template!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("__TEMPLATE__" , #getTemplate(),err=*next)
methodret json!
methodend
classend
rem /**
rem * The renderer can be used to dispaly a list of images based on the cells values using a json object
rem *
REM * @author Hyyan Abo Fakher
rem */
class public BBjGridExWidgetRendererImageRenderer implements BBjGridExWidgetRendererInterface
rem /**
rem * The image's width
rem */
field public BBjString Width! = null()
rem /**
rem * The image's height
rem */
field public BBjString Height! = null()
rem /**
rem * A json object
rem */
field public JsonObject List! = new JsonObject()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString RENDERER_NAME()
methodret "BasicImagesRenderer"
methodend
rem /**
rem * Construct new BBjGridExWidgetRendererImageRenderer
rem *
rem * @param JsonObject list! The images list
rem */
method public BBjGridExWidgetRendererImageRenderer(JsonObject list!)
#List! = list!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("IMAGES_WIDTH" , #getWidth(),err=*next)
json!.addProperty("IMAGES_HEIGHT" , #getHeight(),err=*next)
json!. add("IMAGES_LIST" , #getList(),err=*next)
methodret json!
methodend
classend
rem /**
rem * If you are grouping in the grid, then you will need to provide a group cell renderer as the group cell renderer is what provides the user with the expand and collapse functionality.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public BBjGridExWidgetRendererGroupCellRenderer implements BBjGridExWidgetRendererInterface
rem /**
rem * When true show row counts , hide otherwise
rem */
field public BBjNumber SuppressCount! = null()
rem /**
rem * When true disable double click for expand , enable otherwise
rem */
field public BBjNumber SuppressDoubleClickExpand! = null()
rem /**
rem * When true enable checkbox selection, disable otherwise
rem */
field public BBjNumber Checkbox! = null()
rem /**
rem * Provide an inner renderer
rem */
field public BBjGridExWidgetRendererInterface InnerRenderer! = null()
rem /**
rem * Provide a footer value getter expression
rem */
field public BBjGridExWidgetExpressionInterface FooterValueGetterExpression! = null()
rem /**
rem * Construct new BBjGridExWidgetRendererGroupCellRenderer
rem *
rem * @param BBjGridExWidgetExpressionInterface footerValueGetterExpression! an expression
rem */
method public BBjGridExWidgetRendererGroupCellRenderer(BBjGridExWidgetExpressionInterface footerValueGetterExpression!)
#FooterValueGetterExpression! = footerValueGetterExpression!
methodend
rem /**
rem * Construct new BBjGridExWidgetRendererGroupCellRenderer
rem *
rem * @param BBjString footerValueGetterExpression! an expression
rem */
method public BBjGridExWidgetRendererGroupCellRenderer(BBjString footerValueGetterExpression!)
#setFooterValueGetterExpression(footerValueGetterExpression!)
methodend
rem /**
rem * Create a BBjGridExWidgetExpression from string and set it a footer value getter
rem *
rem * @param BBjString expression! Javascript expression
rem */
method public void setFooterValueGetterExpression(BBjString expression!)
#FooterValueGetterExpression! = new BBjGridExWidgetExpression(expression!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString RENDERER_NAME()
methodret "agGroupCellRenderer"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("suppressCount" , #getSuppressCount().booleanValue(),err=*next)
json!.addProperty("suppressDoubleClickExpand" , #getSuppressDoubleClickExpand().booleanValue(),err=*next)
json!.addProperty("checkbox" , #getCheckbox().booleanValue(),err=*next)
json!.addProperty("footerValueGetter" , #getFooterValueGetterExpression().toString(),err=*next)
if(#getInnerRenderer() <> null()) then
json!.addProperty("innerRenderer" , #getInnerRenderer().RENDERER_NAME(),err=*next)
declare JsonObject innerJson!
innerJson! = #getInnerRenderer().getAsJsonObject()
it! = innerJson!.entrySet().iterator()
WHILE (it!.hasNext())
next! = it!.next()
json!.addProperty(str(next!.getKey()) , str(next!.getValue()),err=*next)
WEND
FI
methodret json!
methodend
classend