Author: julien(a)jboss.com
Date: 2007-04-27 08:54:42 -0400 (Fri, 27 Apr 2007)
New Revision: 7103
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesInfo.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml
Log:
- extended portal object property metadata prototype
- extended the portal object UI property management
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-04-27
12:28:37 UTC (rev 7102)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-04-27
12:54:42 UTC (rev 7103)
@@ -485,7 +485,7 @@
}
//
- selectedProperties = new PropertiesBean(this, true);
+ selectedProperties = new PropertiesBean(this);
//
Collection pages = getSelectedObject().getChildren(PortalObject.PAGE_MASK);
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java 2007-04-27
12:28:37 UTC (rev 7102)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java 2007-04-27
12:54:42 UTC (rev 7103)
@@ -22,19 +22,14 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui;
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.core.impl.model.portal.WindowImpl;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
import javax.faces.model.SelectItem;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Iterator;
import java.util.Map;
-import java.util.Locale;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -45,99 +40,69 @@
{
/** . */
- List entries;
+ List entryList;
/** . */
- int selectedIndex;
+ Map entryMap;
/** . */
- private boolean mutable;
+ int selectedIndex;
/** . */
final PortalObjectManagerBean pomgr;
- public PropertiesBean(PortalObjectManagerBean pomgr, boolean mutable)
+ /** . */
+ private final PropertiesInfo info;
+
+ /** . */
+ private List items;
+
+ public PropertiesBean(PortalObjectManagerBean pomgr)
{
// Get the selected object
PortalObject selectedObject = pomgr.getSelectedObject();
- // Look at declared properties
- List entries = new ArrayList();
- for (Iterator i = selectedObject.getDeclaredProperties().entrySet().iterator();
i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String value = (String)entry.getValue();
- String name = (String)entry.getKey();
+ //
+ PropertiesInfo info = new PropertiesInfo(selectedObject);
- //
- String type = "java.lang.String";
- LocalizedString displayName = new LocalizedString(name, Locale.ENGLISH);
+ //
+ List entryList = new ArrayList(info.getNames().size());
+ Map entryMap = new HashMap(info.getNames().size());
- //
- if (name.equals(ThemeConstants.PORTAL_PROP_LAYOUT))
- {
- continue;
- }
- else if (name.equals(ThemeConstants.PORTAL_PROP_THEME))
- {
- continue;
- }
- else if (name.equals(ThemeConstants.PORTAL_PROP_RENDERSET))
- {
- continue;
- }
- else if (name.equals(ThemeConstants.PORTAL_PROP_REGION))
- {
- continue;
- }
- else if (name.equals(WindowImpl.PORTAL_PROP_WINDOW_CONTENT_TYPE))
- {
- continue;
- }
- else if (name.equals(ThemeConstants.PORTAL_PROP_ORDER))
- {
- displayName = new LocalizedString("Order", Locale.ENGLISH);
- }
- else if (name.equals(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME))
- {
- displayName = new LocalizedString("Default child name",
Locale.ENGLISH);
- }
- else if (name.equals(DynaRenderOptions.PARTIAL_REFRESH_ENABLED))
- {
- displayName = new LocalizedString("Partial Refresh Enabled",
Locale.ENGLISH);
- type = "java.lang.Boolean";
- }
- //
+ for (Iterator i = selectedObject.getProperties().keySet().iterator();i.hasNext();)
+ {
+ String propertyName = (String)i.next();
+ String propertyValue = selectedObject.getProperty(propertyName);
- if (!mutable)
- {
- throw new IllegalStateException("Cannot add non mutable entry to a
mutable preferences bean");
- }
-
//
- PropertyInfo info = new PropertyInfo(name, displayName, type, false);
+ PropertyInfo propertyInfo = info.getPropertyInfo(propertyName);
//
- PropertyBean propertyBean = new PropertyBean(this, info, value);
+ boolean inherited =
!selectedObject.getDeclaredProperties().containsKey(propertyName);
- //
- entries.add(propertyBean);
+ // If null it is probably an inherited property that does not have meaning for
that particular object
+ if (propertyInfo != null)
+ {
+
+ // Filter, keep only public properties
+ if (propertyInfo.getScope() == PropertyInfo.PUBLIC_SCOPE)
+ {
+ PropertyBean propertyBean = new PropertyBean(this, propertyInfo,
inherited, propertyValue);
+ entryList.add(propertyBean);
+ entryMap.put(propertyName, propertyBean);
+ }
+ }
}
- Collections.sort(entries);
//
+ this.info = info;
this.pomgr = pomgr;
- this.entries = entries;
+ this.entryList = entryList;
+ this.entryMap = entryMap;
this.selectedIndex = -1;
- this.mutable = mutable;
}
- public boolean isMutable()
- {
- return mutable;
- }
-
public int getSelectedIndex()
{
return selectedIndex;
@@ -145,7 +110,7 @@
public void setSelectedIndex(int selectedIndex)
{
- if (selectedIndex < 0 || selectedIndex >= entries.size())
+ if (selectedIndex < 0 || selectedIndex >= entryList.size())
{
throw new IllegalArgumentException();
}
@@ -159,31 +124,47 @@
public PreferenceBean getSelectedEntry()
{
- if (selectedIndex < 0 || selectedIndex >= entries.size())
+ if (selectedIndex < 0 || selectedIndex >= entryList.size())
{
return null;
}
- return (PreferenceBean)entries.get(selectedIndex);
+ return (PreferenceBean)entryList.get(selectedIndex);
}
public List getEntries()
{
- return entries;
+ return entryList;
}
public int getSize()
{
- return entries.size();
+ return entryList.size();
}
public SelectItem[] getPropertyItems()
{
- List items = new ArrayList();
- // items.add(new SelectItem(DynaRenderOptions.DND_ENABLED, "DnD
enabled"));
- items.add(new SelectItem(DynaRenderOptions.PARTIAL_REFRESH_ENABLED, "Partial
Refresh Enabled"));
- items.add(new SelectItem(ThemeConstants.PORTAL_PROP_ORDER, "Order"));
- items.add(new SelectItem(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME,
"Default child name"));
+ if (items == null)
+ {
+ items = new ArrayList();
+ for (Iterator i = info.getNames().iterator();i.hasNext();)
+ {
+ String propertyName = (String)i.next();
+
+ // Add only missing property
+ if (!entryMap.containsKey(propertyName))
+ {
+ PropertyInfo propertyInfo = info.getPropertyInfo(propertyName);
+
+ // Add only property user can change state
+ if (propertyInfo.getScope() == PropertyInfo.PUBLIC_SCOPE &&
propertyInfo.getAccessMode() == PropertyInfo.READ_WRITE_ACCESS_MODE)
+ {
+ items.add(new SelectItem(propertyInfo.getName(),
propertyInfo.getDisplayName().getDefaultString()));
+ }
+ }
+ }
+ }
+
+ //
return (SelectItem[])items.toArray(new SelectItem[items.size()]);
}
-
}
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesInfo.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesInfo.java
(rev 0)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesInfo.java 2007-04-27
12:54:42 UTC (rev 7103)
@@ -0,0 +1,159 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.admin.ui;
+
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.impl.model.portal.WindowImpl;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaRenderOptions;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Locale;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertiesInfo
+{
+
+ //
+
+ public static final PropertyInfo THEME_LAYOUT_ID = new
PropertyInfo(ThemeConstants.PORTAL_PROP_LAYOUT, new LocalizedString("Layout id",
Locale.ENGLISH), "java.lang.String", PropertyInfo.READ_WRITE_ACCESS_MODE,
PropertyInfo.PRIVATE_SCOPE);
+ public static final PropertyInfo THEME_THEME_ID = new
PropertyInfo(ThemeConstants.PORTAL_PROP_THEME, new LocalizedString("Theme id",
Locale.ENGLISH), "java.lang.String", PropertyInfo.READ_WRITE_ACCESS_MODE,
PropertyInfo.PRIVATE_SCOPE);
+ public static final PropertyInfo THEME_RENDER_SET_ID = new
PropertyInfo(ThemeConstants.PORTAL_PROP_RENDERSET, new LocalizedString("Renderset
id", Locale.ENGLISH), "java.lang.String",
PropertyInfo.READ_WRITE_ACCESS_MODE, PropertyInfo.PRIVATE_SCOPE);
+ public static final PropertyInfo THEME_RENDER_REGION_ID = new
PropertyInfo(ThemeConstants.PORTAL_PROP_REGION, new LocalizedString("Region id",
Locale.ENGLISH), "java.lang.String", PropertyInfo.READ_WRITE_ACCESS_MODE,
PropertyInfo.PRIVATE_SCOPE);
+ public static final PropertyInfo THEME_RENDER_REGION_ORDER = new
PropertyInfo(ThemeConstants.PORTAL_PROP_ORDER, new LocalizedString("Region
order", Locale.ENGLISH), "java.lang.String",
PropertyInfo.READ_WRITE_ACCESS_MODE, PropertyInfo.PUBLIC_SCOPE);
+
+ //
+
+ public static final PropertyInfo AJAX_PARTIAL_REFRESH = new
PropertyInfo(DynaRenderOptions.PARTIAL_REFRESH_ENABLED, new LocalizedString("Partial
refresh", Locale.ENGLISH), "java.lang.Boolean",
PropertyInfo.READ_WRITE_ACCESS_MODE, PropertyInfo.PUBLIC_SCOPE);
+
+ //
+
+ public static final PropertyInfo WINDOW_CONTENT_TYPE = new
PropertyInfo(WindowImpl.PORTAL_PROP_WINDOW_CONTENT_TYPE, new LocalizedString("Content
type", Locale.ENGLISH), "java.lang.String",
PropertyInfo.READ_WRITE_ACCESS_MODE, PropertyInfo.PRIVATE_SCOPE);
+ public static final PropertyInfo DEFAULT_CHILD_NAME = new
PropertyInfo(WindowImpl.PORTAL_PROP_DEFAULT_OBJECT_NAME, new LocalizedString("Default
child name", Locale.ENGLISH), "java.lang.String",
PropertyInfo.READ_WRITE_ACCESS_MODE, PropertyInfo.PUBLIC_SCOPE);
+ public static final PropertyInfo PAGE_ORDER = new PropertyInfo("order", new
LocalizedString("Tab order", Locale.ENGLISH), "java.lang.String",
PropertyInfo.READ_WRITE_ACCESS_MODE, PropertyInfo.PUBLIC_SCOPE);
+
+ /** . */
+ private static final Map CONTEXT_PROPERTIES = new HashMap();
+
+ /** . */
+ private static final Map PORTAL_PROPERTIES = new HashMap();
+
+ /** . */
+ private static final Map PAGE_PROPERTIES = new HashMap();
+
+ /** . */
+ private static final Map WINDOW_PROPERTIES = new HashMap();
+
+ /** . */
+ private static final Map ALL_PROPERTIES = new HashMap();
+
+ static
+ {
+ PORTAL_PROPERTIES.put(THEME_LAYOUT_ID.getName(), THEME_LAYOUT_ID);
+ PORTAL_PROPERTIES.put(THEME_THEME_ID.getName(), THEME_THEME_ID);
+ PORTAL_PROPERTIES.put(THEME_RENDER_SET_ID.getName(), THEME_RENDER_SET_ID);
+ PORTAL_PROPERTIES.put(DEFAULT_CHILD_NAME.getName(), DEFAULT_CHILD_NAME);
+ PORTAL_PROPERTIES.put(AJAX_PARTIAL_REFRESH.getName(), AJAX_PARTIAL_REFRESH);
+
+ //
+ PAGE_PROPERTIES.put(THEME_LAYOUT_ID.getName(), THEME_LAYOUT_ID);
+ PAGE_PROPERTIES.put(THEME_THEME_ID.getName(), THEME_THEME_ID);
+ PAGE_PROPERTIES.put(THEME_RENDER_SET_ID.getName(), THEME_RENDER_SET_ID);
+ PAGE_PROPERTIES.put(DEFAULT_CHILD_NAME.getName(), DEFAULT_CHILD_NAME);
+ PAGE_PROPERTIES.put(PAGE_ORDER.getName(), PAGE_ORDER);
+ PAGE_PROPERTIES.put(AJAX_PARTIAL_REFRESH.getName(), AJAX_PARTIAL_REFRESH);
+
+ //
+ WINDOW_PROPERTIES.put(AJAX_PARTIAL_REFRESH.getName(), AJAX_PARTIAL_REFRESH);
+ WINDOW_PROPERTIES.put(THEME_RENDER_REGION_ID.getName(), THEME_RENDER_REGION_ID);
+ WINDOW_PROPERTIES.put(THEME_RENDER_REGION_ORDER.getName(),
THEME_RENDER_REGION_ORDER);
+ WINDOW_PROPERTIES.put(WINDOW_CONTENT_TYPE.getName(), WINDOW_CONTENT_TYPE);
+
+ //
+ ALL_PROPERTIES.putAll(CONTEXT_PROPERTIES);
+ ALL_PROPERTIES.putAll(PORTAL_PROPERTIES);
+ ALL_PROPERTIES.putAll(PAGE_PROPERTIES);
+ ALL_PROPERTIES.putAll(WINDOW_PROPERTIES);
+ }
+
+ /** . */
+ private Map entries;
+
+ public PropertiesInfo(PortalObject portalObject)
+ {
+ Map objectProps = null;
+ switch(portalObject.getType())
+ {
+ case PortalObject.TYPE_CONTEXT:
+ objectProps = CONTEXT_PROPERTIES;
+ break;
+ case PortalObject.TYPE_PORTAL:
+ objectProps = PORTAL_PROPERTIES;
+ break;
+ case PortalObject.TYPE_PAGE:
+ objectProps = PAGE_PROPERTIES;
+ break;
+ case PortalObject.TYPE_WINDOW:
+ objectProps = WINDOW_PROPERTIES;
+ break;
+ }
+
+ // Add predefined properties
+ Map entries = new HashMap(objectProps);
+
+ //
+ for (Iterator i = portalObject.getDeclaredProperties().entrySet().iterator();
i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+
+ // Add additional properties
+ if (!ALL_PROPERTIES.containsKey(name))
+ {
+ LocalizedString displayName = new LocalizedString(name, Locale.ENGLISH);
+ PropertyInfo info = new PropertyInfo(name, displayName,
"java.lang.String", PropertyInfo.READ_WRITE_ACCESS_MODE,
PropertyInfo.PUBLIC_SCOPE);
+ entries.put(name, info);
+ }
+ }
+
+ //
+ this.entries = entries;
+ }
+
+ public Set getNames()
+ {
+ return entries.keySet();
+ }
+
+ public PropertyInfo getPropertyInfo(String name)
+ {
+ return (PropertyInfo)entries.get(name);
+ }
+}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java 2007-04-27
12:28:37 UTC (rev 7102)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java 2007-04-27
12:54:42 UTC (rev 7103)
@@ -41,11 +41,15 @@
/** . */
private final PropertyInfo info;
+
+ /** . */
+ private final boolean inherited;
- public PropertyBean(PropertiesBean container, PropertyInfo info, String value)
+ public PropertyBean(PropertiesBean container, PropertyInfo info, boolean inherited,
String value)
{
this.container = container;
this.info = info;
+ this.inherited = inherited;
this.value = value;
}
@@ -56,7 +60,7 @@
public boolean isReadOnly()
{
- return info.isReadOnly();
+ return info.getAccessMode() == PropertyInfo.READ_ONLY_ACCESS_MODE;
}
public LocalizedString getDisplayName()
@@ -64,6 +68,11 @@
return info.getDisplayName();
}
+ public boolean isInherited()
+ {
+ return inherited;
+ }
+
public Object getValue()
{
if (info.getType().equals("java.lang.Boolean"))
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java 2007-04-27
12:28:37 UTC (rev 7102)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java 2007-04-27
12:54:42 UTC (rev 7103)
@@ -32,10 +32,22 @@
{
/** . */
+ public static final int PUBLIC_SCOPE = 0;
+
+ /** . */
+ public static final int PRIVATE_SCOPE = 1;
+
+ /** . */
+ public static final int READ_ONLY_ACCESS_MODE = 0;
+
+ /** . */
+ public static final int READ_WRITE_ACCESS_MODE = 1;
+
+ /** . */
private String name;
/** . */
- private boolean readOnly;
+ private int accessMode;
/** . */
private String type;
@@ -43,12 +55,16 @@
/** . */
private LocalizedString displayName;
- public PropertyInfo(String name, LocalizedString displayName, String type, boolean
readOnly)
+ /** . */
+ private int scope;
+
+ public PropertyInfo(String name, LocalizedString displayName, String type, int
accessMode, int scope)
{
this.name = name;
- this.readOnly = readOnly;
+ this.accessMode = accessMode;
this.displayName = displayName;
this.type = type;
+ this.scope = scope;
}
public LocalizedString getDisplayName()
@@ -61,13 +77,18 @@
return name;
}
- public boolean isReadOnly()
+ public int getAccessMode()
{
- return readOnly;
+ return accessMode;
}
public String getType()
{
return type;
}
+
+ public int getScope()
+ {
+ return scope;
+ }
}
Modified:
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml 2007-04-27
12:28:37 UTC (rev 7102)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml 2007-04-27
12:54:42 UTC (rev 7103)
@@ -12,6 +12,7 @@
<th>Name</th>
<th>Key</th>
<th>Value</th>
+ <th>Inherited</th>
<th>Delete</th>
</tr>
</thead>
@@ -27,13 +28,14 @@
<td>
<c:choose>
<c:when
test="#{prop.type=='java.lang.Boolean'}">
- <h:selectBooleanCheckbox
styleClass="portlet-form-button" value="#{prop.value}" />
+ <h:selectBooleanCheckbox
styleClass="portlet-form-button" value="#{prop.value}"
readonly="#{prop.readOnly}"/>
</c:when>
<c:otherwise>
- <h:inputText styleClass="portlet-form-input-field"
value="#{prop.value}" />
+ <h:inputText styleClass="portlet-form-input-field"
value="#{prop.value}" readonly="#{prop.readOnly}"/>
</c:otherwise>
</c:choose>
</td>
+ <td>#{prop.inherited ? 'Yes' : 'No'}</td>
<td>
<h:commandLink
action="#{propertyAction.removeProperty}">
<h:outputText>Delete</h:outputText>