Ejemplo n.º 1
0
 public static Page toPageModel(UIPage uiPage) {
   Page model = new Page(uiPage.getStorageId());
   toContainer(model, uiPage);
   model.setOwnerId(uiPage.getSiteKey().getName());
   model.setOwnerType(uiPage.getSiteKey().getTypeName());
   model.setIcon(uiPage.getIcon());
   model.setPageId(uiPage.getPageId());
   model.setTitle(uiPage.getTitle());
   model.setAccessPermissions(uiPage.getAccessPermissions());
   model.setEditPermission(uiPage.getEditPermission());
   model.setFactoryId(uiPage.getFactoryId());
   model.setShowMaxWindow(uiPage.isShowMaxWindow());
   model.setModifiable(uiPage.isModifiable());
   return model;
 }
    public void execute(Event<UIPortlet> event) throws Exception {
      UIPortlet uiPortlet = event.getSource();

      UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
      UIWorkingWorkspace uiWorkingWS =
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
      pcontext.ignoreAJAXUpdateOnPortlets(true);

      String windowState = null;

      Object changeWindowStateAttribute =
          event.getRequestContext().getAttribute(CHANGE_WINDOW_STATE_EVENT);
      if (changeWindowStateAttribute != null && changeWindowStateAttribute instanceof String) {
        windowState = (String) changeWindowStateAttribute;
      }

      if (windowState == null) {
        windowState = event.getRequestContext().getRequestParameter(Constants.PORTAL_WINDOW_STATE);
      }
      if (windowState == null) {
        windowState = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID).trim();
      }

      if (windowState == null) {
        windowState = uiPortlet.getCurrentWindowState().toString();
      }

      UIPageBody uiPageBody = uiPortlet.getAncestorOfType(UIPageBody.class);
      UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
      if (windowState.equals(WindowState.MAXIMIZED.toString())) {
        if (uiPageBody != null) {
          uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
          // TODO dang.tung: we have to set maximized portlet for page because in ShowMaxWindow case
          // the PageBody isn't rendered
          //                reference: UIPortalLifecycle, UIPageLifecycle, renderChildren() in
          // UIPageBody
          // ---------------------------------------------------------
          if (uiPage != null && uiPage.isShowMaxWindow()) {
            uiPage.setMaximizedUIPortlet(uiPortlet);
          }
          // ---------------------------------------------------------
          uiPageBody.setMaximizedUIComponent(uiPortlet);
        } else {
          uiPortlet.setCurrentWindowState(WindowState.NORMAL);
        }
        return;
      }
      if (uiPageBody != null) {
        UIPortlet maxPortlet = (UIPortlet) uiPageBody.getMaximizedUIComponent();
        if (maxPortlet == uiPortlet) {
          uiPageBody.setMaximizedUIComponent(null);
        }
      }
      // TODO dang.tung: for ShowMaxWindow situation
      // ----------------------------------------------------------------
      if (uiPage != null) {
        UIPortlet maxPortlet = (UIPortlet) uiPage.getMaximizedUIPortlet();
        if (maxPortlet == uiPortlet) {
          uiPage.setMaximizedUIPortlet(null);
        }
      }
      // -----------------------------------------------------------------
      if (windowState.equals(WindowState.MINIMIZED.toString())) {
        uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
        return;
      }
      uiPortlet.setCurrentWindowState(WindowState.NORMAL);
    }