Skip to content

Commit

Permalink
Complete missing API , and improve demo
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Apr 4, 2019
1 parent adb19c9 commit 4c91fb3
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 66 deletions.
31 changes: 22 additions & 9 deletions BBjGridExWidget.bbj
Expand Up @@ -297,7 +297,7 @@ class public BBjGridExWidget extends BBjWidget
rem * The grid default row height
rem *
rem * @RequiresRefresh
rem */
rem */
field public BBjNumber RowHeight! = 30
rem /**
rem * The grid sidebar
Expand All @@ -314,7 +314,7 @@ class public BBjGridExWidget extends BBjWidget
rem * @RequiresRefresh
rem * @Enterprise
rem */
field protected BBjGridExWidgetStatusBar Statusbar! = new BBjGridExWidgetStatusBar()
field protected BBjGridExWidgetStatusBar Statusbar! = new BBjGridExWidgetStatusBar(#this!)
field public BBjString GRIDID$ = java.util.UUID.randomUUID().toString()
field private BBjHtmlView HTMLView!
field private Boolean IsReady! = BBjAPI.FALSE
Expand Down Expand Up @@ -390,7 +390,8 @@ class public BBjGridExWidget extends BBjWidget
FI

htmlview! = #getCanvas().addHtmlView(101,0,0,#getCanvas().getWidth(),#getCanvas().getHeight(),"",$0010$)
htmlview!.setNoEdge(1)
htmlview!.setNoEdge(1)

if (info(3,6)<>"5" and #Debug>0) then
url$ = htmlview!.getAttribute("remoteDebuggingURL")

Expand Down Expand Up @@ -1341,18 +1342,15 @@ class public BBjGridExWidget extends BBjWidget
rem */
method public BBjGridExWidgetRow getSelectedRow()
returnedRow! = #executeScript("gw_getSelectedRow('" + #GRIDID$ + "')")

if len(returnedRow!) > 0 then
if len(returnedRow!) > 0 then
parser! = new JsonParser()
parsedRow! = parser!.parse(returnedRow!).getAsJsonObject()
row! = new BBjGridExWidgetRow(#RS!)

row!.setId(parsedRow!.get("id").getAsString())
row!.setChildIndex(parsedRow!.get("childIndex").getAsInt())
row!.setIndex(parsedRow!.get("index").getAsString())
row!.setParentKey(parsedRow!.get("parentKey").getAsString())
row!.setIsSelected(iff(parsedRow!.get("selected").getAsString() = "true" , 1 , 0))

methodret row!
fi

Expand Down Expand Up @@ -2269,7 +2267,6 @@ classend
class public BBjGridExWidgetSelectRowEvent

field public BBjVector SelectedRows! = new BBjVector()

rem /**
rem * Get the number of affected rows by the last event
rem *
Expand All @@ -2278,6 +2275,7 @@ class public BBjGridExWidgetSelectRowEvent
method public BBjNumber getSelectedRowCount()
methodret #SelectedRows!.size()
methodend

classend

class public BBjGridWidgetCellEditingEvent
Expand Down Expand Up @@ -2651,6 +2649,7 @@ interface public BBjGridExWidgetStatusBarComponentInterface

method public JsonObject getAsJsonObject()
methodend

interfaceend
rem /**
rem * AbstractBBjGridExWidgetStatusBarComponent
Expand Down Expand Up @@ -2808,6 +2807,18 @@ class public BBjGridExWidgetStatusBar
rem */
field protected HashMap components! = new HashMap()
rem /**
rem * The BBjGridExWidget instance
rem */
field protected BBjGridExWidget Widget!
rem /**
rem * Construct new sidebar
rem *
rem * @param BBjGridExWidget widget!
rem */
method public BBjGridExWidgetStatusBar(BBjGridExWidget widget!)
#Widget! = widget!
methodend
rem /**
rem * Add statusbar component
rem *
rem * @param BBjGridExWidgetStatusBarComponentInterface component! a statusbar component
Expand Down Expand Up @@ -2847,14 +2858,16 @@ class public BBjGridExWidgetStatusBar
rem * @param BBjNumber visiblity! 0 to hide component , 1 to show compoent
rem */
method public void setComponentVisibility(BBjGridExWidgetStatusBarComponentInterface component! , BBjNumber visiblity!)
#Widget!.__executeScript__("gw_setStatusbarComponentVisiblity('" + #Widget!.getGRIDID() + "','" + component!.getName() + "'," + str(visiblity!) + ")")
methodend
rem /**
rem * Hide/show statusbar component
rem *
rem * @param BBjString name$ the component name
rem * @param BBjNumber visiblity! 0 to hide component , 1 to show compoent
rem */
method public void setComponentVisibility(name$ , visiblity!)
method public void setComponentVisibility(BBjString name$ , BBjNumber visiblity!)
#Widget!.__executeScript__("gw_setStatusbarComponentVisiblity('" + #Widget!.getGRIDID() + "','" + name$ + "'," + str(visiblity!) + ")")
methodend
rem /**
rem * Convert the statusbar into a parsable json string
Expand Down
52 changes: 0 additions & 52 deletions Demo/Enterprise/Statusbar.bbj

This file was deleted.

91 changes: 91 additions & 0 deletions Demo/Enterprise/StatusbarDemo.bbj
@@ -0,0 +1,91 @@
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidgetStatusBarTotalRowCountComponent
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidgetStatusBarFilteredRowCountComponent
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidgetStatusBarTotalAndFilteredRowCountComponent
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidgetStatusBarSelectedRowCountComponent
use com.basiscomponents.bc.SqlQueryBC
use java.sql.Types

? 'HIDE'

declare auto BBjTopLevelWindow wnd!
declare BBjGridExWidget grid!


wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"Statusbar Demo")
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye")
wnd!.setCallback(BBjAPI.ON_RESIZE,"resize")

rem btn! = wnd!.addButton(202,10,10,80,22,"SELECT")
rem btn!.setCallback(BBjAPI.ON_BUTTON_PUSH,"onToggle")

static! = wnd!.addStaticText(202,10,10,200,25,"Toggle Statusbar Components" , $0000$ )
totalRow! = wnd!.addCheckBox(203,10,30,200,22,"Total Row")
totalRow!.setSelected(1)
totalRow!.setName(BBjGridExWidgetStatusBarTotalRowCountComponent.getName())
totalRow!.setCallback(BBjAPI.ON_CHECK_OFF,"onToggle")
totalRow!.setCallback(BBjAPI.ON_CHECK_ON,"onToggle")

filteredRow! = wnd!.addCheckBox(204,10,50,200,22,"Filtered Row")
filteredRow!.setSelected(1)
filteredRow!.setName(BBjGridExWidgetStatusBarFilteredRowCountComponent.getName())
filteredRow!.setCallback(BBjAPI.ON_CHECK_OFF,"onToggle")
filteredRow!.setCallback(BBjAPI.ON_CHECK_ON,"onToggle")

totalAndFilteredRow! = wnd!.addCheckBox(205,10,70,200,22,"Total And Filtered Row")
totalAndFilteredRow!.setSelected(1)
totalAndFilteredRow!.setName(BBjGridExWidgetStatusBarTotalAndFilteredRowCountComponent.getName())
totalAndFilteredRow!.setCallback(BBjAPI.ON_CHECK_OFF,"onToggle")
totalAndFilteredRow!.setCallback(BBjAPI.ON_CHECK_ON,"onToggle")

selectedRow! = wnd!.addCheckBox(206,10,90,200,22,"Selected Row")
selectedRow!.setSelected(1)
selectedRow!.setName(BBjGridExWidgetStatusBarSelectedRowCountComponent.getName())
selectedRow!.setCallback(BBjAPI.ON_CHECK_OFF,"onToggle")
selectedRow!.setCallback(BBjAPI.ON_CHECK_ON,"onToggle")

grid! = new BBjGridExWidget(wnd!,100,200,0,600,600)
grid!.setSelectionMode(grid!.GRID_SELECT_ROW())
grid!.setMultipleSelection(1)
grid!.setEnableFilter(1)
rem grid!.setEnableFloatingFilter(1)

statusbar! = grid!.getStatusbar()
statusbar!.addComponent(new BBjGridExWidgetStatusBarTotalRowCountComponent())
statusbar!.addComponent(new BBjGridExWidgetStatusBarFilteredRowCountComponent())
statusbar!.addComponent(new BBjGridExWidgetStatusBarTotalAndFilteredRowCountComponent("right"))
statusbar!.addComponent(new BBjGridExWidgetStatusBarSelectedRowCountComponent("center"))

gosub fillGrid

process_events

fillGrid:

declare SqlQueryBC sbc!

sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
rs! = sbc!.retrieve("SELECT * FROM CDINVENTORY")
grid!.setData(rs!)
return

byebye:
bye

resize:
ev! = BBjAPI().getLastEvent()
w=ev!.getWidth()
h=ev!.getHeight()
grid!.setSize(w,h)
return

onToggle:
event! = BBjAPI().getLastEvent()
control! = event!.getControl()

name$ = control!.getName()
visiblity! = iff(control!.isSelected() , 1 ,0)

statusbar! = grid!.getStatusbar()
statusbar!.setComponentVisibility(name$ , visiblity!)
return
44 changes: 43 additions & 1 deletion js/dist/bbj-grid-widget.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions js/dist/bbj-grid-widget.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/report.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/src/api.js
Expand Up @@ -12,4 +12,5 @@ export * from './api/cells.js';
export * from './api/state.js';
export * from './api/toolpanel.js';
export * from './api/menus.js';
export * from './api/statusbar.js';
export * from './api/jss.js';
13 changes: 13 additions & 0 deletions js/src/api/statusbar.js
@@ -0,0 +1,13 @@
/*
* This file is part of the grid project
* (c) Basis Europe <eu@basis.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

export function gw_setStatusbarComponentVisiblity(id, key, visiblity) {
const options = gw_getGrid(id).options;
let statusBarComponent = options.api.getStatusPanel(key);
statusBarComponent.setVisible(Boolean(visiblity));
}

0 comments on commit 4c91fb3

Please sign in to comment.