Author: julien(a)jboss.com
Date: 2007-05-24 08:54:26 -0400 (Thu, 24 May 2007)
New Revision: 7322
Added:
trunk/common/src/main/org/jboss/portal/common/util/CollectionMap.java
trunk/common/src/main/org/jboss/portal/common/util/ListMap.java
Modified:
trunk/common/src/main/org/jboss/portal/common/util/SetMap.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java
trunk/theme/src/main/org/jboss/portal/test/theme/model/WindowObject.java
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/renderer/WindowRendererContext.java
Log:
JBPORTAL-1463 : Dashboard window moving is inconsistent
Added: trunk/common/src/main/org/jboss/portal/common/util/CollectionMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/CollectionMap.java
(rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/util/CollectionMap.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.util;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * A map of collections.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class CollectionMap implements Serializable
+{
+
+ /** The underlying map. */
+ protected Map map;
+
+ public CollectionMap()
+ {
+ init(null);
+ }
+
+ public CollectionMap(SetMap other) throws IllegalArgumentException
+ {
+ if (other == null)
+ {
+ throw new IllegalArgumentException("Cannot copy null argument");
+ }
+ init(other);
+ }
+
+ /**
+ * Add an object in the set keyed under the specified key.
+ */
+ public void put(Object key, Object o)
+ {
+ Collection collection = (Collection)map.get(key);
+ if (collection == null)
+ {
+ collection = newCollection();
+ map.put(key, collection);
+ }
+ add(collection, o);
+ }
+
+ /**
+ * Return the set of keys.
+ */
+ public Set keySet()
+ {
+ return map.keySet();
+ }
+
+ /**
+ * Remove the entire set of objects specified by the key.
+ */
+ public void remove(Object key)
+ {
+ map.remove(key);
+ }
+
+ /**
+ * Remove an object in the set keyed under the specified key.
+ */
+ public void remove(Object key, Object o)
+ {
+ Collection collection = (Collection)map.get(key);
+ if (collection != null)
+ {
+ remove(collection, o);
+ if (collection.isEmpty())
+ {
+ map.remove(key);
+ }
+ }
+ }
+
+ /**
+ * Return true if the specified set contains the object o.
+ */
+ public boolean contains(Object key, Object o)
+ {
+ Collection collection = (Collection)map.get(key);
+ if (collection == null)
+ {
+ return false;
+ }
+ else
+ {
+ return collection.contains(o);
+ }
+ }
+
+ /**
+ * Return an iterator over the values in the set specified by the key.
+ */
+ public Iterator iterator(final Object key)
+ {
+ Collection set = (Collection)map.get(key);
+ if (set == null)
+ {
+ return Collections.EMPTY_SET.iterator();
+ }
+ else
+ {
+ final Iterator iterator = set.iterator();
+ return new Iterator()
+ {
+ public boolean hasNext()
+ {
+ return iterator.hasNext();
+ }
+ public Object next()
+ {
+ return iterator.next();
+ }
+ public void remove()
+ {
+ iterator.remove();
+ if (!iterator.hasNext())
+ {
+ map.remove(key);
+ }
+ }
+ };
+ }
+ }
+
+ private void init(CollectionMap other)
+ {
+ //
+ this.map = new HashMap();
+
+ //
+ if (other != null)
+ {
+ for (Iterator i = other.map.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ Object key = entry.getKey();
+ Collection value = (Collection)entry.getValue();
+ map.put(key, newCollection(value));
+ }
+ }
+ }
+
+ protected abstract void add(Collection c, Object o);
+
+ protected abstract void remove(Collection c, Object o);
+
+ protected abstract Collection newCollection();
+
+ protected abstract Collection newCollection(Collection other);
+}
Added: trunk/common/src/main/org/jboss/portal/common/util/ListMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/ListMap.java
(rev 0)
+++ trunk/common/src/main/org/jboss/portal/common/util/ListMap.java 2007-05-24 12:54:26
UTC (rev 7322)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.util;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ListMap extends CollectionMap
+{
+
+ /** An optional comparator. */
+ protected Comparator comparator;
+
+ public ListMap()
+ {
+ }
+
+ public ListMap(SetMap other) throws IllegalArgumentException
+ {
+ super(other);
+ }
+
+ public ListMap(SetMap other, Comparator comparator) throws IllegalArgumentException
+ {
+ super(other);
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ public ListMap(Comparator comparator)
+ {
+ super();
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ protected void add(Collection c, Object o)
+ {
+ c.add(o);
+
+ //
+ if (comparator != null)
+ {
+ Collections.sort((List)c, comparator);
+ }
+ }
+
+ protected void remove(Collection c, Object o)
+ {
+ c.remove(o);
+
+ //
+ if (comparator != null)
+ {
+ Collections.sort((List)c, comparator);
+ }
+ }
+
+ protected Collection newCollection()
+ {
+ return new ArrayList();
+ }
+
+ protected Collection newCollection(Collection other)
+ {
+ return new ArrayList(other);
+ }
+}
Modified: trunk/common/src/main/org/jboss/portal/common/util/SetMap.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/SetMap.java 2007-05-24 12:41:21 UTC
(rev 7321)
+++ trunk/common/src/main/org/jboss/portal/common/util/SetMap.java 2007-05-24 12:54:26 UTC
(rev 7322)
@@ -22,16 +22,12 @@
******************************************************************************/
package org.jboss.portal.common.util;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import java.util.Comparator;
import java.util.TreeSet;
import java.util.SortedSet;
-import java.io.Serializable;
+import java.util.Collection;
/**
* A map of set. This object does not handle synchronization and use HashMap and HashSet
@@ -40,122 +36,53 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class SetMap implements Serializable
+public class SetMap extends CollectionMap
{
/** Version. */
static final long serialVersionUID = -7239767000556095977L;
- /** The underlying map. */
- protected Map map;
-
/** An optional comparator. */
protected Comparator comparator;
public SetMap()
{
- init(null, null);
}
public SetMap(SetMap other) throws IllegalArgumentException
{
- if (other == null)
- {
- throw new IllegalArgumentException("Cannot copy null argument");
- }
- init(other, null);
+ super(other);
}
- /**
- * Copy constructor.
- *
- * @throws IllegalArgumentException if the argument is null
- */
public SetMap(SetMap other, Comparator comparator) throws IllegalArgumentException
{
- if (other == null)
- {
- throw new IllegalArgumentException("Cannot copy null argument");
- }
+ super(other);
+
+ //
if (comparator == null)
{
throw new IllegalArgumentException("No null comparator allowed");
}
- init(other, comparator);
+
+ //
+ this.comparator = comparator;
}
public SetMap(Comparator comparator)
{
+ super();
+
+ //
if (comparator == null)
{
throw new IllegalArgumentException("No null comparator allowed");
}
- init(null, comparator);
- }
- /**
- * Add an object in the set keyed under the specified key.
- */
- public void put(Object key, Object o)
- {
- Set set = (Set)map.get(key);
- if (set == null)
- {
- set = newSet();
- map.put(key, set);
- }
- set.add(o);
+ //
+ this.comparator = comparator;
}
/**
- * Return the set of keys.
- */
- public Set keySet()
- {
- return map.keySet();
- }
-
- /**
- * Remove the entire set of objects specified by the key.
- */
- public void remove(Object key)
- {
- map.remove(key);
- }
-
- /**
- * Remove an object in the set keyed under the specified key.
- */
- public void remove(Object key, Object o)
- {
- Set set = (Set)map.get(key);
- if (set != null)
- {
- set.remove(o);
- if (set.isEmpty())
- {
- map.remove(key);
- }
- }
- }
-
- /**
- * Return true if the specified set contains the object o.
- */
- public boolean contains(Object key, Object o)
- {
- Set set = (Set)map.get(key);
- if (set == null)
- {
- return false;
- }
- else
- {
- return set.contains(o);
- }
- }
-
- /**
* Return the set specified by the key.
*/
public Set get(Object key)
@@ -163,61 +90,17 @@
return (Set)map.get(key);
}
- /**
- * Return an iterator over the values in the set specified by the key.
- */
- public Iterator iterator(final Object key)
+ protected void add(Collection c, Object o)
{
- Set set = (Set)map.get(key);
- if (set == null)
- {
- return Collections.EMPTY_SET.iterator();
- }
- else
- {
- final Iterator iterator = set.iterator();
- return new Iterator()
- {
- public boolean hasNext()
- {
- return iterator.hasNext();
- }
- public Object next()
- {
- return iterator.next();
- }
- public void remove()
- {
- iterator.remove();
- if (!iterator.hasNext())
- {
- map.remove(key);
- }
- }
- };
- }
+ c.add(o);
}
- private void init(SetMap other, Comparator comparator)
+ protected void remove(Collection c, Object o)
{
- //
- this.map = new HashMap();
- this.comparator = comparator;
-
- //
- if (other != null)
- {
- for (Iterator i = other.map.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- Object key = entry.getKey();
- Set value = (Set)entry.getValue();
- map.put(key, newSet(value));
- }
- }
+ c.remove(o);
}
- private Set newSet()
+ protected Collection newCollection()
{
if (comparator == null)
{
@@ -229,7 +112,7 @@
}
}
- private Set newSet(Set other)
+ protected Collection newCollection(Collection other)
{
if (comparator == null)
{
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -139,7 +139,7 @@
windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER,
"emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER,
"emptyRenderer");
WindowResult res = new WindowResult("", tabbedNav,
Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
- WindowContext blah = new WindowContext("BLAH",
"navigation", 0, res);
+ WindowContext blah = new WindowContext("BLAH",
"navigation", "0", res);
rendition.getPageResult().addWindowContext(blah);
//
@@ -157,7 +157,7 @@
windowProps.put(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER,
"emptyRenderer");
windowProps.put(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER,
"emptyRenderer");
WindowResult res = new WindowResult("", dashboardNav,
Collections.EMPTY_MAP, windowProps, null, WindowState.NORMAL, Mode.VIEW);
- WindowContext bluh = new WindowContext("BLUH",
"dashboardnav", 0, res);
+ WindowContext bluh = new WindowContext("BLUH",
"dashboardnav", "0", res);
rendition.getPageResult().addWindowContext(bluh);
//
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -301,7 +301,7 @@
WindowContext wc = new WindowContext(
_window.getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT),
_window.getProperty(ThemeConstants.PORTAL_PROP_REGION),
- 0,
+ "0",
windowResult);
//
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/render/RenderPortletInstanceCommand.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -114,7 +114,7 @@
//
WindowResult res = new WindowResult("", content,
Collections.EMPTY_MAP, windowProps, header, WindowState.MAXIMIZED, Mode.VIEW);
- WindowContext blah = new WindowContext("BILTO", "maximized",
0, res);
+ WindowContext blah = new WindowContext("BILTO", "maximized",
"0", res);
result.addWindowContext(blah);
//
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/action/MoveWindowCommand.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -31,8 +31,11 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.ThemeTools;
+import org.jboss.portal.common.util.ListMap;
import java.util.Iterator;
+import java.util.Comparator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -73,72 +76,100 @@
public ControllerResponse execute() throws ControllerException
{
-
- // For now just update the navigational state of the page
-// PageNavigationalState pns =
(PageNavigationalState)getContext().getAttribute(NAVIGATIONAL_STATE_SCOPE, page.getId());
-
- //
-/*
- for (Iterator i = pns.getWindowContexts().iterator(); i.hasNext();)
+ if (isDashboard())
{
- WindowContext windowCtx = (WindowContext)i.next();
- String windowRegion = windowCtx.getRegionName();
- if (targetId.equals(windowCtx.getId()))
+ // First relayout all windows correctly except the target window
+ ListMap blah = new ListMap(tmp);
+ for (Iterator i = page.getChildren(PortalObject.WINDOW_MASK).iterator();
i.hasNext();)
{
- windowCtx.setRegionName(toRegion);
- windowCtx.setOrder(toPos);
+ Window window = (Window)i.next();
+ if (window != target)
+ {
+ String region =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
+ if (region != null)
+ {
+ blah.put(region, window);
+ }
+ }
}
- else if (fromRegion.equals(windowRegion) && fromPos <
windowCtx.getOrder())
+
+ //
+ for (Iterator i = blah.keySet().iterator();i.hasNext();)
{
- windowCtx.setOrder(windowCtx.getOrder() - 1);
- }
- else if (toRegion.equals(windowRegion) && toPos <=
windowCtx.getOrder())
- {
- windowCtx.setOrder(windowCtx.getOrder() + 1);
- }
- }
-*/
+ String key = (String)i.next();
- //
- if (isDashboard())
- {
- for (Iterator i = page.getChildren().iterator(); i.hasNext();)
- {
- PortalObject child = (PortalObject)i.next();
- if (child.getType() == PortalObject.TYPE_WINDOW)
+ //
+ boolean processFrom = key.equals(fromRegion);
+ boolean processTo = key.equals(toRegion);
+
+ //
+ if (!processFrom && !processTo)
{
- Window window = (Window)child;
- PortalObjectId windowId = window.getId();
- String regionId =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
- String posAsString =
window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
- if (regionId != null && posAsString != null)
+ int order = 0;
+ for (Iterator j = blah.iterator(key);j.hasNext();)
{
- try
+ Window window = (Window)j.next();
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(order++));
+ }
+ }
+ else
+ {
+ if (processFrom)
+ {
+ int order = 0;
+ for (Iterator j = blah.iterator(key);j.hasNext();)
{
- int pos = Integer.parseInt(posAsString);
- if (targetId.equals(windowId))
+ Window window = (Window)j.next();
+
+ //
+ if (window == target)
{
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION,
toRegion);
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(toPos));
+ order --;
}
- else if (fromRegion.equals(regionId) && fromPos < pos)
+ else
{
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(toPos - 1));
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(order++));
}
- else if (toRegion.equals(regionId) && toPos <= pos)
+ }
+ }
+ if (processTo)
+ {
+ int order = 0;
+ for (Iterator j = blah.iterator(key);j.hasNext();)
+ {
+ Window window = (Window)j.next();
+
+ //
+ if (order == toPos)
{
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(toPos + 1));
+ order++;
}
+
+ //
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(order++));
}
- catch (NumberFormatException e)
- {
- }
}
}
}
+
+ //
+ target.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
+ target.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER,
Integer.toString(toPos));
}
//
return null;
}
+
+ private static final Comparator tmp = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ Window window1 = (Window)o1;
+ Window window2 = (Window)o2;
+ String order1 = window1.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
+ String order2 = window2.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
+ return ThemeTools.compareWindowOrder(order1, window1.getName(), order2,
window2.getName());
+ }
+ };
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -218,7 +218,7 @@
WindowContext wc = new WindowContext(
window.getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT),
region,
- Integer.parseInt(order),
+ order,
result);
pageResult.addWindowContext(wc);
}
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java 2007-05-24
12:41:21 UTC (rev 7321)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/DynaTestContext.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -336,7 +336,7 @@
"",
wrc.getWindowState(),
wrc.getMode());
- WindowContext wc = new WindowContext(wrc.getId(), rrc.getId(), j.getIndex(),
wr);
+ WindowContext wc = new WindowContext(wrc.getId(), rrc.getId(),
Integer.toString(j.getIndex()), wr);
result.addWindowContext(wc);
}
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/model/WindowObject.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/model/WindowObject.java 2007-05-24
12:41:21 UTC (rev 7321)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/model/WindowObject.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.test.theme.model;
-import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
@@ -109,13 +108,13 @@
return id;
}
- public int getOrder()
+ public String getOrder()
{
for (IteratorStatus i = new
IteratorStatus(region.windows.values().iterator());i.hasNext();)
{
if (this == i.next())
{
- return i.getIndex();
+ return Integer.toString(i.getIndex());
}
}
throw new IllegalStateException("Should not happen");
Modified:
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/theme/src/main/org/jboss/portal/test/theme/tmp/render/TestRenderedMarkup.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -148,7 +148,7 @@
String title = "WindowA_" + i + " Title";
String content = "<p>WindowA_" + i + "
Content</p>";
- WindowContext wCtx = new WindowContext("WindowA_" + i,
"left", i, createWindowMarkup(title, content));
+ WindowContext wCtx = new WindowContext("WindowA_" + i,
"left", "" + i, createWindowMarkup(title, content));
pageResult.addWindowContext(wCtx);
markupResult = createWindowMarkup(title, content);
@@ -161,7 +161,7 @@
String title = "WindowB_" + i + " Title";
String content = "<p>WindowB_" + i + "
Content</p>";
- WindowContext wCtx = new WindowContext("WindowB_" + i,
"center", i, createWindowMarkup(title, content));
+ WindowContext wCtx = new WindowContext("WindowB_" + i,
"center", "" + i, createWindowMarkup(title, content));
pageResult.addWindowContext(wCtx);
markupResult = createWindowMarkup(title, content);
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-05-24 12:41:21
UTC (rev 7321)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/JSPLayout.java 2007-05-24 12:54:26
UTC (rev 7322)
@@ -133,7 +133,7 @@
//
pageResult.setLayoutState("maximized");
wc.setRegionName("maximized");
- wc.setOrder(0);
+ wc.setOrder("0");
// Yes it is ugly
pageResult.rebuild();
Modified:
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -31,8 +31,6 @@
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
/**
* Implementation of a Region renderer that creates no markup, and only passes control to
the Portlet renderer of the
@@ -61,18 +59,8 @@
/** @see RegionRenderer#renderBody */
public void renderBody(RendererContext rendererContext, RegionRendererContext rrc)
throws RenderException
{
- Map orderedItems = new TreeMap();
-
- //
for (Iterator i = rrc.getWindows().iterator(); i.hasNext();)
{
- WindowRendererContext window = (WindowRendererContext)i.next();
- orderedItems.put(new Integer(window.getOrder()), window);
- }
-
- //
- for (Iterator i = orderedItems.values().iterator(); i.hasNext();)
- {
WindowRendererContext wrc = (WindowRendererContext)i.next();
rendererContext.render(wrc);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-05-24 12:41:21
UTC (rev 7321)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-05-24 12:54:26
UTC (rev 7322)
@@ -31,7 +31,6 @@
import java.util.Set;
import java.util.Collection;
import java.util.Iterator;
-import java.util.Collections;
/**
* Interface to represent the read only information of a rendered portal page.
<p>The page result allows access to all
@@ -168,23 +167,6 @@
region.addWindowContext(windowContext);
}
- public WindowContext addWindow(String regionName, String windowId, String windowName,
WindowResult window)
- {
- int order = 0;
-
- //
- Region region = getRegion2(regionName);
- if (region != null)
- {
- order = region.getWindows().size();
- }
-
- //
- WindowContext windowCtx = new WindowContext(windowId, regionName, order, window);
- addWindowContext(windowCtx);
- return windowCtx;
- }
-
// PageRenderContext implementation
*********************************************************************************
public String getProperty(String name)
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-05-24 12:41:21 UTC
(rev 7321)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-05-24 12:54:26 UTC
(rev 7322)
@@ -25,12 +25,12 @@
import org.jboss.portal.theme.render.renderer.RegionRendererContext;
import org.jboss.portal.theme.Orientation;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
/**
* A region on a page. <p>A region wraps one or more portlets to allow them to act
as one unit inside the layout of a
@@ -49,12 +49,9 @@
private final PageResult page;
/** . */
- private boolean sorted;
+ final List windows;
/** . */
- final ArrayList windows;
-
- /** . */
private Map properties;
/**
@@ -68,7 +65,6 @@
this.page = page;
this.name = name;
this.windows = new ArrayList();
- this.sorted = false;
this.properties = new HashMap();
}
@@ -80,7 +76,7 @@
/** @return if there are any portlet windows in this region */
public boolean isEmpty()
{
- return windows == null || windows.isEmpty();
+ return windows.isEmpty();
}
/**
@@ -90,8 +86,8 @@
*/
void addWindowContext(WindowContext windowContext)
{
- sorted = false;
windows.add(windowContext);
+ Collections.sort(windows);
}
public String toString()
@@ -118,15 +114,10 @@
public Collection getWindows()
{
- if (windows == null)
+ if (windows.isEmpty())
{
return Collections.EMPTY_LIST;
}
- if (!sorted)
- {
- Collections.sort(windows);
- sorted = true;
- }
return Collections.unmodifiableList(windows);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-05-24
12:41:21 UTC (rev 7321)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -25,6 +25,7 @@
import org.jboss.portal.theme.render.renderer.WindowRendererContext;
import org.jboss.portal.theme.render.renderer.DecorationRendererContext;
import org.jboss.portal.theme.render.renderer.PortletRendererContext;
+import org.jboss.portal.theme.ThemeTools;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
@@ -61,12 +62,12 @@
private String regionName;
/** . */
- private int order;
+ private String order;
/** . */
final WindowResult result;
- public WindowContext(String id, String regionName, int order, WindowResult result)
+ public WindowContext(String id, String regionName, String order, WindowResult result)
{
this.id = id;
this.regionName = regionName;
@@ -79,7 +80,7 @@
return id;
}
- public int getOrder()
+ public String getOrder()
{
return order;
}
@@ -124,7 +125,7 @@
this.regionName = regionName;
}
- public void setOrder(int order)
+ public void setOrder(String order)
{
this.order = order;
}
@@ -136,7 +137,8 @@
public int compareTo(Object o)
{
- return order - ((WindowContext)o).order;
+ WindowContext that = (WindowContext)o;
+ return ThemeTools.compareWindowOrder(this.order, this.id, that.order, that.id);
}
public boolean equals(Object o)
Modified:
trunk/theme/src/main/org/jboss/portal/theme/render/renderer/WindowRendererContext.java
===================================================================
---
trunk/theme/src/main/org/jboss/portal/theme/render/renderer/WindowRendererContext.java 2007-05-24
12:41:21 UTC (rev 7321)
+++
trunk/theme/src/main/org/jboss/portal/theme/render/renderer/WindowRendererContext.java 2007-05-24
12:54:26 UTC (rev 7322)
@@ -35,7 +35,7 @@
String getId();
- int getOrder();
+ String getOrder();
WindowState getWindowState();