Author: julien(a)jboss.com
Date: 2008-06-26 20:39:53 -0400 (Thu, 26 Jun 2008)
New Revision: 11165
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerWindowStateInfo.java
Log:
add support for custom window state runtime info
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java 2008-06-27
00:18:38 UTC (rev 11164)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java 2008-06-27
00:39:53 UTC (rev 11165)
@@ -96,9 +96,14 @@
public void add(String contentType, WindowState windowState)
{
+ add(contentType, new ContainerWindowStateInfo(windowState));
+ }
+
+ public void add(String contentType, ContainerWindowStateInfo windowState)
+ {
try
{
- supportedWindowStates.put(contentType, new
ContainerWindowStateInfo(windowState));
+ supportedWindowStates.put(contentType, windowState);
}
catch (IllegalArgumentException e)
{
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-06-27
00:18:38 UTC (rev 11164)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-06-27
00:39:53 UTC (rev 11165)
@@ -37,6 +37,7 @@
import org.jboss.portal.portlet.impl.metadata.PublicRenderParameterMetaData;
import org.jboss.portal.portlet.impl.metadata.UserAttributeMetaData;
import org.jboss.portal.portlet.impl.metadata.CustomPortletModeMetaData;
+import org.jboss.portal.portlet.impl.metadata.CustomWindowStateMetaData;
import org.jboss.portal.portlet.impl.metadata.common.ContainerRuntimeMetaData;
import org.jboss.portal.portlet.impl.metadata.common.InitParamMetaData;
import org.jboss.portal.portlet.impl.metadata.event.EventDefinitionMetaData;
@@ -140,6 +141,9 @@
private static final Map<String, CustomPortletModeMetaData>
EMPTY_CUSTOM_PORTLET_MODES = Collections.emptyMap();
/** . */
+ private static final Map<String, CustomWindowStateMetaData>
EMPTY_CUSTOM_WINDOW_STATES = Collections.emptyMap();
+
+ /** . */
private final PortletApplication10MetaData portletApplicationMD;
/** . */
@@ -167,6 +171,9 @@
private final Map<Mode, ContainerModeInfo> customModes;
/** . */
+ private final Map<WindowState, ContainerWindowStateInfo> customWindowStates;
+
+ /** . */
private final Logger log = Logger.getLogger(ContainerInfoBuilder.class);
public ContainerInfoBuilder(
@@ -182,6 +189,7 @@
this.portlets = new LinkedHashMap<String, ContainerPortletInfo>();
this.applicationOptions = new HashMap<String, ContainerOptionInfo>();
this.customModes = new HashMap<Mode, ContainerModeInfo>();
+ this.customWindowStates = new HashMap<WindowState,
ContainerWindowStateInfo>();
}
public ContainerPortletApplicationInfo getApplication()
@@ -248,6 +256,10 @@
{
portletApplicationMD.setCustomPortletModes(EMPTY_CUSTOM_PORTLET_MODES);
}
+ if (portletApplicationMD.getCustomWindowStates() == null)
+ {
+ portletApplicationMD.setCustomWindowStates(EMPTY_CUSTOM_WINDOW_STATES);
+ }
}
private void fixMetaData(PortletMetaData portletMD)
@@ -423,63 +435,86 @@
ContainerFilterInfo filter = build(filterMD);
allFilters.put(filter.getName(), filter);
}
+ }
- // Build custom mode infos for reuse in portlet info
- for (CustomPortletModeMetaData customPortletModeMD :
portletApplicationMD.getCustomPortletModes().values())
+ //
+ Map<String, UserAttributeMetaData> userAttributesMD =
portletApplicationMD.getUserAttributes();
+ Set<String> supportedUserAttributes;
+ if (userAttributesMD != null)
+ {
+ supportedUserAttributes =
Collections.unmodifiableSet(userAttributesMD.keySet());
+ }
+ else
+ {
+ supportedUserAttributes = Collections.emptySet();
+ }
+ ContainerUserInfo user = new ContainerUserInfo(supportedUserAttributes);
+
+ // Build custom mode infos for reuse in portlet info
+ for (CustomPortletModeMetaData customPortletModeMD :
portletApplicationMD.getCustomPortletModes().values())
+ {
+ Mode mode = Mode.create(customPortletModeMD.getPortletMode());
+
+ //
+ LocalizedString description = customPortletModeMD.getDescription();
+
+ //
+ ContainerModeInfo modeInfo;
+ if (customPortletModeMD.isPortalManaged())
{
- Mode mode = Mode.create(customPortletModeMD.getPortletMode());
+ if (description != null)
+ {
+ modeInfo = new ContainerModeInfo(mode, description);
+ }
+ else
+ {
+ modeInfo = new ContainerModeInfo(mode);
+ }
+ }
+ else
+ {
+ ResourceBundleManager bundleMgr = context.getBundleManager();
//
- LocalizedString description = customPortletModeMD.getDescription();
+ LocalizedString displayName =
bundleMgr.getLocalizedValue("javax.portlet.app.custom-portlet-mode." + mode +
".decoration-name", "" + mode);
//
- ContainerModeInfo modeInfo;
- if (customPortletModeMD.isPortalManaged())
+ if (description != null)
{
- if (description != null)
- {
- modeInfo = new ContainerModeInfo(mode, description);
- }
- else
- {
- modeInfo = new ContainerModeInfo(mode);
- }
+ modeInfo = new ContainerPortletManagedModeInfo(mode, description,
displayName);
}
else
{
- ResourceBundleManager bundleMgr = context.getBundleManager();
+ modeInfo = new ContainerPortletManagedModeInfo(mode, displayName);
+ }
+ }
- //
- LocalizedString displayName =
bundleMgr.getLocalizedValue("javax.portlet.app.custom-portlet-mode." + mode +
".decoration-name", "" + mode);
+ //
+ customModes.put(mode, modeInfo);
+ }
- //
- if (description != null)
- {
- modeInfo = new ContainerPortletManagedModeInfo(mode, description,
displayName);
- }
- else
- {
- modeInfo = new ContainerPortletManagedModeInfo(mode, displayName);
- }
- }
+ // Build custom window state infos for reuse in portlet info
+ for (CustomWindowStateMetaData customPortletModeMD :
portletApplicationMD.getCustomWindowStates().values())
+ {
+ WindowState windowState =
WindowState.create(customPortletModeMD.getWindowState());
- //
- customModes.put(mode, modeInfo);
+ //
+ LocalizedString description = customPortletModeMD.getDescription();
+
+ //
+ ContainerWindowStateInfo windowStateInfo;
+ if (description != null)
+ {
+ windowStateInfo = new ContainerWindowStateInfo(windowState, description);
}
- }
+ else
+ {
+ windowStateInfo = new ContainerWindowStateInfo(windowState);
+ }
- //
- Map<String, UserAttributeMetaData> userAttributesMD =
portletApplicationMD.getUserAttributes();
- Set<String> supportedUserAttributes;
- if (userAttributesMD != null)
- {
- supportedUserAttributes =
Collections.unmodifiableSet(userAttributesMD.keySet());
+ //
+ customWindowStates.put(windowState, windowStateInfo);
}
- else
- {
- supportedUserAttributes = Collections.emptySet();
- }
- ContainerUserInfo user = new ContainerUserInfo(supportedUserAttributes);
//
return new ContainerPortletApplicationInfo(
@@ -860,16 +895,26 @@
}
}
- //
+ // then process window states
+ for (WindowStateMetaData windowStateMD : supportsMD.getWindowStates())
+ {
+ ContainerWindowStateInfo windowStateInfo =
customWindowStates.get(windowStateMD.getWindowState());
+
+ //
+ if (windowStateInfo != null)
+ {
+ capabilities.add(mimeType, windowStateInfo);
+ }
+ else
+ {
+ capabilities.add(mimeType, windowStateMD.getWindowState());
+ }
+ }
+
+ // Override those as also now they must be supported
capabilities.add(mimeType, WindowState.NORMAL);
capabilities.add(mimeType, WindowState.MINIMIZED);
capabilities.add(mimeType, WindowState.MAXIMIZED);
-
- // Then process each window state
- for (WindowStateMetaData windowStateMD : supportsMD.getWindowStates())
- {
- capabilities.add(mimeType, windowStateMD.getWindowState());
- }
}
//
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java 2008-06-27
00:18:38 UTC (rev 11164)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java 2008-06-27
00:39:53 UTC (rev 11165)
@@ -52,6 +52,10 @@
{
throw new IllegalArgumentException("Specified mode cannot be null!");
}
+ if (description == null)
+ {
+ throw new IllegalArgumentException("Specified description cannot be
null!");
+ }
//
this.mode = mode;
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerWindowStateInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerWindowStateInfo.java 2008-06-27
00:18:38 UTC (rev 11164)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerWindowStateInfo.java 2008-06-27
00:39:53 UTC (rev 11165)
@@ -43,6 +43,30 @@
/** . */
private final WindowState windowState;
+ /** . */
+ private final LocalizedString description;
+
+ public ContainerWindowStateInfo(WindowState windowState, LocalizedString description)
+ {
+ if (windowState == null)
+ {
+ throw new IllegalArgumentException("Specified window state cannot be
null!");
+ }
+ if (description == null)
+ {
+ throw new IllegalArgumentException("Specified description cannot be
null!");
+ }
+
+ //
+ this.windowState = windowState;
+ this.description = description;
+ }
+
+ public ContainerWindowStateInfo(WindowState windowState)
+ {
+ this(windowState, DEFAULT_DESCRIPTION);
+ }
+
public boolean equals(Object o)
{
if (this == o)
@@ -65,18 +89,9 @@
return windowState.hashCode();
}
- public ContainerWindowStateInfo(WindowState windowState)
- {
- if (windowState == null)
- {
- throw new IllegalArgumentException("Specified window state cannot be
null!");
- }
- this.windowState = windowState;
- }
-
public LocalizedString getDescription()
{
- return DEFAULT_DESCRIPTION; //fix-me
+ return description;
}
public WindowState getWindowState()