Author: julien_viet
Date: 2010-01-26 13:03:45 -0500 (Tue, 26 Jan 2010)
New Revision: 1448
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentHandle.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/metadata/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java
Removed:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Container.java
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIGroupManagement.java
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiApplication.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Component.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIBreadcumbs.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java
portal/trunk/webui/core/src/main/resources/binding.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/UIComponentFactory.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java
Log:
- make Component (config) immutable so it can be easily referenced during the
serialization of UIComponent
- make the template override for the components UIPortalNavigation, UIPortalNavigation2,
UISiteMapPortlet, UIBreadcumbsPortlet at the component level
- better serialize UIComponents
- introduce ComponentMetaData that takes XML configuration and create immutable Component
objects
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIGroupManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIGroupManagement.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIGroupManagement.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -62,7 +62,7 @@
public UIGroupManagement() throws Exception
{
UIBreadcumbs uiBreadcum = addChild(UIBreadcumbs.class, null,
"BreadcumbsGroupManagement");
-
uiBreadcum.getComponentConfig().setTemplate("system:/groovy/webui/core/UIBreadcumbs.gtmpl");
+ uiBreadcum.setTemplate("system:/groovy/webui/core/UIBreadcumbs.gtmpl");
addChild(UIGroupExplorer.class, null, null);
addChild(UIGroupDetail.class, null, null);
uiBreadcum.setBreadcumbsStyle("UIExplorerHistoryPath");
Modified:
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java
===================================================================
---
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIBreadcumbsPortlet.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -59,7 +59,7 @@
String template = prefers.getValue("template",
"system:/groovy/webui/core/UIBreadcumbs.gtmpl");
UIBreadcumbs uiBreadCumbs = addChild(UIBreadcumbs.class, null, null);
- uiBreadCumbs.getComponentConfig().setTemplate(template);
+ uiBreadCumbs.setTemplate(template);
}
public void loadSelectedPath()
Modified:
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java
===================================================================
---
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UINavigationPortlet.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -46,7 +46,7 @@
UIPortalNavigation portalNavigation = addChild(UIPortalNavigation.class,
"UIHorizontalNavigation", null);
portalNavigation.setUseAjax(Boolean.valueOf(prefers.getValue("useAJAX",
"true")));
portalNavigation.setShowUserNavigation(Boolean.valueOf(prefers.getValue("showUserNavigation",
"true")));
- portalNavigation.getComponentConfig().setTemplate(template);
+ portalNavigation.setTemplate(template);
portalNavigation.setCssClassName(prefers.getValue("CSSClassName",
""));
}
Modified:
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java
===================================================================
---
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -45,6 +45,6 @@
UIPortalNavigation2 portalNavigation = addChild(UIPortalNavigation2.class,
"UIHorizontalNavigation", null);
portalNavigation.setUseAjax(Boolean.valueOf(prefers.getValue("useAJAX",
"true")));
- portalNavigation.getComponentConfig().setTemplate(template);
+ portalNavigation.setTemplate(template);
}
}
\ No newline at end of file
Modified:
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java
===================================================================
---
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -58,7 +58,7 @@
UIPortalNavigation uiPortalNavigation = addChild(UIPortalNavigation.class,
"UISiteMap", null);
uiPortalNavigation.loadTreeNodes();
- uiPortalNavigation.getComponentConfig().setTemplate(template);
+ uiPortalNavigation.setTemplate(template);
}
public boolean isUseAjax()
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -19,19 +19,16 @@
package org.exoplatform.webui.application;
-import org.exoplatform.webui.config.Component;
-import org.exoplatform.webui.config.Event;
-import org.exoplatform.webui.config.EventInterceptor;
-import org.exoplatform.webui.config.InitParams;
-import org.exoplatform.webui.config.Param;
-import org.exoplatform.webui.config.Validator;
-import org.exoplatform.webui.config.WebuiConfiguration;
+import org.exoplatform.webui.config.*;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.config.annotation.EventInterceptorConfig;
import org.exoplatform.webui.config.annotation.ParamConfig;
import org.exoplatform.webui.config.annotation.ValidatorConfig;
+import org.exoplatform.webui.config.metadata.ComponentMetaData;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.jibx.runtime.BindingDirectory;
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IUnmarshallingContext;
@@ -60,6 +57,10 @@
*/
private Map<String, Component> configs_ = new HashMap<String,
Component>();
+ /** The logger. */
+ private final Logger log;
+
+ /** . */
private org.exoplatform.webui.config.Application application_;
/**
@@ -68,6 +69,9 @@
*/
public ConfigurationManager(InputStream inputStream) throws Exception
{
+ // Logger first
+ log = LoggerFactory.getLogger(ConfigurationManager.class);
+
IBindingFactory bfact = BindingDirectory.getFactory(WebuiConfiguration.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
WebuiConfiguration config = (WebuiConfiguration)uctx.unmarshalDocument(inputStream,
null);
@@ -83,14 +87,14 @@
}
if (config.getComponents() != null)
{
- for (Component component : config.getComponents())
+ for (ComponentMetaData componentMetaData : config.getComponents())
{
- String key = component.getType();
- if (component.getId() != null)
+ String key = componentMetaData.getType();
+ if (componentMetaData.getId() != null)
{
- key = key + ":" + component.getId();
+ key = key + ":" + componentMetaData.getId();
}
- configs_.put(key, component);
+ configs_.put(key, new Component(componentMetaData));
}
}
@@ -106,12 +110,7 @@
{
for (Component component : configs)
{
- String key = component.getType();
- if (component.getId() != null)
- {
- key = key + ":" + component.getId();
- }
- configs_.put(key, component);
+ configs_.put(component.getKey(), component);
}
}
@@ -136,6 +135,38 @@
return configs;
}
+ public Component getComponentConfig(ComponentHandle handle)
+ {
+ Component component = configs_.get(handle.getKey());
+
+ //
+ if (component == null)
+ {
+ Class<?> owner = handle.getOwner();
+ process(owner);
+ }
+
+ //
+ return configs_.get(handle.getKey());
+ }
+
+ private void process(Class<?> owner)
+ {
+ if (owner == null)
+ {
+ throw new NullPointerException("Cannot process a null owner");
+ }
+ try
+ {
+ Component[] components = annotationToComponents(owner);
+ setComponentConfigs(components);
+ }
+ catch (Exception e)
+ {
+ log.error("Could not create component configuration for owner " +
owner.getName(), e);
+ }
+ }
+
/**
* Gets a component of a given class and identified by id
*
@@ -150,21 +181,19 @@
{
key = key + ":" + id;
}
+
+ //
Component config = configs_.get(key);
if (config != null)
{
return config;
}
- try
- {
- Component[] components = annotationToComponents(type);
- setComponentConfigs(components);
- return configs_.get(key);
- }
- catch (Exception e)
- {
- return null;
- }
+
+ //
+ process(type);
+
+ //
+ return configs_.get(key);
}
public org.exoplatform.webui.config.Application getApplication()
@@ -218,28 +247,37 @@
private Component toComponentConfig(ComponentConfig annotation, Class<?> clazz)
throws Exception
{
- Component config = new Component();
+ String template = null;
+ if (annotation.template().length() > 0)
+ {
+ template = annotation.template();
+ }
+
+ //
+ String id = null;
if (annotation.id().length() > 0)
{
- config.setId(annotation.id());
+ id = annotation.id();
}
+ //
Class<?> type = annotation.type() == void.class ? clazz : annotation.type();
- config.setType(type.getName());
- if (annotation.template().length() > 0)
- {
- config.setTemplate(annotation.template());
- }
+
+ //
+ String lifecycle = null;
if (annotation.lifecycle() != void.class)
{
- config.setLifecycle(annotation.lifecycle().getName());
+ lifecycle = annotation.lifecycle().getName();
}
+
+ //
+ String decorator = null;
if (annotation.decorator().length() > 0)
{
- config.setDecorator(annotation.decorator());
+ decorator = annotation.decorator();
}
- config.setInitParams(toInitParams(annotation.initParams()));
+ //
EventConfig[] eventAnnotations = annotation.events();
ArrayList<Event> events;
if (eventAnnotations.length != 0)
@@ -254,8 +292,8 @@
{
events = new ArrayList<Event>();
}
- config.setEvents(events);
+ //
EventInterceptorConfig[] eventInterceptorAnnotations =
annotation.eventInterceptors();
ArrayList<EventInterceptor> eventInterceptors;
if (eventInterceptorAnnotations.length != 0)
@@ -270,8 +308,8 @@
{
eventInterceptors = new ArrayList<EventInterceptor>();
}
- config.setEventInterceptors(eventInterceptors);
+ //
ValidatorConfig[] validatorAnnotations = annotation.validators();
ArrayList<Validator> validators;
if (validatorAnnotations.length != 0)
@@ -286,9 +324,19 @@
{
validators = new ArrayList<Validator>();
}
- config.setValidators(validators);
- return config;
+ //
+ return new Component(
+ clazz,
+ id,
+ type.getName(),
+ lifecycle,
+ template,
+ decorator,
+ toInitParams(annotation.initParams()),
+ validators,
+ events,
+ eventInterceptors);
}
private Event toEventConfig(EventConfig annotation) throws Exception
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiApplication.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiApplication.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiApplication.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -110,6 +110,7 @@
throw new Exception("Cannot find the configuration for the component "
+ type.getName() + ", configId "
+ configId);
}
+ System.out.println("Created component " + type.getName() + " with
configId=" + configId + " and id=" + id + " and config=" +
config);
T uicomponent = Util.createObject(type, config.getInitParams());
uicomponent.setComponentConfig(id, config);
return uicomponent;
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/replication/model/TypeDomain.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -26,6 +26,8 @@
import
org.exoplatform.webui.application.replication.model.metadata.ConvertedTypeMetaData;
import org.exoplatform.webui.application.replication.model.metadata.DomainMetaData;
import org.exoplatform.webui.application.replication.model.metadata.TypeMetaData;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import java.io.Serializable;
import java.lang.reflect.Field;
@@ -42,6 +44,9 @@
{
/** . */
+ private static final Logger log = LoggerFactory.getLogger(TypeDomain.class);
+
+ /** . */
private static final Map<Class<?>, Class<?>> primitiveToWrapperMap =
new HashMap<Class<?>, Class<?>>();
static
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Component.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Component.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Component.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -20,6 +20,8 @@
package org.exoplatform.webui.config;
import org.exoplatform.webui.Util;
+import org.exoplatform.webui.application.replication.api.annotations.Converted;
+import org.exoplatform.webui.config.metadata.ComponentMetaData;
import org.exoplatform.webui.core.lifecycle.Lifecycle;
import org.exoplatform.webui.event.EventListener;
@@ -29,123 +31,148 @@
import java.util.Map;
/** Created by The eXo Platform SARL Author : Tuan Nguyen tuan08(a)users.sourceforge.net
May 4, 2006 */
+(a)Converted(ComponentConfigConverter.class)
public class Component
{
- private String id;
+ final ComponentHandle handle;
- private String type;
+ private final String id;
- private String lifecycle;
+ private final String type;
- private String template;
+ private final String lifecycle;
- private String decorator;
+ private final String template;
- private InitParams initParams;
+ private final String decorator;
- // Note: Specific List implementations are required by JiBX :/
+ private final InitParams initParams;
- private ArrayList<Validator> validators;
+ private final List<Validator> validators;
- private ArrayList<Event> events;
+ private final List<Event> events;
- private ArrayList<EventInterceptor> eventInterceptors;
+ private final List<EventInterceptor> eventInterceptors;
- transient private Map<String, Event> eventMap;
+ private Map<String, Event> eventMap;
- transient private Lifecycle componentLifecycle;
+ private Lifecycle componentLifecycle;
- public String getId()
+ public Component(ComponentMetaData metaData)
{
- return id;
+ this(
+ new ComponentHandle(null, metaData.getId() == null ? metaData.getType() :
metaData.getType() + metaData.getId()),
+ metaData.getId(),
+ metaData.getType(),
+ metaData.getLifecycle(),
+ metaData.getTemplate(),
+ metaData.getDecorator(),
+ metaData.getInitParams(),
+ metaData.getValidators(),
+ metaData.getEvents(),
+ metaData.getEventInterceptors());
}
- public String getType()
+ public Component(
+ Class<?> owner,
+ String id,
+ String type,
+ String lifecycle,
+ String template,
+ String decorator,
+ InitParams initParams,
+ List<Validator> validators,
+ List<Event> events,
+ List<EventInterceptor> eventInterceptors)
{
- return type;
+ this(
+ new ComponentHandle(owner, id == null ? type : type + ":" + id),
+ id,
+ type,
+ lifecycle,
+ template,
+ decorator,
+ initParams,
+ validators,
+ events,
+ eventInterceptors);
}
- public String getLifecycle()
+ private Component(
+ ComponentHandle handle,
+ String id,
+ String type,
+ String lifecycle,
+ String template,
+ String decorator,
+ InitParams initParams,
+ List<Validator> validators,
+ List<Event> events,
+ List<EventInterceptor> eventInterceptors)
{
- return lifecycle;
+ this.handle = handle;
+ this.id = id;
+ this.type = type;
+ this.lifecycle = lifecycle;
+ this.template = template;
+ this.decorator = decorator;
+ this.initParams = initParams;
+ this.validators = validators;
+ this.events = events;
+ this.eventInterceptors = eventInterceptors;
}
- public String getTemplate()
+ public String getKey()
{
- return template;
+ return handle.getKey();
}
- public String getDecorator()
+ public String getId()
{
- return decorator;
+ return id;
}
- public void setId(String id)
+ public String getType()
{
- this.id = id;
+ return type;
}
- public void setType(String type)
+ public String getLifecycle()
{
- this.type = type;
+ return lifecycle;
}
- public void setLifecycle(String lifecycle)
+ public String getTemplate()
{
- this.lifecycle = lifecycle;
+ return template;
}
- public void setTemplate(String template)
+ public String getDecorator()
{
- this.template = template;
+ return decorator;
}
- public void setDecorator(String decorator)
- {
- this.decorator = decorator;
- }
-
public InitParams getInitParams()
{
return initParams;
}
- public void setInitParams(InitParams initParams)
+ public List<Validator> getValidators()
{
- this.initParams = initParams;
- }
-
- public ArrayList<Validator> getValidators()
- {
return validators;
}
- public void setValidators(ArrayList<Validator> validators)
+ public List<Event> getEvents()
{
- this.validators = validators;
- }
-
- public ArrayList<Event> getEvents()
- {
return events;
}
- public void setEvents(ArrayList<Event> events)
+ public List<EventInterceptor> getEventInterceptors()
{
- this.events = events;
- }
-
- public ArrayList<EventInterceptor> getEventInterceptors()
- {
return eventInterceptors;
}
- public void setEventInterceptors(ArrayList<EventInterceptor> events)
- {
- eventInterceptors = events;
- }
-
public Event getUIComponentEventConfig(String eventName) throws Exception
{
if (eventMap != null)
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.config;
+
+import org.exoplatform.webui.application.ConfigurationManager;
+import org.exoplatform.webui.application.WebuiApplication;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.replication.api.TypeConverter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ComponentConfigConverter extends TypeConverter<Component,
ComponentHandle>
+{
+
+ @Override
+ public ComponentHandle write(Component external) throws Exception
+ {
+ return external.handle;
+ }
+
+ @Override
+ public Component read(ComponentHandle internal) throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ WebuiApplication webuiApp = (WebuiApplication)context.getApplication();
+ ConfigurationManager configMgr = webuiApp.getConfigurationManager();
+ return configMgr.getComponentConfig(internal);
+ }
+}
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentHandle.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentHandle.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentHandle.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.config;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ComponentHandle implements Serializable
+{
+
+ /** The owner type of the component that may be null if no owner exists. */
+ private final Class<?> owner;
+
+ /** The component key. */
+ private final String key;
+
+ public ComponentHandle(Class<?> owner, String key)
+ {
+ this.owner = owner;
+ this.key = key;
+ }
+
+ public Class<?> getOwner()
+ {
+ return owner;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Container.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Container.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Container.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -1,74 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.webui.config;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Author : Nhu Dinh Thuan
- * nhudinhthuan(a)yahoo.com
- * May 19, 2006
- */
-public class Container extends Component
-{
-
- protected String title;
-
- protected List<Component> children = new ArrayList<Component>(5);
-
- public String getTitle()
- {
- return title;
- }
-
- public void setTitle(String s)
- {
- title = s;
- }
-
- public List getChildren()
- {
- return children;
- }
-
- @SuppressWarnings("unchecked")
- public void setChildren(List l)
- {
- children = l;
- }
-
- public void addChild(Component comp)
- {
- children.add(comp);
- }
-
- public void addComponent(Component comp)
- {
- children.add(comp);
- }
-
- public Iterator<Component> getChildIterator()
- {
- return children.iterator();
- }
-
-}
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -19,6 +19,8 @@
package org.exoplatform.webui.config;
+import org.exoplatform.webui.config.metadata.ComponentMetaData;
+
import java.util.ArrayList;
/**
@@ -30,7 +32,7 @@
private ArrayList<String> annotationClasses;
- private ArrayList<Component> components;
+ private ArrayList<ComponentMetaData> components;
private Application application;
@@ -39,7 +41,7 @@
return annotationClasses;
}
- public ArrayList<Component> getComponents()
+ public ArrayList<ComponentMetaData> getComponents()
{
return components;
}
Added:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java
(rev 0)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -0,0 +1,140 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.webui.config.metadata;
+
+import org.exoplatform.webui.config.Event;
+import org.exoplatform.webui.config.EventInterceptor;
+import org.exoplatform.webui.config.InitParams;
+import org.exoplatform.webui.config.Validator;
+
+import java.util.ArrayList;
+
+/** Created by The eXo Platform SARL Author : Tuan Nguyen tuan08(a)users.sourceforge.net
May 4, 2006 */
+public class ComponentMetaData
+{
+
+ private String id;
+
+ private String type;
+
+ private String lifecycle;
+
+ private String template;
+
+ private String decorator;
+
+ private InitParams initParams;
+
+ private ArrayList<Validator> validators;
+
+ private ArrayList<Event> events;
+
+ private ArrayList<EventInterceptor> eventInterceptors;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public String getLifecycle()
+ {
+ return lifecycle;
+ }
+
+ public String getTemplate()
+ {
+ return template;
+ }
+
+ public String getDecorator()
+ {
+ return decorator;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public void setLifecycle(String lifecycle)
+ {
+ this.lifecycle = lifecycle;
+ }
+
+ public void setTemplate(String template)
+ {
+ this.template = template;
+ }
+
+ public void setDecorator(String decorator)
+ {
+ this.decorator = decorator;
+ }
+
+ public InitParams getInitParams()
+ {
+ return initParams;
+ }
+
+ public void setInitParams(InitParams initParams)
+ {
+ this.initParams = initParams;
+ }
+
+ public ArrayList<Validator> getValidators()
+ {
+ return validators;
+ }
+
+ public void setValidators(ArrayList<Validator> validators)
+ {
+ this.validators = validators;
+ }
+
+ public ArrayList<Event> getEvents()
+ {
+ return events;
+ }
+
+ public void setEvents(ArrayList<Event> events)
+ {
+ this.events = events;
+ }
+
+ public ArrayList<EventInterceptor> getEventInterceptors()
+ {
+ return eventInterceptors;
+ }
+
+ public void setEventInterceptors(ArrayList<EventInterceptor> events)
+ {
+ eventInterceptors = events;
+ }
+}
\ No newline at end of file
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIBreadcumbs.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIBreadcumbs.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIBreadcumbs.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -59,6 +59,22 @@
*/
private String styleBread = "default";
+ /**
+ * The runtime template.
+ */
+ private String template;
+
+ @Override
+ public String getTemplate()
+ {
+ return template != null ? template : super.getTemplate();
+ }
+
+ public void setTemplate(String template)
+ {
+ this.template = template;
+ }
+
public List<LocalPath> getPath()
{
return path_;
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -58,10 +58,8 @@
protected UIComponent uiparent;
- private String configId;
+ protected Component config;
- protected transient Component config;
-
private transient ValueRendererRegistry rendererRegistry = new
ValueRendererRegistry();
private static final Lifecycle DEFAULT_LIFECYCLE = new Lifecycle();
@@ -183,7 +181,6 @@
public void setComponentConfig(String componentId, Component config) throws Exception
{
this.config = config;
- this.configId = config.getId();
if (componentId == null || componentId.length() == 0)
{
componentId = config.getId();
Modified: portal/trunk/webui/core/src/main/resources/binding.xml
===================================================================
--- portal/trunk/webui/core/src/main/resources/binding.xml 2010-01-26 10:23:31 UTC (rev
1447)
+++ portal/trunk/webui/core/src/main/resources/binding.xml 2010-01-26 18:03:45 UTC (rev
1448)
@@ -55,7 +55,7 @@
<!-- component object mapping -->
- <mapping name="ui-component-config"
class="org.exoplatform.webui.config.Component">
+ <mapping name="ui-component-config"
class="org.exoplatform.webui.config.metadata.ComponentMetaData">
<value name="id" field="id" style="attribute"
usage="optional" />
<value name="type" field="type" />
<value name="lifecycle" field="lifecycle"
usage="optional" />
@@ -93,7 +93,7 @@
<value name="class" style="element"/>
</collection>
- <collection item-type="org.exoplatform.webui.config.Component"
+ <collection
item-type="org.exoplatform.webui.config.metadata.ComponentMetaData"
field="components" usage="optional" />
<structure usage="optional" field="application"/>
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/UIComponentFactory.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/UIComponentFactory.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/replication/UIComponentFactory.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -38,8 +38,6 @@
public class UIComponentFactory extends ObjectFactory<UIComponent>
{
-
-
private <S extends UIComponent> Object getFieldValue(String fieldName,
Map<FieldModel<? super S, ?>, ?> state)
{
for (Map.Entry<FieldModel<? super S, ?>, ?> entry : state.entrySet())
@@ -56,30 +54,12 @@
@Override
public <S extends UIComponent> S create(Class<S> type,
Map<FieldModel<? super S, ?>, ?> state) throws CreateException
{
- // Get config id
- String configId = (String)getFieldValue("configId", state);
- String id = (String)getFieldValue("id", state);
-
//
try
{
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- WebuiApplication webuiApp = (WebuiApplication) context.getApplication();
- ConfigurationManager configMgr = webuiApp.getConfigurationManager();
- Component config = configMgr.getComponentConfig(type, configId);
+ Component config = (Component)getFieldValue("config", state);
- //
- S instance;
- if (config != null)
- {
- instance = Util.createObject(type, config.getInitParams());
- instance.setComponentConfig(id, config);
- }
- else
- {
- instance = Util.createObject(type, null);
- instance.setId(id);
- }
+ S instance = Util.createObject(type, config != null ? config.getInitParams() :
null);
// Now set state
for (Map.Entry<FieldModel<? super S, ?>, ?> entry :
state.entrySet())
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -52,6 +52,19 @@
private String cssClassName = "";
+ private String template;
+
+ @Override
+ public String getTemplate()
+ {
+ return template != null ? template : super.getTemplate();
+ }
+
+ public void setTemplate(String template)
+ {
+ this.template = template;
+ }
+
public UIComponent getViewModeUIComponent()
{
return null;
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java 2010-01-26
10:23:31 UTC (rev 1447)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java 2010-01-26
18:03:45 UTC (rev 1448)
@@ -40,6 +40,19 @@
protected Object selectedParent_;
+ private String template;
+
+ @Override
+ public String getTemplate()
+ {
+ return template != null ? template : super.getTemplate();
+ }
+
+ public void setTemplate(String template)
+ {
+ this.template = template;
+ }
+
public UIComponent getViewModeUIComponent()
{
return null;