Tabs and Layouts

Tabs and Layouts is a SOLoist sample application that shows the use of the tab component, a few static components (label, link, image, and HTML), and various layout policies supported in SOLoist.

Live Demo

UML Model

None.

Bussines 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.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.TableLayoutData;
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();
		application.setName("TabLayoutStaticComponents");
		SoloistServiceServlet.registerApplication(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.setStyle("titleStyle"); // setting CSS class name (.titleStyle)
 
		GUIPanelComponent topPanel = GUIPanelComponent.createFlow(root);
		topPanel.setStyle("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", TableLayoutData.create(row++, col--));
		GUIImageComponent.create(table, "images/logo.png", TableLayoutData.create(row, col++));
		GUIHTMLComponent.create(table, "<h1>GUI<i>HTMLComponent</i></h1>", TableLayoutData.create(row, col));
 
		GUIPanelComponent dock = GUIPanelComponent.createDock(tabs); // Dock layout
		dock.setStyle("box");
		GUILabelComponent.create(dock, "GUILabelComponent", DockLayoutData.create(DockLayoutDirection.NORTH, 5));
		GUILinkComponent.create(dock, "GUILinkComponent", "http://www.soloist4uml.com", "_blank", DockLayoutData.create(DockLayoutDirection.EAST, 9));
		GUIImageComponent.create(dock, "images/logo.png", DockLayoutData.create(DockLayoutDirection.WEST, 12));
		GUIHTMLComponent.create(dock, "<h1>GUI<i>HTMLComponent</i></h1>", DockLayoutData.create(DockLayoutDirection.SOUTH, 5));
 
		GUIPanelComponent xy = GUIPanelComponent.createAbsolute(tabs); // XY layout
		xy.setStyle("box");
		GUILabelComponent.create(xy, "GUILabelComponent").setLayoutData(XYLayoutData.create(5, 10, "120px", "30px"));
		GUILinkComponent.create(xy, "GUILinkComponent", "http://www.soloist4uml.com", "_blank").setLayoutData(XYLayoutData.create(155, 20, "120px", "30px"));
		GUIImageComponent.create(xy, "images/logo.png").setLayoutData(XYLayoutData.create(55, 110, "160px", "80px"));
		GUIHTMLComponent.create(xy, "<h1>GUI<i>HTMLComponent</i></h1>").setLayoutData(XYLayoutData.create(205, 50, "280px", "40px"));
 
	}
 
	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