rem /** rem * TreeSearch.bbj rem * rem * This program lets you experiment with different attributes of the BBjTree. rem * It also enables searching on the two tree controls, and adds a global rem * search so that we can search both trees simultaneously. rem * rem */ rem If the app is running in BUI, switch it automatically to run in the DWC client instead rem ================================================================================ if (info(3, 6) = "5") then bui! = BBjAPI().getBuiManager() url! = bui!.getUrl().replaceAll("apps", "webapp") action! = bui!.urlAction(url!) bui!.setEndAction(action!) release endif rem Create the main window wnd! = BBjAPI().openSysGui("X0").addWindow("BBj Tree Search",$00100083$) wnd!.setCallback(BBjAPI.ON_CLOSE,"eoj") rem Define the main window's layout using CSS Grid json! = new JsonObject() json!.addProperty("box-sizing", "border-box") json!.addProperty("width", "100%") json!.addProperty("height", "100%") json!.addProperty("padding", "var(--bbj-space-l)") json!.addProperty("display", "grid") json!.addProperty("gap", "var(--bbj-space-xl)") json!.addProperty("grid-template-columns", "1fr") json!.addProperty("grid-template-rows", "auto auto 1fr") json!.addProperty("justify-items", "stretch") json!.addProperty("align-items", "stretch") wnd!.setPanelStyle("@element", json!.toString()) rem Define the CSS for the BBjChildWindows that will be applied after we create them jsonChildWindow! = new JsonObject() jsonChildWindow!.addProperty("border-radius", "var(--bbj-border-radius)") jsonChildWindow!.addProperty("border-color", "var(--bbj-color-default-dark)") jsonChildWindow!.addProperty("padding", "var(--bbj-space) var(--bbj-space) var(--bbj-space-m) var(--bbj-space)") jsonChildWindow!.addProperty("display", "flex") jsonChildWindow!.addProperty("gap", "var(--bbj-space-3xl)") jsonChildWindow!.addProperty("overflow", "auto") rem Define the options window with toggleable attributes optsWnd! = wnd!.addChildWindow("BBj Tree's Boolean Attributes", $00109000$, BBjAPI().getSysGui().getAvailableContext()) optsWnd!.setPanelStyle("@element", jsonChildWindow!.toString()) rem Define the attributes in a vector that will be used to create checkboxes vectAttributes! = BBjAPI().makeVector() vectAttributes!.addItem("connect"); vectAttributes!.addItem("no-group-icons"); vectAttributes!.addItem("no-leaf-icons") vectAttributes!.addItem("multi-selection"); vectAttributes!.addItem("multi-selection-by-click") vectAttributes!.addItem("contiguous-selection"); vectAttributes!.addItem("allow-deselection-by-click") rem Create the checkboxes for the attributes for i = 0 to vectAttributes!.size() - 1 attrib! = str(vectAttributes!.getItem(i)) chk! = optsWnd!.addCheckBox(attrib!) chk!.setName(attrib!) chk!.setCallback(BBjCheckBox.ON_CHECK_OFF, "onOptsCheckOff") chk!.setCallback(BBjCheckBox.ON_CHECK_ON, "onOptsCheckOn") next rem Create a global search window and apply our custom CSS that we defined earlier searchWnd! = wnd!.addChildWindow("Global Search", $00109000$, BBjAPI().getSysGui().getAvailableContext()) searchWnd!.setPanelStyle("@element", jsonChildWindow!.toString()) globalSearch! = searchWnd!.addEditBox("",$$, "search") globalSearch!.setPlaceholder("Type to search both trees") globalSearch!.setStyle("width", "100%") globalSearch!.setCallback(globalSearch!.ON_EDIT_MODIFY , "onGlobalSearch") rem Create the BBjTree control child window treeWnd! = wnd!.addChildWindow("BBjTree Controls", $00109000$, BBjAPI().getSysGui().getAvailableContext()) treeWnd!.setPanelStyle("@element", jsonChildWindow!.toString()) json! = new JsonObject() json!.addProperty("box-sizing", "border-box") json!.addProperty("width", "100%") json!.addProperty("height", "100%") json!.addProperty("padding", "var(--bbj-space) var(--bbj-space) var(--bbj-space-m) var(--bbj-space)") json!.addProperty("display", "grid") json!.addProperty("gap", "var(--bbj-space-3xl)") json!.addProperty("grid-template-columns", "1fr 1fr") json!.addProperty("justify-items", "stretch") json!.addProperty("align-items", "stretch") REM json!.addProperty("max-height", "28em") REM json!.addProperty("height", "28em") json!.addProperty("overflow", "auto") treeWnd!.setPanelStyle("@element", json!.toString()) rem Define custom styling for the trees jsonTree! = new JsonObject() jsonTree!.addProperty("background", "hsl( var(--bbj-color-default-h), var(--bbj-color-default-s), 96%)") jsonTree!.addProperty("border", "1px solid hsl( var(--bbj-color-default-h), var(--bbj-color-default-s), 92%)") jsonTree!.addProperty("border-radius", "var(--bbj-border-radius)") jsonTree!.addProperty("border-top-width", "0") rem Add the first tree and define a custom error message via the search-nodata attribute tree1! = treeWnd!.addTree() tree1!.setAttribute("search-input","true") tree1!.setAttribute("search-placeholder","Search first tree") tree1!.setStyle("@element", jsonTree!.toString()) css! = "