package rs.soloist.soloist.sample.companyorganization.init; import static rs.sol.soloist.server.guiconfiguration.construction.GUIFactory.createElementComponent; import static rs.sol.soloist.server.guiconfiguration.construction.GUIFactory.createSubnodesInput; import rs.sol.soloist.client.common.GUIFeatureNames; import rs.sol.soloist.helpers.init.Initializer; import rs.sol.soloist.sample.companyorganization.Department; import rs.sol.soloist.sample.companyorganization.Employee; import rs.sol.soloist.server.builtindomains.builtincommands.CmdCreateObjectAndLinkToObject; import rs.sol.soloist.server.builtindomains.builtindatatypes.Boolean; import rs.sol.soloist.server.builtindomains.builtindatatypes.Integer; 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.GUIMenuComponent; import rs.sol.soloist.server.guiconfiguration.components.GUIMenuItemComponent; 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.GUIFactory; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIElementComponent; import rs.sol.soloist.server.guiconfiguration.elementcomponents.GUIFieldEditor; 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.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.TableLayout; import rs.sol.soloist.server.guiconfiguration.layout.TableLayoutData; import rs.sol.soloist.server.guiconfiguration.layout.VerticalAlignment; import rs.sol.soloist.server.guiconfiguration.layout.VerticalLayout; import rs.sol.soloist.server.guiconfiguration.style.GUIBindingsFeature; import rs.sol.soloist.server.guiconfiguration.style.GUIContext; import rs.sol.soloist.server.guiconfiguration.style.GUIObjectSetting; import rs.sol.soloist.server.guiconfiguration.style.GUITextFeature; public class ApplicationInit implements Initializer { //Root department private Department rootDepartment = new Department(); //Layout private CellLayoutData leftHorizontalLayoutData; private CellLayoutData centerHorizontalMiddleVerticalLayoutData; private CellLayoutData rightHorizontalLayoutData; //Main private GUIApplicationComponent application; private GUIContext context; private GUIPanelComponent mainPanel; //Title panel private GUIPanelComponent titlePanel; //Menu private GUIMenuItemComponent menuItem; //Central panel private GUIPanelComponent departmentPanel; private GUIElementComponent departmentTreeView; private GUIElementComponent membersList; private GUIPanelComponent employeePanel; //Buttons private GUIPanelComponent employeeButtonPanel; private GUIPanelComponent departmentButtonPanel; public void initLayout(){ leftHorizontalLayoutData = new CellLayoutData(); leftHorizontalLayoutData.horizontalAlignment.set(HorizontalAlignment.LEFT); centerHorizontalMiddleVerticalLayoutData = new CellLayoutData(); centerHorizontalMiddleVerticalLayoutData.horizontalAlignment.set(HorizontalAlignment.CENTER); centerHorizontalMiddleVerticalLayoutData.verticalAlignment.set(VerticalAlignment.MIDDLE); rightHorizontalLayoutData = new CellLayoutData(); rightHorizontalLayoutData.horizontalAlignment.set(HorizontalAlignment.RIGHT); } public void initObjectSpace(){ //Adding departments rootDepartment.name.set(new Text("SOL")); Department d2 = new Department(); d2.name.set(new Text("Headquarters")); Department d3 = new Department(); d3.name.set(new Text("Research & Development")); Department d4 = new Department(); d4.name.set(new Text("Production")); Department d5 = new Department(); d5.name.set(new Text("Commerce")); Department d6 = new Department(); d6.name.set(new Text("Development")); Department d7 = new Department(); d7.name.set(new Text("Quality Assurance")); Department d8 = new Department(); d8.name.set(new Text("Marketing")); Department d9 = new Department(); d9.name.set(new Text("Sales")); Department d10 = new Department(); d10.name.set(new Text("Support")); rootDepartment.subDepts.add(d2); rootDepartment.subDepts.add(d3); rootDepartment.subDepts.add(d4); rootDepartment.subDepts.add(d5); d4.subDepts.add(d6); d4.subDepts.add(d7); d5.subDepts.add(d8); d5.subDepts.add(d9); d5.subDepts.add(d10); //Adding employees Employee e1 = new Employee(); e1.firstName.set(new Text("Dragan")); e1.lastName.set(new Text("Milicev")); e1.isMarried.set(new Boolean(true)); e1.numberOfChildren.set(new Integer(3)); Employee e2 = new Employee(); e2.firstName.set(new Text("Zarko")); e2.lastName.set(new Text("Mijailovic")); Employee e3 = new Employee(); e3.firstName.set(new Text("Nikola")); e3.lastName.set(new Text("Mihajlovic")); Employee e4 = new Employee(); e4.firstName.set(new Text("Nemanja")); e4.lastName.set(new Text("Kojic")); Employee e5 = new Employee(); e5.firstName.set(new Text("Sanja")); e5.lastName.set(new Text("Mitrovic")); Employee e6 = new Employee(); e6.firstName.set(new Text("Andrija")); e6.lastName.set(new Text("Misevic")); Employee e7 = new Employee(); e7.firstName.set(new Text("Jelena")); e7.lastName.set(new Text("Marasevic")); Employee e8 = new Employee(); e8.firstName.set(new Text("Jasmina")); e8.lastName.set(new Text("Dustinac")); Employee e9 = new Employee(); e9.firstName.set(new Text("Vukasin")); e9.lastName.set(new Text("Milovanovic")); Employee e10 = new Employee(); e10.firstName.set(new Text("Luka")); e10.lastName.set(new Text("Stanisic")); d2.members.add(e1); d3.members.add(e2); d6.members.add(e3); d7.members.add(e4); d5.members.add(e5); d4.members.add(e6); d10.members.add(e7); d8.members.add(e8); d9.members.add(e9); d3.members.add(e10); } public void initTitlePanel(){ titlePanel = GUIFactory.createVerticalPanel(mainPanel); titlePanel.styleName.set(new Text("panel1")); GUIPanelComponent panel11 = GUIFactory.createTablePanel(titlePanel); CellLayoutData.setCellSize(panel11, "100%", null); LayoutData.setSize(panel11, "100%", null); GUIImageComponent leftLogoComponent = new GUIImageComponent(); panel11.children.add(leftLogoComponent); leftLogoComponent.url.set(new Text("res/img/logo-left.bmp")); CellLayoutData.setAlignment(leftLogoComponent, HorizontalAlignment.LEFT, null); leftLogoComponent.layoutData.set(new TableLayoutData(0, 0)); GUILabelComponent logoLabel = GUIFactory.createLabel(panel11, "SOLoist 4 Demo - Company Organization", null); logoLabel.layoutData.set(new TableLayoutData(0, 1)); CellLayoutData.setAlignment(logoLabel, HorizontalAlignment.CENTER, VerticalAlignment.MIDDLE); logoLabel.styleName.set(new Text("logo_label")); GUILinkComponent backLink = new GUILinkComponent(); backLink.parent.set(panel11); backLink.caption.set(new Text("Back to SOLoist home")); backLink.href.set(new Text("http://www.soloist4uml.com/")); backLink.layoutData.set(new TableLayoutData(0, 2)); CellLayoutData.setAlignment(backLink, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM); } public void initMenu(){ GUIMenuComponent menu = new GUIMenuComponent(); menu.horizontal.set(new Boolean(true)); titlePanel.children.add(menu); menuItem = new GUIMenuItemComponent(); menuItem.text.set(new Text("HOME")); menu.items.add(menuItem); } public void initCentralPanel(){ GUIPanelComponent centralPanel = GUIFactory.createVerticalPanel(mainPanel); centralPanel.styleName.set(new Text("panel2")); GUIDeckComponent deck1 = new GUIDeckComponent(); centralPanel.children.add(deck1); departmentPanel = GUIFactory.createHorizontalPanel(deck1); GUIPanelComponent treePanel = GUIFactory.createVerticalPanel(departmentPanel); GUIFactory.createLabel(treePanel, "Select department: ", null); departmentTreeView = createElementComponent(treePanel, new GUIInputKind(), new GUITreeWidget(), createSubnodesInput(rootDepartment, true), null); departmentTreeView.styleName.set(new Text("departments")); GUIPanelComponent detailsPanel = GUIFactory.createPanel(departmentPanel, new TableLayout(4, 2)); GUIFactory.createLabel(detailsPanel, "Name: ", new TableLayoutData(0,0)); GUIElementComponent nameSlotComponent = GUIFactory.createSlotEditorComponent(detailsPanel, Department.FQPropertyNames.name, new GUIFieldEditor(),new TableLayoutData(0,1)); GUIFactory.createLabel(detailsPanel, "Responsibility: ", new TableLayoutData(1,0)); GUIElementComponent respSlotComponent = GUIFactory.createSlotEditorComponent(detailsPanel, Department.FQPropertyNames.responsibility, new GUIFieldEditor(), new TableLayoutData(1,1)); GUIFactory.createLabel(detailsPanel, "Members: ", new TableLayoutData(3,0)); GUISlotValueInput members = new GUISlotValueInput(); members.propertyFQName.set(new Text(Department.FQPropertyNames.members)); membersList = createElementComponent(detailsPanel, new GUIInputKind(), new GUIListWidget(), members, new TableLayoutData(4,0,4,2)); membersList.styleName.set(new Text("members")); employeePanel = GUIFactory.createPanel(deck1, null); GUITabComponent tab = new GUITabComponent(); employeePanel.children.add(tab); GUIPanelComponent generalPanel = GUIFactory.createPanel(tab,null); generalPanel.layout.set(new TableLayout(8,3)); tab.tabTexts.add(new Text("General")); GUIFactory.createLabel(generalPanel, "Employee: ", new TableLayoutData(0,0)); GUISingleElementComponent singleEmployeeGeneral = new GUISingleElementComponent(); singleEmployeeGeneral.layoutData.set(new TableLayoutData(0,1)); generalPanel.children.add(singleEmployeeGeneral); GUIFactory.createLabel(generalPanel, "First name: ", new TableLayoutData(1,0)); GUIElementComponent firstnameSlotComponent=GUIFactory.createSlotEditorComponent(generalPanel, Employee.FQPropertyNames.firstName, new GUIFieldEditor(),new TableLayoutData(1,1)); GUIFactory.createLabel(generalPanel, "Last name: ", new TableLayoutData(2,0)); GUIElementComponent lastnameSlotComponent=GUIFactory.createSlotEditorComponent(generalPanel, Employee.FQPropertyNames.lastName, new GUIFieldEditor(),new TableLayoutData(2,1)); GUIFactory.createLabel(generalPanel, "Date of birth: ", new TableLayoutData(3,0)); GUIElementComponent dateSlotComponent=GUIFactory.createSlotEditorComponent(generalPanel, Employee.FQPropertyNames.dateOfBirth, new GUIFieldEditor(),new TableLayoutData(3,1)); GUIFactory.createLabel(generalPanel, "Is married: ", new TableLayoutData(4,0)); GUIElementComponent ismarriedSlotComponent=GUIFactory.createSlotEditorComponent(generalPanel, Employee.FQPropertyNames.isMarried, new GUIFieldEditor(),new TableLayoutData(4,1)); GUIFactory.createLabel(generalPanel, "Number of children: ", new TableLayoutData(5,0)); GUIElementComponent numofchSlotComponent=GUIFactory.createSlotEditorComponent(generalPanel, Employee.FQPropertyNames.numberOfChildren, new GUIFieldEditor(),new TableLayoutData(5,1)); GUIFactory.createLabel(generalPanel, "Contract: ", new TableLayoutData(6,0)); GUIPanelComponent panelFile = GUIFactory.createFileComponent(Employee.FQPropertyNames.contract, true, generalPanel, new TableLayoutData(6,1)); GUIFactory.createLabel(generalPanel, "Department: ", new TableLayoutData(7,0)); GUISlotValueInput departmentGeneral =new GUISlotValueInput(); departmentGeneral.propertyFQName.set(new Text(Employee.FQPropertyNames.dept)); GUIElementComponent departmentGeneralList = createElementComponent(generalPanel, new GUIInputKind(), new GUIListWidget(), departmentGeneral, new TableLayoutData(7,1)); departmentGeneralList.styleName.set(new Text("department")); GUIFactory.createLabel(generalPanel, "Photo: ", new TableLayoutData(0,2)); GUIPanelComponent panelPicture = GUIFactory.createFileComponent(Employee.FQPropertyNames.photo, true, generalPanel, new TableLayoutData(1,2,7,2)); GUIComponent picComp = panelPicture.children.at(0); LayoutData.setSize(picComp, null, "250px"); GUIPanelComponent panelDepartment = GUIFactory.createPanel(tab,null); tab.tabTexts.add(new Text("Department")); panelDepartment.layout.set(new TableLayout(9,3)); GUIFactory.createLabel(panelDepartment, "Employee: ", new TableLayoutData(0,0)); GUISingleElementComponent singleEmployeeDepartment = new GUISingleElementComponent(); singleEmployeeDepartment.layoutData.set(new TableLayoutData(0,1)); panelDepartment.children.add(singleEmployeeDepartment); GUIFactory.createLabel(panelDepartment, "Membership: ", new TableLayoutData(1,0)); GUIElementComponent membershipSlotComponent=GUIFactory.createSlotEditorComponent(panelDepartment, Employee.FQPropertyNames.dept, new GUITreeWidget(), createSubnodesInput(rootDepartment, false), new TableLayoutData(2,0,8,2)); membershipSlotComponent.styleName.set(new Text("membership")); //Bindings for departments GUIFactory.createBinding(departmentTreeView.value, ((GUISlotEditorKind)(nameSlotComponent.kind.val())).element); GUIFactory.createBinding(departmentTreeView.value, ((GUISlotEditorKind)(respSlotComponent.kind.val())).element); GUIFactory.createBinding(departmentTreeView.value, members.element); GUIFactory.createBinding(departmentPanel.input, departmentTreeView.value); //Bindings for employees GUIFactory.createBinding(employeePanel.input, singleEmployeeGeneral.element); GUIFactory.createBinding(employeePanel.input, ((GUISlotEditorKind)(firstnameSlotComponent.kind.val())).element); GUIFactory.createBinding(employeePanel.input, ((GUISlotEditorKind)(lastnameSlotComponent.kind.val())).element); GUIFactory.createBinding(employeePanel.input, ((GUISlotEditorKind)(dateSlotComponent.kind.val())).element); GUIFactory.createBinding(employeePanel.input, ((GUISlotEditorKind)(ismarriedSlotComponent.kind.val())).element); GUIFactory.createBinding(employeePanel.input, ((GUISlotEditorKind)(numofchSlotComponent.kind.val())).element); GUIFactory.createBinding(employeePanel.input, panelFile.input); GUIFactory.createBinding(employeePanel.input, departmentGeneral.element); GUIFactory.createBinding(employeePanel.input, panelPicture.input); GUIFactory.createBinding(employeePanel.input, singleEmployeeDepartment.element); GUIFactory.createBinding(employeePanel.input, ((GUISlotEditorKind)membershipSlotComponent.kind.val()).element); //Bindings for menu GUIFactory.createBinding(menuItem.click, departmentPanel.input); GUIFactory.createBinding(menuItem.click, departmentPanel.show); } public void initButtons(){ GUIButtonComponent btn2CreateEmpl = new GUIButtonComponent(); btn2CreateEmpl.styleName.set(new Text("button")); btn2CreateEmpl.text.set(new Text("Create employee")); departmentButtonPanel.children.add(btn2CreateEmpl); CmdCreateObjectAndLinkToObject createEmplCommand = new CmdCreateObjectAndLinkToObject(); createEmplCommand.className.set(new Text(Employee.FQ_TYPE_NAME)); createEmplCommand.assocEndName.set(new Text(Department.FQPropertyNames.members)); createEmplCommand.type.set(new Text(Department.FQ_TYPE_NAME)); btn2CreateEmpl.command.add(createEmplCommand); GUIFactory.createBinding(departmentTreeView.value, btn2CreateEmpl.firstParam); GUIButtonComponent btn2CreateSubDepr = new GUIButtonComponent(); btn2CreateSubDepr.styleName.set(new Text("button")); btn2CreateSubDepr.text.set(new Text("Create subdepartment")); departmentButtonPanel.children.add(btn2CreateSubDepr); CmdCreateObjectAndLinkToObject createSubDeprCommand= new CmdCreateObjectAndLinkToObject(); createSubDeprCommand.className.set(new Text(Department.FQ_TYPE_NAME)); createSubDeprCommand.assocEndName.set(new Text(Department.FQPropertyNames.subDepts)); createSubDeprCommand.type.set(new Text(Department.FQ_TYPE_NAME)); btn2CreateSubDepr.command.add(createSubDeprCommand); GUIFactory.createBinding(departmentTreeView.value, btn2CreateSubDepr.firstParam); } public void initBottomPanel(){ GUIPanelComponent bottomPanel = GUIFactory.createPanel(mainPanel, new VerticalLayout()); bottomPanel.styleName.set(new Text("panel_3")); GUIDeckComponent deck2 = new GUIDeckComponent(); bottomPanel.children.add(deck2); employeeButtonPanel = GUIFactory.createPanel(deck2, new FlowLayout()); departmentButtonPanel = GUIFactory.createPanel(deck2, new FlowLayout()); departmentButtonPanel.styleName.set(new Text("button_panel")); GUIFactory.createBinding(departmentTreeView.value, departmentButtonPanel.show); initButtons(); GUIPanelComponent statusPanel = GUIFactory.createHorizontalPanel(bottomPanel); statusPanel.styleName.set(new Text("status_bar_panel")); GUIPanelComponent panel331 = GUIFactory.createHorizontalPanel(statusPanel); GUILabelComponent statusBarLabel = GUIFactory.createLabel(panel331, "Status bar: ", null); statusBarLabel.styleName.set(new Text("status_bar_label")); GUIStatusBarComponent statusBar = new GUIStatusBarComponent(); statusBar.styleName.set(new Text("status_bar")); panel331.children.add(statusBar); GUIPanelComponent footerPanel = GUIFactory.createHorizontalPanel(bottomPanel); CellLayoutData.setCellSize(footerPanel, "100%", null); footerPanel.styleName.set(new Text("footer_panel")); GUIHTMLComponent html = new GUIHTMLComponent(); html.parent.set(footerPanel); html.html.set(new Text("Copyright © 2009 - Serbian Object Laboratories ")); CellLayoutData.setAlignment(html, HorizontalAlignment.RIGHT); CellLayoutData.setCellSize(html, "100%", null); } public void initStyle(){ //Object setting department GUIObjectSetting departmentOS = GUIFactory.createObjectSetting(context, Department.FQ_TYPE_NAME); GUIFactory.createSmallIconFeature(departmentOS, "res/img/department.png"); GUIFactory.createNameFeature(departmentOS, "name"); GUIFactory.createSubnodesFeature(departmentOS, "subDepts"); //Object setting employee GUIObjectSetting employeeOS = GUIFactory.createObjectSetting(context, Employee.FQ_TYPE_NAME); GUIFactory.createSmallIconFeature(employeeOS, "res/img/employee.png"); GUIFactory.createNameFeature(employeeOS, "firstName"); GUITextFeature tooltipDepr = new GUITextFeature(); //Tooltip department tooltipDepr.name.set(new Text("Tooltip")); tooltipDepr.isFixed.set(new Boolean(true)); tooltipDepr.textValue.set(new Text("Double click to see details")); departmentOS.features.add(tooltipDepr); //Tooltip employee GUITextFeature tooltipEmpl = new GUITextFeature(); tooltipEmpl.name.set(new Text("Tooltip")); tooltipEmpl.isFixed.set(new Boolean(true)); tooltipEmpl.textValue.set(new Text("Double click to see details")); employeeOS.features.add(tooltipEmpl); //Binding feature department GUIBindingsFeature bfDepartment = new GUIBindingsFeature(); bfDepartment.name.set(new Text(GUIFeatureNames.BINDINGS)); GUIFactory.createBinding(bfDepartment.doubleClick, departmentPanel.input); GUIFactory.createBinding(bfDepartment.doubleClick, departmentPanel.show); GUIFactory.createBinding(bfDepartment.doubleClick, departmentButtonPanel.show); departmentOS.features.add(bfDepartment); //Binding feature employee GUIBindingsFeature bfEmployee = new GUIBindingsFeature(); bfEmployee.name.set(new Text(GUIFeatureNames.BINDINGS)); GUIFactory.createBinding(bfEmployee.doubleClick, employeePanel.show); GUIFactory.createBinding(bfEmployee.doubleClick, employeeButtonPanel.show); GUIFactory.createBinding(bfEmployee.doubleClick, employeePanel.input); employeeOS.features.add(bfEmployee); } public void init() throws Exception { application = new GUIApplicationComponent(); application.name.set(new Text("CompanyOrganization")); context = new GUIContext(); context.supercontext.set(DefaultContextInit.get()); application.context.set(context); mainPanel = GUIFactory.createVerticalPanel(application); mainPanel.styleName.set(new Text("main_panel")); //Layout initLayout(); //Initialize object space initObjectSpace(); //Title panel initTitlePanel(); //Menu initMenu(); //Central panel initCentralPanel(); //Bottom panel initBottomPanel(); //Style settings initStyle(); } }