Author: thomas.heute(a)jboss.com
Date: 2007-10-23 06:22:43 -0400 (Tue, 23 Oct 2007)
New Revision: 8748
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
Log:
JBPORTAL-1619: Multiple maximized windows
By navigating, it's somehow possible to have multiple windows maximized, now there is
a constraint so that when a window is maximized any other window in maximize state is put
to Normal
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2007-10-23
08:35:47 UTC (rev 8747)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2007-10-23
10:22:43 UTC (rev 8748)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.navstate;
+import org.jboss.logging.Logger;
+import org.jboss.portal.WindowState;
import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
@@ -37,7 +39,9 @@
*/
public class PortalObjectNavigationalStateContext implements NavigationalStateContext
{
-
+ /** .*/
+ private Logger logger = Logger.getLogger(PortalObjectNavigationalStateContext.class);
+
/** . */
private static final String VIEW_ID_KEY = "view_id";
@@ -177,12 +181,48 @@
{
if (changes != null && changes.size() > 0)
{
+ Object maximizedKey = null;
for (Iterator i = changes.values().iterator();i.hasNext();)
{
NavigationalStateObjectChange change =
(NavigationalStateObjectChange)i.next();
+ if (change.getNewValue() instanceof WindowNavigationalState)
+ {
+ WindowNavigationalState wns =
(WindowNavigationalState)change.getNewValue();
+ if (wns.getWindowState().equals(WindowState.MAXIMIZED))
+ {
+ if (maximizedKey != null)
+ {
+ // Should never happen, 2 windows shouldn't be maximized at
once
+ logger.error("Two windows are maximized at once, it should not
be possible");
+ }
+ maximizedKey = change.getKey();
+ }
+ }
store.setAttribute(change.getKey(), change.getNewValue());
}
+ // Unmaximize other windows if necessary
+ if (maximizedKey != null)
+ {
+ Set keys = store.getKeys();
+ Iterator it = keys.iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ Object object = store.getAttribute(key);
+ if (object instanceof WindowNavigationalState)
+ {
+ WindowNavigationalState wns = (WindowNavigationalState) object;
+ if (!key.equals(maximizedKey) &&
wns.getWindowState().equals(WindowState.MAXIMIZED))
+ {
+ WindowNavigationalState wns2 = new
WindowNavigationalState(WindowState.NORMAL, wns.getMode(), wns
+ .getContentState());
+ store.setAttribute(key, wns2);
+ }
+ }
+ }
+ }
+
//
changes.clear();
Show replies by date