JBoss Portal SVN: r9198 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state: structural and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-29 09:09:26 -0500 (Thu, 29 Nov 2007)
New Revision: 9198
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralState.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java
Log:
minor javadoc
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java 2007-11-29 13:53:02 UTC (rev 9197)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java 2007-11-29 14:09:26 UTC (rev 9198)
@@ -23,6 +23,10 @@
package org.jboss.portal.presentation.model.state;
/**
+ * A change in the state of the model. The change is the association of a target id and a modification.
+ * The target id refers to an object in the structural state context and the modification is a modification
+ * of its state. Note that the modification could also modify the state of other objects.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
@@ -51,11 +55,21 @@
this.modification = modification;
}
+ /**
+ * Returns the target id of the change.
+ *
+ * @return the target id
+ */
public String getTargetId()
{
return targetId;
}
+ /**
+ * Returns the modification operated on the target id.
+ *
+ * @return the modification
+ */
public M getModification()
{
return modification;
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java 2007-11-29 13:53:02 UTC (rev 9197)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java 2007-11-29 14:09:26 UTC (rev 9198)
@@ -25,6 +25,8 @@
import org.jboss.portal.presentation.model.ModelEvent;
/**
+ * Signals a state change occured.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
@@ -45,6 +47,11 @@
this.change = change;
}
+ /**
+ * Returns the state change that occured.
+ *
+ * @return the state change
+ */
public StateChange getChange()
{
return change;
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java 2007-11-29 13:53:02 UTC (rev 9197)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java 2007-11-29 14:09:26 UTC (rev 9198)
@@ -23,6 +23,8 @@
package org.jboss.portal.presentation.model.state;
/**
+ * An abstract class for the modification of state.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralState.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralState.java 2007-11-29 13:53:02 UTC (rev 9197)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralState.java 2007-11-29 14:09:26 UTC (rev 9198)
@@ -29,6 +29,8 @@
import java.util.List;
/**
+ * The structural state.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2007-11-29 13:53:02 UTC (rev 9197)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2007-11-29 14:09:26 UTC (rev 9198)
@@ -99,11 +99,7 @@
void move(String objectId, String parentId) throws StateChangeVetoException, StateException, IllegalArgumentException;
/**
- * Update the state of a specified object. The <code>Map</code> values are interpreted as follow:
- * <ul>
- * <li>Each non null value will replace an existing value of create a new one</li>
- * <li>Each null value will destroy an existing value</li>
- * </ul>
+ * Update the state of a specified object.
*
* @param objectId the id of the object to udpate
* @param changes the changes
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java 2007-11-29 13:53:02 UTC (rev 9197)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java 2007-11-29 14:09:26 UTC (rev 9198)
@@ -27,6 +27,8 @@
import java.util.Map;
/**
+ * Specification of state modification for structural state.
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
@@ -37,6 +39,13 @@
{
}
+ /**
+ * Update the properties portion of the state. The <code>Map</code> values are interpreted as follow:
+ * <ul>
+ * <li>Each non null value will replace an existing value of create a new one</li>
+ * <li>Each null value will destroy an existing value</li>
+ * </ul>
+ */
public final static class SetProperties extends StructuralStateModification
{
@@ -54,6 +63,10 @@
this.changes = changes;
}
+ /**
+ *
+ * @return
+ */
public Map<String, String> getChanges()
{
return changes;
18 years, 5 months
JBoss Portal SVN: r9197 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: impl/model/state/navigational and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-29 08:53:02 -0500 (Thu, 29 Nov 2007)
New Revision: 9197
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateModification.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
Log:
implement navigational state change eventing
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:35:09 UTC (rev 9196)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -27,6 +27,7 @@
import org.jboss.portal.presentation.model.state.StateChange;
import org.jboss.portal.presentation.model.state.StateChangeEvent;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.navigational.NavigationalStateModification;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
@@ -157,20 +158,33 @@
switch (scopeType)
{
case NAVIGATIONAL:
- context.navigationalStateContext.set(id, propertyName, propertyValue);
+ {
+ NavigationalStateModification mod = new NavigationalStateModification(propertyName, propertyValue);
+ StateChange<NavigationalStateModification> change = new StateChange<NavigationalStateModification>(id, mod);
+
+ // Have context process the change
+ context.navigationalStateContext.update(change);
+
+ // Broadcast event
+ StateChangeEvent event = new StateChangeEvent(change);
+ context.fireEvent(event);
break;
+ }
case STRUCTURAL:
+ {
if (propertyValue instanceof String)
{
Map<String, String> changes = new HashMap<String, String>();
changes.put(propertyName, (String)propertyValue);
- // Have loader process state
+ // Create change
StructuralStateModification mod = new StructuralStateModification.SetProperties(changes);
StateChange<StructuralStateModification> change = new StateChange<StructuralStateModification>(id, mod);
+
+ // Have context process change
context.structuralStateContext.update(change);
- // Update state locally
+ // Update state locally to reflect correct state
Map<String, String> updatedProperties = new HashMap<String, String>(state.getProperties());
updateProperty(updatedProperties, propertyName, (String)propertyValue);
state = new StructuralState(state.getType(), state.getName(), updatedProperties, state.getParentId(), state.getChildrenIds());
@@ -184,6 +198,7 @@
throw new StateChangeVetoException("Structural property value must be string value");
}
break;
+ }
default:
throw new AssertionError();
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java 2007-11-29 13:35:09 UTC (rev 9196)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/navigational/NavigationalStateContextImpl.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -23,11 +23,14 @@
package org.jboss.portal.presentation.impl.model.state.navigational;
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.model.state.navigational.NavigationalStateModification;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.StateException;
+import org.jboss.portal.presentation.model.state.StateChange;
import java.util.Map;
import java.util.HashMap;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,9 +52,33 @@
this(new HashMap<Key, Object>());
}
+ public void update(List<StateChange<NavigationalStateModification>> changes)
+ {
+ for (StateChange<NavigationalStateModification> change : changes)
+ {
+ update(change);
+ }
+ }
+
+ public void update(StateChange<NavigationalStateModification> change)
+ {
+ Key key = new Key(change.getTargetId(), change.getModification().getKey());
+ Object navigationalState = change.getModification().getNavigationalState();
+
+ //
+ if (navigationalState != null)
+ {
+ map.put(key, navigationalState);
+ }
+ else
+ {
+ map.remove(key);
+ }
+ }
+
public void set(String objectId, String key, Object navigationalState) throws StateChangeVetoException, StateException, IllegalArgumentException
{
- map.put(new Key(objectId, key), navigationalState);
+ update(new StateChange<NavigationalStateModification>(objectId, new NavigationalStateModification(key, navigationalState)));
}
public Object get(String objectId, String key) throws IllegalArgumentException
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java 2007-11-29 13:35:09 UTC (rev 9196)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateContext.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -24,7 +24,10 @@
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.StateException;
+import org.jboss.portal.presentation.model.state.StateChange;
+import java.util.List;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
@@ -34,4 +37,8 @@
Object get(String objectId, String key) throws IllegalArgumentException;
void set(String objectId, String key, Object navigationalState) throws StateChangeVetoException, StateException, IllegalArgumentException;
+
+ void update(List<StateChange<NavigationalStateModification>> modifications);
+
+ void update(StateChange<NavigationalStateModification> modification);
}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateModification.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateModification.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/navigational/NavigationalStateModification.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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.presentation.model.state.navigational;
+
+import org.jboss.portal.presentation.model.state.StateModification;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public final class NavigationalStateModification extends StateModification
+{
+
+ /** . */
+ private final String key;
+
+ /** . */
+ private final Object navigationalState;
+
+ public NavigationalStateModification(String key, Object navigationalState)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.key = key;
+ this.navigationalState = navigationalState;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public Object getNavigationalState()
+ {
+ return navigationalState;
+ }
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java 2007-11-29 13:35:09 UTC (rev 9196)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -33,9 +33,13 @@
public abstract class StructuralStateModification extends StateModification
{
- public static class SetProperties extends StructuralStateModification
+ protected StructuralStateModification()
{
+ }
+ public final static class SetProperties extends StructuralStateModification
+ {
+
/** . */
private final Map<String, String> changes;
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java 2007-11-29 13:35:09 UTC (rev 9196)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -25,13 +25,13 @@
import junit.framework.Assert;
import org.jboss.portal.presentation.model.ModelEvent;
import org.jboss.portal.presentation.model.ModelListener;
+import org.jboss.portal.presentation.model.state.StateChange;
+import org.jboss.portal.presentation.model.state.StateChangeEvent;
+import org.jboss.portal.presentation.model.state.navigational.NavigationalStateModification;
import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
-import org.jboss.portal.presentation.model.state.StateChangeEvent;
-import org.jboss.portal.presentation.model.state.StateChange;
import java.util.ArrayList;
import java.util.List;
-import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -69,6 +69,16 @@
Assert.assertEquals(sp.getChanges(), mod.getChanges());
}
+ public void next(String targetId, NavigationalStateModification ns)
+ {
+ StateChangeEvent ste = next(StateChangeEvent.class);
+ StateChange change = ste.getChange();
+ Assert.assertEquals(targetId, change.getTargetId());
+ NavigationalStateModification mod = (NavigationalStateModification)change.getModification();
+ Assert.assertEquals(ns.getKey(), mod.getKey());
+ Assert.assertEquals(ns.getNavigationalState(), mod.getNavigationalState());
+ }
+
public void assertEmpty()
{
Assert.assertEquals(events.size(), index);
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29 13:35:09 UTC (rev 9196)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29 13:53:02 UTC (rev 9197)
@@ -440,6 +440,8 @@
{
MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
UIContext context = createContext();
+ EventAssert eventAssert = new EventAssert();
+ context.addModelListener(eventAssert);
// Check initial state
UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
18 years, 5 months
JBoss Portal SVN: r9196 - in branches/presentation/presentation/src/main/org/jboss/portal/presentation: model and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-29 08:35:09 -0500 (Thu, 29 Nov 2007)
New Revision: 9196
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java
Log:
- not a necessity to expose the structural state context in the UIContext interface as it is something used by the model only
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29 13:35:09 UTC (rev 9196)
@@ -150,14 +150,6 @@
/**
*
- */
- public StructuralStateContext getModelLoader()
- {
- return this.structuralStateContext;
- }
-
- /**
- *
* @param <T>
* @param type
* @return
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:35:09 UTC (rev 9196)
@@ -168,7 +168,7 @@
// Have loader process state
StructuralStateModification mod = new StructuralStateModification.SetProperties(changes);
StateChange<StructuralStateModification> change = new StateChange<StructuralStateModification>(id, mod);
- context.getModelLoader().update(change);
+ context.structuralStateContext.update(change);
// Update state locally
Map<String, String> updatedProperties = new HashMap<String, String>(state.getProperties());
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java 2007-11-29 13:30:41 UTC (rev 9195)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java 2007-11-29 13:35:09 UTC (rev 9196)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.model;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -36,12 +34,6 @@
* @return the object for the specified id or null if it cannot be found
*/
UIObject getObject(String id);
-
- /**
- *
- * @return the model loader
- */
- StructuralStateContext getModelLoader();
/**
*
18 years, 5 months
JBoss Portal SVN: r9195 - in branches/presentation: presentation/src/main/org/jboss/portal/presentation/client/controller and 8 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-29 08:30:41 -0500 (Thu, 29 Nov 2007)
New Revision: 9195
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java
Log:
- don't consider content as a state scope type of the model as it is something that can be regenerated and is up to the client nature to manage it
Modified: branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java
===================================================================
--- branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -26,7 +26,7 @@
import org.jboss.portal.presentation.server.Processor;
import org.jboss.portal.presentation.server.PresentationServer;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
+import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -24,11 +24,10 @@
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.impl.PresentationContextImpl;
-import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
+import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.protocol.GetActivation;
import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.presentation.protocol.ServerAction;
@@ -62,16 +61,11 @@
*/
public class UIController implements RequestController
{
- /**
- *
- */
+
+ /** . */
private PresentationServer presentationServer = null;
- /**
- *
- *
- */
public UIController()
{
}
@@ -80,7 +74,6 @@
/**
* handle is the entry point for handling an incoming Portal request. The request is handed over
* from the Http Layer via the main Portal Servlet
- *
*/
public void handle(ServerInvocation invocation) throws ServerException
{
@@ -131,34 +124,10 @@
//Load the objects in the UITree
UIObject uiObject = presentationContext.getUIContext().getObject(targetId);
-
+
if(uiObject instanceof UIPage)
{
- UIPage page = (UIPage)uiObject;
- //Populate the state of the Windows in the Page that is being displayed
- //inside the UITree
- List<UIObject> windows = page.getChildren();
- if(windows != null)
- {
- for(int i=0; i<windows.size(); i++)
- {
- UIObject cour = windows.get(i);
-
- if(cour instanceof UIWindow)
- {
- UIWindow window = (UIWindow)cour;
- WindowContent windowContent = this.presentationServer.render(presentationContext, window);
-
- /**
- * TODO: decouple this from the model implementation by moving the functinality
- * to another component like a UIPresenter etc
- */
- ((org.jboss.portal.presentation.impl.model.UIWindowImpl)window).
- setContent(windowContent);
- }
- }
- }
- this.render(response.getWriter(), presentationContext.getUIContext(), targetId);
+ render(response.getWriter(), presentationContext, targetId);
}
}
}
@@ -358,10 +327,10 @@
* TODO: this should be used only in classic UI case...eventually when Controller is abstracted, this will be moved to
* the ClassicController implementation
*/
- private void render(PrintWriter clientConnection, UIContext uiContext, String targetId)
+ private void render(PrintWriter clientConnection, PresentationContext presentationContext, String targetId)
{
StringBuffer responseBuffer = new StringBuffer();
- UIObject uiObject = (UIObject)uiContext.getObject(targetId);
+ UIObject uiObject = presentationContext.getUIContext().getObject(targetId);
//Display the page to the client
if(uiObject instanceof UIPage)
@@ -373,14 +342,20 @@
UIObject cour = windows.get(i);
if(cour instanceof UIWindow)
{
- org.jboss.portal.presentation.impl.model.UIWindowImpl window = (org.jboss.portal.presentation.impl.model.UIWindowImpl)cour;
- if(window.getContent() != null)
+ UIWindow window = (UIWindow)cour;
+
+ try
{
+ WindowContent windowContent = this.presentationServer.render(presentationContext, window);
responseBuffer.append("<div>");
- responseBuffer.append("<div id=\"title\">"+window.getContent().getTitle()+"</div>");
- responseBuffer.append("<div id=\"content\">"+window.getContent().getMarkup()+"</div>");
+ responseBuffer.append("<div id=\"title\">").append(windowContent.getTitle()).append("</div>");
+ responseBuffer.append("<div id=\"content\">").append(windowContent.getMarkup()).append("</div>");
responseBuffer.append("</div><br/><br/>");
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
}
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -24,11 +24,9 @@
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
-import org.jboss.portal.presentation.impl.model.state.content.ContentStateContextImpl;
import org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.state.content.ContentStateContext;
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.protocol.LinkActivation;
import org.jboss.portal.presentation.protocol.ServerAction;
@@ -82,15 +80,7 @@
}
//
- ContentStateContext csc = (ContentStateContext)session.getAttribute("csc");
- if (csc == null)
- {
- csc = new ContentStateContextImpl();
- session.setAttribute("csc", csc);
- }
-
- //
- root = new UIContextImpl(presentationServer.getStructuralStateManager(), nsc, csc);
+ root = new UIContextImpl(presentationServer.getStructuralStateManager(), nsc);
}
//
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -30,7 +30,6 @@
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIPortal;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.ContentStateContext;
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
@@ -57,9 +56,6 @@
protected final NavigationalStateContext navigationalStateContext;
/** . */
- protected final ContentStateContext contentStateContext;
-
- /** . */
protected final List<ModelListener> listeners;
private static String getRootId(StructuralStateContext loader)
@@ -74,15 +70,13 @@
public UIContextImpl(
StructuralStateContext structuralStateContext,
- NavigationalStateContext navigationalStateContext,
- ContentStateContext contentStateContext)
+ NavigationalStateContext navigationalStateContext)
{
super(getRootId(structuralStateContext), getRootState(structuralStateContext));
//
this.structuralStateContext = structuralStateContext;
this.navigationalStateContext = navigationalStateContext;
- this.contentStateContext = contentStateContext;
this.listeners = new ArrayList<ModelListener>();
// Put our self in the object cache
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -127,9 +127,6 @@
Object value;
switch (scopeType)
{
- case CONTENT:
- value = context.contentStateContext.get(id, propertyName);
- break;
case NAVIGATIONAL:
value = context.navigationalStateContext.get(id, propertyName);
break;
@@ -159,9 +156,6 @@
}
switch (scopeType)
{
- case CONTENT:
- context.contentStateContext.set(id, propertyName, propertyValue);
- break;
case NAVIGATIONAL:
context.navigationalStateContext.set(id, propertyName, propertyValue);
break;
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -27,7 +27,6 @@
import org.jboss.portal.presentation.model.StateScopeType;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
/**
@@ -42,16 +41,6 @@
super(context, id, state);
}
- public WindowContent getContent()
- {
- return getProperty(StateScopeType.CONTENT, "content", WindowContent.class);
- }
-
- public void setContent(WindowContent windowContent)
- {
- setProperty(StateScopeType.CONTENT, "content", windowContent);
- }
-
/**
*
*/
@@ -74,7 +63,6 @@
public void setMode(Mode mode)
{
setProperty(StateScopeType.NAVIGATIONAL, "mode", mode);
- setProperty(StateScopeType.CONTENT, "content", null);
}
/**
@@ -83,7 +71,6 @@
public void setWindowState(WindowState windowState)
{
setProperty(StateScopeType.NAVIGATIONAL, "windowstate", windowState);
- setProperty(StateScopeType.CONTENT, "content", null);
}
public Object getContentState()
@@ -94,7 +81,6 @@
public void setContentState(Object contentState)
{
setProperty(StateScopeType.NAVIGATIONAL, "content", contentState);
- setProperty(StateScopeType.CONTENT, "content", null);
}
/**
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -29,12 +29,6 @@
public enum StateScopeType
{
/**
- * The content scope type. The content scope defines state which can be stored in the model for convenience but can
- * always be computed again.
- */
- CONTENT,
-
- /**
* The navigational scope type. The navigational scope describe the a kind of change done at runtime by the user when it
* interacts with the model (i.e not all interactions with the model are automatically navigational state changes).
*/
Copied: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java (from rev 9129, branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/WindowContent.java)
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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.presentation.model.content;
+
+/**
+ * The content of a window.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowContent
+{
+
+ /** . */
+ private final long expirationMillis;
+
+ /** . */
+ private final String title;
+
+ /** . */
+ private final String markup;
+
+
+ public WindowContent(long expirationMillis, String title, String markup)
+ {
+ this.expirationMillis = expirationMillis;
+ this.title = title;
+ this.markup = markup;
+ }
+
+ public long getExpirationMillis()
+ {
+ return expirationMillis;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public String getMarkup()
+ {
+ return markup;
+ }
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -24,7 +24,7 @@
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
+import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
/**
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -26,7 +26,6 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
-import org.jboss.portal.presentation.impl.model.state.content.ContentStateContextImpl;
import org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.StateScopeType;
import org.jboss.portal.presentation.model.UIContext;
@@ -34,8 +33,6 @@
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIPortal;
import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import org.jboss.portal.presentation.model.state.StateChange;
-import org.jboss.portal.presentation.model.state.StateChangeEvent;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
@@ -172,7 +169,7 @@
private UIContext createContext()
{
- return new UIContextImpl(model.getStructuralStateContext(), new NavigationalStateContextImpl(), new ContentStateContextImpl());
+ return new UIContextImpl(model.getStructuralStateContext(), new NavigationalStateContextImpl());
}
public void testGetPropertyThrowsIAE()
@@ -273,11 +270,6 @@
assertEquals(StateScopeType.NAVIGATIONAL, propertyName, propertyValue, propertyClass);
}
- <T> void assertContentEquals(String propertyName, T propertyValue, Class<T> propertyClass)
- {
- assertEquals(StateScopeType.CONTENT, propertyName, propertyValue, propertyClass);
- }
-
<T> void assertEquals(StateScopeType scopeType, String propertyName, T propertyValue, Class<T> propertyClass)
{
Assert.assertEquals(propertyValue, object.getProperty(scopeType, propertyName, propertyClass));
@@ -444,25 +436,6 @@
eventAssert.assertEmpty();
}
- public void testUpdateContentProperty()
- {
- MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
- UIContext context = createContext();
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertContentEquals("foo", null, String.class);
-
- // Update content state
- foo.setProperty(StateScopeType.CONTENT, "foo", "foo_new_value");
- fooAssert.assertContentEquals("foo", "foo_new_value", String.class);
-
- // Update content state
- foo.setProperty(StateScopeType.CONTENT, "foo", 2);
- fooAssert.assertContentEquals("foo", 2, Integer.class);
- }
-
public void testUpdateNavigationalProperty()
{
MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java 2007-11-29 13:16:38 UTC (rev 9194)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java 2007-11-29 13:30:41 UTC (rev 9195)
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
-import org.jboss.portal.presentation.impl.model.state.content.ContentStateContextImpl;
import org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.UIContext;
@@ -43,7 +42,7 @@
*/
protected void setUp() throws Exception
{
- this.uiContext = new UIContextImpl(new MockModel().getStructuralStateContext(), new NavigationalStateContextImpl(), new ContentStateContextImpl());
+ this.uiContext = new UIContextImpl(new MockModel().getStructuralStateContext(), new NavigationalStateContextImpl());
}
/**
18 years, 5 months
JBoss Portal SVN: r9194 - in branches/presentation: presentation/src/main/org/jboss/portal/presentation/impl/model and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-29 08:16:38 -0500 (Thu, 29 Nov 2007)
New Revision: 9194
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelEvent.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelListener.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
Log:
added model event feature that will allow to track complex changes during an interaction which will allow the client to react accordingly to perform the necessary state updates
Modified: branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java
===================================================================
--- branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -35,7 +35,9 @@
import org.jboss.portal.presentation.model.UIWindow;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.StateChange;
import java.util.ArrayList;
import java.util.Collection;
@@ -73,7 +75,6 @@
this.portalObjectContainer = portalObjectContainer;
}
-
public String getRootId()
{
return portalObjectContainer.getContext().getId().toString();
@@ -177,6 +178,16 @@
throw new StateChangeVetoException();
}
+ public void update(List<StateChange<StructuralStateModification>> modifications)
+ {
+ throw new StateChangeVetoException();
+ }
+
+ public void update(StateChange<StructuralStateModification> modification)
+ {
+ throw new StateChangeVetoException();
+ }
+
/**
*
*
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.model;
+import org.jboss.portal.presentation.model.ModelEvent;
+import org.jboss.portal.presentation.model.ModelListener;
import org.jboss.portal.presentation.model.UIContainer;
import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
@@ -33,7 +35,9 @@
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -55,6 +59,9 @@
/** . */
protected final ContentStateContext contentStateContext;
+ /** . */
+ protected final List<ModelListener> listeners;
+
private static String getRootId(StructuralStateContext loader)
{
return loader.getRootId();
@@ -76,6 +83,7 @@
this.structuralStateContext = structuralStateContext;
this.navigationalStateContext = navigationalStateContext;
this.contentStateContext = contentStateContext;
+ this.listeners = new ArrayList<ModelListener>();
// Put our self in the object cache
objects.put(getId(), this);
@@ -104,6 +112,20 @@
}
}
+ public void addModelListener(ModelListener listener)
+ {
+ if (listener == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (!listeners.contains(listener))
+ {
+ listeners.add(listener);
+ }
+ }
+
/**
* @return
*/
@@ -157,4 +179,19 @@
return isAllowedAsChild;
}
+
+ protected void fireEvent(ModelEvent event)
+ {
+ for (ModelListener listener : listeners)
+ {
+ try
+ {
+ listener.onEvent(event);
+ }
+ catch (Exception ignore)
+ {
+ System.out.println("ignore = " + ignore);
+ }
+ }
+ }
}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -24,8 +24,11 @@
import org.jboss.portal.presentation.model.StateScopeType;
import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.state.StateChange;
+import org.jboss.portal.presentation.model.state.StateChangeEvent;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
import java.io.Serializable;
import java.util.HashMap;
@@ -167,10 +170,20 @@
{
Map<String, String> changes = new HashMap<String, String>();
changes.put(propertyName, (String)propertyValue);
- context.getModelLoader().update(id, changes);
+
+ // Have loader process state
+ StructuralStateModification mod = new StructuralStateModification.SetProperties(changes);
+ StateChange<StructuralStateModification> change = new StateChange<StructuralStateModification>(id, mod);
+ context.getModelLoader().update(change);
+
+ // Update state locally
Map<String, String> updatedProperties = new HashMap<String, String>(state.getProperties());
updateProperty(updatedProperties, propertyName, (String)propertyValue);
state = new StructuralState(state.getType(), state.getName(), updatedProperties, state.getParentId(), state.getChildrenIds());
+
+ // Broadcast event
+ StateChangeEvent event = new StateChangeEvent(change);
+ context.fireEvent(event);
}
else
{
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelEvent.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelEvent.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelEvent.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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.presentation.model;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class ModelEvent
+{
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelListener.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelListener.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/ModelListener.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * 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.presentation.model;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ModelListener
+{
+ void onEvent(ModelEvent event);
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/UIContext.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -28,18 +28,24 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public interface UIContext extends UIObject
+public interface UIContext extends UIObject
{
/**
*
- * @param id
- * @return
+ * @param id the object id
+ * @return the object for the specified id or null if it cannot be found
*/
UIObject getObject(String id);
/**
*
- * @return
+ * @return the model loader
*/
StructuralStateContext getModelLoader();
+
+ /**
+ *
+ * @param listener the listener
+ */
+ void addModelListener(ModelListener listener);
}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChange.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * 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.presentation.model.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public final class StateChange<M extends StateModification>
+{
+
+ /** . */
+ private final String targetId;
+
+ /** . */
+ private final M modification;
+
+ public StateChange(String targetId, M modification)
+ {
+ if (targetId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (modification == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.targetId = targetId;
+ this.modification = modification;
+ }
+
+ public String getTargetId()
+ {
+ return targetId;
+ }
+
+ public M getModification()
+ {
+ return modification;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeEvent.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 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.presentation.model.state;
+
+import org.jboss.portal.presentation.model.ModelEvent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public final class StateChangeEvent extends ModelEvent
+{
+
+ /** . */
+ private final StateChange change;
+
+ public StateChangeEvent(StateChange change)
+ {
+ if (change == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.change = change;
+ }
+
+ public StateChange getChange()
+ {
+ return change;
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateModification.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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.presentation.model.state;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class StateModification
+{
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -23,10 +23,12 @@
package org.jboss.portal.presentation.model.state.structural;
import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.state.NoSuchStateException;
+import org.jboss.portal.presentation.model.state.StateChange;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.NoSuchStateException;
+import java.util.List;
import java.util.Map;
/**
@@ -54,6 +56,10 @@
*/
String getRootId();
+ void update(List<StateChange<StructuralStateModification>> modifications);
+
+ void update(StateChange<StructuralStateModification> modification);
+
/**
* Create an object.
*
Deleted: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -1,111 +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.presentation.model.state.structural;
-
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.state.StateChangeVetoException;
-import org.jboss.portal.presentation.model.state.StateException;
-import org.jboss.portal.presentation.model.state.NoSuchStateException;
-
-import java.util.Map;
-
-/**
- * The structural state manager.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface StructuralStateManager
-{
-
- /**
- * Load the state of a specified object.
- *
- * @param objectId the object id
- * @return the state of the object or null if such state does not exist
- * @throws IllegalArgumentException if the object id argument is null
- */
- StructuralState load(String objectId) throws IllegalArgumentException;
-
- /**
- * Returns the id of the root object.
- *
- * @return the id of the root object.
- */
- String getRootId();
-
- /**
- * Create an object.
- *
- * @param parentId the id of the parent object
- * @param type the type of the child
- * @param name the name of the child
- * @param properties the initial properties of the child
- * @return the structural state of the child
- * @throws StateChangeVetoException if the creation is vetoed
- * @throws StateException a generic state exception
- * @throws NoSuchStateException if the parent id does not point a valid state
- * @throws IllegalArgumentException if an argument is null or not valid
- */
- StructuralState create(String parentId, Class<? extends UIObject> type, String name, Map<String, String> properties) throws StateChangeVetoException, StateException, IllegalArgumentException;
-
- /**
- * Destroy a specified object.
- *
- * @param objectId the object id to destroy
- * @throws StateChangeVetoException if the creation is vetoed
- * @throws StateException a generic state exception
- * @throws NoSuchStateException if the object id does not point a valid state
- * @throws IllegalArgumentException if an argument is null or not valid
- */
- void destroy(String objectId) throws StateChangeVetoException, StateException, IllegalArgumentException;
-
- /**
- * Move an object to a new parent.
- *
- * @param objectId the object id to move
- * @param parentId the id of the new parent
- * @throws StateChangeVetoException if the creation is vetoed
- * @throws StateException a generic state exception
- * @throws NoSuchStateException if the object id does not point a valid state
- * @throws IllegalArgumentException if an argument is null or not valid
- */
- void move(String objectId, String parentId) throws StateChangeVetoException, StateException, IllegalArgumentException;
-
- /**
- * Update the state of a specified object. The <code>Map</code> values are interpreted as follow:
- * <ul>
- * <li>Each non null value will replace an existing value of create a new one</li>
- * <li>Each null value will destroy an existing value</li>
- * </ul>
- *
- * @param objectId the id of the object to udpate
- * @param changes the changes
- * @throws StateChangeVetoException if the creation is vetoed
- * @throws StateException a generic state exception
- * @throws NoSuchStateException if the object id does not point a valid state
- * @throws IllegalArgumentException if an argument is null or not valid
- */
- void update(String objectId, Map<String, String> changes) throws StateChangeVetoException, StateException, IllegalArgumentException;
-
-}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateModification.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * 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.presentation.model.state.structural;
+
+import org.jboss.portal.presentation.model.state.StateModification;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class StructuralStateModification extends StateModification
+{
+
+ public static class SetProperties extends StructuralStateModification
+ {
+
+ /** . */
+ private final Map<String, String> changes;
+
+ public SetProperties(Map<String, String> changes)
+ {
+ if (changes == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.changes = changes;
+ }
+
+ public Map<String, String> getChanges()
+ {
+ return changes;
+ }
+ }
+}
Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/EventAssert.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * 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.presentation.test.model;
+
+import junit.framework.Assert;
+import org.jboss.portal.presentation.model.ModelEvent;
+import org.jboss.portal.presentation.model.ModelListener;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
+import org.jboss.portal.presentation.model.state.StateChangeEvent;
+import org.jboss.portal.presentation.model.state.StateChange;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EventAssert implements ModelListener
+{
+
+ /** . */
+ private final List<ModelEvent> events = new ArrayList<ModelEvent>();
+
+ /** . */
+ private int index = 0;
+
+ public void onEvent(ModelEvent event)
+ {
+ events.add(event);
+ }
+
+ public <T> T next(Class<T> clazz)
+ {
+ Assert.assertTrue(index < events.size());
+ ModelEvent event = events.get(index++);
+ Assert.assertNotNull(event);
+ Assert.assertTrue(clazz.isInstance(event));
+ return clazz.cast(event);
+ }
+
+ public void next(String targetId, StructuralStateModification.SetProperties sp)
+ {
+ StateChangeEvent ste = next(StateChangeEvent.class);
+ StateChange change = ste.getChange();
+ Assert.assertEquals(targetId, change.getTargetId());
+ StructuralStateModification.SetProperties mod = (StructuralStateModification.SetProperties)change.getModification();
+ Assert.assertEquals(sp.getChanges(), mod.getChanges());
+ }
+
+ public void assertEmpty()
+ {
+ Assert.assertEquals(events.size(), index);
+ }
+}
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -26,14 +26,17 @@
import org.jboss.portal.presentation.model.state.NoSuchStateException;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.StateException;
+import org.jboss.portal.presentation.model.state.StateChange;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -63,46 +66,27 @@
return object != null ? object.takeSnapshot() : null;
}
- public String getRootId()
+ public void update(List<StateChange<StructuralStateModification>> changes)
{
- return root.id;
+ for (StateChange<StructuralStateModification> change : changes)
+ {
+ update(change);
+ }
}
- public StructuralState create(String parentId, Class<? extends UIObject> type, String name, Map<String, String> properties) throws StateChangeVetoException
+ public void update(StateChange<StructuralStateModification> change)
{
- throw new StateChangeVetoException();
- }
+ StructuralStateModification.SetProperties sp = (StructuralStateModification.SetProperties)change.getModification();
- public void destroy(String objectId) throws StateChangeVetoException
- {
- throw new StateChangeVetoException();
- }
-
- public void move(String objectId, String parentId) throws StateChangeVetoException
- {
- throw new StateChangeVetoException();
- }
-
- public void update(String objectId, Map<String, String> changes) throws StateChangeVetoException
- {
- if (objectId == null)
- {
- throw new IllegalArgumentException();
- }
- if (changes == null)
- {
- throw new IllegalArgumentException();
- }
-
//
- MockObjectImpl object = universe.get(objectId);
+ MockObjectImpl object = universe.get(change.getTargetId());
if (object == null)
{
throw new NoSuchStateException();
}
//
- for (Map.Entry<String, String> entry : changes.entrySet())
+ for (Map.Entry<String, String> entry : sp.getChanges().entrySet())
{
String propertyName = entry.getKey();
MockObject.UpdateBehavior behavior = object.propertyBehaviors.get(propertyName);
@@ -131,6 +115,31 @@
}
}
}
+
+ public String getRootId()
+ {
+ return root.id;
+ }
+
+ public StructuralState create(String parentId, Class<? extends UIObject> type, String name, Map<String, String> properties) throws StateChangeVetoException
+ {
+ throw new StateChangeVetoException();
+ }
+
+ public void destroy(String objectId) throws StateChangeVetoException
+ {
+ throw new StateChangeVetoException();
+ }
+
+ public void move(String objectId, String parentId) throws StateChangeVetoException
+ {
+ throw new StateChangeVetoException();
+ }
+
+ public void update(String objectId, Map<String, String> changes) throws StateChangeVetoException
+ {
+ update(new StateChange<StructuralStateModification>(objectId, new StructuralStateModification.SetProperties(changes)));
+ }
};
public StructuralStateContext getStructuralStateContext()
Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29 12:30:00 UTC (rev 9193)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29 13:16:38 UTC (rev 9194)
@@ -34,7 +34,10 @@
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIPortal;
import org.jboss.portal.presentation.model.state.NoSuchStateException;
+import org.jboss.portal.presentation.model.state.StateChange;
+import org.jboss.portal.presentation.model.state.StateChangeEvent;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
import java.util.Collections;
import java.util.List;
@@ -304,17 +307,21 @@
public void testUpdateExistingMutableStructuralProperty()
{
MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
+ String fooId = mockFoo.getId();
mockFoo.setPropertyValue("foo", "foo_value");
UIContext context = createContext();
+ EventAssert eventAssert = new EventAssert();
+ context.addModelListener(eventAssert);
// Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
+ UIPortal foo = (UIPortal)context.getObject(fooId);
PropertyAssert fooAssert = new PropertyAssert(foo);
fooAssert.assertStructuralEquals("foo", "foo_value");
// Update structural property
foo.setProperty(StateScopeType.STRUCTURAL, "foo", "foo_new_value");
fooAssert.assertStructuralEquals("foo", "foo_new_value");
+ eventAssert.next(fooId, new StructuralStateModification.SetProperties(Collections.singletonMap("foo", "foo_new_value")));
// Try a non string type
try
@@ -326,17 +333,20 @@
{
}
fooAssert.assertStructuralEquals("foo", "foo_new_value");
+ eventAssert.assertEmpty();
}
public void testUpdateExistingNonMutableStructuralProperty()
{
MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
+ String fooId = mockFoo.getId();
mockFoo.setPropertyValue("foo", "foo_value");
mockFoo.setPropertyBehavior("foo", MockObject.Failure.veto());
UIContext context = createContext();
+ EventAssert eventAssert = new EventAssert();
// Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
+ UIPortal foo = (UIPortal)context.getObject(fooId);
PropertyAssert fooAssert = new PropertyAssert(foo);
fooAssert.assertStructuralEquals("foo", "foo_value");
@@ -350,6 +360,7 @@
{
}
fooAssert.assertStructuralEquals("foo", "foo_value");
+ eventAssert.assertEmpty();
// Try a non string type
try
@@ -361,21 +372,26 @@
{
}
fooAssert.assertStructuralEquals("foo", "foo_value");
+ eventAssert.assertEmpty();
}
public void testUpdateNonExistingMutableStructuralProperty()
{
MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
+ String fooId = mockFoo.getId();
UIContext context = createContext();
+ EventAssert eventAssert = new EventAssert();
+ context.addModelListener(eventAssert);
// Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
+ UIPortal foo = (UIPortal)context.getObject(fooId);
PropertyAssert fooAssert = new PropertyAssert(foo);
fooAssert.assertStructuralEquals("foo", null);
// Update structural property
foo.setProperty(StateScopeType.STRUCTURAL, "foo", "foo_new_value");
fooAssert.assertStructuralEquals("foo", "foo_new_value");
+ eventAssert.next(fooId, new StructuralStateModification.SetProperties(Collections.singletonMap("foo", "foo_new_value")));
// Try a non string type
try
@@ -387,6 +403,7 @@
{
}
fooAssert.assertStructuralEquals("foo", "foo_new_value");
+ eventAssert.assertEmpty();
}
public void testUpdateNonExistingNonMutableStructuralProperty()
@@ -394,6 +411,8 @@
MockObject mockFoo = model.getRoot().addChild("foo", MockObject.Type.PORTAL);
mockFoo.setPropertyBehavior("foo", MockObject.Failure.veto());
UIContext context = createContext();
+ EventAssert eventAssert = new EventAssert();
+ context.addModelListener(eventAssert);
// Check initial state
UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
@@ -410,6 +429,7 @@
{
}
fooAssert.assertStructuralEquals("foo", null);
+ eventAssert.assertEmpty();
// Try a non string type
try
@@ -421,6 +441,7 @@
{
}
fooAssert.assertStructuralEquals("foo", null);
+ eventAssert.assertEmpty();
}
public void testUpdateContentProperty()
18 years, 5 months
JBoss Portal SVN: r9193 - modules/identity/tags/JBP_IDENTITY_1_0_1/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-11-29 07:30:00 -0500 (Thu, 29 Nov 2007)
New Revision: 9193
Modified:
modules/identity/tags/JBP_IDENTITY_1_0_1/build/build-thirdparty.xml
modules/identity/tags/JBP_IDENTITY_1_0_1/build/build.xml
Log:
Girl, tonight we're gonna make love. You know how I know, baby? 'Cause it's Wednesday. And Wednesday night is the night that we make love. Tuesday night's the night that we go and visit your mother, but Wednesday night is the night that we make love.
Modified: modules/identity/tags/JBP_IDENTITY_1_0_1/build/build-thirdparty.xml
===================================================================
--- modules/identity/tags/JBP_IDENTITY_1_0_1/build/build-thirdparty.xml 2007-11-29 12:16:48 UTC (rev 9192)
+++ modules/identity/tags/JBP_IDENTITY_1_0_1/build/build-thirdparty.xml 2007-11-29 12:30:00 UTC (rev 9193)
@@ -47,8 +47,8 @@
are pushed to the http://repository.jboss.com site.
-->
- <componentref name="jboss-portal/modules/common" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/test" version="1.0-SNAPSHOT"/>
+ <componentref name="jboss-portal/modules/common" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/test" version="1.0.1"/>
<componentref name="apache-log4j" version="1.2.8"/>
<componentref name="apache-logging" version="1.0.5.SP1-jboss"/>
<componentref name="apache-xerces" version="2.7.1"/>
Modified: modules/identity/tags/JBP_IDENTITY_1_0_1/build/build.xml
===================================================================
--- modules/identity/tags/JBP_IDENTITY_1_0_1/build/build.xml 2007-11-29 12:16:48 UTC (rev 9192)
+++ modules/identity/tags/JBP_IDENTITY_1_0_1/build/build.xml 2007-11-29 12:30:00 UTC (rev 9193)
@@ -61,7 +61,7 @@
<property name="version.major" value="1"/>
<property name="version.minor" value="0"/>
- <property name="version.revision" value="0"/>
+ <property name="version.revision" value="1"/>
<property name="version.tag" value="GA"/>
<property name="version.name" value=""/>
18 years, 5 months
JBoss Portal SVN: r9192 - modules/identity/tags.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-11-29 07:16:48 -0500 (Thu, 29 Nov 2007)
New Revision: 9192
Added:
modules/identity/tags/JBP_IDENTITY_1_0_1/
Log:
Tagging identity 1.0.1
Copied: modules/identity/tags/JBP_IDENTITY_1_0_1 (from rev 9191, modules/identity/branches/JBP_IDENTITY_BRANCH_1_0)
18 years, 5 months
JBoss Portal SVN: r9191 - modules/portlet/tags/JBP_PORTLET_1_0_1/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-11-29 07:12:54 -0500 (Thu, 29 Nov 2007)
New Revision: 9191
Modified:
modules/portlet/tags/JBP_PORTLET_1_0_1/build/build-thirdparty.xml
modules/portlet/tags/JBP_PORTLET_1_0_1/build/build.xml
Log:
Business time
Two minutes in heaven is better than one minute in heaven.
Modified: modules/portlet/tags/JBP_PORTLET_1_0_1/build/build-thirdparty.xml
===================================================================
--- modules/portlet/tags/JBP_PORTLET_1_0_1/build/build-thirdparty.xml 2007-11-29 12:01:06 UTC (rev 9190)
+++ modules/portlet/tags/JBP_PORTLET_1_0_1/build/build-thirdparty.xml 2007-11-29 12:12:54 UTC (rev 9191)
@@ -46,9 +46,9 @@
are pushed to the http://repository.jboss.com site.
-->
- <componentref name="jboss-portal/modules/common" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/web" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/test" version="1.0-SNAPSHOT"/>
+ <componentref name="jboss-portal/modules/common" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/web" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/test" version="1.0.1"/>
<componentref name="sun-servlet" version="2.4"/>
<componentref name="sun-jaf" version="1.1"/>
Modified: modules/portlet/tags/JBP_PORTLET_1_0_1/build/build.xml
===================================================================
--- modules/portlet/tags/JBP_PORTLET_1_0_1/build/build.xml 2007-11-29 12:01:06 UTC (rev 9190)
+++ modules/portlet/tags/JBP_PORTLET_1_0_1/build/build.xml 2007-11-29 12:12:54 UTC (rev 9191)
@@ -61,7 +61,7 @@
<property name="version.major" value="1"/>
<property name="version.minor" value="0"/>
- <property name="version.revision" value="0"/>
+ <property name="version.revision" value="1"/>
<property name="version.tag" value="GA"/>
<property name="version.name" value=""/>
18 years, 5 months
JBoss Portal SVN: r9190 - modules/portlet/tags.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-11-29 07:01:06 -0500 (Thu, 29 Nov 2007)
New Revision: 9190
Added:
modules/portlet/tags/JBP_PORTLET_1_0_1/
Log:
Tagging Portlet 1.0.1
Copied: modules/portlet/tags/JBP_PORTLET_1_0_1 (from rev 9189, modules/portlet/branches/JBP_PORTLET_BRANCH_1_0)
18 years, 5 months
JBoss Portal SVN: r9189 - modules/web/tags/JBP_WEB_1_1_0/build.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-11-29 06:56:14 -0500 (Thu, 29 Nov 2007)
New Revision: 9189
Modified:
modules/web/tags/JBP_WEB_1_1_0/build/build-thirdparty.xml
modules/web/tags/JBP_WEB_1_1_0/build/build.xml
Log:
Use 1.1.0 version
Use fixed version of modules
Modified: modules/web/tags/JBP_WEB_1_1_0/build/build-thirdparty.xml
===================================================================
--- modules/web/tags/JBP_WEB_1_1_0/build/build-thirdparty.xml 2007-11-29 11:37:46 UTC (rev 9188)
+++ modules/web/tags/JBP_WEB_1_1_0/build/build-thirdparty.xml 2007-11-29 11:56:14 UTC (rev 9189)
@@ -47,8 +47,8 @@
are pushed to the http://repository.jboss.com site.
-->
- <componentref name="jboss-portal/modules/common" version="trunk-SNAPSHOT"/>
- <componentref name="jboss-portal/modules/test" version="trunk-SNAPSHOT"/>
+ <componentref name="jboss-portal/modules/common" version="1.1.0"/>
+ <componentref name="jboss-portal/modules/test" version="1.1.0"/>
<!-- -->
<componentref name="sun-servlet" version="2.4"/>
Modified: modules/web/tags/JBP_WEB_1_1_0/build/build.xml
===================================================================
--- modules/web/tags/JBP_WEB_1_1_0/build/build.xml 2007-11-29 11:37:46 UTC (rev 9188)
+++ modules/web/tags/JBP_WEB_1_1_0/build/build.xml 2007-11-29 11:56:14 UTC (rev 9189)
@@ -59,10 +59,10 @@
<!--| Project version information. |-->
<!--+==============================+-->
- <property name="version.major" value="2"/>
- <property name="version.minor" value="6"/>
+ <property name="version.major" value="1"/>
+ <property name="version.minor" value="1"/>
<property name="version.revision" value="0"/>
- <property name="version.tag" value="A"/>
+ <property name="version.tag" value="GA"/>
<property name="version.name" value="Ninja"/>
<!-- This must be set to the CVS tag for any release -->
18 years, 5 months