コード例 #1
0
  /**
   * 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);
  }
コード例 #2
0
 /**
  * Creates the button that can convert to ui designer view.
  *
  * @return the toggle button
  */
 private ToggleButton createUDButton() {
   final ToggleButton udButton = new ToggleButton();
   udButton.setToolTip("UI Designer");
   udButton.setIcon(icons.udIcon());
   udButton.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         public void componentSelected(ButtonEvent ce) {
           if (!udButton.isPressed()) {
             udButton.toggle(true);
           } else {
             modelerContainer.remove(buildingModelerView);
             modelerContainer.add(uiDesignerView);
             Cookies.setCookie(Constants.CURRETN_ROLE, Role.ROLE_DESIGNER);
             modelerContainer.layout();
           }
         }
       });
   udButton.setToggleGroup("modeler-switch");
   if (Role.ROLE_DESIGNER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) {
     udButton.toggle(true);
   }
   return udButton;
 }