-
Notifications
You must be signed in to change notification settings - Fork 7
/
GxState.bbj
77 lines (63 loc) · 2.1 KB
/
GxState.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
rem package BBjGridExWidget
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/BBjGridExWidget.bbj::BBjGridExWidget
use com.google.gson.JsonParser
use com.google.gson.JsonArray
use com.google.gson.JsonObject
use com.google.gson.JsonElement
rem /**
rem * The Grid state object
rem *
rem * @author Hyyan Abo Fakher , Stephan Wald
rem */
class public GxState
field private BBjString String$
method public GxState(BBjString String$)
#setString(String$)
methodend
method public BBjString getString()
methodret #String$
methodend
method public void setString(BBjString jsonstr$)
if len(jsonstr$)>2 and jsonstr$(1,1)="[" then
rem old format that had only columns
jsonstr$="{""columns"":"+jsonstr$
jsonstr$=jsonstr$+",""groups"":[],""filters"":{}}"
FI
#String$ = jsonstr$
methodend
method public String toString()
methodret #String$
methodend
method public BBjVector getVisibleColumns()
declare BBjVector v!
declare JsonArray jarray!
declare JsonObject jobject!
declare JsonElement jelement!
v! = new BBjVector()
if #String$<>null() and #String$>"" then
jelement! = new JsonParser().parse(#String$,err=fail)
jobject! = jelement!.getAsJsonObject(err=fail)
jarray! = jobject!.getAsJsonArray("columns",err=fail)
s=jarray!.size()
if s>0 then
for i=0 to s-1
obj! = jarray!.get(i).getAsJsonObject()
name$ = str(obj!.get("colId").getAsString())
hide! = obj!.get("hide").getAsBoolean()
if hide! <> BBjAPI.TRUE then
v!.addItem(name$)
FI
next
FI
FI
fail:
methodret v!
methodend
classend