コード例 #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
ファイル: UIAddNewApplication.java プロジェクト: haint/webos
  /**
   * 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);
  }