Ejemplo n.º 1
0
  public void invokeSetBindingBean(Object bean) throws Exception {
    String ownerType = getUIFormSelectBox("ownerType").getValue();
    String ownerId = getUIStringInput("ownerId").getValue();

    // As ownerId is now normalized, we have to maker sure that owenerId of 'group' type starts with
    // a '/'
    if (PortalConfig.GROUP_TYPE.equals(ownerType) && ownerId.charAt(0) != '/') {
      ownerId = "/" + ownerId;
    }

    Page page = (Page) bean;
    page.setPageId(getUIStringInput("pageId").getValue());
    page.setOwnerType(ownerType);
    page.setOwnerId(ownerId);
    page.setName(getUIStringInput("name").getValue());
    String title = getUIStringInput("title").getValue();
    if (title == null || title.trim().length() < 1) title = page.getName();
    page.setTitle(title);

    if (!page.isShowMaxWindow()) {
      page.setShowMaxWindow((Boolean) getUIFormCheckBoxInput("showMaxWindow").getValue());
    }
    if (!PortalConfig.USER_TYPE.equals(page.getOwnerType())) {
      page.setAccessPermissions(
          uiPermissionSetting.getChild(UIListPermissionSelector.class).getValue());
      page.setEditPermission(uiPermissionSetting.getChild(UIPermissionSelector.class).getValue());
    }
    UserACL userACL = getApplicationComponent(UserACL.class);
    userACL.hasPermission(page);

    UIFormInputItemSelector uiTemplate = getChildById("Template");
    if (uiTemplate != null) {
      SelectItemOption<?> itemOption = uiTemplate.getSelectedItemOption();
      if (itemOption != null) {
        page.setFactoryId(itemOption.getIcon());
        //        page.setTemplate((String)itemOption.getValue());
        if (page.getFactoryId().equals(Page.DESKTOP_PAGE)) page.setShowMaxWindow(true);
      }
    }
    UIPageTemplateOptions uiConfigOptions = getChild(UIPageTemplateOptions.class);
    if (uiConfigOptions == null) return;
    Page selectedPage =
        uiConfigOptions.createPageFromSelectedOption(page.getOwnerType(), page.getOwnerId());
    if (selectedPage == null) return;
    page.setChildren(selectedPage.getChildren());
    page.setFactoryId(selectedPage.getFactoryId());
    if (Page.DESKTOP_PAGE.equals(page.getFactoryId())) page.setShowMaxWindow(true);
  }
Ejemplo n.º 2
0
  /**
   * Add Application to UiPage
   *
   * @param event
   * @throws Exception
   */
  private static void addApplicationToPage(Event<UIAddNewApplication> event, boolean atStartup)
      throws Exception {
    UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
    UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
    PortalRequestContext pcontext = Util.getPortalRequestContext();

    UIDesktopPage uiDesktopPage = uiPortal.findFirstComponentOfType(UIDesktopPage.class);
    if (uiDesktopPage == null) {
      pcontext.addUIComponentToUpdateByAjax(
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID));
      UIMaskWorkspace maskWorkspace = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
      maskWorkspace.createEvent("Close", Event.Phase.DECODE, event.getRequestContext()).broadcast();
      pcontext.setFullRender(true);
      return;
    }

    String applicationId = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);

    Application application = event.getSource().getApplication(applicationId);
    ApplicationType appType = application.getType();

    UIPortlet uiPortlet = uiDesktopPage.createUIComponent(UIPortlet.class, null, null);
    ApplicationState appState;

    // TODO: Check if there 's already a portlet window of this portlet. A CloneApplicationState
    // should be created in such case
    appState = new TransientApplicationState<Object>(application.getContentId());

    uiPortlet.setState(new PortletState(appState, appType));
    uiPortlet.setPortletInPortal(false);

    if (atStartup) {
      uiPortlet.getProperties().setProperty("appStatus", "HIDE");
    }

    String portletName = application.getApplicationName();
    String displayName = application.getDisplayName();
    if (displayName != null) {
      uiPortlet.setTitle(displayName);
    } else if (portletName != null) {
      uiPortlet.setTitle(portletName);
    }
    uiPortlet.setDescription(application.getDescription());
    List<String> accessPers = application.getAccessPermissions();
    String[] accessPermissions = accessPers.toArray(new String[accessPers.size()]);
    uiPortlet.setAccessPermissions(accessPermissions);

    // Add portlet to page
    uiDesktopPage.addChild(uiPortlet);

    if (uiDesktopPage.isModifiable()) {
      Page page = (Page) PortalDataMapper.buildModelObject(uiDesktopPage);
      if (page.getChildren() == null) {
        page.setChildren(new ArrayList<ModelObject>());
      }
      DataStorage dataService = uiPortalApp.getApplicationComponent(DataStorage.class);
      dataService.save(page);

      // Rebuild the uiPage to synchronize (storageId, storageName) mapping
      page = dataService.getPage(page.getPageId());
      page.setModifiable(true);
      uiDesktopPage.getChildren().clear();
      PortalDataMapper.toUIPage(uiDesktopPage, page);
    }

    UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
    pcontext.setFullRender(true);
    pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
  }
Ejemplo n.º 3
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>());
    }