Author: julien(a)jboss.com
Date: 2007-04-03 08:48:01 -0400 (Tue, 03 Apr 2007)
New Revision: 6908
Removed:
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
Log:
simplified the navigational state change objects in order to compact create/update/destroy
into a single object. remove unused listener interface def for now as it uses a batch
delivery mechanism.
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -41,8 +41,8 @@
import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.ns.NavigationalStateChange;
-import org.jboss.portal.core.ns.NavigationalStateObjectUpdated;
import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.core.ns.NavigationalStateObjectChange;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.page.WindowResult;
@@ -247,54 +247,53 @@
{
NavigationalStateChange change = (NavigationalStateChange)i.next();
- //
- if (change instanceof NavigationalStateObjectUpdated)
+ // A change that modifies potentially the page structure
+ if (!(change instanceof NavigationalStateObjectChange))
{
- NavigationalStateObjectUpdated update =
(NavigationalStateObjectUpdated)change;
+ refresh = true;
+ break;
+ }
+ NavigationalStateObjectChange update =
(NavigationalStateObjectChange)change;
- // Get the state key
- NavigationalStateKey key = update.getKey();
+ // A change that modifies potentially the page structure
+ if (update.getType() != NavigationalStateObjectChange.UPDATE)
+ {
+ refresh = true;
+ break;
+ }
- // We consider only portal object types
- if (key.getType() == WindowNavigationalState.class)
- {
- // Get old window state
- WindowNavigationalState oldNS =
(WindowNavigationalState)update.getOldValue();
- WindowState oldWindowState = oldNS != null ? oldNS.getWindowState() :
null;
+ // Get the state key
+ NavigationalStateKey key = update.getKey();
- // Get new window state
- WindowNavigationalState newNS =
(WindowNavigationalState)update.getNewValue();
- WindowState newWindowState = newNS != null ? newNS.getWindowState() :
null;
+ // We consider only portal object types
+ if (key.getType() == WindowNavigationalState.class)
+ {
+ // Get old window state
+ WindowNavigationalState oldNS =
(WindowNavigationalState)update.getOldValue();
+ WindowState oldWindowState = oldNS != null ? oldNS.getWindowState() :
null;
- // Check if window state requires a refresh
- if (WindowState.MAXIMIZED.equals(oldWindowState))
- {
- if (!WindowState.MAXIMIZED.equals(newWindowState))
- {
- refresh = true;
- }
- }
- else if (WindowState.MAXIMIZED.equals(newWindowState))
- {
- refresh = true;
- }
+ // Get new window state
+ WindowNavigationalState newNS =
(WindowNavigationalState)update.getNewValue();
+ WindowState newWindowState = newNS != null ? newNS.getWindowState() :
null;
- //
- if (refresh)
+ // Check if window state requires a refresh
+ if (WindowState.MAXIMIZED.equals(oldWindowState))
+ {
+ if (!WindowState.MAXIMIZED.equals(newWindowState))
{
+ refresh = true;
break;
}
-
- // Collect the dirty window id
- dirtyWindowIds.add(key.getId());
}
+ else if (WindowState.MAXIMIZED.equals(newWindowState))
+ {
+ refresh = true;
+ break;
+ }
+
+ // Collect the dirty window id
+ dirtyWindowIds.add(key.getId());
}
- else
- {
- // A change that modifies potentially the page structure
- refresh = true;
- break;
- }
}
// Commit changes
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -25,9 +25,6 @@
import org.jboss.portal.core.ns.NavigationalStateContext;
import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.core.ns.NavigationalStateObjectChange;
-import org.jboss.portal.core.ns.NavigationalStateObjectCreated;
-import org.jboss.portal.core.ns.NavigationalStateObjectUpdated;
-import org.jboss.portal.core.ns.NavigationalStateObjectDestroyed;
import org.jboss.portal.common.invocation.AttributeResolver;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
@@ -86,20 +83,14 @@
if (changes != null)
{
NavigationalStateObjectChange change =
(NavigationalStateObjectChange)changes.get(nsKey);
- if (change instanceof NavigationalStateObjectCreated)
+ switch(change.getType())
{
- NavigationalStateObjectCreated created =
(NavigationalStateObjectCreated)change;
- return created.getValue();
+ case NavigationalStateObjectChange.CREATE:
+ case NavigationalStateObjectChange.UPDATE:
+ return change.getNewValue();
+ case NavigationalStateObjectChange.DESTROY:
+ return null;
}
- else if (change instanceof NavigationalStateObjectUpdated)
- {
- NavigationalStateObjectUpdated updated =
(NavigationalStateObjectUpdated)change;
- return updated.getNewValue();
- }
- else if (change instanceof NavigationalStateObjectDestroyed)
- {
- return null;
- }
}
//
@@ -151,18 +142,12 @@
changes.remove(effectiveKey);
//
- if (change instanceof NavigationalStateObjectCreated)
+ switch(change.getType())
{
- NavigationalStateObjectCreated created =
(NavigationalStateObjectCreated)change;
- oldNS = (WindowNavigationalState)created.getValue();
+ case NavigationalStateObjectChange.CREATE:
+ case NavigationalStateObjectChange.UPDATE:
+ oldNS = (WindowNavigationalState)change.getOldValue();
}
- else if (change instanceof NavigationalStateObjectUpdated)
- {
- NavigationalStateObjectUpdated updated =
(NavigationalStateObjectUpdated)change;
- oldNS = (WindowNavigationalState)updated.getNewValue();
- }
-
- //
}
}
@@ -178,7 +163,7 @@
{
if (oldNS != null)
{
- change = new NavigationalStateObjectDestroyed(effectiveKey, oldNS);
+ change = NavigationalStateObjectChange.newDestroy(effectiveKey, oldNS);
}
else
{
@@ -228,11 +213,11 @@
//
if (oldNS != null)
{
- change = new NavigationalStateObjectUpdated(effectiveKey, oldNS, newNS);
+ change = NavigationalStateObjectChange.newUpdate(effectiveKey, oldNS,
newNS);
}
else
{
- change = new NavigationalStateObjectCreated(effectiveKey, newNS);
+ change = NavigationalStateObjectChange.newCreate(effectiveKey, newNS);
}
}
@@ -266,21 +251,7 @@
for (Iterator i = changes.values().iterator();i.hasNext();)
{
NavigationalStateObjectChange change =
(NavigationalStateObjectChange)i.next();
- if (change instanceof NavigationalStateObjectCreated)
- {
- NavigationalStateObjectCreated created =
(NavigationalStateObjectCreated)change;
- store.setAttribute(created.getKey(), created.getValue());
- }
- else if (change instanceof NavigationalStateObjectUpdated)
- {
- NavigationalStateObjectUpdated updated =
(NavigationalStateObjectUpdated)change;
- store.setAttribute(updated.getKey(), updated.getNewValue());
- }
- else
- {
- NavigationalStateObjectDestroyed destroyed =
(NavigationalStateObjectDestroyed)change;
- store.setAttribute(destroyed.getKey(), null);
- }
+ store.setAttribute(change.getKey(), change.getNewValue());
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java 2007-04-03
12:27:57 UTC (rev 6907)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -23,9 +23,11 @@
package org.jboss.portal.core.ns;
/**
+ * Base navigational state change.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class NavigationalStateChange
+public abstract class NavigationalStateChange
{
}
Deleted:
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -1,31 +0,0 @@
-/******************************************************************************
- * 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.core.ns;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface NavigationalStateChangeListener
-{
-}
Modified: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -23,6 +23,10 @@
package org.jboss.portal.core.ns;
/**
+ * The change of the navigational state of a single object. If both old and new values
are not null, it denotes
+ * an update. Whenever the old value is null, a creation occured and conversely if the
new value is null, a
+ * destruction occured.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -30,16 +34,82 @@
{
/** . */
+ public static final int UPDATE = 0;
+
+ /** . */
+ public static final int CREATE = 1;
+
+ /** . */
+ public static final int DESTROY = 2;
+
+ /** . */
+ private final Object oldValue;
+
+ /** . */
+ private final Object newValue;
+
+ /** . */
private NavigationalStateKey key;
- public NavigationalStateObjectChange(NavigationalStateKey key)
+ private NavigationalStateObjectChange(NavigationalStateKey key, Object oldValue,
Object newValue)
{
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No key provided");
+ }
this.key = key;
+ this.oldValue = oldValue;
+ this.newValue = newValue;
}
+ public int getType()
+ {
+ return oldValue == null ? CREATE : (newValue == null ? DESTROY : UPDATE);
+ }
+
public NavigationalStateKey getKey()
{
return key;
}
+ public Object getOldValue()
+ {
+ return oldValue;
+ }
+
+ public Object getNewValue()
+ {
+ return newValue;
+ }
+
+ public static NavigationalStateObjectChange newUpdate(NavigationalStateKey key, Object
oldValue, Object newValue)
+ {
+ if (oldValue == null)
+ {
+ throw new IllegalArgumentException("No old value provided");
+ }
+ if (newValue == null)
+ {
+ throw new IllegalArgumentException("No new value provided");
+ }
+ return new NavigationalStateObjectChange(key, oldValue, newValue);
+ }
+
+ public static NavigationalStateObjectChange newCreate(NavigationalStateKey key, Object
newValue)
+ {
+ if (newValue == null)
+ {
+ throw new IllegalArgumentException("No new value provided");
+ }
+ return new NavigationalStateObjectChange(key, null, newValue);
+ }
+
+ public static NavigationalStateObjectChange newDestroy(NavigationalStateKey key,
Object oldValue)
+ {
+ if (oldValue == null)
+ {
+ throw new IllegalArgumentException("No old value provided");
+ }
+ return new NavigationalStateObjectChange(key, oldValue, null);
+ }
}
Deleted: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -1,45 +0,0 @@
-/******************************************************************************
- * 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.core.ns;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class NavigationalStateObjectCreated extends NavigationalStateObjectChange
-{
-
- /** . */
- private final Object value;
-
- public NavigationalStateObjectCreated(NavigationalStateKey key, Object value)
- {
- super(key);
- this.value = value;
- }
-
- public Object getValue()
- {
- return value;
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -1,45 +0,0 @@
-/******************************************************************************
- * 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.core.ns;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class NavigationalStateObjectDestroyed extends NavigationalStateObjectChange
-{
-
- /** . */
- private final Object value;
-
- public NavigationalStateObjectDestroyed(NavigationalStateKey key, Object value)
- {
- super(key);
- this.value = value;
- }
-
- public Object getValue()
- {
- return value;
- }
-}
Deleted: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java 2007-04-03
12:27:57 UTC (rev 6907)
+++
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java 2007-04-03
12:48:01 UTC (rev 6908)
@@ -1,54 +0,0 @@
-/******************************************************************************
- * 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.core.ns;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class NavigationalStateObjectUpdated extends NavigationalStateObjectChange
-{
-
- /** . */
- private final Object oldValue;
-
- /** . */
- private final Object newValue;
-
- public NavigationalStateObjectUpdated(NavigationalStateKey key, Object oldValue,
Object newValue)
- {
- super(key);
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
-
- public Object getOldValue()
- {
- return oldValue;
- }
-
- public Object getNewValue()
- {
- return newValue;
- }
-}