/** * Creates the center view in viewport by the user role, if the role is building modeler, then * show the building modeler view, else show the ui designer view. * * @param authority the authority */ private void createCenter(Authority authority) { List<String> roles = authority.getRoles(); modelerContainer = new LayoutContainer(); modelerContainer.setLayout(new FitLayout()); WidgetSelectionUtil widgetSelectionUtil = new WidgetSelectionUtil(eventBus); if (roles.contains(Role.ROLE_ADMIN) || (roles.contains(Role.ROLE_DESIGNER) && roles.contains(Role.ROLE_MODELER))) { this.buildingModelerView = new BuildingModelerView(eventBus); this.uiDesignerView = new UIDesignerView(widgetSelectionUtil); this.uiDesignerPresenter = new UIDesignerPresenter(eventBus, this.uiDesignerView, widgetSelectionUtil); if (Role.ROLE_DESIGNER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) { modelerContainer.add(uiDesignerView); } else { modelerContainer.add(buildingModelerView); } } else if (roles.contains(Role.ROLE_MODELER) && !roles.contains(Role.ROLE_DESIGNER)) { this.buildingModelerView = new BuildingModelerView(eventBus); modelerContainer.add(buildingModelerView); } else if (roles.contains(Role.ROLE_DESIGNER) && !roles.contains(Role.ROLE_MODELER)) { this.uiDesignerView = new UIDesignerView(widgetSelectionUtil); this.uiDesignerPresenter = new UIDesignerPresenter(eventBus, this.uiDesignerView, widgetSelectionUtil); modelerContainer.add(uiDesignerView); } BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.CENTER); data.setMargins(new Margins(0, 5, 0, 5)); viewport.add(modelerContainer, data); }
/** * Creates the applicationToolBar in the viewport's north part. The applicationToolBar's buttons * lies on the user role. */ private void createNorth() { ToolBar applicationToolBar = new ToolBar(); List<String> roles = authority.getRoles(); if (roles.contains(Role.ROLE_ADMIN) || (roles.contains(Role.ROLE_DESIGNER) && roles.contains(Role.ROLE_MODELER))) { applicationToolBar.add(createBMButton()); applicationToolBar.add(createUDButton()); SeparatorToolItem separatorItem = new SeparatorToolItem(); separatorItem.setWidth("20"); applicationToolBar.add(separatorItem); if (roles.contains(Role.ROLE_ADMIN)) { applicationToolBar.add(createAccountManageButton()); } initSaveAndExportButtons(); applicationToolBar.add(saveButton); applicationToolBar.add(exportButton); applicationToolBar.add(createOnLineTestBtn()); } else if (roles.contains(Role.ROLE_DESIGNER) && !roles.contains(Role.ROLE_MODELER)) { initSaveAndExportButtons(); applicationToolBar.add(saveButton); applicationToolBar.add(exportButton); applicationToolBar.add(createOnLineTestBtn()); } applicationToolBar.add(new FillToolItem()); applicationToolBar.add(createLogoutButton()); BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.NORTH, 25); data.setMargins(new Margins(0, 5, 0, 5)); viewport.add(applicationToolBar, data); }