Author: julien(a)jboss.com
Date: 2007-11-26 06:38:33 -0500 (Mon, 26 Nov 2007)
New Revision: 9103
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScope.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java
Log:
kind of implement property access on ui objects
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-26
11:24:36 UTC (rev 9102)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-26
11:38:33 UTC (rev 9103)
@@ -22,13 +22,14 @@
******************************************************************************/
package org.jboss.portal.presentation.impl.model;
-import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.presentation.model.StateScopeType;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.state.ObjectState;
import java.io.Serializable;
import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -46,16 +47,6 @@
*
*/
protected final String id;
-
- /**
- *
- */
- protected final String name;
-
- /**
- *
- */
- protected final String parentId;
/**
*
@@ -67,31 +58,34 @@
*/
private final ObjectState state;
-
/**
*
*/
+ private final Map<String, String> transientState;
+
+ /**
+ *
+ */
+ private final Map<String, String> navigationalState;
+
public UIObjectImpl(UIContextImpl context, String id, ObjectState state)
{
this.id = id;
this.state = state;
- this.parentId = state.getParentId();
- this.name = state.getName();
this.context = context;
this.children = new UIObjectList(this.context, state.getChildrenIds());
+ this.transientState = new HashMap<String, String>();
+ this.navigationalState = new HashMap<String, String>();
}
- /**
- *
- */
public UIObjectImpl(String id, ObjectState state)
{
this.id = id;
this.state = state;
- this.parentId = state.getParentId();
- this.name = state.getName();
this.context = (UIContextImpl)this;
this.children = new UIObjectList(this.context, state.getChildrenIds());
+ this.transientState = new HashMap<String, String>();
+ this.navigationalState = new HashMap<String, String>();
}
//UIObject interface
implementation-----------------------------------------------------------------------------------------------------------------------------
@@ -105,7 +99,17 @@
public String getProperty(StateScopeType scopeType, String propertyName)
{
- throw new NotYetImplemented("Just a place holder for now");
+ switch (scopeType)
+ {
+ case TRANSIENT:
+ return transientState.get(propertyName);
+ case NAVIGATIONAL:
+ return navigationalState.get(propertyName);
+ case PERSISTENT:
+ return state.getProperties().get(propertyName);
+ default:
+ throw new AssertionError();
+ }
}
public UIObject getChild(String name)
@@ -125,7 +129,7 @@
*/
public String getName()
{
- return this.name;
+ return state.getName();
}
/**
@@ -133,7 +137,7 @@
*/
public UIObject getParent()
{
- return parentId != null ? context.getObject(parentId) : null;
+ return state.getParentId() != null ? context.getObject(state.getParentId()) :
null;
}
/**
@@ -177,12 +181,6 @@
throw new UnsupportedOperationException("todo");
}
- /**
- *
- * @param <T>
- * @param type
- * @return
- */
protected abstract <T extends UIObject> boolean isAllowedAsChild(Class<T>
type);
Deleted:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScope.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScope.java 2007-11-26
11:24:36 UTC (rev 9102)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScope.java 2007-11-26
11:38:33 UTC (rev 9103)
@@ -1,45 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.model;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public enum StateScope
-{
- /**
- * The content scope.
- */
- CONTENT,
-
- /**
- * The navigational scope.
- */
- NAVIGATIONAL,
-
- /**
- * The server scope.
- */
- SERVER
-}
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-26
11:24:36 UTC (rev 9102)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java 2007-11-26
11:38:33 UTC (rev 9103)
@@ -29,17 +29,17 @@
public enum StateScopeType
{
/**
- * The content scope.
+ * The transient scope type.
*/
- CONTENT,
+ TRANSIENT,
/**
- * The navigational scope.
+ * The navigational scope type.
*/
NAVIGATIONAL,
/**
- * The server scope.
+ * The persistent scope type.
*/
- SERVER
+ PERSISTENT
}