From portal-commits at lists.jboss.org Mon Jul 7 14:31:35 2008 Content-Type: multipart/mixed; boundary="===============4140410775354662655==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r11326 - in modules/presentation/trunk: classic/src/main/java/org/jboss/portal/presentation/classic and 3 other directories. Date: Mon, 07 Jul 2008 14:31:34 -0400 Message-ID: --===============4140410775354662655== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2008-07-07 14:31:34 -0400 (Mon, 07 Jul 2008) New Revision: 11326 Removed: modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presen= tation/classic/model/ClassicUINode.java modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presen= tation/classic/model/ClassicViewPortContext.java Modified: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentat= ion/ajax/server/model/AjaxViewPortContext.java modules/presentation/trunk/classic/src/main/java/org/jboss/portal/presen= tation/classic/ClassicPresentationClient.java modules/presentation/trunk/portal/src/main/java/org/jboss/portal/present= ation/portal/model/ModelAdapter.java modules/presentation/trunk/portal/src/main/java/org/jboss/portal/present= ation/portal/model/ModelStructuralState.java modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/p= resentation/impl/state/structural/adapter/StructuralAdapter.java modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/p= resentation/impl/state/structural/adapter/StructuralStateContextImpl.java Log: update rest of codebase to work with framework changes Modified: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/pr= esentation/ajax/server/model/AjaxViewPortContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presenta= tion/ajax/server/model/AjaxViewPortContext.java 2008-07-07 17:45:48 UTC (re= v 11325) +++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presenta= tion/ajax/server/model/AjaxViewPortContext.java 2008-07-07 18:31:34 UTC (re= v 11326) @@ -23,11 +23,12 @@ package org.jboss.portal.presentation.ajax.server.model; = import org.jboss.portal.presentation.model.ViewPortContext; -import org.jboss.portal.presentation.model.ui.UIObject; +import org.jboss.portal.presentation.model.UIObjectContext; import org.jboss.portal.presentation.model.ui.UIContext; import org.jboss.portal.presentation.model.ui.UIPage; import org.jboss.portal.presentation.model.ui.UIWindow; import org.jboss.portal.presentation.model.ui.UILayout; +import org.jboss.portal.presentation.model.ui.UIObject; import org.jboss.portal.presentation.ajax.client.model.update.ModelUpdate; import org.jboss.portal.presentation.ajax.client.model.update.AddObject; import org.jboss.portal.presentation.ajax.client.model.update.RemoveObject; @@ -36,12 +37,13 @@ import org.jboss.portal.presentation.ajax.client.model.update.AddChild; import org.jboss.portal.presentation.ajax.client.model.update.RemoveChild; import org.jboss.portal.presentation.ajax.client.model.update.ObjectType; -import org.jboss.portal.presentation.state.StateType; import org.jboss.portal.common.NotYetImplemented; = import java.util.ArrayList; import java.util.Map; import java.util.HashMap; +import java.util.Set; +import java.io.Serializable; = /** * @author Julien Viet @@ -54,11 +56,11 @@ private ArrayList updates; = /** . */ - private Map objects; + private Map objects; = public AjaxViewPortContext() { - objects =3D new HashMap(); + objects =3D new HashMap(); updates =3D new ArrayList(); } = @@ -69,12 +71,12 @@ return tmp; } = - public UIObject getObject(String objectId) + public UIObjectContext getObject(String objectId) { return objects.get(objectId); } = - public void addObject(UIObject object) + public void addObject(UIObjectContext object) { String objectId =3D object.getId(); = @@ -82,20 +84,23 @@ objects.put(objectId, object); = // + Class type =3D object.getType(); + + // int objectType; - if (object instanceof UIContext) + if (UIContext.class.isAssignableFrom(type)) { objectType =3D ObjectType.CONTEXT; } - else if (object instanceof UIPage) + else if (UIPage.class.isAssignableFrom(type)) { objectType =3D ObjectType.PAGE; } - else if (object instanceof UIWindow) + else if (UIWindow.class.isAssignableFrom(type)) { objectType =3D ObjectType.WINDOW; } - else if (object instanceof UILayout) + else if (UILayout.class.isAssignableFrom(type)) { objectType =3D ObjectType.PANE; } @@ -104,23 +109,14 @@ throw new NotYetImplemented(); } = - // - Map objectProperties =3D new HashMap(); - for (String propertyName : object.getPropertyNames(StateType.STRUCTU= RAL)) - { - Object propertyValue =3D object.getPropertyValue(StateType.STRUCT= URAL, propertyName, Object.class); - objectProperties.put(propertyName, propertyValue); - } - - // - updates.add(new AddObject(objectId, objectType, objectProperties)); + // We clone the map because of the immutability of the context prope= rties that cannot + // be serialized by GWT. The type javax.util.HashMap is serializable= by GWT + updates.add(new AddObject(objectId, objectType, new HashMap(object.getProperties()))); } = - public void updateObject(String objectId) + public void updateObject(String objectId, Set removedProperties= , Map updatedProperties, Map ad= dedProperties) { -// updates -// - throw new NotYetImplemented(); + throw new NotYetImplemented("todo"); } = public void removeObject(String objectId) Modified: modules/presentation/trunk/classic/src/main/java/org/jboss/portal= /presentation/classic/ClassicPresentationClient.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/classic/src/main/java/org/jboss/portal/prese= ntation/classic/ClassicPresentationClient.java 2008-07-07 17:45:48 UTC (rev= 11325) +++ modules/presentation/trunk/classic/src/main/java/org/jboss/portal/prese= ntation/classic/ClassicPresentationClient.java 2008-07-07 18:31:34 UTC (rev= 11326) @@ -22,8 +22,6 @@ *************************************************************************= *****/ package org.jboss.portal.presentation.classic; = -import org.jboss.portal.presentation.classic.model.ClassicUINode; -import org.jboss.portal.presentation.classic.model.ClassicViewPortContext; import org.jboss.portal.presentation.classic.protocol.ClassicActionDecoder= Context; import org.jboss.portal.presentation.classic.protocol.ClassicActionEncoder= Context; import org.jboss.portal.presentation.view.PageViewPortScope; @@ -33,6 +31,8 @@ import org.jboss.portal.presentation.protocol.codec.ActionEncoderContext; import org.jboss.portal.presentation.client.PresentationClient; import org.jboss.portal.presentation.impl.model.UIModelImpl; +import org.jboss.portal.presentation.impl.model.pull.DetachedViewPortConte= xt; +import org.jboss.portal.presentation.impl.model.pull.DetachedUINode; import org.jboss.portal.presentation.impl.state.navigational.NavigationalS= tateContextImpl; import org.jboss.portal.presentation.impl.state.navigational.NavigationalS= tateContextSerialization; import org.jboss.portal.presentation.model.UIModel; @@ -240,7 +240,7 @@ = // StructuralStateContext ssc =3D server.getStructuralStateContext(); - ClassicViewPortContext context =3D new ClassicViewPortContext(); + DetachedViewPortContext context =3D new DetachedViewPortContext(navi= gationalStateContext); UIModel model =3D new UIModelImpl(null, ssc); ViewPort viewPort =3D model.createViewPort(context, scope); = @@ -248,7 +248,7 @@ viewPort.refresh(); = // - ClassicUINode node =3D context.getNode(nodeId); + DetachedUINode node =3D context.getNode(nodeId); = // resp.setContentType("text/html"); Deleted: modules/presentation/trunk/classic/src/main/java/org/jboss/portal/= presentation/classic/model/ClassicUINode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/classic/src/main/java/org/jboss/portal/prese= ntation/classic/model/ClassicUINode.java 2008-07-07 17:45:48 UTC (rev 11325) +++ modules/presentation/trunk/classic/src/main/java/org/jboss/portal/prese= ntation/classic/model/ClassicUINode.java 2008-07-07 18:31:34 UTC (rev 11326) @@ -1,71 +0,0 @@ -/*************************************************************************= ***** - * JBoss, a division of Red Hat = * - * Copyright 2008, 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.classic.model; - -import org.jboss.portal.presentation.model.ui.UIObject; -import org.jboss.portal.presentation.model.UINode; - -import java.util.Collection; -import java.util.Map; - -/** - * @author Julien Viet - * @version $Revision: 630 $ - */ -public class ClassicUINode implements UINode -{ - - /** . */ - private final UIObject object; - - /** . */ - ClassicUINode parent; - - /** . */ - Map children; - - public ClassicUINode(UIObject object) - { - this.object =3D object; - } - - public ClassicUINode getParent() - { - return parent; - } - - public String getId() - { - return object.getId(); - } - - public UIObject getObject() - { - return object; - } - - public Collection getChildren() - { - return children =3D=3D null ? null : children.values(); - } -} Deleted: modules/presentation/trunk/classic/src/main/java/org/jboss/portal/= presentation/classic/model/ClassicViewPortContext.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/classic/src/main/java/org/jboss/portal/prese= ntation/classic/model/ClassicViewPortContext.java 2008-07-07 17:45:48 UTC (= rev 11325) +++ modules/presentation/trunk/classic/src/main/java/org/jboss/portal/prese= ntation/classic/model/ClassicViewPortContext.java 2008-07-07 18:31:34 UTC (= rev 11326) @@ -1,103 +0,0 @@ -/*************************************************************************= ***** - * JBoss, a division of Red Hat = * - * Copyright 2008, 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.classic.model; - -import org.jboss.portal.presentation.model.ui.UIObject; -import org.jboss.portal.presentation.model.ViewPortContext; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Julien Viet - * @version $Revision: 630 $ - */ -public class ClassicViewPortContext implements ViewPortContext -{ - - /** . */ - final Map nodes =3D new HashMap(); - - public ClassicUINode getNode(String nodeId) - { - return nodes.get(nodeId); - } - - public UIObject getObject(String objectId) - { - ClassicUINode node =3D nodes.get(objectId); - - // - if (node =3D=3D null) - { - return null; - } - else - { - return node.getObject(); - } - } - - public void addObject(UIObject object) - { - ClassicUINode node =3D new ClassicUINode(object); - - // - nodes.put(node.getId(), node); - } - - public void updateObject(String objectId) - { - throw new UnsupportedOperationException(); - } - - public void removeObject(String objectId) - { - throw new UnsupportedOperationException(); - } - - public void createChildren(String parentId) - { - nodes.get(parentId).children =3D new HashMap(= ); - } - - public void destroyChildren(String parentId) - { - throw new UnsupportedOperationException(); - } - - public void addChild(String parentId, String childId) - { - ClassicUINode parent =3D nodes.get(parentId); - ClassicUINode child =3D nodes.get(childId); - - // - parent.children.put(child.getId(), child); - child.parent =3D parent; - } - - public void removeChild(String parentId, String childId) - { - throw new UnsupportedOperationException(); - } -} Modified: modules/presentation/trunk/portal/src/main/java/org/jboss/portal/= presentation/portal/model/ModelAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presen= tation/portal/model/ModelAdapter.java 2008-07-07 17:45:48 UTC (rev 11325) +++ modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presen= tation/portal/model/ModelAdapter.java 2008-07-07 18:31:34 UTC (rev 11326) @@ -305,12 +305,4 @@ // return new ModelStructuralState(type, properties); } - - public void lock(Object o) - { - } - - public void unlock(Object o) - { - } } Modified: modules/presentation/trunk/portal/src/main/java/org/jboss/portal/= presentation/portal/model/ModelStructuralState.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presen= tation/portal/model/ModelStructuralState.java 2008-07-07 17:45:48 UTC (rev = 11325) +++ modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presen= tation/portal/model/ModelStructuralState.java 2008-07-07 18:31:34 UTC (rev = 11326) @@ -58,26 +58,4 @@ { return properties; } - - public boolean equals(Object obj) - { - if (obj =3D=3D this) - { - return true; - } - if (obj instanceof ModelStructuralState) - { - ModelStructuralState that =3D (ModelStructuralState)obj; - - // - if (!that.type.equals(this.type)) - { - return false; - } - - // - return that.properties.equals(this.properties); - } - return false; - } } Modified: modules/presentation/trunk/presentation/src/main/java/org/jboss/p= ortal/presentation/impl/state/structural/adapter/StructuralAdapter.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/= presentation/impl/state/structural/adapter/StructuralAdapter.java 2008-07-0= 7 17:45:48 UTC (rev 11325) +++ modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/= presentation/impl/state/structural/adapter/StructuralAdapter.java 2008-07-0= 7 18:31:34 UTC (rev 11326) @@ -30,6 +30,14 @@ import java.io.Serializable; = /** + * The structural adapter used to adapt a back end model to a structural s= tate context interface. This framework + * should be used only to build prototypes. + * = + *
    + *
  • Consistency is based on object equality and not versionning
  • + *
  • It MUST not be used in production as no locking is performed and pe= rformance are not optimal
  • + *
