예제 #1
0
    public void execute(final Event<UIPortletForm> event) throws Exception {
      UIPortletForm uiPortletForm = event.getSource();
      UIPortlet uiPortlet = uiPortletForm.getUIPortlet();
      UIFormInputIconSelector uiIconSelector =
          uiPortletForm.getChild(UIFormInputIconSelector.class);
      uiPortletForm.invokeSetBindingBean(uiPortlet);
      if (uiIconSelector.getSelectedIcon().equals("Default")) {
        uiPortlet.setIcon("PortletIcon");
      } else {
        uiPortlet.setIcon(uiIconSelector.getSelectedIcon());
      }
      UIFormInputThemeSelector uiThemeSelector =
          uiPortletForm.getChild(UIFormInputThemeSelector.class);
      uiPortlet.putSuitedTheme(
          null, uiThemeSelector.getChild(UIItemThemeSelector.class).getSelectedTheme());
      uiPortletForm.savePreferences();
      UIMaskWorkspace uiMaskWorkspace = uiPortletForm.getParent();
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      uiMaskWorkspace.createEvent("Close", Phase.DECODE, pcontext).broadcast();
      if (uiPortletForm.hasEditMode()) {
        uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
      }

      String width = uiPortletForm.getUIStringInput("width").getValue();
      if (width == null || width.length() == 0) {
        uiPortlet.setWidth(null);
      } else {
        if (!width.endsWith("px")) {
          width.concat("px");
        }
        uiPortlet.setWidth(width);
      }

      String height = uiPortletForm.getUIStringInput("height").getValue();
      if (height == null || height.length() == 0) {
        uiPortlet.setHeight(null);
      } else {
        if (!height.endsWith("px")) {
          height.concat("px");
        }
        uiPortlet.setHeight(height);
      }

      pcontext
          .getJavascriptManager()
          .addJavascript("eXo.portal.PortalComposer.toggleSaveButton();");
      UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
      UIWorkingWorkspace uiWorkingWS =
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
      pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
      pcontext.ignoreAJAXUpdateOnPortlets(true);
    }
예제 #2
0
  @SuppressWarnings("unchecked")
  public UIPortletForm() throws Exception {
    super("UIPortletForm");
    UIFormInputSet uiPortletPrefSet = new UIFormInputSet(FIELD_PORTLET_PREF).setRendered(false);
    addUIFormInput(uiPortletPrefSet);
    UIFormInputSet uiSettingSet = new UIFormInputSet("PortletSetting");
    uiSettingSet
        .addUIFormInput(new UIFormInputInfo("displayName", "displayName", null))
        .addUIFormInput(
            new UIFormStringInput("title", "title", null)
                .addValidator(StringLengthValidator.class, 3, 60)
                .addValidator(NotHTMLTagValidator.class, "UIPortletForm.msg.InvalidPortletTitle"))
        .addUIFormInput(
            new UIFormStringInput("width", "width", null)
                .addValidator(
                    ExpressionValidator.class,
                    "(^([1-9]\\d*)px$)?",
                    "UIPortletForm.msg.InvalidWidthHeight"))
        .addUIFormInput(
            new UIFormStringInput("height", "height", null)
                .addValidator(
                    ExpressionValidator.class,
                    "(^([1-9]\\d*)px$)?",
                    "UIPortletForm.msg.InvalidWidthHeight"))
        .addUIFormInput(new UICheckBoxInput("showInfoBar", "showInfoBar", false))
        .addUIFormInput(new UICheckBoxInput("showPortletMode", "showPortletMode", false))
        .addUIFormInput(new UICheckBoxInput("showWindowState", "showWindowState", false))
        .addUIFormInput(
            new UIFormTextAreaInput("description", "description", null)
                .addValidator(
                    NotHTMLTagValidator.class, "UIPortletForm.msg.InvalidPortletDescription"));
    addUIFormInput(uiSettingSet);
    UIFormInputIconSelector uiIconSelector = new UIFormInputIconSelector("Icon", "icon");
    addUIFormInput(uiIconSelector);

    UIFormInputThemeSelector uiThemeSelector = new UIFormInputThemeSelector(FIELD_THEME, null);
    SkinService skinService = getApplicationComponent(SkinService.class);
    uiThemeSelector.getChild(UIItemThemeSelector.class).setValues(skinService.getPortletThemes());
    addUIFormInput(uiThemeSelector);

    UIListPermissionSelector uiListPermissionSelector =
        createUIComponent(UIListPermissionSelector.class, null, null);
    uiListPermissionSelector.configure("UIAccessPermission", "accessPermissions");
    uiListPermissionSelector.addValidator(EmptyIteratorValidator.class);
    UIFormInputSet uiPermissionSet =
        createUIComponent(UIFormInputSet.class, "PortletPermission", null);
    uiPermissionSet.addChild(uiListPermissionSelector);
    addUIFormInput(uiPermissionSet);
  }