Skip to content

Commit

Permalink
refactor!: deprecate GxStatusBarComponentInterface.NAME()
Browse files Browse the repository at this point in the history
BREAKING CHANGE: deprecate `GxStatusBarComponentInterface.NAME()` in favor of `GxStatusBarComponentInterface.getId()`
  • Loading branch information
hyyan committed May 5, 2020
1 parent 1ee0490 commit f79fe64
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 22 deletions.
73 changes: 57 additions & 16 deletions GxStatusBar.bbj
Expand Up @@ -25,10 +25,19 @@ interface public GxStatusBarComponentInterface
rem * Get the component name
rem *
rem * @returns BBjString the component name
rem *
rem * @deprecated use `getId()` instead
rem */

method public static BBjString NAME()
rem /**
rem * Get the component id
rem *
rem * @returns BBjString the component unique id
rem */

method public static BBjString getId()
rem /**
rem * Set the component alignment
rem *
rem * @param BBjString alignment$ "right", "left" or "center"
Expand Down Expand Up @@ -78,7 +87,7 @@ class public GxStatusBarComponent implements GxStatusBarComponentInterface
declare JsonObject json!

json! = new JsonObject()
json!.addProperty("statusPanel",#this!.NAME())
json!.addProperty("statusPanel",#getId())
json!.addProperty("align",#getAlignment())
methodret json!
methodend
Expand All @@ -102,6 +111,12 @@ class public GxStatusBarSelectedRowCountComponent extends GxStatusBarComponent
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
methodret GxStatusBarSelectedRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agSelectedRowCountComponent"
methodend

Expand All @@ -124,6 +139,12 @@ class public GxStatusBarFilteredRowCountComponent extends GxStatusBarComponent
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
methodret GxStatusBarFilteredRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agFilteredRowCountComponent"
methodend

Expand All @@ -146,6 +167,12 @@ class public GxStatusBarTotalAndFilteredRowCountComponent extends GxStatusBarCom
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
methodret GxStatusBarTotalAndFilteredRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agTotalAndFilteredRowCountComponent"
methodend

Expand All @@ -168,6 +195,12 @@ class public GxStatusBarTotalRowCountComponent extends GxStatusBarComponent
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
methodret GxStatusBarTotalRowCountComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agTotalRowCountComponent"
methodend

Expand Down Expand Up @@ -201,6 +234,12 @@ class public GxStatusBarAggregationComponent extends GxStatusBarComponent
rem * {@inheritDoc}
rem */
method public static BBjString NAME()
methodret GxStatusBarAggregationComponent.getId()
methodend
rem /**
rem * {@inheritDoc}
rem */
method public static BBjString getId()
methodret "agAggregationComponent"
methodend
rem /**
Expand Down Expand Up @@ -256,44 +295,46 @@ class public GxStatusBar
rem * @param GxStatusBarComponentInterface component! a statusbar component
rem */
method public void addComponent(GxStatusBarComponentInterface component!)
#Components!.put(component!.NAME(),component!)
#Components!.put(component!.getId(),component!)
methodend
rem /**
rem * Get statusbar component
rem *
rem * @param BBjString name! the component name
rem * @param BBjString id! The component id
rem *
rem * @return GxStatusBarComponentInterface The component instance
rem */
method public GxStatusBarComponentInterface getComponent(BBjString name!)
method public GxStatusBarComponentInterface getComponent(BBjString id!)
declare auto GxStatusBarComponentInterface c!

c! = #Components!.get(name!)
c! = #Components!.get(id!)
methodret c!
methodend
rem /**
rem * Remove statusbar component
rem *
rem * @param BBjString name! the component name
rem * @param BBjString id! The component id
rem */
method public void removeComponent(BBjString name!)
#Components!.remove(name!)
method public void removeComponent(BBjString id!)
#Components!.remove(id!)
methodend
rem /**
rem * Remove statusbar component
rem *
rem * @param GxStatusBarComponentInterface component! a statusbar component
rem */
method public void removeComponent(GxStatusBarComponentInterface component!)
#Components!.remove(component!.NAME())
#Components!.remove(component!.getId())
methodend
rem /**
rem * Hide/show statusbar component
rem *
rem * @param BBjString name! the component name
rem * @param BBjString id! The component id
rem * @param BBjNumber visibility! 0 to hide component, 1 to show component
rem */
method public void setComponentVisibility(BBjString name! , BBjNumber visibility!)
scriptKey! = "$wnd.gw_setStatusbarComponentVisibility" + name!
#Widget!.getExecutor().execute(scriptKey!,"$wnd.gw_setStatusbarComponentVisibility('" + #Widget!.getGRIDID() + "','" + name! + "'," + str(visibility!) + ")")
method public void setComponentVisibility(BBjString id! , BBjNumber visibility!)
scriptKey! = "$wnd.gw_setStatusbarComponentVisibility" + id!
#Widget!.getExecutor().execute(scriptKey!,"$wnd.gw_setStatusbarComponentVisibility('" + #Widget!.getGRIDID() + "','" + id! + "'," + str(visibility!) + ")")
methodend
rem /**
rem * Hide/show statusbar component
Expand All @@ -302,7 +343,7 @@ class public GxStatusBar
rem * @param BBjNumber visibility! 0 to hide component, 1 to show component
rem */
method public void setComponentVisibility(GxStatusBarComponentInterface component! , BBjNumber visibility!)
#setComponentVisibility(component!.NAME() , visibility!)
#setComponentVisibility(component!.getId() , visibility!)
methodend
rem /**
rem * Convert the statusbar into a parsable json string
Expand All @@ -314,7 +355,7 @@ class public GxStatusBar

defs! = new JsonArray()
it! = #Components!.entrySet().iterator()
while it!.hasNext()=BBjAPI.TRUE
while it!.hasNext() = BBjAPI.TRUE
defs!.add(it!.next().getValue().getAsJsonObject())
wend

Expand All @@ -325,4 +366,4 @@ class public GxStatusBar
methodret new Gson().toJson(json!)
methodend

classend
classend
12 changes: 6 additions & 6 deletions demo/Enhanced/Statusbar.bbj
Expand Up @@ -24,25 +24,25 @@ 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(GxStatusBarTotalRowCountComponent.NAME())
totalRow!.setName(GxStatusBarTotalRowCountComponent.getId())
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(GxStatusBarFilteredRowCountComponent.NAME())
filteredRow!.setName(GxStatusBarFilteredRowCountComponent.getId())
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(GxStatusBarTotalAndFilteredRowCountComponent.NAME())
totalAndFilteredRow!.setName(GxStatusBarTotalAndFilteredRowCountComponent.getId())
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(GxStatusBarSelectedRowCountComponent.NAME())
selectedRow!.setName(GxStatusBarSelectedRowCountComponent.getId())
selectedRow!.setCallback(BBjAPI.ON_CHECK_OFF,"onToggle")
selectedRow!.setCallback(BBjAPI.ON_CHECK_ON,"onToggle")

Expand Down Expand Up @@ -79,10 +79,10 @@ onToggle:
control! = event!.getControl()

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

statusbar! = grid!.getStatusbar()
statusbar!.setComponentVisibility(name$ , visiblity!)
statusbar!.setComponentVisibility(name$ , visibility!)
return

byebye:
Expand Down

0 comments on commit f79fe64

Please sign in to comment.