+ * * @author Julien Viet * @version $Revision: 630 $ */ @@ -40,20 +48,15 @@ = N getNode(String id); = - N getParent(N n); + N getParent(N node); = - Collection getChildren(N n); + Collection getChildren(N node); = - String getId(N n); + String getId(N node); = - Class getType(N n); + Class getType(N node); = - Map getProperties(N n); + Map getProperties(N node); = - StructuralState getState(N n); - - void lock(N n); - - void unlock(N n); - + StructuralState getState(N node); } Modified: modules/presentation/trunk/presentation/src/main/java/org/jboss/p= ortal/presentation/impl/state/structural/adapter/StructuralStateContextImpl= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/= presentation/impl/state/structural/adapter/StructuralStateContextImpl.java = 2008-07-07 17:45:48 UTC (rev 11325) +++ modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/= presentation/impl/state/structural/adapter/StructuralStateContextImpl.java = 2008-07-07 18:31:34 UTC (rev 11326) @@ -71,33 +71,23 @@ = private StructuralObjectImpl takeSnapshot(N node) { - adapter.lock(node); + StructuralState state =3D adapter.getState(node); = // - try + Set childrenIds =3D new HashSet(); + for (N childNode : adapter.getChildren(node)) { - StructuralState state =3D adapter.getState(node); + childrenIds.add(adapter.getId(childNode)); + } = - // - Set childrenIds =3D new HashSet(); - for (N childNode : adapter.getChildren(node)) - { - childrenIds.add(adapter.getId(childNode)); - } + // + N parent =3D adapter.getParent(node); = - // - N parent =3D adapter.getParent(node); + // + String parentId =3D parent !=3D null ? adapter.getId(parent) : null; = - // - String parentId =3D parent !=3D null ? adapter.getId(parent) : nu= ll; - - // - return new StructuralObjectImpl(adapter.getId(node), parentId, Co= llections.unmodifiableSet(childrenIds), state); - } - finally - { - adapter.unlock(node); - } + // + return new StructuralObjectImpl(adapter.getId(node), parentId, Colle= ctions.unmodifiableSet(childrenIds), state); } = public Collection loadChildren(StructuralObject struc= turalParent) throws IllegalArgumentException, StateException @@ -116,7 +106,9 @@ throw new NoSuchStateException(); } = - if (!takeSnapshot(parentNode).equals(structuralParent)) + // + StructuralState parentNodeState =3D adapter.getState(parentNode); + if (!equals(parentNodeState, structuralParent.getState())) { throw new StaleStateException(); } @@ -134,6 +126,17 @@ return structuralChildren; } = + private boolean equals(StructuralState o1, StructuralState o2) + { + if (!o1.getType().equals(o2.getType())) + { + return false; + } + + // + return o1.getProperties().equals(o2.getProperties()); + } + public StructuralObject loadParent(StructuralObject structuralChild) th= rows IllegalArgumentException, StateException { if (structuralChild =3D=3D null) --===============4140410775354662655==--