public void execute(Event<UIPortlet> event) throws Exception { UIPortlet uiPortlet = event.getSource(); String portletMode = null; Object changePortletModeAttribute = event.getRequestContext().getAttribute(CHANGE_PORTLET_MODE_EVENT); if (changePortletModeAttribute != null && changePortletModeAttribute instanceof String) { portletMode = (String) changePortletModeAttribute; } if (portletMode == null) { portletMode = event.getRequestContext().getRequestParameter(Constants.PORTAL_PORTLET_MODE); } if (portletMode == null) { portletMode = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID); } if (portletMode == null) { portletMode = uiPortlet.getCurrentPortletMode().toString(); } log.trace( "Change portlet mode of " + uiPortlet.getPortletContext().getId() + " to " + portletMode); if (portletMode.equals(PortletMode.HELP.toString())) { uiPortlet.setCurrentPortletMode(PortletMode.HELP); } else if (portletMode.equals(PortletMode.EDIT.toString())) { uiPortlet.setCurrentPortletMode(PortletMode.EDIT); } else if (portletMode.equals(PortletMode.VIEW.toString())) { uiPortlet.setCurrentPortletMode(PortletMode.VIEW); } else { PortletMode customMode = new PortletMode(portletMode); uiPortlet.setCurrentPortletMode(customMode); } event.getRequestContext().addUIComponentToUpdateByAjax(uiPortlet); }
/** * This method is used to set the next portlet mode if this one needs to be modified because of * the incoming request */ public static void setNextMode(UIPortlet uiPortlet, PortletMode portletMode) { if (portletMode != null) { if (portletMode.equals(PortletMode.HELP)) { uiPortlet.setCurrentPortletMode(PortletMode.HELP); } else if (portletMode.equals(PortletMode.EDIT)) { uiPortlet.setCurrentPortletMode(PortletMode.EDIT); } else { uiPortlet.setCurrentPortletMode(PortletMode.VIEW); } } }
public void setValues(final UIPortlet uiPortlet) throws Exception { uiPortlet_ = uiPortlet; invokeGetBindingBean(uiPortlet_); String icon = uiPortlet.getIcon(); if (icon == null || icon.length() < 0) { icon = "PortletIcon"; } getChild(UIFormInputIconSelector.class).setSelectedIcon(icon); getChild(UIFormInputThemeSelector.class) .getChild(UIItemThemeSelector.class) .setSelectedTheme(uiPortlet.getSuitedTheme(null)); if (hasEditMode()) { uiPortlet.setCurrentPortletMode(PortletMode.EDIT); } else { Map<String, String> portletPreferenceMaps = new HashMap<String, String>(); org.gatein.pc.api.Portlet portlet = uiPortlet.getProducedOfferedPortlet(); Set<String> keySet = portlet.getInfo().getPreferences().getKeys(); for (String key : keySet) { PreferenceInfo preferenceInfo = portlet.getInfo().getPreferences().getPreference(key); if (!preferenceInfo.isReadOnly()) { String ppValue = (preferenceInfo.getDefaultValue().size() > 0) ? preferenceInfo.getDefaultValue().get(0) : ""; portletPreferenceMaps.put(key, ppValue); } } Portlet pp = uiPortlet.getPreferences(); if (pp != null) { for (Preference pref : pp) { if (!pref.isReadOnly()) { portletPreferenceMaps.put( pref.getName(), (pref.getValues().size() > 0) ? pref.getValues().get(0) : ""); } } } if (portletPreferenceMaps.size() > 0) { Set<String> ppKeySet = portletPreferenceMaps.keySet(); UIFormInputSet uiPortletPrefSet = getChildById(FIELD_PORTLET_PREF); uiPortletPrefSet.getChildren().clear(); for (String ppKey : ppKeySet) { String ppValue = portletPreferenceMaps.get(ppKey); UIFormStringInput preferenceStringInput = new UIFormStringInput(ppKey, null, ppValue); preferenceStringInput.setLabel(ppKey); preferenceStringInput.addValidator(MandatoryValidator.class); uiPortletPrefSet.addUIFormInput(preferenceStringInput); } uiPortletPrefSet.setRendered(true); setSelectedTab(FIELD_PORTLET_PREF); return; } setSelectedTab("PortletSetting"); } }
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); }
public void execute(final Event<UIPortletForm> event) throws Exception { UIPortletForm uiPortletForm = event.getSource(); UIPortlet uiPortlet = uiPortletForm.getUIPortlet(); if (uiPortletForm.hasEditMode()) { uiPortlet.setCurrentPortletMode(PortletMode.VIEW); } UIPortalApplication uiPortalApp = Util.getUIPortalApplication(); PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext(); // add by Pham Dinh Tan UIMaskWorkspace uiMaskWorkspace = uiPortalApp.getChildById(UIPortalApplication.UI_MASK_WS_ID); uiMaskWorkspace.broadcast(event, Phase.DECODE); pcontext.ignoreAJAXUpdateOnPortlets(true); }