예제 #1
0
  @SuppressWarnings("unchecked")
  public UIPageForm(InitParams initParams) throws Exception {
    super("UIPageForm");
    PortalRequestContext pcontext = Util.getPortalRequestContext();
    UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
    List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
    ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));

    UserPortalConfig userPortalConfig =
        configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
    ExoContainer container = ExoContainerContext.getCurrentContainer();
    UserACL acl = (UserACL) container.getComponentInstanceOfType(UserACL.class);
    if (acl.hasEditPermission(userPortalConfig.getPortalConfig())) {
      ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
    }
    ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
    ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());

    UIFormSelectBox uiSelectBoxOwnerType = new UIFormSelectBox(OWNER_TYPE, OWNER_TYPE, ownerTypes);
    uiSelectBoxOwnerType.setOnChange("ChangeOwnerType");

    UIFormInputSet uiSettingSet = new UIFormInputSet("PageSetting");
    uiSettingSet
        .addUIFormInput(new UIFormStringInput("pageId", "pageId", null).setEditable(false))
        .addUIFormInput(uiSelectBoxOwnerType)
        .addUIFormInput(ownerIdInput)
        .addUIFormInput(
            new UIFormStringInput("name", "name", null)
                .addValidator(StringLengthValidator.class, 3, 30)
                .addValidator(IdentifierValidator.class)
                .addValidator(MandatoryValidator.class))
        .addUIFormInput(
            new UIFormStringInput("title", "title", null)
                .addValidator(StringLengthValidator.class, 3, 120))
        .addUIFormInput(new UIFormCheckBoxInput("showMaxWindow", "showMaxWindow", false));
    addUIFormInput(uiSettingSet);
    setSelectedTab(uiSettingSet.getId());

    // WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
    // Param param = initParams.getParam("PageTemplate");
    // List<SelectItemCategory> itemCategories =
    // (List<SelectItemCategory>)param.getMapGroovyObject(context);
    // UIFormInputItemSelector uiTemplate = new UIFormInputItemSelector("Template", "template");
    // uiTemplate.setItemCategories(itemCategories);
    // addUIFormInput(uiTemplate);

    uiPermissionSetting = createUIComponent(UIFormInputSet.class, "PermissionSetting", null);
    UIListPermissionSelector uiListPermissionSelector =
        createUIComponent(UIListPermissionSelector.class, null, null);
    uiListPermissionSelector.configure("UIListPermissionSelector", "accessPermissions");
    uiListPermissionSelector.addValidator(EmptyIteratorValidator.class);
    uiPermissionSetting.addChild(uiListPermissionSelector);
    uiPermissionSetting.setSelectedComponent(uiListPermissionSelector.getId());
    UIPermissionSelector uiEditPermission =
        createUIComponent(UIPermissionSelector.class, null, null);
    uiEditPermission.setRendered(false);
    uiEditPermission.addValidator(
        org.exoplatform.webui.organization.UIPermissionSelector.MandatoryValidator.class);
    uiEditPermission.setEditable(false);
    uiEditPermission.configure("UIPermissionSelector", "editPermission");
    uiPermissionSetting.addChild(uiEditPermission);

    // TODO: This following line is fixed for bug PORTAL-2127
    uiListPermissionSelector
        .getChild(UIFormPopupWindow.class)
        .setId("UIPageFormPopupGroupMembershipSelector");

    List<String> groups = configService.getMakableNavigations(pcontext.getRemoteUser(), true);
    if (groups.size() > 0) {
      Collections.sort(groups);
      ownerTypes.add(new SelectItemOption<String>(PortalConfig.GROUP_TYPE));
      List<SelectItemOption<String>> groupsItem = new ArrayList<SelectItemOption<String>>();
      for (String group : groups) {
        groupsItem.add(new SelectItemOption<String>(group));
      }
      groupIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, groupsItem);
      groupIdSelectBox.setOnChange("ChangeOwnerId");
      groupIdSelectBox.setParent(uiSettingSet);
    }
    setActions(new String[] {"Save", "Close"});
  }
