/*
* Copyright 2011 Serbian Object Laboratories (SOL)
*
* Licensed under the GPL licence
*
* http://www.gnu.org/licenses/gpl.html
*/
package companyorganization;
import rs.sol.soloist.client.common.GUIFeatureNames;
import rs.sol.soloist.helpers.init.DefaultContextInit;
import rs.sol.soloist.helpers.init.Initializer;
import rs.sol.soloist.helpers.init.InitializerFailedException;
import rs.sol.soloist.server.builtindomains.builtincommands.CmdCreateObjectAndLinkToObject;
import rs.sol.soloist.server.builtindomains.builtindatatypes.Boolean;
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.components.GUIStatusBarComponent;
import rs.sol.soloist.server.guiconfiguration.components.GUITabComponent;
import rs.sol.soloist.server.guiconfiguration.construction.GUIComponent;
import rs.sol.soloist.server.guiconfiguration.construction.GUIComponentBinding;
import rs.sol.soloist.server.guiconfiguration.construction.GUIFactory;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIElementComponent;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIFieldWidget;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIInputKind;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIListWidget;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISingleElementComponent;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISlotEditorKind;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISlotValueInput;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUISubnodesInput;
import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUITreeWidget;
import rs.sol.soloist.server.guiconfiguration.layout.CellLayoutData;
import rs.sol.soloist.server.guiconfiguration.layout.FlowLayout;
import rs.sol.soloist.server.guiconfiguration.layout.HorizontalAlignment;
import rs.sol.soloist.server.guiconfiguration.layout.LayoutData;
import rs.sol.soloist.server.guiconfiguration.layout.TableLayoutData;
import rs.sol.soloist.server.guiconfiguration.layout.VerticalAlignment;
import rs.sol.soloist.server.guiconfiguration.style.GUIBindingsFeature;
import rs.sol.soloist.server.guiconfiguration.style.GUIContext;
import rs.sol.soloist.server.guiconfiguration.style.GUINavigatorFeature;
import rs.sol.soloist.server.guiconfiguration.style.GUIObjectSetting;
import rs.sol.soloist.server.guiconfiguration.style.GUIPictureFeature;
import rs.sol.soloist.server.guiconfiguration.style.GUITextFeature;
import rs.sol.soloist.server.server.SoloistServiceServlet;
import companyorganization.Department;
import companyorganization.Employee;
import configuration.ObjectSpaceInit;
public class ApplicationInit implements Initializer {
private static final String COPYRIGHT_TEXT = "Copyright © 2011 - Serbian Object Laboratories (SOL) - Licence ";
private static final String TITLE = "SOLoist Demo - Company Organization";
private GUIApplicationComponent application;
private GUIContext context;
private GUIPanelComponent mainPanel;
private GUIPanelComponent titlePanel;
private GUIDeckComponent centralPanel;
private GUIPanelComponent departmentPanel;
private GUIElementComponent departmentTreeView;
private GUIElementComponent membersList;
public void init() throws InitializerFailedException {
application = new GUIApplicationComponent();
SoloistServiceServlet.registerApplication(application);
application.name.set(Text.fromString("CompanyOrganization"));
application.title.set(Text.fromString("Company Organization"));
context = new GUIContext();
context.supercontext.set(DefaultContextInit.getRoot());
application.context.set(context);
mainPanel = GUIPanelComponent.createVertical(application);
mainPanel.styleName.set(Text.fromString("main_panel"));
// Title panel
initTitlePanel();
// Central panel
centralPanel = GUIDeckComponent.create(GUIPanelComponent.createFlow(mainPanel));
centralPanel.styleName.set(Text.fromString("centralPanel"));
initDepartmentPanel();
// Bottom panel
initBottomPanel();
// Style settings
initStyle();
}
public void initTitlePanel() {
titlePanel = GUIPanelComponent.createHorizontal(mainPanel);
titlePanel.styleName.set(Text.fromString("titlePanel"));
CellLayoutData.setAlignment(titlePanel, VerticalAlignment.TOP);
CellLayoutData.setCellSize(titlePanel, "100%", "80");
// Logo
GUIImageComponent leftLogoComponent = GUIImageComponent.create(titlePanel);
leftLogoComponent.url.set(Text.fromString("res/img/logo-left.png"));
leftLogoComponent.styleName.set(Text.fromString("logo-image"));
CellLayoutData.setCellSize(leftLogoComponent, "200", null);
GUILabelComponent pageTitle = GUILabelComponent.create(titlePanel, TITLE, null);
pageTitle.styleName.set(Text.fromString("page_title"));
GUILinkComponent poweredBy = GUILinkComponent.create(titlePanel, "Powered by SOLoist", "http://www.soloist4uml.com/");
poweredBy.styleName.set(Text.fromString("poweredBy"));
CellLayoutData.setAlignment(poweredBy, VerticalAlignment.BOTTOM);
}
public void initDepartmentPanel() {
departmentPanel = GUIPanelComponent.createVertical(GUIPanelComponent.createFlow(centralPanel));
departmentPanel.styleName.set(Text.fromString("tablePanels"));
GUILabelComponent labelEmployeeTitle = GUILabelComponent.create(departmentPanel, "Departments details", null);
labelEmployeeTitle.styleName.set(Text.fromString("titleLabel"));
GUIPanelComponent departmentDetailsPanel = GUIPanelComponent.createHorizontal(departmentPanel);
departmentDetailsPanel.styleName.set(Text.fromString("tablePanels"));
// Department panel
GUIPanelComponent treePanel = GUIPanelComponent.createVertical(departmentDetailsPanel);
treePanel.styleName.set(Text.fromString("tablePanels"));
GUILabelComponent.create(treePanel, "Select Department: ", null);
departmentTreeView = GUIElementComponent.create(treePanel, new GUIInputKind(), new GUITreeWidget(), GUISubnodesInput.create(ObjectSpaceInit
.getRootDepartment(), true), null);
departmentTreeView.styleName.set(Text.fromString("departments"));
GUIPanelComponent detailsPanel = GUIPanelComponent.createTable(departmentDetailsPanel);
detailsPanel.styleName.set(Text.fromString("tablePanels"));
GUILabelComponent.create(detailsPanel, "Name: ", 0, 0);
GUIElementComponent nameSlot = GUIElementComponent.createSlotEditor(detailsPanel, Department.PROPERTIES.name, 0, 1);
LayoutData.setSize(nameSlot, "300px", "25px");
GUILabelComponent lab3 = GUILabelComponent.create(detailsPanel, "Responsibility: ", 1, 0);
CellLayoutData.setAlignment(lab3, VerticalAlignment.TOP);
GUIElementComponent respSlotComponent = GUIElementComponent.createSlotEditor(detailsPanel, Department.PROPERTIES.responsibility,
GUIFieldWidget.createMultilineText(), 1, 1);
LayoutData.setSize(respSlotComponent, "300px", "100px");
GUILabelComponent.create(detailsPanel, "Members: ", 3, 0);
membersList = GUIElementComponent.create(detailsPanel, new GUIInputKind(), new GUIListWidget(), GUISlotValueInput
.create(Department.PROPERTIES.members), new TableLayoutData(4, 0, 1, 2));
membersList.styleName.set(Text.fromString("members"));
// end Department panel
// Bindings for departments
GUIComponentBinding.create(departmentTreeView.value, GUISlotEditorKind.get(nameSlot).element);
GUIComponentBinding.create(departmentTreeView.value, GUISlotEditorKind.get(respSlotComponent).element);
GUIComponentBinding.create(departmentTreeView.value, GUISlotValueInput.get(membersList).element);
}
public void initBottomPanel() {
GUIPanelComponent bottomPanel = GUIPanelComponent.createVertical(mainPanel);
bottomPanel.styleName.set(Text.fromString("bottomPanel"));
GUIPanelComponent statusBarPanel = GUIPanelComponent.createHorizontal(bottomPanel);
statusBarPanel.styleName.set(Text.fromString("status_bar_panel"));
CellLayoutData.setCellSize(statusBarPanel, "100%", null);
GUILabelComponent statusBarLabel = GUILabelComponent.create(statusBarPanel, "Status bar: ", null);
CellLayoutData.setCellSize(statusBarLabel, "75px", null);
statusBarLabel.styleName.set(Text.fromString("status_bar_label"));
GUIStatusBarComponent statusBar = GUIStatusBarComponent.create(statusBarPanel);
statusBar.styleName.set(Text.fromString("status_bar"));
GUIHTMLComponent html = new GUIHTMLComponent();
html.parent.set(statusBarPanel);
html.html.set(Text.fromString(COPYRIGHT_TEXT));
html.styleName.set(Text.fromString("footer_panel"));
CellLayoutData.setAlignment(html, HorizontalAlignment.LEFT);
CellLayoutData.setSize(html, "400", null);
}
public void initStyle() {
// Object setting for department
GUIObjectSetting departmentOS = GUIObjectSetting.create(application.getContext(), Department.CLASSIFIER);
GUIPictureFeature.createSmallIcon(departmentOS, "res/img/CompanyOrganizationIcons/3.01_Department1.png");
GUITextFeature.createName(departmentOS, "name");
GUINavigatorFeature.createSubnodes(departmentOS, "subDepts");
// Object setting for employee
GUIObjectSetting employeeOS = GUIObjectSetting.create(application.getContext(), Employee.CLASSIFIER);
GUIPictureFeature.createSmallIcon(employeeOS, "res/img/CompanyOrganizationIcons/3.03_MaleEmployee2.png");
GUITextFeature.createName(employeeOS, "name");
// Tooltip for department
GUITextFeature tooltipDepr = new GUITextFeature();
tooltipDepr.isFixed.set(new Boolean(true));
tooltipDepr.textValue.set(Text.fromString("Double click to see details"));
departmentOS.features.add(tooltipDepr);
}
}