Example #1
0
 public void execute(Event<UIGroupMembershipSelector> event) throws Exception {
   UIPageForm uiForm = event.getSource().getAncestorOfType(UIPageForm.class);
   /*if (!uiForm.getUIStringInput(OWNER_TYPE).getValue().equals(PortalConfig.GROUP_TYPE))
      return;
   String editPer = uiForm.findFirstComponentOfType(UIPermissionSelector.class).getValue();
   if (editPer == null || editPer.length() < 1)
      return;
   String group = editPer.substring(editPer.indexOf("/") + 1);
   uiForm.ownerIdInput.setValue(group);*/
   event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
 }
Example #2
0
 public void execute(Event<UIPageForm> event) throws Exception {
   UIPageForm uiForm = event.getSource();
   String groupIdSelected = uiForm.groupIdSelectBox.getValue();
   groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
   String permission = "*:" + groupIdSelected;
   uiForm
       .findFirstComponentOfType(UIListPermissionSelector.class)
       .setValue(new String[] {permission});
   UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
   permission = userACL.getMakableMT() + ":" + groupIdSelected;
   uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
 }
Example #3
0
 public void execute(Event<UIPageForm> event) throws Exception {
   UIPageForm uiForm = event.getSource();
   UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE);
   String ownerType = uiSelectBox.getValue();
   PortalRequestContext prContext = Util.getPortalRequestContext();
   UIFormInputSet uiSettingSet = uiForm.getChildById("PageSetting");
   uiForm.setSelectedTab("PageSetting");
   List<UIComponent> list = uiSettingSet.getChildren();
   if (PortalConfig.USER_TYPE.equals(ownerType)) {
     uiForm.removeChildById("PermissionSetting");
     list.remove(2);
     list.add(2, uiForm.ownerIdInput);
     uiForm.ownerIdInput.setValue(prContext.getRemoteUser());
   } else {
     if (uiForm.getChildById("PermissionSetting") == null) {
       uiForm.addUIComponentInput(uiForm.uiPermissionSetting);
     }
     if (PortalConfig.PORTAL_TYPE.equals(ownerType)) {
       list.remove(2);
       list.add(2, uiForm.ownerIdInput);
       uiForm.ownerIdInput.setValue(prContext.getPortalOwner());
       uiForm
           .findFirstComponentOfType(UIListPermissionSelector.class)
           .setValue(Util.getUIPortal().getAccessPermissions());
       uiForm
           .findFirstComponentOfType(UIPermissionSelector.class)
           .setValue(Util.getUIPortal().getEditPermission());
     } else {
       list.remove(2);
       list.add(2, uiForm.groupIdSelectBox);
       String groupIdSelected = uiForm.groupIdSelectBox.getValue();
       groupIdSelected =
           groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
       String permission = "*:" + groupIdSelected;
       uiForm
           .findFirstComponentOfType(UIListPermissionSelector.class)
           .setValue(new String[] {permission});
       UserACL userACL = uiForm.getApplicationComponent(UserACL.class);
       permission = userACL.getMakableMT() + ":" + groupIdSelected;
       uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
     }
   }
   prContext.addUIComponentToUpdateByAjax(uiForm.getParent());
 }
Example #4
0
    public void execute(Event<UIPageForm> event) throws Exception {
      UIPageForm uiPageForm = event.getSource();
      UIPortalApplication uiPortalApp = uiPageForm.getAncestorOfType(UIPortalApplication.class);
      PortalRequestContext pcontext = Util.getPortalRequestContext();
      UIMaskWorkspace uiMaskWS = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
      uiMaskWS.setUIComponent(null);
      uiMaskWS.setShow(false);
      pcontext.addUIComponentToUpdateByAjax(uiMaskWS);

      UIPage uiPage = uiPageForm.getUIPage();
      if (uiPage == null) return;
      String storageId = uiPage.getStorageId();
      Page page = new Page();
      page.setPageId(uiPage.getPageId());
      uiPageForm.invokeSetBindingBean(page);
      page.setOwnerType(uiPage.getOwnerType());
      List<UIPortlet> uiPortlets = new ArrayList<UIPortlet>();
      findAllPortlet(uiPortlets, uiPage);
      ArrayList<ModelObject> applications = new ArrayList<ModelObject>();
      for (UIPortlet uiPortlet : uiPortlets) {
        applications.add(PortalDataMapper.buildModelObject(uiPortlet));
      }

      if (Page.DESKTOP_PAGE.equals(uiPage.getFactoryId())
          && !Page.DESKTOP_PAGE.equals(page.getFactoryId())) {
        page.setShowMaxWindow(false);
        uiPage.getChildren().clear();
        page.setChildren(applications);

        PortalDataMapper.toUIPage(uiPage, page);
        //        if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
        if (page.getChildren() == null) page.setChildren(new ArrayList<ModelObject>());

        //        uiEditBar.setUIPage(uiPage);
        //        Class<?> [] childrenToRender = {UIPageEditBar.class,
        //            UIPageNodeSelector.class, UIPageNavigationControlBar.class};
        //        uiManagement.setRenderedChildrenOfTypes(childrenToRender);

        pcontext.setFullRender(true);
        UIWorkingWorkspace uiWorkingWS =
            uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
        pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);

        return;
      }

      if (Page.DESKTOP_PAGE.equals(page.getFactoryId())) {
        uiPage.getChildren().clear();
        page.setChildren(applications);

        PortalDataMapper.toUIPage(uiPage, page);
        //        if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
        if (page.getChildren() == null) page.setChildren(new ArrayList<ModelObject>());

        UIPortalToolPanel toolPanel = Util.getUIPortalToolPanel();
        toolPanel.setShowMaskLayer(true);
        pcontext.setFullRender(true);
        UIWorkingWorkspace uiWorkingWS =
            uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
        pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
        DataStorage dataService = uiPageForm.getApplicationComponent(DataStorage.class);
        dataService.save(page);
        return;
      }

      List<UIComponent> uiChildren = uiPage.getChildren();
      if (uiChildren == null) {
        PortalDataMapper.toUIPage(uiPage, page);
        return;
      }
      ArrayList<ModelObject> children = new ArrayList<ModelObject>();
      for (UIComponent child : uiChildren) {
        ModelObject component = PortalDataMapper.buildModelObject(child);
        if (component != null) children.add(component);
      }
      page.setChildren(children);
      uiPage.getChildren().clear();

      try {
        PortalDataMapper.toUIPage(uiPage, page);
      } catch (NoSuchDataException de) {
        uiPortalApp.addMessage(
            new ApplicationMessage(
                "UIPageForm.msg.notExistOrDeleted", null, ApplicationMessage.ERROR));
        UIPortalComposer uiPortalComposer =
            (UIPortalComposer) uiPortalApp.findComponentById("UIPageEditor");
        if (uiPortalComposer != null) {
          Event aboutEvent =
              new Event<UIPortalComposer>(uiPortalComposer, "Abort", event.getRequestContext());
          uiPortalComposer.broadcast(aboutEvent, event.getExecutionPhase());
        }
      }

      uiPage.setStorageId(storageId);
      //      if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
      if (page.getChildren() == null) page.setChildren(new ArrayList<ModelObject>());
    }