예제 #2
0
  @Override
  public void activate() {
    UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class);
    try {
      currentNode = uiExplorer.getCurrentNode();
      initParams();
    } catch (Exception E) {
      return;
    }

    /** node field */
    UIFormStringInput uiFormNameValueStringInput = new UIFormStringInput(NODE, NODE, nameValue_);
    uiFormNameValueStringInput.setEditable(false);

    /** visible field */
    UIFormCheckBoxInput<Boolean> uiFormVisibleValueCheckBoxInput =
        new UIFormCheckBoxInput<Boolean>(IS_VISIBLE, IS_VISIBLE, false);
    uiFormVisibleValueCheckBoxInput.setChecked(isVisible);

    /** navigation node field */
    UIFormStringInput uiFormNavigationNodeValueStringInput =
        new UIFormStringInput(
            NAVIGATION_NODE_STRING_INPUT, NAVIGATION_NODE_STRING_INPUT, navigationNode_);
    uiFormNavigationNodeValueStringInput.setEditable(false);

    UIFormInputSetWithAction navigationNodeInputSet =
        new UIFormInputSetWithAction(NAVIGATION_NODE_INPUT_SET);
    navigationNodeInputSet.setActionInfo(
        NAVIGATION_NODE_STRING_INPUT,
        new String[] {"SelectNavigationNode", "RemoveNavigationNode"});
    navigationNodeInputSet.addUIFormInput(uiFormNavigationNodeValueStringInput);

    /** index field */
    UIFormStringInput uiFormIndexValueStringInput =
        new UIFormStringInput(INDEX, INDEX, String.valueOf(index_));
    try {
      uiFormIndexValueStringInput.addValidator(NumberFormatValidator.class);
    } catch (Exception E) {
      // TODO : add log
    }

    /** clickable field */
    UIFormCheckBoxInput<Boolean> uiFormClickableValueCheckBoxInput =
        new UIFormCheckBoxInput<Boolean>(IS_CLICKABLE, IS_CLICKABLE, false);
    uiFormClickableValueCheckBoxInput.setChecked(isClickable);

    /** TARGET PAGE */
    UIFormStringInput uiFormTargetPageValueStringInput =
        new UIFormStringInput(
            LIST_TARGET_PAGE_STRING_INPUT, LIST_TARGET_PAGE_STRING_INPUT, listTargetPage_);
    uiFormTargetPageValueStringInput.setEditable(false);

    UIFormInputSetWithAction targetPageInputSet =
        new UIFormInputSetWithAction(LIST_TARGET_PAGE_INPUT_SET);

    targetPageInputSet.setActionInfo(
        LIST_TARGET_PAGE_STRING_INPUT,
        new String[] {"SelectListTargetPage", "RemoveListTargetPage"});
    targetPageInputSet.addUIFormInput(uiFormTargetPageValueStringInput);

    /** DETAIL_TARGET PAGE */
    UIFormStringInput uiFormDetailTargetPageValueStringInput =
        new UIFormStringInput(
            DETAIL_TARGET_PAGE_STRING_INPUT, DETAIL_TARGET_PAGE_STRING_INPUT, detailTargetPage_);
    uiFormDetailTargetPageValueStringInput.setEditable(false);
    UIFormInputSetWithAction detailTargetPageInputSet =
        new UIFormInputSetWithAction(DETAIL_TARGET_PAGE_INPUT_SET);
    detailTargetPageInputSet.setActionInfo(
        DETAIL_TARGET_PAGE_STRING_INPUT,
        new String[] {"SelectDetailTargetPage", "RemoveDetailTargetPage"});
    detailTargetPageInputSet.addUIFormInput(uiFormDetailTargetPageValueStringInput);

    /*
    if (!navigationNode_.equals("")) {
    	uiFormIndexValueStringInput.setEnable(false);
    	uiFormClickableValueRadioBoxInput.setEnable(false);
    }
    */
    addChild(uiFormNameValueStringInput);
    addChild(uiFormVisibleValueCheckBoxInput);
    addChild(navigationNodeInputSet);
    if (renderIndexField) {
      addChild(uiFormIndexValueStringInput);
    }
    addChild(uiFormClickableValueCheckBoxInput);
    addChild(targetPageInputSet);
    addChild(detailTargetPageInputSet);

    setActions(new String[] {"Save", "Cancel"});
  }