-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor : move predefined menu items to
BBjGridContextMenuItem
and…
… remove `BBjGridContextMenuPredefinedMenuitem` BREAKING CHANGE: `BBjGridContextMenuPredefinedMenuitem` is removed , use `BBjGridContextMenuItem` instead (@see Enterprise/ContextMenuDemo.bbj).
- Loading branch information
Showing
2 changed files
with
120 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,115 @@ | ||
rem /** | ||
rem * This file is part of the BBjGridExWidget plugin. | ||
rem * (c) Basis Europe <eu@basis.com> | ||
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 ::BBjGridExWidget/BBjGridExWidgetContextMenu.bbj::BBjGridContextMenuItem | ||
use ::BBjGridExWidget/BBjGridExWidgetContextMenu.bbj::BBjGridContextMenuPredefinedMenuitem | ||
use ::BBjGridExWidget/BBjGridExWidgetContextMenu.bbj::BBjGridContextMenu | ||
use ::BBjGridExWidget/BBjGridExWidgetContextMenu.bbj::BBjGridContextMenuItem | ||
use com.basiscomponents.db.ResultSet | ||
use com.basiscomponents.bc.SqlQueryBC | ||
use java.sql.Types | ||
use com.google.gson.JsonObject | ||
|
||
? 'HIDE' | ||
|
||
declare auto BBjTopLevelWindow wnd! | ||
declare auto BBjListButton lb_db! | ||
declare auto BBjListButton lb_tbl! | ||
declare auto BBjToolButton btn_fit! | ||
declare BBjGridExWidget grid! | ||
|
||
lic!=System.getProperty("bbjgridexwidget.license") | ||
|
||
if lic!=null() or str(lic!)="" then | ||
a=msgbox("set license key in bbj.properties under bbjgridexwidget.license=<yourlicense>",48,"Demo for Enterprise Features") | ||
release | ||
fi | ||
|
||
BBjGridExWidget.setLicenseKey(lic!) | ||
|
||
wnd! = BBjAPI().openSysGui("X0").addWindow(10,10,800,600,"BBj Grid Ex Demo") | ||
wnd! .setCallback(BBjAPI.ON_CLOSE,"byebye") | ||
wnd! .setCallback(BBjAPI.ON_RESIZE,"resize") | ||
|
||
grid! = new BBjGridExWidget(wnd!,100,0,0,800,600) | ||
|
||
|
||
gosub fillGrid | ||
wnd!.setCallback(BBjAPI.ON_CLOSE,"byebye") | ||
wnd!.setCallback(BBjAPI.ON_RESIZE,"resize") | ||
|
||
gosub main | ||
process_events | ||
|
||
fillGrid: | ||
|
||
declare SqlQueryBC sbc! | ||
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("ChileCompany")) | ||
rs! = sbc!.retrieve("SELECT * FROM CUSTOMER") | ||
|
||
style! = new JsonObject() | ||
style!.addProperty("background","#bdbdbd") | ||
grid!.addStyle(".maps-style" , style!) | ||
|
||
menu! = new BBjGridContextMenu() | ||
|
||
rem predefined items | ||
menu!.addItem(BBjGridContextMenuPredefinedMenuitem.AUTO_SIZE_ALL()) | ||
menu!.addItem(BBjGridContextMenuPredefinedMenuitem.RESET_COLUMNS()) | ||
menu!.addItem(BBjGridContextMenuPredefinedMenuitem.EXPORT()) | ||
|
||
rem custom item | ||
item! = new BBjGridContextMenuItem(6000,"Show Direction") | ||
item!.setTooltip("Open the location in Google Maps") | ||
item!.setIcon("http://icons.iconarchive.com/icons/papirus-team/papirus-apps/256/maps-icon.png" , 20 , 20) | ||
item!.setCssClasses("maps-style") | ||
menu!.addItem(item!) | ||
grid!.setCallback(6000,"onShowDirection") | ||
|
||
|
||
rem custom item | ||
item! = new BBjGridContextMenuItem(6001,"Search Firstname in Namepedia") | ||
item!.setTooltip("Search First Name in Namepedia") | ||
item!.setIcon("http://icons.iconarchive.com/icons/papirus-team/papirus-apps/256/godot-icon.png" , 20 , 20) | ||
menu!.addItem(item!) | ||
grid!.setCallback(6001,"onShowFirstName") | ||
|
||
item! = new BBjGridContextMenuItem(6002,"Copy Functions") | ||
rem /** | ||
rem * Retrive the data from the database and configure the grid | ||
rem */ | ||
main: | ||
declare SqlQueryBC sbc! | ||
declare ResultSet rs! | ||
|
||
sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("ChileCompany")) | ||
rs! = sbc!.retrieve("SELECT * FROM CUSTOMER") | ||
|
||
rem /** | ||
rem * Create a new context menu to attach to the grid | ||
rem */ | ||
menu! = new BBjGridContextMenu() | ||
|
||
rem /** | ||
rem * Add some predefined items with their actions to the menu | ||
rem * @see <a href="https://bbj-plugins.github.io/BBjGridExWidget/javadoc/BBjGridExWidget/ContextMenu/BBjGridContextMenuItem.html">BBjGridContextMenuItem</a> | ||
rem */ | ||
menu!.addItem(BBjGridContextMenuItem.AUTO_SIZE_ALL()) | ||
menu!.addItem(BBjGridContextMenuItem.RESET_COLUMNS()) | ||
menu!.addItem(BBjGridContextMenuItem.EXPORT()) | ||
|
||
rem /** | ||
rem * Create custom menu items | ||
rem * | ||
rem * Any custom menu item requires two params , an id (used for handling events) and a label | ||
rem * When the item is clicked on the client , the client will notify the grid with an event | ||
rem * using the chosen id so you can use the grid's setCallback method to handle the event | ||
rem */ | ||
|
||
direction! = new BBjGridContextMenuItem(6000,"Show Direction") | ||
direction!.setIcon("http://icons.iconarchive.com/icons/papirus-team/papirus-apps/256/maps-icon.png" , 20 , 20) | ||
direction!.setTooltip("Open the location in Google Maps") | ||
menu!.addItem(direction!) | ||
|
||
namepedia! = new BBjGridContextMenuItem(6001,"Search Firstname in Namepedia") | ||
namepedia!.setIcon("http://icons.iconarchive.com/icons/papirus-team/papirus-apps/256/godot-icon.png" , 20 , 20) | ||
namepedia!.setTooltip("Search First Name in Namepedia") | ||
menu!.addItem(namepedia!) | ||
|
||
copy! = new BBjGridContextMenuItem(6002,"Copy Functions") | ||
submenu! = new BBjGridContextMenu() | ||
submenu!.addItem(BBjGridContextMenuPredefinedMenuitem.COPY()) | ||
submenu!.addItem(BBjGridContextMenuPredefinedMenuitem.COPY_WITH_HEADERS()) | ||
item!.setSubMenu(submenu!) | ||
menu!.addItem(item!) | ||
|
||
grid!.setContextMenu(menu!) | ||
grid!.setData(rs!) | ||
submenu!.addItem(BBjGridContextMenuItem.COPY()) | ||
submenu!.addItem(BBjGridContextMenuItem.COPY_WITH_HEADERS()) | ||
copy!.setSubMenu(submenu!) | ||
menu!.addItem(copy!) | ||
|
||
rem /** | ||
rem * init the grid and attache the menu items callbacks | ||
rem */ | ||
grid! = new BBjGridExWidget(wnd!,100,0,0,800,600) | ||
grid!.setContextMenu(menu!) | ||
grid!.setData(rs!) | ||
grid!.setCallback(6000,"onShowDirection") | ||
grid!.setCallback(6001,"onShowFirstName") | ||
return | ||
|
||
onShowDirection: | ||
|
||
ev! = BBjAPI().getLastEvent() | ||
ev! = ev!.getObject() | ||
|
||
row! = ev!.getRow().asDataRow() | ||
url$ = "https://www.google.com/maps/search/?api=1&query=" + java.net.URLEncoder.encode(row!.getFieldAsString("BILL_ADDR1").trim() + "," + row!.getFieldAsString("COUNTRY").trim()) | ||
BBjAPI().getThinClient().browse(url$) | ||
ev! = BBjAPI().getLastEvent() | ||
ev! = ev!.getObject() | ||
row! = ev!.getRow().asDataRow() | ||
url$ = "https://www.google.com/maps/search/?api=1&query=" + java.net.URLEncoder.encode(row!.getFieldAsString("BILL_ADDR1").trim() + "," + row!.getFieldAsString("COUNTRY").trim()) | ||
BBjAPI().getThinClient().browse(url$) | ||
return | ||
|
||
|
||
onShowFirstName: | ||
ev! = BBjAPI().getLastEvent() | ||
ev! = ev!.getObject() | ||
|
||
row! = ev!.getRow().asDataRow() | ||
url$ = "http://www.namepedia.org/en/firstname/?q="+java.net.URLEncoder.encode(row!.getFieldAsString("FIRST_NAME").trim()) | ||
BBjAPI().getThinClient().browse(url$) | ||
ev! = BBjAPI().getLastEvent() | ||
ev! = ev!.getObject() | ||
row! = ev!.getRow().asDataRow() | ||
url$ = "http://www.namepedia.org/en/firstname/?q="+java.net.URLEncoder.encode(row!.getFieldAsString("FIRST_NAME").trim()) | ||
BBjAPI().getThinClient().browse(url$) | ||
return | ||
|
||
byebye: | ||
bye | ||
|
||
rem /** | ||
rem * Listen to the BBjTopLevelWindow resize events and | ||
rem * resize the grid to fill the available space. | ||
rem */ | ||
resize: | ||
ev! = BBjAPI().getLastEvent() | ||
grid!.setSize(ev!.getWidth(),ev!.getHeight()) | ||
ev! = BBjAPI().getLastEvent() | ||
w=ev!.getWidth() | ||
h=ev!.getHeight() | ||
grid!.setSize(w,h) | ||
return | ||
|
||
rem /** | ||
rem * Close the demo | ||
rem */ | ||
byebye: | ||
bye |