This is an old revision of the document!


Tabs and Layouts Sample

This sample introduces tab component, a few static components (label, link, etc.) and different supported layouts.

Live example

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.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.components.GUITabComponent;
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 TabLayoutStaticComponents implements Initializer {
 
	INSTANCE;
 
	@Override
	public void init() throws InitializerFailedException {
 
		GUIApplicationComponent application = new GUIApplicationComponent(); // new web page
		application.name.set(Text.fromString("TabLayoutStaticComponents")); // set some kind of name for application component so you can refer it by that name from the corresponding html page
		SoloistServiceServlet.registerApplication(application); // register application
 
		GUIPanelComponent root = GUIPanelComponent.createFlow(application); // remember, application can have only one child, do not add more panels to it
 
		GUILabelComponent title = GUILabelComponent.create(root, "Tabs and Layouts");
		title.styleName.set(Text.fromString("titleStyle")); // setting CSS class name (.titleStyle)
 
		GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);
		topPanel.styleName.set(Text.fromString("topPanel"));
 
		GUITabComponent tabs = GUITabComponent.create(topPanel, new String[] { "Vertical", "Horizontal", "Flow", "Table", "Dock", "XY" });
 
		GUIPanelComponent verticalPanel = GUIPanelComponent.createVertical(tabs); // vertical layout
		createStaticComponents(verticalPanel);
 
		GUIPanelComponent horizontalPanel = GUIPanelComponent.createHorizontal(tabs); // horizontal layout
		createStaticComponents(horizontalPanel);
 
		GUIPanelComponent flowPanel = GUIPanelComponent.createFlow(tabs); // flow layout (HTML normal flow)
		createStaticComponents(flowPanel);
 
		GUIPanelComponent table = GUIPanelComponent.createTable(tabs); // Table Layout
		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(tabs); // Dock layout
		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 layout
		xy.styleName.set(Text.fromString("box"));
		xy.parent.set(tabs);
		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));
 
	}
 
	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>");
	}
 
}
Print/export