Skip to content

Commit

Permalink
partly workaround for #72
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Wald committed Feb 15, 2019
1 parent 75f13d2 commit 7b8c97b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
44 changes: 44 additions & 0 deletions BBjGridExWidget.bbj
Expand Up @@ -324,6 +324,7 @@ class public BBjGridExWidget extends BBjWidget
field private BBjString DataFingerprint$
field private BBjNumber newW!
field private BBjNumber newH!
field private BBjString lastColumnStateHash$
rem /**
rem * disabled default constructor
rem */
Expand Down Expand Up @@ -532,6 +533,43 @@ class public BBjGridExWidget extends BBjWidget
swend
methodend
rem /**
rem * set a callback to a label
rem */
method public void setCallback(int p_eventType!, String p_callback!)
#super!.setCallback(p_eventType!, p_callback!)

rem this if statement can go when https://github.com/BBj-Plugins/BBjGridExWidget/issues/72
rem is resolved
if p_eventType!=#ON_GRID_COLUMN_STATE_CHANGE() then
BBjAPI().createTimer("timer"+#GRIDID$, 1, #this!, "onTimer")
fi
methodend
rem /**
rem * set callback to a method in an object instance
rem */
method public void setCallback(int p_eventType!, CustomObject p_snippetSetInstance!, String p_method!)
#super!.setCallback(p_eventType!,p_snippetSetInstance!, p_snippetSetInstance!)

rem this if statement can go when https://github.com/BBj-Plugins/BBjGridExWidget/issues/72
rem is resolved
if p_eventType!=#ON_GRID_COLUMN_STATE_CHANGE() then
BBjAPI().createTimer("timer"+#GRIDID$, 1, #this!, "onTimer")
fi
methodend

method public void onTimer(BBjTimerEvent ev!)
rem this method can go when https://github.com/BBj-Plugins/BBjGridExWidget/issues/72
rem is resolved
event! = #getColumnState()
md$ = java.security.MessageDigest.getInstance("MD5").digest(event!.getString())
if md$<> #lastColumnStateHash$ then
if #lastColumnStateHash$<>"" then
#fireEvent(#ON_GRID_COLUMN_STATE_CHANGE(),event!)
fi
#lastColumnStateHash$ = md$
fi
methodend
rem /**
rem * set the data into the grid
rem * @param ResultSet: the com.basiscomponents.db.ResultSet with the data
rem */
Expand Down Expand Up @@ -1490,6 +1528,12 @@ class public BBjGridExWidget extends BBjWidget
methodret 5007
methodend
rem /**
rem * @return constant value to define cell double click event
rem */
method public static BBjNumber ON_GRID_COLUMN_STATE_CHANGE()
methodret 5008
methodend
rem /**
rem * @return constant value to define row position
rem */
method public static BBjString GRID_ROWPOS_TOP()
Expand Down
14 changes: 11 additions & 3 deletions Demo/ColumnStateDemo.bbj
Expand Up @@ -20,6 +20,7 @@ wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize")

tb_get! = wnd!.addButton(300,10,3,200,25,"GET STATE")
tb_get!.setEnabled(0)
tb_set! = wnd!.addButton(301,230,3,200,25,"SET STATE")
tb_refresh! = wnd!.addButton(302,450,3,200,25,"REFRESH")

Expand Down Expand Up @@ -82,7 +83,10 @@ declare SqlQueryBC sbc!
group!.addItem("PLAYINGTIME")
grid!.addColumnGroup("group3" , "Misc",group! , 0 , "my-group-class")

grid!.setData(rs!)
grid!.setData(rs!)

grid!.setCallback(grid!.ON_GRID_COLUMN_STATE_CHANGE(),"onColumnStateChange")

return

byebye:
Expand All @@ -96,16 +100,20 @@ return
getState:
state! = grid!.getColumnState()
clipfromstr 1,state!.toString()


tb_get!.setEnabled(0)
return

setState:
if state!<>null() then
grid!.setColumnState(state!)
fi
tb_get!.setEnabled(0)
return

refresh:
grid!.setData(rs!)
return

onColumnStateChange:
tb_get!.setEnabled(1)
return

0 comments on commit 7b8c97b

Please sign in to comment.