-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGxCellEditors.bbj
1110 lines (1060 loc) · 35.8 KB
/
GxCellEditors.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 contains the classes of all supported CellEditor components
rem */
rem package GxCellEditors
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <eu@basis.cloud>
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/GxOptions.bbj::GxOptionsBoolean
use ::BBjGridExWidget/GxOptions.bbj::GxOptionsDateTime
use ::BBjGridExWidget/GxRenderers.bbj::GxRendererInterface
use ::BBjGridExWidget/GxRenderers.bbj::GxRendererCustomHTML
use ::BBjGridExWidget/GxClientModels.bbj::GxClientRowModel
use ::BBjGridExWidget/GxClientModels.bbj::GxClientColumnModel
use com.google.gson.JsonObject
use com.google.gson.JsonArray
use com.google.gson.JsonPrimitive
use com.google.gson.Gson
use java.util.HashSet
rem /**
rem * Column Filter Public Interface
rem *
rem * @author Hyyan Abo Fakher
rem */
interface public GxCellEditorInterface
rem /**
rem * A constant which holds the client cell editor real name
rem */
method public static BBjString getCellEditorName()
rem /**
rem * Convert the filter definition to Json Object
rem *
rem * @return JsonObject The filter as JsonObject
rem */
method public JsonObject getAsJsonObject()
rem /**
rem * Compare two filters
rem *
rem * @param cellEditor! - Another cell editor instance to compare with
rem *
rem * @return bool - true when they are equal , false otherwise
rem */
method public boolean equals(GxCellEditorInterface cellEditor!)
interfaceend
rem /**
rem * Compare two cell editor components
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorComparator
rem /**
rem * Compare two cell editors
rem *
rem * @param one! - First cell editor instance
rem * @param two! - Second cell editor instance
rem *
rem * @return boolean true when they are equal , false otherwise
rem */
method public static boolean compare(GxCellEditorInterface one! , GxCellEditorInterface two!)
if(one!.getCellEditorName() <> two!.getCellEditorName())
methodret BBjAPI.FALSE
FI
methodret one!.getAsJsonObject().equals(two!.getAsJsonObject())
methodend
classend
rem /**
rem * Abstract implementation for GxCellEditorInterface
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorAbstract implements GxCellEditorInterface
rem /**
rem * {@inheritDoc}
rem */
method public boolean equals(GxCellEditorInterface cellEditor!)
methodret GxCellEditorComparator.compare(#this!, cellEditor!)
methodend
classend
rem /**
rem * Simple text editors that use the standard HTML 'input' tag
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorText extends GxCellEditorAbstract
rem /**
rem * If set to true then the grid will use the provided cell formatter if one is provided.
rem */
field public BBjNumber UserFormatter! = 0
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "agTextCellEditor"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("useFormatter",#getUserFormatter().booleanValue() , err=*next)
methodret json!
methodend
classend
rem /**
rem * Same as GxCellEditorText but as popup.
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorPopupText extends GxCellEditorText
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "agPopupTextCellEditor"
methodend
classend
rem /**
rem * Simple editor that uses the standard HTML 'textarea' tag.
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorLargeText extends GxCellEditorText
rem /**
rem * Max number of characters to allow. Default is 200.
rem */
field public BBjNumber MaxLength! = 200
rem /**
rem * Number of character rows to display. Default is 10.
rem */
field public BBjNumber Rows! = 10
rem /**
rem * Number of character columns to display. Default is 60.
rem */
field public BBjNumber Cols! = 60
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "agLargeTextCellEditor"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("maxLength",#getMaxLength().longValue() , err=*next)
json!.addProperty("rows",#getRows().longValue() , err=*next)
json!.addProperty("cols",#getCols().longValue() , err=*next)
methodret json!
methodend
classend
rem /**
rem * Simple editors that use the standard HTML select tag.
rem *
rem * The standard HTML select to behave oddly in the grid. This is because the browser doesn't have a great API for
rem * opening and closing the selected popup.
rem *
rem * We advise that you don't use it unless you have to - that is we advise against GxCellEditorSelect
rem * as they give poor user experience, especially if using keyboard navigation.
rem *
rem * If using Enhanced grid , you should use the provided GxCellEditorRichSelect.
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorSelect extends GxCellEditorAbstract
rem /**
rem * An array of values to allow the user to select from
rem */
field public JsonArray Values! = new JsonArray()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "agSelectCellEditor"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.add("values", iff(#getValues().size() > 0 , #getValues() , empty!), err=*next)
methodret json!
methodend
classend
rem /**
rem * Simple editors that use the standard HTML select tag.
rem *
rem * It is same as GxCellEditorSelect but as popup.
rem *
rem * The standard HTML select to behave oddly in the grid. This is because the browser doesn't have a great API for
rem * opening and closing the selected popup.
rem *
rem * We advise that you don't use it unless you have to - that is we advise against GxCellEditorPopupSelect
rem * as they give poor user experience, especially if using keyboard navigation.
rem *
rem * If using Enhanced grid, you should use the provided GxCellEditorRichSelect.
rem *
rem * <br><b><small>#Enterprise</small></b>
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorPopupSelect extends GxCellEditorSelect
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "agPopupSelectCellEditor"
methodend
classend
rem /**
rem * Available in Enhanced Grid only. An alternative to using the browser's select popup for dropdown inside the grid.
rem *
rem * <br><b><small>#Enterprise</small></b>
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorRichSelect extends GxCellEditorSelect
rem /**
rem * Provide a cell renderer for each value
rem */
field public GxRendererInterface CellRenderer! = null()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "agRichSelectCellEditor"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
renderer! = #getCellRenderer()
if(renderer! <> null()) then
json!.addProperty("cellRenderer" , renderer!.getCellRendererName(),err=*next)
json!. add("cellRendererParams" , renderer!.getAsJsonObject(),err=*next)
FI
methodret json!
methodend
classend
rem /**
rem * Simple switch button to switch boolean values
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicBoolean extends GxOptionsBoolean implements GxCellEditorInterface
rem /**
rem * The value to use when when the component needs to return a true value.
rem * in case it is null() then we use the first item in PossibleTrueValues!
rem */
field public BBjString UsedTrueValue! = null()
rem /**
rem * The value to use when when the component needs to return a false value.
rem * in case it is null() then we use the first item in PossibleFalseValues!
rem */
field public BBjString UsedFalseValue! = null()
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "BooleanEditor"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = #super!.getAsJsonObject()
json!.addProperty("booleanUsedTrueValue",#getUsedTrueValue(), err=*next)
json!.addProperty("booleanUsedFalseValue",#getUsedFalseValue(), err=*next)
methodret json!
methodend
rem /**
rem * {@inheritDoc}
rem */
method public boolean equals(GxCellEditorInterface cellEditor!)
methodret GxCellEditorComparator.compare(#this!, cellEditor!)
methodend
classend
rem /**
rem * A simple boolean editor based on the GxCellEditorSelect.
rem *
rem * The editor provides a select box where the user can selected one of the three values (true , false , none)
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicBooleanSelect extends GxCellEditorSelect
rem /**
rem * The value to use when when the component needs to return a true value.
rem */
field public BBjString UsedTrueValue! = "true"
rem /**
rem * The value to use when when the component needs to return a false value.
rem */
field public BBjString UsedFalseValue! = "false"
rem /**
rem * The value to use when when the component needs to return a none/empty/null value.
rem * in case it is null() , then the none option will be hidden from the rendered list
rem */
field public BBjString UsedNoneValue! = ""
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem *
rem * @param BBjString trueValue! The value to use when when the component needs to return a true value.
rem * @param BBjString falseValue! The value to use when when the component needs to return a false value.
rem * @param BBjString noneValue! The value to use when when the component needs to return a none/empty/null value.
rem * in case it is null() , then the none option will be hidden from the rendered list
rem */
method public GxCellEditorBasicBooleanSelect(BBjString trueValue!,BBjString falseValue!,BBjString noneValue!)
#super!()
#setUsedTrueValue(trueValue!)
#setUsedFalseValue(falseValue!)
#setUsedNoneValue(noneValue!)
methodend
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem *
rem * @param BBjString trueValue! The value to use when when the component needs to return a true value.
rem * @param BBjString falseValue! The value to use when when the component needs to return a false value.
rem */
method public GxCellEditorBasicBooleanSelect(BBjString trueValue!,BBjString falseValue!)
#this!(trueValue!,falseValue!,"")
methodend
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem *
rem * @param BBjString trueValue! The value to use when when the component needs to return a true value.
rem */
method public GxCellEditorBasicBooleanSelect(BBjString trueValue!)
#this!(trueValue!,"false")
methodend
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem */
method public GxCellEditorBasicBooleanSelect()
#this!("true")
methodend
rem /**
rem * Set The value to use when when the component needs to return a true value.
rem *
rem * @param BBjString trueValue!
rem */
method public void setUsedTrueValue(BBjString trueValue!)
#getValues().remove(new JsonPrimitive(#UsedTrueValue!))
if(trueValue! <> null())
#getValues().add(trueValue!)
fi
#UsedTrueValue! = trueValue!
methodend
rem /**
rem * Set The value to use when when the component needs to return a true value.
rem *
rem * @param BBjString trueValue!
rem */
method public void setUsedFalseValue(BBjString falseValue!)
#getValues().remove(new JsonPrimitive(#UsedFalseValue!))
if(falseValue! <> null())
#getValues().add(falseValue!)
fi
#UsedFalseValue! = falseValue!
methodend
rem /**
rem * Set The value to use when when the component needs to return a none/empty/null value.
rem * in case it is null() , then the none option will be hidden from the rendered list
rem *
rem * @param BBjString trueValue!
rem */
method public void setUsedNoneValue(BBjString noneValue!)
#getValues().remove(new JsonPrimitive(#UsedNoneValue!))
if(noneValue! <> null())
#getValues().add(noneValue!)
fi
#UsedNoneValue! = noneValue!
methodend
classend
rem /**
rem * A simple boolean editor based on the GxCellEditorRichSelect.
rem *
rem * The editor provides a select box where the user can selected one of the three values (true , false , none)
rem *
rem * <br><b><small>#OnlyGUI</small></b>
rem * <br><b><small>#Enterprise</small></b>
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicBooleanRichSelect extends GxCellEditorRichSelect
rem /**
rem * The value to use when when the component needs to return a true value.
rem */
field public BBjString UsedTrueValue! = "true"
rem /**
rem * The value to use when when the component needs to return a false value.
rem */
field public BBjString UsedFalseValue! = "false"
rem /**
rem * The value to use when when the component needs to return a none/empty/null value.
rem * in case it is null() , then the none option will be hidden from the rendered list
rem */
field public BBjString UsedNoneValue! = ""
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem *
rem * @param BBjString trueValue! The value to use when when the component needs to return a true value.
rem * @param BBjString falseValue! The value to use when when the component needs to return a false value.
rem * @param BBjString noneValue! The value to use when when the component needs to return a none/empty/null value.
rem * in case it is null() , then the none option will be hidden from the rendered list
rem */
method public GxCellEditorBasicBooleanRichSelect(BBjString trueValue!,BBjString falseValue!,BBjString noneValue!)
#super!()
#setUsedTrueValue(trueValue!)
#setUsedFalseValue(falseValue!)
#setUsedNoneValue(noneValue!)
template$ = "<% "+
: "var value = params.value.toString();"+
: "switch(value){"+
: " case '" + #getUsedTrueValue() + "':"+
: " print('✔ True');"+
: " break;" +
: " case '" + #getUsedFalseValue() + "':"+
: " print('✘ False');"+
: " break;" +
: " case '" + #getUsedNoneValue() + "':"+
: " print('∅ None');"+
: " break;"+
: "} %>"
#setCellRenderer(new GxRendererCustomHTML(template$))
methodend
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem *
rem * @param BBjString trueValue! The value to use when when the component needs to return a true value.
rem * @param BBjString falseValue! The value to use when when the component needs to return a false value.
rem */
method public GxCellEditorBasicBooleanRichSelect(BBjString trueValue!,BBjString falseValue!)
#this!(trueValue!,falseValue!,"")
methodend
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem *
rem * @param BBjString trueValue! The value to use when when the component needs to return a true value.
rem */
method public GxCellEditorBasicBooleanRichSelect(BBjString trueValue!)
#this!(trueValue!,"false")
methodend
rem /**
rem * Construct new GxCellEditorBasicBooleanSelect
rem */
method public GxCellEditorBasicBooleanRichSelect()
#this!("true")
methodend
rem /**
rem * Set The value to use when when the component needs to return a true value.
rem *
rem * @param BBjString trueValue!
rem */
method public void setUsedTrueValue(BBjString trueValue!)
#getValues().remove(new JsonPrimitive(#UsedTrueValue!))
if(trueValue! <> null())
#getValues().add(trueValue!)
fi
#UsedTrueValue! = trueValue!
methodend
rem /**
rem * Set The value to use when when the component needs to return a true value.
rem *
rem * @param BBjString trueValue!
rem */
method public void setUsedFalseValue(BBjString falseValue!)
#getValues().remove(new JsonPrimitive(#UsedFalseValue!))
if(falseValue! <> null())
#getValues().add(falseValue!)
fi
#UsedFalseValue! = falseValue!
methodend
rem /**
rem * Set The value to use when when the component needs to return a none/empty/null value.
rem * in case it is null() , then the none option will be hidden from the rendered list
rem *
rem * @param BBjString trueValue!
rem */
method public void setUsedNoneValue(BBjString noneValue!)
#getValues().remove(new JsonPrimitive(#UsedNoneValue!))
if(noneValue! <> null())
#getValues().add(noneValue!)
fi
#UsedNoneValue! = noneValue!
methodend
classend
rem /**
rem * Simple number input
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicNumber extends GxCellEditorAbstract
rem /**
rem * The min allowed value
rem */
field public BBjNumber Min! = null()
rem /**
rem * The max allowed value
rem */
field public BBjNumber Max! = null()
rem /**
rem * The increment / decrement step
rem */
field public BBjNumber Step! = null()
rem /**
rem * A bbj number mask.
rem * When it is set we use it to validate the number
rem */
rem field public BBjString Mask! = null()
rem /**
rem * The number's group separator to use. by default the bbj group separator will be used
rem */
field public BBjString GroupSeparator! = null()
rem /**
rem * The number's decimal separator to use. by default the bbj decimal separator will be used
rem */
field public BBjString DecimalSeparator! = null()
rem /**
rem * Affects the output by switching the way a mask with "#" characters in the trailing positions is filled.
rem * for example, the function NumberMask.mask(.10:"#.##") returns .10 instead of .1 .
rem * The options is used only when numberMask is defined
rem */
field public BBjNumber ForceTrailingZeros = 0
rem /**
rem * Construct new GxCellEditorBasicNumber
rem *
rem * @param mask! A bbj number mask to validate the number
rem */
rem method public GxCellEditorBasicNumber(BBjString mask!)
rem #super!()
rem #Mask! = mask!
rem methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "NumberEditor"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("numberMinValue" , #getMin().doubleValue() , err=*next)
json!.addProperty("numberMaxValue" , #getMax().doubleValue() , err=*next)
json!.addProperty("numberStepValue" , #getStep().doubleValue() , err=*next)
rem json!.addProperty("numberMask" , #getMask() , err=*next)
json!.addProperty("numberGroupingSeparator" , #getGroupSeparator() , err=*next)
json!.addProperty("numberDecimalSeparator" , #getDecimalSeparator() , err=*next)
json!.addProperty("numberForceTrailingZeros" , #getForceTrailingZeros().booleanValue() , err=*next)
methodret json!
methodend
classend
rem /**
rem * Simple text input
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicText extends GxCellEditorAbstract
rem /**
rem * A bbj string mask
rem * When set we use it to validate the value
rem */
field public BBjString Mask! = null()
rem /**
rem * A regular expression that the input's value must match in order for the value to pass constraint validation
rem */
field public BBjString Pattern! = null()
rem /**
rem * The input title , when null and the textMask options is defined , then we use the mask as title , when set to default we the browser's default title , other wise the value defined in this option
rem */
field public BBjString Title! = null()
rem /**
rem * When true , then the input cannot be empty and a value is required to consider
rem * the input valid
rem */
field public BBjNumber Required! = 1
rem /**
rem * Construct new GxCellEditorBasicText
rem *
rem * @params mask! A bbj string mask to validate the value
rem */
method public GxCellEditorBasicText(BBjString mask!)
#super!()
#Mask! = mask!
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "TextEditor"
methodend
rem /**
rem * @override
rem *
rem * {@inheritDoc}
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!
json! = new JsonObject()
json!.addProperty("textMask" , #getMask() , err=*next)
json!.addProperty("textPattern" , #getPattern() , err=*next)
json!.addProperty("textTitle" , #getTitle() , err=*next)
json!.addProperty("textRequired" , #getRequired().booleanValue() , err=*next)
methodret json!
methodend
classend
rem /**
rem * A cell editor for timestamps
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicDateTime extends GxOptionsDateTime implements GxCellEditorInterface
rem /**
rem * Construct new GxFilterBasicDateTime
rem *
rem * @param mask! BBj date mask
rem */
method public GxCellEditorBasicDateTime(BBjString mask!)
#super!()
#setMask(mask!)
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getCellEditorName()
methodret "DateTimeEditor"
methodend
rem /**
rem * {@inheritDoc}
rem */
method public boolean equals(GxCellEditorInterface cellEditor!)
methodret GxCellEditorComparator.compare(#this!, cellEditor!)
methodend
classend
rem /**
rem * Alias for GxCellEditorBasicDateTime
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicTimestamp extends GxCellEditorBasicDateTime
rem /**
rem * Construct new GxFilterBasicDateTime
rem *
rem * @param mask! BBj date mask
rem */
method public GxCellEditorBasicTimestamp(BBjString mask!)
#super!(mask!)
methodend
classend
rem /**
rem * A date cell editor
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicDate extends GxCellEditorBasicDateTime
rem /**
rem * Construct a new GxCellEditorBasicDate
rem */
method public GxCellEditorBasicDate()
#setEnableTime(0)
#setMask("%Y/%Mz/%Dz")
methodend
rem /**
rem * Construct new GxCellEditorBasicDate
rem *
rem * @param mask! BBj date mask
rem */
method public GxCellEditorBasicDate(BBjString mask!)
#super!(mask!)
#setEnableTime(0)
methodend
classend
rem /**
rem * A date cell editor
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorBasicTime extends GxCellEditorBasicDateTime
rem /**
rem * Construct a new GxCellEditorBasicTime
rem */
method public GxCellEditorBasicTime()
#setEnableTime(1)
#setEnableCalendar(0)
#setMask("%Hz:%mz:%sz")
methodend
rem /**
rem * Construct new GxCellEditorBasicTime
rem *
rem * @param mask! BBj date mask
rem */
method public GxCellEditorBasicTime(BBjString mask!)
#super!(mask!)
#setEnableTime(1)
#setEnableCalendar(0)
methodend
classend
rem /**
rem * A interface which defines how a suggestion's resolver/builder
rem * should build the suggesting lst
rem *
rem * @author Hyyan Abo Fakher
rem *
rem * @see `GxCellEditor.GxCellEditorSuggestionResolver` which is a generic implementation of this interface
rem */
interface public GxCellEditorSuggestionResolverInterface
rem /**
rem * Resolve/build the suggestion list
rem *
rem * @param BBjString term! The search term
rem * @param GxClientColumnModel column! The column model
rem * @param GxClientRowModel row! The row model
rem *
rem * @return JsonArray A json array of json objects. Each json object should contain
rem * three properties "label" , "value" , "group"(optional)
rem */
method public JsonArray resolve(BBjString term!, GxClientColumnModel column!, GxClientRowModel row!)
interfaceend
rem /**
rem * An generic implementation of `GxCellEditorSuggestionResolverInterface`
rem *
rem * The class implements the `resolve` method defined in `GxCellEditorSuggestionResolverInterface`
rem * and exposes some helpers methods like `addItem` , `createItem` to help building
rem * the suggestion list.
rem *
rem * Any Custom object which extends this class must implement the `doResolve` method
rem * which accepts the search term.
rem *
rem * ex:
rem *
rem * <pre>
rem * use ::BBjGridExWidget/GxCellEditors.bbj::GxCellEditorSuggestionResolver
rem *
rem * class public CustomResolver extends GxCellEditorSuggestionResolver
rem *
rem * method public void doResolve(BBjString term!)
rem * sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rem * rs! = sbc!.retrieve(String.format("SELECT TITLE , MUSICTYPE, CDNUMBER FROM CDINVENTORY WHERE TITLE LIKE '%%%s%%' ORDER BY MUSICTYPE",term!))
rem *
rem * it! = rs!.iterator()
rem * while it!.hasNext()
rem * next! = it!.next()
rem * label! = String.format("[%s] %s",#getColumn().getName(), next!.getFieldAsString("TITLE"))
rem * value! = next!.getFieldAsString("CDNUMBER")
rem * group! = next!.getFieldAsString("MUSICTYPE")
rem *
rem * #addItem(label!, value!, group!)
rem * wend
rem * methodend
rem * classend
rem * </pre>
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorSuggestionResolver implements GxCellEditorSuggestionResolverInterface
rem /**
rem * A json array which is used by the `addItem` methods and it
rem * will be returned by the implemented `resolve` method
rem */
field public JsonArray List! = new JsonArray()
rem /**
rem * The search term
rem */
field public BBjString Term! = ""
rem /**
rem * The column model
rem */
field public GxClientColumnModel Column! = null()
rem /**
rem * The row model
rem */
field public GxClientRowModel Row! = null()
rem /**
rem * {@inheritDoc}
rem */
method public JsonArray resolve(BBjString term!, GxClientColumnModel column!, GxClientRowModel row!)
#setList(new JsonArray())
#setColumn(column!)
#setRow(Row!)
#setTerm(term!)
#doResolve(term!)
methodret #getList()
methodend
rem /**
rem * Do resolve the suggestion list
rem *
rem * @param BBjString term! The search term
rem */
method protected void doResolve(BBjString term!)
methodend
rem /**
rem * add a new suggestion item
rem *
rem * @param BBjString label! The item label. It will be used to display the item in the list
rem * @param BBjString value! The item value. It will be used to inset the input's value
rem * @param BBjString group! The item group. Display suggestions separated into one or multiple groups
rem *
rem * @return JsonObject
rem */
method public void addItem(BBjString label!, BBjString value!, BBjString group!)
#getList().add(#createItem(label!, value!, group!))
methodend
rem /**
rem * Add a new suggestion item
rem *
rem * @param BBjString label! The item label. It will be used to display the item in the list
rem * @param BBjString value! The item value. It will be used to inset the input's value
rem *
rem * @return JsonObject
rem */
method public void addItem(BBjString label!, BBjString value!)
#getList().add(#createItem(label!, value!))
methodend
rem /**
rem * Add a new suggestion item
rem *
rem * @param BBjString label! The item label. It will be used to display the item in the list
rem *
rem * @return JsonObject
rem */
method public void addItem(BBjString label!)
#getList().add(#createItem(label!))
methodend
rem /**
rem * Create a new suggestion item
rem *
rem * @param BBjString label! The item label. It will be used to display the item in the list
rem * @param BBjString value! The item value. It will be used to inset the input's value
rem * @param BBjString group! The item group. Display suggestions separated into one or multiple groups
rem *
rem * @return JsonObject
rem */
method public JsonObject createItem(BBjString label!, BBjString value!, BBjString group!)
item! = new JsonObject()
item!.addProperty("label", label!)
item!.addProperty("value", value!)
if (group! <> null())
item!.addProperty("group", group!)
fi
methodret item!
methodend
rem /**
rem * Create a new suggestion item
rem *
rem * @param BBjString label! The item label. It will be used to display the item in the list
rem * @param BBjString value! The item value. It will be used to inset the input's value
rem *
rem * @return JsonObject
rem */
method public JsonObject createItem(BBjString label!, BBjString value!)
methodret #createItem(label!, value!, null())
methodend
rem /**
rem * Create a new suggestion item
rem *
rem * @param BBjString label! The item label. It will be used to display the item in the list
rem *
rem * @return JsonObject
rem */
method public JsonObject createItem(BBjString label!)
methodret #createItem(label!, label!)
methodend
classend
rem /**
rem * A Suggestion/autocomplete cell editor.
rem *
rem * The suggestion cell editor is an input which gives the user a list of values (suggestions)
rem * to choose from while it types.
rem *
rem * The suggestion list can be resolved using a custom object which implements
rem * `GxCellEditorSuggestionResolverInterface` or extends `GxCellEditorSuggestionResolver`
rem *
rem * ex:
rem *
rem * <pre>
rem * use ::BBjGridExWidget/GxCellEditors.bbj::GxCellEditorSuggestion
rem *
rem * editor! = new GxCellEditorSuggestion("ANY_UNIQUE_ID",new CustomResolver())
rem * editor!.setEmptyMessage("No data to display")
rem *
rem * column! = grid!.getColumn("COLUMN_ID")
rem * column!.setCellEditor(editor2!)
rem * </pre>
rem *
rem * @see `GxCellEditor.GxCellEditorSuggestionResolver` to learn how to implement an resolver
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxCellEditorSuggestion extends GxCellEditorAbstract
rem /**
rem * A regular expression that the input's value must match
rem * In order for the value to pass constraint validation
rem */
field public BBjString Pattern! = null()
rem /**
rem * The input title , when set to null() or "default" then
rem * we use the browser's default title , other wise the value defined in this option
rem */
field public BBjString Title! = null()
rem /**
rem * When true , then the input cannot be empty and a value is required to consider
rem * the input valid
rem */
field public BBjNumber Required! = 1
rem /**
rem * When true , then input values which are not part
rem * of the suggestion list will be accepted , rejected otherwise
rem */
field public BBjNumber AllowCustomValues! = 0
rem /**
rem * Setup the suggestion list width in pixels
rem */
field public BBjNumber Width! = null()
rem /**
rem * Setup the suggestion list height in pixels
rem */
field public BBjNumber Height! = null()
rem /**
rem * When true , then the suggestion will not be triggered for
rem * invalid inputs
rem */
field public BBjNumber SuppressSuggestionOnInvalidInput! = 0
rem /**
rem * An HTML template to be used for rendering the suggestion items
rem *
rem * ex: