This is an old revision of the document!
Table of Contents
Deck and Layouts Sample
This sample upgrades on previous one, introduces deck component, buttons and most importantly bindings (GUIBindingComponent). Clicking on buttons will show appropriate panel with same few static components, but with different layouts. Deck component has history stack, which can be browsed using back and forward input pins (click on « and » buttons).
Live example
UML Model
None.
Business Logic Code
None.
GUI Code
package rs.sol.sampleapps; import rs.sol.soloist.helpers.init.Initializer; import rs.sol.soloist.helpers.init.InitializerFailedException; import rs.sol.soloist.server.builtindomains.builtindatatypes.Text; import rs.sol.soloist.server.guiconfiguration.components.GUIApplicationComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIButtonComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIDeckComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIHTMLComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIImageComponent; import rs.sol.soloist.server.guiconfiguration.components.GUILabelComponent; import rs.sol.soloist.server.guiconfiguration.components.GUILinkComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIPanelComponent; import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding; import rs.sol.soloist.server.guiconfiguration.layout.DockLayoutData; import rs.sol.soloist.server.guiconfiguration.layout.DockLayoutDirection; import rs.sol.soloist.server.guiconfiguration.layout.XYLayout; import rs.sol.soloist.server.guiconfiguration.layout.XYLayoutData; import rs.sol.soloist.server.server.SoloistServiceServlet; public enum DeckLayoutStaticComponents implements Initializer { INSTANCE; @Override public void init() throws InitializerFailedException { GUIApplicationComponent application = new GUIApplicationComponent(); application.name.set(Text.fromString("DeckLayoutStaticComponents")); SoloistServiceServlet.registerApplication(application); GUIPanelComponent root = GUIPanelComponent.createFlow(application); GUILabelComponent title = GUILabelComponent.create(root, "Deck and Layouts"); title.styleName.set(Text.fromString("titleStyle")); GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root); topPanel.styleName.set(Text.fromString("topPanel")); GUIDeckComponent deck = GUIDeckComponent.create(topPanel); deck.styleName.set(Text.fromString("deckH")); GUIPanelComponent verticalPanel = GUIPanelComponent.createVertical(deck); createStaticComponents(verticalPanel); GUIPanelComponent horizontalPanel = GUIPanelComponent.createHorizontal(deck); createStaticComponents(horizontalPanel); GUIPanelComponent flowPanel = GUIPanelComponent.createFlow(deck); createStaticComponents(flowPanel); GUIPanelComponent table = GUIPanelComponent.createTable(deck); int row = 0, col = 0; GUILabelComponent.create(table, "GUILabelComponent", row, col++); GUILinkComponent.create(table, "GUILinkComponent", "http://www.soloist4uml.com", row++, col--); GUIImageComponent.create(table, "images/logo.png", row, col++); GUIHTMLComponent.create(table, "<h1>GUI<i>HTMLComponent</i></h1>", row, col); GUIPanelComponent dock = GUIPanelComponent.createDock(deck); dock.styleName.set(Text.fromString("box")); GUILabelComponent.create(dock, "GUILabelComponent").layoutData.set(new DockLayoutData(DockLayoutDirection.NORTH, 5)); GUILinkComponent.create(dock, "GUILinkComponent", "http://www.soloist4uml.com", "_blank").layoutData .set(new DockLayoutData(DockLayoutDirection.EAST, 9)); GUIImageComponent.create(dock, "images/logo.png").layoutData.set(new DockLayoutData(DockLayoutDirection.WEST, 12)); GUIHTMLComponent.create(dock, "<h1>GUI<i>HTMLComponent</i></h1>").layoutData.set(new DockLayoutData(DockLayoutDirection.SOUTH, 5)); GUIPanelComponent xy = new GUIPanelComponent(); xy.styleName.set(Text.fromString("box")); xy.parent.set(deck); xy.layout.set(new XYLayout()); GUILabelComponent.create(xy, "GUILabelComponent").layoutData.set(new XYLayoutData(5, 10, 120, 30)); GUILinkComponent.create(xy, "GUILinkComponent", "http://www.soloist4uml.com", "_blank").layoutData.set(new XYLayoutData(155, 20, 120, 30)); GUIImageComponent.create(xy, "images/logo.png").layoutData.set(new XYLayoutData(55, 110, 160, 80)); GUIHTMLComponent.create(xy, "<h1>GUI<i>HTMLComponent</i></h1>").layoutData.set(new XYLayoutData(205, 50, 280, 40)); GUIButtonComponent verticalBtn = GUIButtonComponent.create(topPanel, "Vertical"); GUIButtonComponent horizontalBtn = GUIButtonComponent.create(topPanel, "Horizontal"); GUIButtonComponent flowBtn = GUIButtonComponent.create(topPanel, "Flow"); GUIButtonComponent tableBtn = GUIButtonComponent.create(topPanel, "Table"); GUIButtonComponent dockBtn = GUIButtonComponent.create(topPanel, "Dock"); GUIButtonComponent xyBtn = GUIButtonComponent.create(topPanel, "XY"); // clicking on button will send signal to show input pin of corresponding panel which in turn will be shown in deck GUIComponentBinding.create(verticalBtn.click, verticalPanel.show); GUIComponentBinding.create(horizontalBtn.click, horizontalPanel.show); GUIComponentBinding.create(flowBtn.click, flowPanel.show); GUIComponentBinding.create(tableBtn.click, table.show); GUIComponentBinding.create(dockBtn.click, dock.show); GUIComponentBinding.create(xyBtn.click, xy.show); GUIButtonComponent backBtn = GUIButtonComponent.create(topPanel, "<<"); GUIButtonComponent forwardBtn = GUIButtonComponent.create(topPanel, ">>"); GUIComponentBinding.create(forwardBtn.click, deck.forward); GUIComponentBinding.create(backBtn.click, deck.back); } private void createStaticComponents(GUIPanelComponent parent) { GUILabelComponent.create(parent, "GUILabelComponent"); GUILinkComponent.create(parent, "GUILinkComponent", "http://www.soloist4uml.com", "_blank"); GUIImageComponent.create(parent, "images/logo.png"); GUIHTMLComponent.create(parent, "<h1>GUI<i>HTMLComponent</i></h1>"); } }