-
Notifications
You must be signed in to change notification settings - Fork 7
/
GxClientModels.bbj
1608 lines (1538 loc) · 50.1 KB
/
GxClientModels.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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
rem /**
rem * The package exports a collection of classes which describe the client models in BBj.
rem */
rem package GxClientModels
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/GxFilters.bbj::GxColumnFilterTextFilterOptions
use ::BBjGridExWidget/GxFilters.bbj::GxColumnFilterDateTimeFilterOptions
use ::BBjGridExWidget/GxFilters.bbj::GxColumnFilterNumberFilterOptions
use com.google.gson.Gson
use com.google.gson.JsonParser
use com.google.gson.JsonObject
use com.google.gson.JsonArray
use com.google.gson.JsonPrimitive
use com.basiscomponents.db.DataRow
use java.util.ArrayList
use java.util.Arrays
use java.util.HashSet
use java.util.LinkedHashSet
use java.util.HashMap
use java.lang.StringBuilder
REM /**
REM * A client model for rows
REM *
REM * @author Hyyan Abo Fakher
REM */
class public GxClientRowModel
rem /**
rem * The row id
rem */
field public BBjString Id!
rem /**
rem * The row index
rem */
field public BBjNumber Index!
rem /**
rem * The row child index.
rem * if the childIndex is `-1` then the row is pinned to top or bottom
rem */
field public BBjNumber ChildIndex!
rem /**
rem * The row parent key, if any
rem */
field public BBjString ParentKey!
rem /**
rem * True when the row is selected, false otherwise
rem */
field public BBjNumber IsSelected!
rem /**
rem * The client row data as JsonObject.
rem */
field public JsonObject ClientRow!
rem /**
rem * The row pin position (top , bottom , null)
rem */
field public BBjString Floating! = BBjGridExWidget.GRID_FLOATING_NONE()
rem /**
rem * BBjGridExWidget instance
rem */
field protected BBjGridExWidget Widget!
rem /**
rem * Disable default constructor
rem */
method private GxClientRowModel()
methodend
rem /**
rem * Construct new client row
rem *
rem * @param BBjGridExWidget widget! The widget instance
rem */
method public GxClientRowModel(BBjGridExWidget widget!)
#Widget! = widget!
methodend
rem /**
rem * Get the widget instance
rem *
rem * @return BBjGridExWidget
rem */
method public BBjGridExWidget getWidget()
methodret #Widget!
methodend
rem /**
rem * The method will merge the row data coming from the client with
rem * the current DataRow.
rem *
rem * @see BBjGridExWidget.includeClientRowDataInRowModels()
rem */
method public DataRow updateFromClientRow()
clientRow! = #getClientRow()
if(clientRow! = null())
throw "The client row is not included in this model.To include it in the model configure the grid to include it by calling BBjGridExWidget.includeClientRowDataInRowModels(1)" , 256
fi
clientRow! = clientRow!.deepCopy()
dataRow! = #asDataRow()
clientRow!.remove("__ROW_INDEX")
clientRow!.remove("meta")
dataRow!.mergeRecord(DataRow.fromJson(clientRow!.toString()),BBjAPI.TRUE)
methodret dataRow!
methodend
rem /**
rem * Convert the client row to a DataRow
rem *
rem * @return DataRow
rem */
method public DataRow asDataRow()
nodeId! = #getWidget().getRowNodeId()
rs! = #getWidget().getRS()
dr! = new DataRow()
rem the row is pinned
if(-1 = #getChildIndex())
rem pinned ResultSets always use `__ROW_INDEX` for indexing
nodeId! = "__ROW_INDEX"
switch #getFloating()
case BBjGridExWidget.GRID_FLOATING_TOP()
rs! = #getWidget().getOptions().getPinnedTopRows()
break
case BBjGridExWidget.GRID_FLOATING_BOTTOM()
rs! = #getWidget().getOptions().getPinnedBottomRows()
break
case default
throw "Unable to find the source of the floating row.", 256
break
swend
fi
rem in case the RowNodeId is a column in the ResultSet
if(rs!.getColumnIndex(nodeId!) <> -1 ) then
rem indexed by an existing column
filter! = new DataRow()
filter!.setFieldValue(nodeId!,str(#getId()))
filteredRS! = rs!.filterBy(filter!)
if(filteredRS!.count() <> 1) then
throw "Cannot query the selected row from the ResultSet. [RowNodeId = " + nodeId! + " , Index = " + str(#getIndex()) + "]", 256
fi
methodret filteredRS!.get(0)
fi
if(-1 = #getChildIndex())
methodret rs!.get(#getIndex())
fi
dr! = rs!.get(#getId(), err=*next)
methodret dr!
methodend
rem /**
rem * Get the row data as JsonObject
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
declare JsonParser parser!
parser! = new JsonParser()
rowAsJson! = str(#asDataRow().toJson(#getWidget().getRowNodeId()))
ar! = parser!.parse(rowAsJson!).getAsJsonArray()
obj! = ar!.get(0).getAsJsonObject()
methodret obj!
methodend
rem /**
rem * Alias for <i>getAsJsonObject()</i>
rem *
rem * @see getAsJsonObject()
rem */
method public JsonObject getData()
methodret #getAsJsonObject()
methodend
rem /**
rem * Convert row to string
rem *
rem * @return BBjString The row id
rem */
method public String toString()
methodret #Id!
methodend
classend
REM /**
REM * A model for the client column
REM *
REM * @author Hyyan Abo Fakher
REM */
class public GxClientColumnModel
rem /**
rem * BBjGridExWidget instance
rem */
field protected BBjGridExWidget Widget!
rem /**
rem * The column name
rem */
field protected BBjString Name!
rem /**
rem * Disable default constructor
rem */
method private GxClientColumnModel()
methodend
rem /**
rem * Construct new GxClientColumnModel
rem *
rem * @param BBjGridExWidget widget! The widget instance
rem * @param BBjString name! the column's name/id
rem */
method public GxClientColumnModel(BBjGridExWidget widget! , BBjString name!)
#Name! = name!
#Widget! = widget!
methodend
rem /**
rem * Get the widget instance
rem *
rem * @return BBjGridExWidget
rem */
method public BBjGridExWidget getWidget()
methodret #Widget!
methodend
rem /**
rem * Get the column index
rem *
rem * Returns the index of the column with the specified name.
rem *
rem * @return BBjNumber column's index
rem */
method public BBjNumber getIndex()
methodret #getWidget().getRS().getColumnIndex(#getName())
methodend
rem /**
rem * Get the column type
rem *
rem * Returns the value of the ColumnType property from the ResultSet's metadata.
rem *
rem * @return BBjNumber column's type
rem */
method public BBjNumber getType()
methodret #getWidget().getRS().getColumnType(#getIndex())
methodend
rem /**
rem * Get the column type
rem *
rem * Returns the metadata of the column.
rem *
rem * @return BBjNumber column's metadata
rem */
method public HashMap getMetaData()
methodret #getWidget().getRS().getColumnMetaData(#getName())
methodend
rem /**
rem * Get the column name
rem *
rem * @return BBjString column's name
rem */
method public BBjString getName()
methodret #Name!
methodend
rem /**
rem * Convert column to string
rem *
rem * @return BBjString The column
rem */
method public String toString()
methodret #getName()
methodend
classend
REM /**
REM * A model for the client cell
REM *
REM * @author Hyyan Abo Fakher
REM */
class public GxClientCellModel
rem /**
rem * The cell's row.
rem */
field public GxClientRowModel Row!
rem /**
rem * The cell's column
rem */
field public GxClientColumnModel Column!
rem /**
rem * The cell's value
rem */
field public BBjString Value!
classend
REM /**
REM * This model is used when range selections are read from the client
REM *
REM * @author Hyyan Abo Fakher
REM */
class public GxClientRangeSelectionModel
rem /**
rem * An array of column objects where every object is instance of GxClientColumnModel
rem */
field public BBjVector Columns! = new BBjVector()
rem /**
rem * An array of rows objects where every object is instance of GxClientRowModel
rem */
field public BBjVector Rows! = new BBjVector()
classend
rem /**
rem * The model is used to compose a range selection model in order to be applied on the client.
rem *
rem * Ranges are normally bounded by a start and end row. However it is also possible to define a range unbounded
rem * by rows (ie to contain all rows). For an unbounded range, do not provided start or end row positions.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxClientAddRangeSelectionModel
rem /**
rem * A list of column ids to use. Note that none existing columns will be ignored silently
rem */
field public ArrayList Columns! = new ArrayList()
rem /**
rem * Start row id or index
rem */
field public BBjString Start! = null()
rem /**
rem * End row id or index
rem */
field public BBjString End! = null()
rem /**
rem * Add columns as comma separated string
rem *
rem * @param BBjString columns! columns as comma separated string (ex: CDNUMBER, COST)
rem */
method public void setColumns(BBjString columns!)
arrayList! = new ArrayList()
list! = Arrays.asList(columns!.split(","))
it! = list!.iterator()
WHILE (it!.hasNext())
arrayList!.add(cvs(it!.next(),128))
WEND
#setColumns(arrayList!)
methodend
rem /**
rem * Convert the model to JSON object
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("columns" , iff(#getColumns().size() <> 0 ,new Gson().toJson(#getColumns()), listIsEmpty!) , err=*next)
json!.addProperty("start" , #getStart(), err=*next)
json!.addProperty("end" , #getEnd(), err=*next)
methodret json!
methodend
classend
rem /**
rem * The model is used to compose a range chart model in order to be applied on the client.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public GxClientAddRangeChartModel
rem /**
rem * Defines the range of cells to be charted. A range is normally defined with start and end rows and a list of columns,
rem * If the start and end rows are omitted, the range covers all rows (ie entire columns are selected).
rem */
field public GxClientAddRangeSelectionModel RangeSelection! = null()
rem /**
rem * The type of chart to create
rem */
field public BBjString Type! = null()
rem /**
rem * Normally when a chart is displayed using the grid, the grid will highlight the range the chart is charting
rem * when the chart gets focus, to suppress this behaviour, set the field to false
rem */
field public BBjNumber SuppressChartRanges! = null()
rem /**
rem * When set to true, series values will be summed for each category before charting.
rem */
field public BBjNumber Aggregate! = null()
rem /**
rem * Constant value to define groupedBar chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_GROUPEDBAR()
methodret "groupedBar"
methodend
rem /**
rem * Constant value to define stackedBar chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_STACKEDBAR()
methodret "stackedBar"
methodend
rem /**
rem * Constant value to define normalizedBar chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_NORMALIZEDBAR()
methodret "normalizedBar"
methodend
rem /**
rem * Constant value to define groupedColumn chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_GROUPEDCOLUMN()
methodret "groupedColumn"
methodend
rem /**
rem * Constant value to define stackedColumn chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_STACKEDCOLUMN()
methodret "stackedColumn"
methodend
rem /**
rem * Constant value to define normalizedColumn chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_NORMALIZEDCOLUMN()
methodret "normalizedColumn"
methodend
rem /**
rem * Constant value to define line chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_LINE()
methodret "line"
methodend
rem /**
rem * Constant value to define pie chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_PIE()
methodret "pie"
methodend
rem /**
rem * Constant value to define doughnut chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_DOUGHNUT()
methodret "doughnut"
methodend
rem /**
rem * Constant value to define area chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_AREA()
methodret "area"
methodend
rem /**
rem * Constant value to define stackedArea chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_STACKEDAREA()
methodret "stackedArea"
methodend
rem /**
rem * Constant value to define normalizedArea chart
rem *
rem * @return BBjString
rem */
method public static BBjString TYPE_NORMALIZEDAREA()
methodret "normalizedArea"
methodend
rem /**
rem * Convert the model to JSON object
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!. add("cellRange" , #getRangeSelection().getAsJsonObject() , err=*next)
json!.addProperty("chartType" , #getType(), err=*next)
json!.addProperty("suppressChartRanges" , #getSuppressChartRanges().booleanValue(), err=*next)
json!.addProperty("aggregate" , #getAggregate().booleanValue(), err=*next)
methodret json!
methodend
classend
rem /**
rem * The model is used to represent a keypress on the client
rem *
REM * @author Hyyan Abo Fakher
rem */
rem */
class public GxClientKeypressModel
rem /**
rem * A DOMString with the code value of the physical key represented by the event.
rem */
field public BBjString Code! = null()
rem /**
rem * A Number representing the Unicode reference number of the key.
rem * For keys whose char attribute contains multiple characters, this is the Unicode value of the first character in that attribute.
rem */
field public BBjNumber KeyCode! = null()
rem /**
rem * A Boolean that is true if the Alt key was active when the key event was generated.
rem */
field public BBjNumber IsAltDown! = null()
rem /**
rem * A Boolean that is true if the Shift key was active when the key event was generated.
rem */
field public BBjNumber IsShiftDown! = null()
rem /**
rem * A Boolean that is true if the Ctrl key was active when the key event was generated.
rem */
field public BBjNumber IsCtrlDown! = null()
classend
rem /**
rem * The sorting model describes how the columns will be sorted on the client
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxClientSortModel
rem /**
rem * The array which contain column => sorting mapping
rem */
field protected JsonObject Model! = new JsonObject()
rem /**
rem * Add new column sorting to the model
rem *
rem * @param BBjString column! The column id
rem * @param BBjString direction! the sort direction
rem *
rem * @see BBJGridExWidgetColumns.SORT_DESC()
rem * @see BBJGridExWidgetColumns.SORT_ASC()
rem */
method public void add(BBjString column! , BBjString sorting!)
#getModel().addProperty(column!,sorting!)
methodend
rem /**
rem * Get sorting for the given column
rem *
rem * @param BBjString column! the column id
rem *
rem * @return BBjString the column's sorting
rem */
method public BBjString get(BBjString column!)
result! = null()
if(#getModel().has(column!))
result! = #getModel().get(column!).getAsString()
fi
methodret result!
methodend
rem /**
rem * Remove a column from the model
rem *
rem * @param BBjString column! the column id
rem */
method public void remove(BBjString column!)
#getModel().remove(column! ,err=*next )
methodend
rem /**
rem * Convert the model to JSON array
rem *
rem * @return JsonObject
rem */
method public JsonArray getAsJsonArray()
declare JsonArray json!
json! = new JsonArray()
if(#getModel().size() > 0)
json!.add(#getModel())
fi
methodret json!
methodend
classend
rem /**
rem * The model describes an transaction operation that can be passed to the grid
rem * to add / remove & update that data at once.
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxClientTransactionModel
rem /**
rem * An array of rows to add
rem */
field public HashSet Add! = new LinkedHashSet()
rem /**
rem * An array of row to remove
rem */
field public HashSet Remove! = new LinkedHashSet()
rem /**
rem * An array of rows to update
rem */
field public HashSet Update! = new LinkedHashSet()
rem /**
rem * Index for rows to add
rem *
rem * @deprecated `GxClientTransactionModel.addIndex` is deprecated. If you want precision control of adding data, use `BBjGridExWidget.updateData` instead
rem */
field public BBjNumber AddIndex! = 0
rem /**
rem * BBjGridExWidget instance
rem */
field public BBjGridExWidget Widget!
rem /**
rem * Construct new transaction model
rem *
rem * @param BBjGridExWidget widget! The widget instance
rem */
method public GxClientTransactionModel(BBjGridExWidget widget!)
#Widget! = widget!
methodend
rem /**
rem * Add new row
rem *
rem * @param DataRow row! A new data row to add
rem */
method public void add(DataRow row!)
#getAdd().add(row!)
methodend
rem /**
rem * Add new row
rem *
rem * @param DataRow row! An already existing row to remove
rem */
method public void remove(DataRow row!)
#getRemove().add(row!)
methodend
rem /**
rem * Update a row
rem *
rem * @param DataRow row! An already existing row to update
rem */
method public void update(DataRow row!)
#getUpdate().add(row!)
methodend
rem /**
rem * Execute the transaction on the widget model (ResultSet)
rem *
rem * @return JsonObject
rem */
method public JsonObject execute()
declare JsonObject json!
declare JsonArray add!
declare JsonArray update!
declare JsonArray remove!
json! = new JsonObject()
json!.addProperty("addIndex" , #getAddIndex().longValue(err=*next),err=*next)
add! = new JsonArray()
addIt! = #getAdd().iterator()
while(addIt!.hasNext())
row! = addIt!.next()
#getWidget().getRS().add(#getAddIndex() , row!)
parser! = new JsonParser()
add!.add(parser!.parse(row!.toJson(#getWidget().getRowNodeId())).getAsJsonArray().get(0).getAsJsonObject())
wend
json!.add("add" ,add!)
update! = new JsonArray()
updateIt! = #getUpdate().iterator()
while(updateIt!.hasNext())
row! = updateIt!.next()
rowIndex! = #getWidget().getRS().indexOf(row!)
#getWidget().getRS().remove(rowIndex!)
#getWidget().getRS().add(rowIndex! , row!)
parser! = new JsonParser()
update!.add(parser!.parse(row!.toJson(#getWidget().getRowNodeId())).getAsJsonArray().get(0).getAsJsonObject())
wend
json!.add("update" , update!)
remove! = new JsonArray()
removeIt! = #getRemove().iterator()
while(removeIt!.hasNext())
row! = removeIt!.next()
parser! = new JsonParser()
rowIndex! = #getWidget().getRS().indexOf(row!)
if #getWidget().getRowNodeId() <> "__ROW_INDEX" then
value! = #getWidget().getRS().getItem(rowIndex!).getFieldAsString(#getWidget().getRowNodeId())
else
value! = #getWidget().getRS().getItem(rowIndex!).getRowKey()
FI
#getWidget().getRS().remove(rowIndex!)
remove!.add(value!)
wend
json!.add("remove",remove!)
methodret json!
methodend
classend
rem /**
rem * When saving or restoring state on a filter the filter model is used.
rem * The filter model represents the state of the filter
rem *
rem * @author Hyyan Abo Fakher
rem */
interface public GxClientFilterModel
rem /**
rem * Convert the model to JSON object
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
rem /**
rem * Check if the filter supported the combined model
rem *
rem * @return BBjNumber true when the filter support combined model , false otherwise
rem */
method public BBjNumber supportsCombinedModel()
rem /**
rem * Set the widget instance
rem *
rem * @param BBjGridExWidget widget!
rem */
method public void setWidget(BBjGridExWidget widget!)
rem /**
rem * Get the widget instance
rem *
rem * @return BBjGridExWidget
rem */
method public BBjGridExWidget getWidget()
rem /**
rem * Set the working column
rem *
rem * @param BBjString column! the column id
rem */
method public void setColumn(BBjString column!)
rem /**
rem * Get the working column
rem *
rem * @return BBjString
rem */
method public BBjString getColumn()
rem /**
rem * Apply the filter
rem *
rem * This method will only compose the model and send it to the client in case `send!` is true.
rem * On the client the new model will be displayed on the filter panel but it will not be applied on the data.
rem * To execute the model on the client you need to call `execute(1)`
rem *
rem * @see GxClientFilterModel.execute()
rem *
rem * @param BBjNumber send! when true the model will be send to the client , false otherwise
rem *
rem * @return BBjString The generated js code used to apply the model
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method public BBjString apply(BBjNumber send!)
rem /**
rem * Apply the filter
rem *
rem * This method only compose the model and send it to the client
rem * On the client the new model will be displayed on the filter panel but it will not be applied on the data.
rem * To execute the model on the client you need to call `execute(1)`
rem *
rem * @see GxClientFilterModel.execute()
rem *
rem * @return BBjString The generated js code used to apply the model
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method public BBjString apply()
rem /**
rem * Tell the grid to refresh rows based on the filter. the filter does not do this automatically in case multiple
rem * filters are going to get set.
rem *
rem * @param BBjNumber send! when true the execution code will executed on the client , false otherwise
rem * @return BBjString The generated js code used to execute the model on the client
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method public BBjString execute(BBjNumber send!)
rem /**
rem * Tell the grid to refresh rows based on the filter. the filter does not do this automatically in case multiple
rem * filters are going to get set.
rem *
rem * @param BBjNumber send! when true the execution code will executed on the client , false otherwise
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method public BBjString execute()
rem /**
rem * Update the filter on the client and execute it.
rem *
rem * @return BBjString the js code used
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method public BBjString update()
rem /**
rem * Check if the filter is action or not
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @return BBjNumber true when action , false otherwise
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method public BBjNumber isFilterActive()
rem /**
rem * Clear the filter
rem *
rem * @return BBjString the js code used to clear the filter
rem */
method public void clearFilter()
interfaceend
rem /**
rem * A generic abstract implementation for the GxClientFilterModel interface
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxClientFilterAbstractModel implements GxClientFilterModel
rem /**
rem * BBjGridExWidget instance
rem */
field public BBjGridExWidget Widget!
rem /**
rem * The working column
rem */
field public BBjString Column!
rem /**
rem * Disable constructor
rem */
method protected GxClientFilterAbstractModel()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjString apply(BBjNumber send!)
code! = String.format(";%s.setModel(%s);" ,#getFilterInstance(), #getAsJsonObject())
if(send!.booleanValue()) #getWidget().getExecutor().execute(code!)
methodret code!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjString apply()
methodret #apply(1)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjString execute(BBjNumber send!)
#assertWidget()
widget! = #getWidget()
code! = String.format(";$gw_wnd.gw_getGrid('%s').options.api.onFilterChanged();", widget!.getRootId())
if(send!.booleanValue()) widget!.getExecutor().execute(code!)
methodret code!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjString execute()
methodret #execute(1)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjString update()
code! = #apply(0) + #execute(0)
? code!
#getWidget().getExecutor().execute(code!)
methodret code!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public BBjNumber isFilterActive()
#assertWidget()
widget! = #getWidget()
if(widget!.getIsReady() = BBjAPI.FALSE) methodret 0
code! = String.format(";%s.isFilterActive();" , #getFilterInstance())
isActive! = widget!.getExecutor().execute(code! , 0)
methodret isActive!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public void clearFilter()
methodend
rem /**
rem * Assert the column exists
rem *
rem * @throws 256 when the column is null
rem */
method protected void assertColumn()
if (#getColumn() = null()) throw "Cannot execute filter action on null() column" , 256
methodend
rem /**
rem * Assert the widget exists
rem *
rem * @throws 256 when the widget is null
rem */
method protected void assertWidget()
if (#getWidget() = null()) throw "The filter model is not attached to a grid instance" , 256
methodend
rem /**
rem * Return the js code required to obtain an instance of the client filter object
rem *
rem * @return BBjString the js code
rem *
rem * @throws 256 when the column or the widget are not defined
rem */
method protected BBjString getFilterInstance()
#assertColumn()
#assertWidget()
code! = String.format("$gw_wnd.gw_getGrid('%s').options.api.getFilterInstance('%s')", #getWidget().getRootId(), #getColumn())
methodret code!
methodend
classend
rem /**
rem * A filter a which wraps two filter models and combine them with an `OR` or `AND` operator
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxClientFilterCombinedModel extends GxClientFilterAbstractModel
rem /**
rem * The combine operator
rem *
rem * @see GxClientFilterCombinedModel.OPERATOR_OR()
rem * @see GxClientFilterCombinedModel.OPERATOR_AND()
rem */
field public BBjString Operator! = GxClientFilterCombinedModel.OPERATOR_AND()
rem /**
rem * The first filter condition
rem */
field public GxClientFilterModel FirstCondition! = null()
rem /**
rem * The second filter condition
rem */
field public GxClientFilterModel SecondCondition! = null()
rem /**
rem * Constant value which defines the `OR` operator
rem *
rem * @return BBjString
rem */
method public static BBjString OPERATOR_OR()
methodret "OR"
methodend
rem /**
rem * Constant value which defines the `AND` operator
rem *
rem * @return BBjString
rem */
method public static BBjString OPERATOR_AND()
methodret "AND"
methodend
rem /**
rem * Construct new GxClientFilterCombinedModel
rem *
rem * @param GxClientFilterModel condition1! the first condition (instance of a filter model)
rem * @param GxClientFilterModel condition2! the second condition (instance of a filter model)
rem * @param BBjString Operator! the combine operator
rem */
method public GxClientFilterCombinedModel(GxClientFilterModel condition1! , GxClientFilterModel condition2! , BBjString operator!)
#setOperator(operator!)
#setFirstCondition(condition1!)
#setSecondCondition(condition2!)
methodend
rem /**
rem * Construct new GxClientFilterCombinedModel
rem *
rem * @param GxClientFilterModel condition1! the first condition (instance of a filter model)
rem * @param GxClientFilterModel condition2! the second condition (instance of a filter model)