Author: julien_viet
Date: 2010-07-22 06:34:44 -0400 (Thu, 22 Jul 2010)
New Revision: 3676
Added:
portal/trunk/webui/framework/
portal/trunk/webui/framework/pom.xml
portal/trunk/webui/framework/src/
portal/trunk/webui/framework/src/main/
portal/trunk/webui/framework/src/main/java/
portal/trunk/webui/framework/src/main/java/org/
portal/trunk/webui/framework/src/main/java/org/exoplatform/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/Util.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/StateManager.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiApplication.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Application.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentHandle.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Event.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/EventInterceptor.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/InitParams.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Param.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Validator.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfig.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfigs.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventConfig.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventInterceptorConfig.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ParamConfig.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ValidatorConfig.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/metadata/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIContainer.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/Event.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/EventListener.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/MonitorEvent.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/exception/
portal/trunk/webui/framework/src/main/resources/
portal/trunk/webui/framework/src/main/resources/binding.xml
Removed:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/Util.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/StateManager.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/WebuiRequestContext.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Application.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/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/Event.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/EventInterceptor.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/InitParams.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Param.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Validator.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/annotation/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/metadata/
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIApplication.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIContainer.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/Event.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/EventListener.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/MonitorEvent.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/exception/
portal/trunk/webui/core/src/main/resources/binding.xml
Modified:
portal/trunk/component/management/
portal/trunk/component/test/
portal/trunk/component/test/core/
portal/trunk/component/test/jcr/
portal/trunk/component/test/organization/
portal/trunk/examples/portlets/
portal/trunk/examples/portlets/jsfhellouser/
portal/trunk/examples/portlets/jsphellouser/
portal/trunk/examples/portlets/simplesthelloworld/
portal/trunk/examples/portlets/struts-jpetstore/
portal/trunk/examples/skins/
portal/trunk/examples/skins/simpleskin/
portal/trunk/packaging/jboss-as/ear/pom.xml
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
portal/trunk/pom.xml
portal/trunk/testsuite/
portal/trunk/testsuite/selenium-snifftests/
portal/trunk/testsuite/webuibasedsamples/
portal/trunk/webui/core/pom.xml
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
portal/trunk/webui/pom.xml
Log:
GTNPORTAL-1369: Decouple webui base framework from the core webui module
Property changes on: portal/trunk/component/management
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/component/test
___________________________________________________________________
Name: svn:ignore
+ *.iml
Property changes on: portal/trunk/component/test/core
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/component/test/jcr
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/component/test/organization
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/examples/portlets
___________________________________________________________________
Name: svn:ignore
+ *.iml
Property changes on: portal/trunk/examples/portlets/jsfhellouser
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/examples/portlets/jsphellouser
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/examples/portlets/simplesthelloworld
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Property changes on: portal/trunk/examples/portlets/struts-jpetstore
___________________________________________________________________
Name: svn:ignore
+ target
*.iml
Property changes on: portal/trunk/examples/skins
___________________________________________________________________
Name: svn:ignore
+ *.iml
Property changes on: portal/trunk/examples/skins/simpleskin
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Modified: portal/trunk/packaging/jboss-as/ear/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as/ear/pom.xml 2010-07-22 08:00:54 UTC (rev 3675)
+++ portal/trunk/packaging/jboss-as/ear/pom.xml 2010-07-22 10:34:44 UTC (rev 3676)
@@ -128,6 +128,10 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.framework</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.webui.portal</artifactId>
</dependency>
<dependency>
Modified: portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
---
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js 2010-07-22
10:34:44 UTC (rev 3676)
@@ -136,9 +136,13 @@
addDependency(new Project("com.sun.xml.stream", "sjsxp",
"jar", "1.0"));
module.webui = {};
+ module.webui.framework =
+ new Project("org.exoplatform.portal",
"exo.portal.webui.framework", "jar", module.version).
+ addDependency(module.component.web);
+
module.webui.core =
new Project("org.exoplatform.portal", "exo.portal.webui.core",
"jar", module.version).
- addDependency(module.component.web);
+ addDependency(module.webui.framework);
module.webui.eXo =
new Project("org.exoplatform.portal", "exo.portal.webui.eXo",
"jar", module.version).
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-07-22 08:00:54 UTC (rev 3675)
+++ portal/trunk/pom.xml 2010-07-22 10:34:44 UTC (rev 3676)
@@ -422,6 +422,11 @@
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.framework</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.webui.portal</artifactId>
<version>3.2.0-Beta01-SNAPSHOT</version>
</dependency>
Property changes on: portal/trunk/testsuite
___________________________________________________________________
Name: svn:ignore
+ *.iml
Property changes on: portal/trunk/testsuite/selenium-snifftests
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
profiles.xml
+ *.iml
target
.classpath
.project
profiles.xml
Property changes on: portal/trunk/testsuite/webuibasedsamples
___________________________________________________________________
Name: svn:ignore
- target
+ *.iml
target
Modified: portal/trunk/webui/core/pom.xml
===================================================================
--- portal/trunk/webui/core/pom.xml 2010-07-22 08:00:54 UTC (rev 3675)
+++ portal/trunk/webui/core/pom.xml 2010-07-22 10:34:44 UTC (rev 3676)
@@ -34,7 +34,7 @@
<dependencies>
<dependency>
<groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.web</artifactId>
+ <artifactId>exo.portal.webui.framework</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
@@ -50,36 +50,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jibx</groupId>
- <artifactId>maven-jibx-plugin</artifactId>
- <version>${org.jibx.version}</version>
- <configuration>
- <directory>src/main/resources</directory>
- <includes>
- <includes>binding.xml</includes>
- </includes>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>bind</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
Deleted: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/Util.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/Util.java 2010-07-22
08:00:54 UTC (rev 3675)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/Util.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,68 +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;
-
-import org.exoplatform.webui.config.InitParams;
-
-/**
- * Created by The eXo Platform SAS
- * May 10, 2006
- *
- * A utility class that provides static methods to create new objects, of a given type
- */
-public class Util
-{
- /**
- * The default parameters given to the constructor
- */
- static Class<?>[] CONSTRUCTOR_PARAMS = {InitParams.class};
-
- /**
- *
- * @param type The type of the object to create, given as a String
- * @param params The parameters to give to the constructor
- * @return A new object of the given type
- * @throws Exception
- */
- static public Object createObject(String type, InitParams params) throws Exception
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Class<?> clazz = cl.loadClass(type);
- return createObject(clazz, params);
- }
-
- /**
- *
- * @param <T> The type of the object to create
- * @param type The type parameter given as a Class object
- * @param params The parameters to give to the constructor
- * @return The object of type T
- * @throws Exception
- */
- static public <T> T createObject(Class<T> type, InitParams params) throws
Exception
- {
- if (params == null)
- {
- return type.getConstructor().newInstance();
- }
- Object[] args = {params};
- return type.getConstructor(CONSTRUCTOR_PARAMS).newInstance(args);
- }
-}
Deleted:
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-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,408 +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.application;
-
-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;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * May 10, 2006
- * <p/>
- * Manages the ComponentConfig of a list of components.
- *
- * @see ComponentConfig
- */
-public class ConfigurationManager
-{
- /**
- * todo (julien) : this map should be synchronized somehow
- * <p/>
- * The components of which we manage the configuration
- */
- private Map<String, Component> configs_ = new HashMap<String,
Component>();
-
- /** The logger. */
- private final Logger log;
-
- /** . */
- private org.exoplatform.webui.config.Application application_;
-
- /**
- * @param inputStream A stream that links the configuration file
- * @throws Exception
- */
- 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);
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (config.getAnnotationClasses() != null)
- {
- for (String annotationClass : config.getAnnotationClasses())
- {
- //process annotation and get the Component
- Component[] components = annotationToComponents(cl, annotationClass);
- setComponentConfigs(components);
- }
- }
- if (config.getComponents() != null)
- {
- for (ComponentMetaData componentMetaData : config.getComponents())
- {
- String key = componentMetaData.getType();
- if (componentMetaData.getId() != null)
- {
- key = key + ":" + componentMetaData.getId();
- }
- configs_.put(key, new Component(componentMetaData));
- }
- }
-
- application_ = config.getApplication();
- }
-
- /**
- * Adds components to the list
- *
- * @param configs An array of Component
- */
- void setComponentConfigs(Component[] configs)
- {
- for (Component component : configs)
- {
- configs_.put(component.getKey(), component);
- }
- }
-
- /**
- * Gets the components of a given class
- *
- * @param clazz The class of the components
- * @return the list of components
- */
- public List<Component> getComponentConfig(Class<?> clazz)
- {
- List<Component> configs = new ArrayList<Component>();
- Collection<Component> values = configs_.values();
- String type = clazz.getName();
- for (Component comp : values)
- {
- if (comp.getType().equals(type))
- {
- configs.add(comp);
- }
- }
- 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
- *
- * @param type The class of the component
- * @param id The id of the component
- * @return The component
- */
- public Component getComponentConfig(Class<?> type, String id)
- {
- String key = type.getName();
- if (id != null)
- {
- key = key + ":" + id;
- }
-
- //
- Component config = configs_.get(key);
- if (config != null)
- {
- return config;
- }
-
- //
- process(type);
-
- //
- return configs_.get(key);
- }
-
- public org.exoplatform.webui.config.Application getApplication()
- {
- return application_;
- }
-
- /**
- * Gets an array of Component from a ComponentConfig annotation
- *
- * @param cl the classloader to create the annotation
- * @param annClass the annotation class
- * @return The array of Component
- * @throws Exception
- */
- Component[] annotationToComponents(ClassLoader cl, String annClass) throws Exception
- {
- Class<?> clazz = cl.loadClass(annClass);
- return annotationToComponents(clazz);
- }
-
- /**
- * Gets an array of Component from a ComponentConfig annotation
- *
- * @param clazz The annotation class from which to get the ComponentConfig
- * @return The array of Component
- * @throws Exception
- */
- Component[] annotationToComponents(Class<?> clazz) throws Exception
- {
- ComponentConfig annotation = clazz.getAnnotation(ComponentConfig.class);
- if (annotation != null)
- {
- return new Component[]{toComponentConfig(annotation, clazz)};
- }
-
- ComponentConfigs annotations = clazz.getAnnotation(ComponentConfigs.class);
- if (annotations != null)
- {
- ComponentConfig[] listAnnotations = annotations.value();
- Component[] componentConfigs = new Component[listAnnotations.length];
- for (int i = 0; i < componentConfigs.length; i++)
- {
- componentConfigs[i] = toComponentConfig(listAnnotations[i], clazz);
- }
- return componentConfigs;
- }
-
- return new Component[]{};
- }
-
- private Component toComponentConfig(ComponentConfig annotation, Class<?> clazz)
throws Exception
- {
- String template = null;
- if (annotation.template().length() > 0)
- {
- template = annotation.template();
- }
-
- //
- String id = null;
- if (annotation.id().length() > 0)
- {
- id = annotation.id();
- }
-
- //
- Class<?> type = annotation.type() == void.class ? clazz : annotation.type();
-
- //
- String lifecycle = null;
- if (annotation.lifecycle() != void.class)
- {
- lifecycle = annotation.lifecycle().getName();
- }
-
- //
- String decorator = null;
- if (annotation.decorator().length() > 0)
- {
- decorator = annotation.decorator();
- }
-
- //
- EventConfig[] eventAnnotations = annotation.events();
- ArrayList<Event> events;
- if (eventAnnotations.length != 0)
- {
- events = new ArrayList<Event>();
- for (EventConfig eventAnnotation : eventAnnotations)
- {
- events.add(toEventConfig(eventAnnotation));
- }
- }
- else
- {
- events = new ArrayList<Event>();
- }
-
- //
- EventInterceptorConfig[] eventInterceptorAnnotations =
annotation.eventInterceptors();
- ArrayList<EventInterceptor> eventInterceptors;
- if (eventInterceptorAnnotations.length != 0)
- {
- eventInterceptors = new ArrayList<EventInterceptor>();
- for (EventInterceptorConfig eventAnnotation : eventInterceptorAnnotations)
- {
- eventInterceptors.add(toEventInterceptorConfig(eventAnnotation));
- }
- }
- else
- {
- eventInterceptors = new ArrayList<EventInterceptor>();
- }
-
- //
- ValidatorConfig[] validatorAnnotations = annotation.validators();
- ArrayList<Validator> validators;
- if (validatorAnnotations.length != 0)
- {
- validators = new ArrayList<Validator>();
- for (ValidatorConfig ele : validatorAnnotations)
- {
- validators.add(toValidator(ele));
- }
- }
- else
- {
- validators = new ArrayList<Validator>();
- }
-
- //
- return new Component(
- clazz,
- id,
- type.getName(),
- lifecycle,
- template,
- decorator,
- toInitParams(annotation.initParams()),
- validators,
- events,
- eventInterceptors);
- }
-
- private Event toEventConfig(EventConfig annotation) throws Exception
- {
- Event event = new Event();
- event.setExecutionPhase(annotation.phase());
- event.setConfirm(annotation.confirm());
- event.setInitParams(toInitParams(annotation.initParams()));
- ArrayList<String> listeners = new ArrayList<String>();
- for (Class<?> clazz : annotation.listeners())
- {
- listeners.add(clazz.getName());
- }
- if (annotation.name().length() > 0)
- {
- event.setName(annotation.name());
- }
- else if (annotation.listeners().length > 0)
- {
- String name = annotation.listeners()[0].getSimpleName();
- int idx = name.indexOf("ActionListener");
- if (idx > -1)
- {
- name = name.substring(0, idx);
- }
- event.setName(name);
- }
- event.setListeners(listeners);
- return event;
- }
-
- private EventInterceptor toEventInterceptorConfig(EventInterceptorConfig annotation)
throws Exception
- {
- EventInterceptor eventInterceptor = new EventInterceptor();
- eventInterceptor.setType(annotation.type().getName());
- ArrayList<String> list = new ArrayList<String>();
- Collections.addAll(list, annotation.interceptors());
- eventInterceptor.setInterceptors(list);
- eventInterceptor.setInitParams(toInitParams(annotation.initParams()));
- return eventInterceptor;
- }
-
- private Validator toValidator(ValidatorConfig annotation) throws Exception
- {
- Validator validator = new Validator();
- validator.setType(annotation.type().getName());
- validator.setInitParams(toInitParams(annotation.initParams()));
- return validator;
- }
-
- private InitParams toInitParams(ParamConfig[] annotations)
- {
- if (annotations == null || annotations.length < 1)
- {
- return null;
- }
- ArrayList<Param> listParam = new ArrayList<Param>();
- for (ParamConfig ele : annotations)
- {
- Param param = new Param();
- param.setName(ele.name());
- param.setValue(ele.value());
- listParam.add(param);
- }
- InitParams initParams = new InitParams();
- initParams.setParams(listParam);
- return initParams;
- }
-}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/StateManager.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/StateManager.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/StateManager.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,31 +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.application;
-
-import org.exoplatform.webui.core.UIApplication;
-
-abstract public class StateManager
-{
- abstract public UIApplication restoreUIRootComponent(WebuiRequestContext context)
throws Exception;
-
- abstract public void storeUIRootComponent(WebuiRequestContext context) throws
Exception;
-
- abstract public void expire(String sessionId, WebuiApplication app) throws Exception;
-}
\ No newline at end of file
Deleted:
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-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiApplication.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,124 +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.application;
-
-import org.exoplatform.web.application.Application;
-import org.exoplatform.web.application.ApplicationLifecycle;
-import org.exoplatform.webui.Util;
-import org.exoplatform.webui.config.Component;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-
-import java.io.InputStream;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- *Created by The eXo Platform SAS
- * May 7, 2006
- *
- * This abstract class defines several methods to abstract the differnt type of web
application the
- * eXo web framework can provide such as portal or portlet.
- */
-abstract public class WebuiApplication extends Application
-{
-
- private ConfigurationManager configManager_;
-
- private StateManager stateManager_;
-
- /**
- * This initialisation goals is to first extract and parse the webui configuration XML
file
- * defined inside the web.xml of the web application.
- *
- * The ConfigurationManager class is responsible of the parsing and then wrap all the
information
- * about the UI configuration.
- *
- * One of the information is the real implementation of the StateManager object. That
object is
- * extracted from the configuration and stored as a field in that class.
- *
- * Lifecycle phases are also extracted from the XML file, referenced in this
WebuiApplication class
- * and initialized at the same time.
- *
- */
- public void onInit() throws Exception
- {
- String configPath = getApplicationInitParam("webui.configuration");
- InputStream is = getResourceResolver().getInputStream(configPath);
- configManager_ = new ConfigurationManager(is);
- String stateManagerClass = configManager_.getApplication().getStateManager();
- StateManager stManager = (StateManager)Util.createObject(stateManagerClass, null);
- setStateManager(stManager);
- List<ApplicationLifecycle> lifecycleListeners =
- configManager_.getApplication().getApplicationLifecycleListeners();
- setApplicationLifecycle(lifecycleListeners);
- for (ApplicationLifecycle lifecycle : lifecycleListeners)
- lifecycle.onInit(this);
- }
-
- public ConfigurationManager getConfigurationManager()
- {
- return configManager_;
- }
-
- public StateManager getStateManager()
- {
- return stateManager_;
- }
-
- public void setStateManager(StateManager sm)
- {
- stateManager_ = sm;
- }
-
- abstract public String getApplicationInitParam(String name);
-
- public <T> void broadcast(Event<T> event) throws Exception
- {
- List<EventListener> listeners =
configManager_.getApplication().getApplicationEventListeners(event.getName());
- if (listeners == null)
- return;
- for (EventListener<T> listener : listeners)
- listener.execute(event);
- }
-
- public <T extends UIComponent> T createUIComponent(Class<T> type, String
configId, String id,
- WebuiRequestContext context) throws Exception
- {
- Component config = configManager_.getComponentConfig(type, configId);
- if (config == null)
- {
- throw new Exception("Cannot find the configuration for the component "
+ type.getName() + ", configId "
- + configId);
- }
- T uicomponent = Util.createObject(type, config.getInitParams());
- uicomponent.setComponentConfig(id, config);
- return uicomponent;
- }
-
- public Set<UIComponent> getDefaultUIComponentToUpdateByAjax(WebuiRequestContext
context)
- {
- Set<UIComponent> list = new LinkedHashSet<UIComponent>(3);
- list.add(context.getUIApplication());
- return list;
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,200 +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.application;
-
-import org.exoplatform.resolver.ApplicationResourceResolver;
-import org.exoplatform.resolver.ResourceResolver;
-import org.exoplatform.web.application.Application;
-import org.exoplatform.web.application.RequestContext;
-import org.exoplatform.web.application.URLBuilder;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIComponent;
-
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.LinkedHashSet;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-/**
- * Created by The eXo Platform SAS
- * May 7, 2006
- *
- * The main class to manage the request context in a webui environment
- *
- * It adds:
- * - some access to the root UI component (UIApplication)
- * - access to the request and response objects
- * - information about the current state of the request
- * - the list of object to be updated in an AJAX way
- * - an access to the ResourceResolver bound to an uri scheme
- * - the reference on the StateManager object
- */
-abstract public class WebuiRequestContext extends RequestContext
-{
-
- protected UIApplication uiApplication_;
-
- protected String sessionId_;
-
- protected ResourceBundle appRes_;
-
- private StateManager stateManager_;
-
- private boolean responseComplete_ = false;
-
- private boolean processRender_ = false;
-
- private Set<UIComponent> uicomponentToUpdateByAjax;
-
- public WebuiRequestContext(Application app)
- {
- super(app);
- }
-
- public String getSessionId()
- {
- return sessionId_;
- }
-
- protected void setSessionId(String id)
- {
- sessionId_ = id;
- }
-
- public UIApplication getUIApplication()
- {
- return uiApplication_;
- }
-
- public void setUIApplication(UIApplication uiApplication) throws Exception
- {
- uiApplication_ = uiApplication;
- appRes_ = null;
- }
-
- public ResourceBundle getApplicationResourceBundle()
- {
- if (appRes_ == null)
- {
- try
- {
- Locale locale = getLocale();
- appRes_ = getApplication().getResourceBundle(locale);
- }
- catch (Exception e)
- {
- throw new UndeclaredThrowableException(e);
- }
- }
- return appRes_;
- }
-
- public String getActionParameterName()
- {
- return WebuiRequestContext.ACTION;
- }
-
- public String getUIComponentIdParameterName()
- {
- return UIComponent.UICOMPONENT;
- }
-
- @Override
- public abstract URLBuilder<UIComponent> getURLBuilder();
-
- public abstract String getRequestContextPath();
-
- /**
- * Returns the context path of the portal or null if it does not execute in the
context
- * of an aggregated portal request.
- *
- * @return the portal context path
- */
- public abstract String getPortalContextPath();
-
- abstract public <T> T getRequest() throws Exception;
-
- abstract public <T> T getResponse() throws Exception;
-
- public boolean isResponseComplete()
- {
- return responseComplete_;
- }
-
- public void setResponseComplete(boolean b)
- {
- responseComplete_ = b;
- }
-
- abstract public void sendRedirect(String url) throws Exception;
-
- public boolean getProcessRender()
- {
- return processRender_;
- }
-
- public void setProcessRender(boolean b)
- {
- processRender_ = b;
- }
-
- public Set<UIComponent> getUIComponentToUpdateByAjax()
- {
- return uicomponentToUpdateByAjax;
- }
-
- public void addUIComponentToUpdateByAjax(UIComponent uicomponent)
- {
- if (uicomponentToUpdateByAjax == null)
- {
- uicomponentToUpdateByAjax = new LinkedHashSet<UIComponent>();
- }
- uicomponentToUpdateByAjax.add(uicomponent);
- }
-
- public ResourceResolver getResourceResolver(String uri)
- {
- Application app = getApplication();
- while (app != null)
- {
- ApplicationResourceResolver appResolver = app.getResourceResolver();
- ResourceResolver resolver = appResolver.getResourceResolver(uri);
- if (resolver != null)
- return resolver;
- RequestContext pcontext = getParentAppRequestContext();
- if (pcontext != null)
- app = pcontext.getApplication();
- else
- app = null;
- }
- return null;
- }
-
- public StateManager getStateManager()
- {
- return stateManager_;
- }
-
- public void setStateManager(StateManager manager)
- {
- stateManager_ = manager;
- }
-}
\ No newline at end of file
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,16 +1,16 @@
-/**
+/*
* 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
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Application.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Application.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Application.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,121 +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 org.exoplatform.web.application.ApplicationLifecycle;
-import org.exoplatform.webui.Util;
-import org.exoplatform.webui.event.EventListener;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * May 7, 2006
- */
-public class Application
-{
-
- private InitParams initParams;
-
- private String uiroot;
-
- private String stateManager;
-
- public InitParams getInitParams()
- {
- return initParams;
- }
-
- private ArrayList<String> lifecycleListeners;
-
- private ArrayList<Event> events;
-
- transient private Map<String, Event> eventMap;
-
- public String getUIRootComponent()
- {
- return uiroot;
- }
-
- public String getStateManager()
- {
- return stateManager;
- }
-
- public ArrayList<String> getLifecyleListeners()
- {
- return lifecycleListeners;
- }
-
- public ArrayList<Event> getEvents()
- {
- return events;
- }
-
- public Event getApplicationEventConfig(String eventName)
- {
- if (eventMap != null)
- return eventMap.get(eventName);
- eventMap = new HashMap<String, Event>();
- if (events == null)
- return null;
- for (Event event : events)
- {
- eventMap.put(event.getName(), event);
- }
- return eventMap.get(eventName);
- }
-
- public List<EventListener> getApplicationEventListeners(String eventName) throws
Exception
- {
- Event event = getApplicationEventConfig(eventName);
- if (event == null)
- return null;
- List<EventListener> cachedListeners = event.getCachedEventListeners();
- if (cachedListeners != null)
- return cachedListeners;
- cachedListeners = new ArrayList<EventListener>();
- for (String listener : event.getListeners())
- {
- EventListener eventListener = (EventListener)Util.createObject(listener, null);
- cachedListeners.add(eventListener);
- }
- event.setCachedEventListeners(cachedListeners);
- return cachedListeners;
- }
-
- public List<ApplicationLifecycle> getApplicationLifecycleListeners() throws
Exception
- {
- List<ApplicationLifecycle> appLifecycles = new
ArrayList<ApplicationLifecycle>();
- if (lifecycleListeners == null)
- return appLifecycles;
- for (String type : lifecycleListeners)
- {
- ApplicationLifecycle instance = (ApplicationLifecycle)Util.createObject(type,
null);
- appLifecycles.add(instance);
- }
- return appLifecycles;
- }
-}
\ No newline at end of file
Deleted:
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-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Component.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,254 +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 org.exoplatform.webui.Util;
-import org.exoplatform.commons.serialization.api.annotations.Converted;
-import org.exoplatform.webui.config.metadata.ComponentMetaData;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.core.lifecycle.Lifecycle;
-import org.exoplatform.webui.event.EventListener;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-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
-{
-
- final ComponentHandle handle;
-
- private final String id;
-
- private final String type;
-
- private final String lifecycle;
-
- private final String template;
-
- private final String decorator;
-
- private final InitParams initParams;
-
- private final List<Validator> validators;
-
- private final List<Event> events;
-
- private final List<EventInterceptor> eventInterceptors;
-
- private Map<String, Event> eventMap;
-
- private Lifecycle<UIComponent> componentLifecycle;
-
- public Component(ComponentMetaData metaData)
- {
- 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 Component(
- Class<?> owner,
- String id,
- String type,
- String lifecycle,
- String template,
- String decorator,
- InitParams initParams,
- List<Validator> validators,
- List<Event> events,
- List<EventInterceptor> eventInterceptors)
- {
- this(
- new ComponentHandle(owner, id == null ? type : type + ":" + id),
- id,
- type,
- lifecycle,
- template,
- decorator,
- initParams,
- validators,
- events,
- eventInterceptors);
- }
-
- 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)
- {
- 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 getKey()
- {
- return handle.getKey();
- }
-
- 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 InitParams getInitParams()
- {
- return initParams;
- }
-
- public List<Validator> getValidators()
- {
- return validators;
- }
-
- public List<Event> getEvents()
- {
- return events;
- }
-
- public List<EventInterceptor> getEventInterceptors()
- {
- return eventInterceptors;
- }
-
- public Event getUIComponentEventConfig(String eventName) throws Exception
- {
- if (eventMap != null)
- {
- return eventMap.get(eventName);
- }
- eventMap = new HashMap<String, Event>();
- if (events == null)
- {
- return null;
- }
- for (Event event : events)
- {
- createCachedEventListeners(event);
- eventMap.put(event.getName(), event);
- }
- return eventMap.get(eventName);
- }
-
- public List<EventListener> getUIComponentEventListeners(String eventName) throws
Exception
- {
- Event event = getUIComponentEventConfig(eventName);
- if (event == null)
- {
- return null;
- }
- List<EventListener> cachedListeners = event.getCachedEventListeners();
- if (cachedListeners != null)
- {
- return cachedListeners;
- }
- cachedListeners = new ArrayList<EventListener>();
- for (String listener : event.getListeners())
- {
- if (listener.indexOf(".") < 0)
- {
- listener = type + "$" + listener;
- }
- EventListener eventListener = (EventListener)Util.createObject(listener,
event.getInitParams());
- cachedListeners.add(eventListener);
- }
- event.setCachedEventListeners(cachedListeners);
- return cachedListeners;
- }
-
- private void createCachedEventListeners(Event event) throws Exception
- {
- List<EventListener> cachedListeners = new ArrayList<EventListener>();
- for (String listener : event.getListeners())
- {
- if (listener.indexOf(".") < 0)
- {
- listener = type + "$" + listener;
- }
- EventListener eventListener = (EventListener)Util.createObject(listener,
event.getInitParams());
- cachedListeners.add(eventListener);
- }
- event.setCachedEventListeners(cachedListeners);
- }
-
- public Lifecycle<UIComponent> getUIComponentLifecycle() throws Exception
- {
- if (componentLifecycle != null)
- {
- return componentLifecycle;
- }
- if (lifecycle != null)
- {
- componentLifecycle = (Lifecycle<UIComponent>)Util.createObject(lifecycle,
null);
- }
- else
- {
- componentLifecycle =
(Lifecycle<UIComponent>)Util.createObject(Lifecycle.class, null);
- }
- return componentLifecycle;
- }
-
-}
\ No newline at end of file
Deleted:
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 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,48 +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 org.exoplatform.webui.application.ConfigurationManager;
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.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);
- }
-}
Deleted:
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 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentHandle.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,52 +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.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/Event.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Event.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Event.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,129 +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 org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.event.Event.Phase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * May 9, 2006
- */
-public class Event
-{
-
- private String name;
-
- private String confirm;
-
- private InitParams initParams;
-
- private ArrayList<String> listeners;
-
- transient private List<EventListener> eventListeners_;
-
- private String phase = "process";
-
- transient private Phase executionPhase_ = null;
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getPhase()
- {
- return phase;
- }
-
- public void setPhase(String s)
- {
- phase = s;
- }
-
- public List<String> getListeners()
- {
- return listeners;
- }
-
- public void setListeners(ArrayList<String> listeners)
- {
- this.listeners = listeners;
- }
-
- public InitParams getInitParams()
- {
- return initParams;
- }
-
- public void setInitParams(InitParams initParams)
- {
- this.initParams = initParams;
- }
-
- public String getConfirm()
- {
- return confirm;
- }
-
- public void setConfirm(String confirm)
- {
- this.confirm = confirm;
- }
-
- public Phase getExecutionPhase()
- {
- if (executionPhase_ != null)
- return executionPhase_;
- try
- {
- executionPhase_ = Phase.valueOf(phase.toUpperCase());
- }
- catch (Exception e)
- {
- executionPhase_ = Phase.PROCESS;
- }
- return executionPhase_;
- }
-
- public void setExecutionPhase(Phase executionPhase)
- {
- this.executionPhase_ = executionPhase;
- }
-
- public List<EventListener> getCachedEventListeners() throws Exception
- {
- return eventListeners_;
- }
-
- public void setCachedEventListeners(List<EventListener> list)
- {
- eventListeners_ = list;
- }
-
-}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/EventInterceptor.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/EventInterceptor.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/EventInterceptor.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,69 +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;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * May 4, 2006
- */
-public class EventInterceptor
-{
-
- private String type;
-
- private InitParams initParams;
-
- private ArrayList<String> interceptors;
-
- public String getType()
- {
- return type;
- }
-
- public void setType(String type)
- {
- this.type = type;
- }
-
- public ArrayList<String> getInterceptors()
- {
- return interceptors;
- }
-
- public void setInterceptors(ArrayList<String> interceptors)
- {
- this.interceptors = interceptors;
- }
-
- public InitParams getInitParams()
- {
- return initParams;
- }
-
- public void setInitParams(InitParams initParams)
- {
- this.initParams = initParams;
- }
-
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/InitParams.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/InitParams.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/InitParams.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,57 +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;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * May 9, 2006
- */
-public class InitParams
-{
-
- private ArrayList<Param> params;
-
- public Param getParam(String name)
- {
- if (params == null)
- return null;
- for (Param param : params)
- {
- if (name.equals(param.getName()))
- return param;
- }
- return null;
- }
-
- public ArrayList<Param> getParams()
- {
- return params;
- }
-
- public void setParams(ArrayList<Param> params)
- {
- this.params = params;
- }
-
-}
\ No newline at end of file
Deleted: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Param.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Param.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Param.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,117 +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 groovy.lang.Binding;
-import groovy.lang.GroovyShell;
-
-import org.exoplatform.resolver.ResourceResolver;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.xml.object.XMLObject;
-import org.gatein.common.logging.Logger;
-import org.gatein.common.logging.LoggerFactory;
-
-import java.io.InputStream;
-
-public class Param
-{
-
- /** . */
- private static final Logger log = LoggerFactory.getLogger(Param.class);
-
- private String name;
-
- private String value;
-
- private transient Object object;
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- public Object getMapXMLObject(WebuiRequestContext context) throws Exception
- {
- if (object != null)
- return object;
- ResourceResolver resolver = context.getResourceResolver(value);
- InputStream is = resolver.getInputStream(value);
- object = XMLObject.getObject(is);
- is.close();
- return object;
- }
-
- @SuppressWarnings("unchecked")
- public Object getMapGroovyObject(WebuiRequestContext context) throws Exception
- {
- try
- {
- if (object != null)
- return object;
- ResourceResolver resolver = context.getResourceResolver(value);
- InputStream is = resolver.getInputStream(value);
- //TODO if is == null throw an exception saying the it's impossible to find
the file
- Binding binding = new Binding();
- GroovyShell shell = new
GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
- object = shell.evaluate(is);
- is.close();
- return object;
- }
- catch (Exception e)
- {
- log.error("A problem in the groovy script : " + value, e);
- throw e;
- }
- }
-
- public Object getFreshObject(WebuiRequestContext context) throws Exception
- {
- try
- {
- ResourceResolver resolver = context.getResourceResolver(value);
- InputStream is = resolver.getInputStream(value);
- Binding binding = new Binding();
- GroovyShell shell = new
GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
- object = shell.evaluate(is);
- is.close();
- return object;
- }
- catch (Exception e)
- {
- log.error("A problem in the groovy script : " + value, e);
- throw e;
- }
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Validator.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Validator.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Validator.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,55 +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;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * May 4, 2006
- */
-public class Validator
-{
-
- private String type;
-
- private InitParams initParams;
-
- public InitParams getInitParams()
- {
- return initParams;
- }
-
- public void setInitParams(InitParams initParams)
- {
- this.initParams = initParams;
- }
-
- public String getType()
- {
- return type;
- }
-
- public void setType(String type)
- {
- this.type = type;
- }
-
-}
Deleted:
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-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,54 +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 org.exoplatform.webui.config.metadata.ComponentMetaData;
-
-import java.util.ArrayList;
-
-/**
- * Created by The eXo Platform SAS
- * May 4, 2006
- */
-public class WebuiConfiguration
-{
-
- private ArrayList<String> annotationClasses;
-
- private ArrayList<ComponentMetaData> components;
-
- private Application application;
-
- public ArrayList<String> getAnnotationClasses()
- {
- return annotationClasses;
- }
-
- public ArrayList<ComponentMetaData> getComponents()
- {
- return components;
- }
-
- public Application getApplication()
- {
- return application;
- }
-
-}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIApplication.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIApplication.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIApplication.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,140 +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.core;
-
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.exception.MessageException;
-
-import java.io.Writer;
-
-/**
- * Created by The eXo Platform SAS
- * May 8, 2006
- */
-@Serialized
-abstract public class UIApplication extends UIContainer
-{
-
- protected static Log log = ExoLogger.getLogger("portal:UIApplication");
-
- private String owner;
-
- private long lastAccessApplication_;
-
- private UIPopupMessages uiPopupMessages_;
- private static final String UIAPPLICATION = "uiapplication";
-
- public UIApplication() throws Exception
- {
- uiPopupMessages_ = createUIComponent(UIPopupMessages.class, null, null);
- uiPopupMessages_.setId("_" + uiPopupMessages_.hashCode());
- }
-
- public String getOwner()
- {
- return owner;
- }
-
- public void setOwner(String s)
- {
- owner = s;
- }
-
- public UIPopupMessages getUIPopupMessages()
- {
- return uiPopupMessages_;
- }
-
- public void addMessage(ApplicationMessage message)
- {
- uiPopupMessages_.addMessage(message);
- }
-
- public void clearMessages()
- {
- uiPopupMessages_.clearMessages();
- }
-
- public long getLastAccessApplication()
- {
- return lastAccessApplication_;
- }
-
- public void setLastAccessApplication(long time)
- {
- lastAccessApplication_ = time;
- }
-
- public String getUIComponentName()
- {
- return UIAPPLICATION;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T findComponentById(String lookupId)
- {
- if (uiPopupMessages_.getId().equals(lookupId))
- return (T)uiPopupMessages_;
- return (T)super.findComponentById(lookupId);
- }
-
- public void renderChildren() throws Exception
- {
- super.renderChildren();
- if (uiPopupMessages_ == null)
- return;
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- uiPopupMessages_.processRender(context);
- }
-
- public void processAction(WebuiRequestContext context) throws Exception
- {
- try
- {
- super.processAction(context);
- }
- catch (MessageException ex)
- {
- uiPopupMessages_.addMessage(ex.getDetailMessage());
- }
- catch (Throwable t)
- {
- Object[] args = {t.getMessage()};
- ApplicationMessage msg =
- new ApplicationMessage("UIApplication.msg.unknown-error", args,
ApplicationMessage.ERROR);
- uiPopupMessages_.addMessage(msg);
- log.error("Error during the processAction phase", t);
- }
- }
-
- public void renderBlockToUpdate(UIComponent uicomponent, WebuiRequestContext context,
Writer w) throws Exception
- {
- w.write("<div class=\"BlockToUpdate\">");
- w.append("<div
class=\"BlockToUpdateId\">").append(uicomponent.getId()).append("</div>");
- w.write("<div class=\"BlockToUpdateData\">");
- uicomponent.processRender(context);
- w.write("</div>");
- w.write("</div>");
- }
-}
\ No newline at end of file
Deleted:
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-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,494 +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.core;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.resolver.ResourceResolver;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.web.application.Parameter;
-import org.exoplatform.web.application.URLBuilder;
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.config.Component;
-import org.exoplatform.webui.core.lifecycle.Lifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.event.MonitorEvent;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** Created by The eXo Platform SAS May 7, 2006 */
-@Serialized
-abstract public class UIComponent
-{
- private static final Log log = ExoLogger.getLogger("webui:UIComponent");
-
- final static public String OBJECTID = "objectId";
-
- final static public String UICOMPONENT = "uicomponent";
-
- final static public String AJAX_ASYNC = "ajax_async";
-
- private String id;
-
- private boolean rendered = true;
-
- protected UIComponent uiparent;
-
- protected Component config;
-
- private static final Lifecycle<UIComponent> DEFAULT_LIFECYCLE = new
Lifecycle<UIComponent>();
-
- public String getId()
- {
- return this.id;
- }
-
- public UIComponent setId(String id)
- {
- if (id == null)
- {
- this.id = Integer.toString(hashCode());
- }
- else
- {
- this.id = id;
- }
- return this;
- }
-
- public String getName()
- {
- return getClass().getSimpleName();
- }
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T getParent()
- {
- return (T)this.uiparent;
- }
-
- public void setParent(UIComponent uicomponent)
- {
- this.uiparent = uicomponent;
- }
-
- public boolean isRendered()
- {
- return this.rendered;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T setRendered(boolean b)
- {
- this.rendered = b;
- return (T)this;
- }
-
- //
- // public void processInit(WebuiRequestContext context) throws Exception {
- // MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.INIT,
context);
- // config.getUIComponentLifecycle().init(this, context) ;
- // if(mevent != null) {
- // mevent.setEndExecutionTime(System.currentTimeMillis()) ;
- // mevent.broadcast() ;
- // }
- // }
- //
-
- public void processDecode(WebuiRequestContext context) throws Exception
- {
- MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.DECODE,
context);
- getLifecycle().processDecode(this, context);
- if (mevent != null)
- {
- mevent.setEndExecutionTime(System.currentTimeMillis());
- mevent.broadcast();
- }
- }
-
- public void processAction(WebuiRequestContext context) throws Exception
- {
- MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.PROCESS,
context);
- getLifecycle().processAction(this, context);
- if (mevent != null)
- {
- mevent.setEndExecutionTime(System.currentTimeMillis());
- mevent.broadcast();
- }
- }
-
- public void processRender(WebuiRequestContext context) throws Exception
- {
- MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.RENDER,
context);
- getLifecycle().processRender(this, context);
- if (mevent != null)
- {
- mevent.setEndExecutionTime(System.currentTimeMillis());
- mevent.broadcast();
- }
- }
-
- private Lifecycle<UIComponent> getLifecycle() throws Exception
- {
- if (config == null)
- {
- log.debug("No config was found for " + getClass().getSimpleName() +
" with id '" + id + "'. Using a default one.");
- return DEFAULT_LIFECYCLE;
- }
- return config.getUIComponentLifecycle();
- }
-
- //
- // public void processDestroy(WebuiRequestContext context) throws Exception {
- // MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.DESTROY,
context);
- // config.getUIComponentLifecycle().init(this, context) ;
- // if(mevent != null) {
- // mevent.setEndExecutionTime(System.currentTimeMillis()) ;
- // mevent.broadcast() ;
- // }
- // }
-
- public Component getComponentConfig()
- {
- return this.config;
- }
-
- public void setComponentConfig(String componentId, Component config) throws Exception
- {
- this.config = config;
- if (componentId == null || componentId.length() == 0)
- {
- componentId = config.getId();
- }
- if (componentId == null)
- {
- String type = config.getType();
- componentId = type.substring(type.lastIndexOf('.') + 1);
- }
- setId(componentId);
- }
-
- public void setComponentConfig(Class<?> clazz, String id)
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- WebuiApplication app = (WebuiApplication)context.getApplication();
- this.config = app.getConfigurationManager().getComponentConfig(clazz, id);
- }
-
- public String getTemplate()
- {
- return config != null ? config.getTemplate() : null;
- }
-
- public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context,
String template)
- {
- return context.getResourceResolver(template);
- }
-
- public <T extends UIComponent> T getAncestorOfType(Class<T> classType)
- {
- UIComponent parent = getParent();
- while (parent != null)
- {
- if (classType.isInstance(parent))
- {
- return classType.cast(parent);
- }
- parent = parent.getParent();
- }
- return null;
- }
-
- protected String loadConfirmMesssage(org.exoplatform.webui.config.Event event,
WebuiRequestContext context,
- String beanId)
- {
- String confirmKey = event.getConfirm();
- if (confirmKey.length() < 1)
- {
- return confirmKey;
- }
- try
- {
- String confirm = context.getApplicationResourceBundle().getString(confirmKey);
- return confirm.replaceAll("\\{0\\}", beanId);
- }
- catch (Exception e)
- {
- }
- return confirmKey;
- }
-
- public String event(String name) throws Exception
- {
- return event(name, null);
- }
-
- public String event(String name, String beanId) throws Exception
- {
- return event(name, beanId, null);
- }
-
- /**
- * Render an event ajax URL for a given bean.
- *
- * @param name the event name
- * @param beanId the optional bean id
- * @param params the optional event parameters
- * @return the rendered URL
- * @throws Exception any exception
- */
- public String event(String name, String beanId, Parameter[] params) throws Exception
- {
- return renderEventURL(true, name, beanId, params);
- }
-
- public String url(String name) throws Exception
- {
- return url(name, null);
- }
-
- public String url(String name, String beanId) throws Exception
- {
- return url(name, beanId, null);
- }
-
- /**
- * Render an event URL for a given bean.
- *
- * @param name the event name
- * @param beanId the optional bean id
- * @param params the optional event parameters
- * @return the rendered URL
- * @throws Exception any exception
- */
- public String url(String name, String beanId, Parameter[] params) throws Exception
- {
- return renderEventURL(false, name, beanId, params);
- }
-
- /**
- * Render an event URL of a given bean.
- *
- * @param ajax the url type, true for ajax, false otherwise
- * @param name the event name
- * @param beanId the optional bean id
- * @param params the optional event parameters
- * @return the rendered URL
- * @throws Exception any exception
- */
- public String renderEventURL(boolean ajax, String name, String beanId, Parameter[]
params) throws Exception
- {
- org.exoplatform.webui.config.Event event = config.getUIComponentEventConfig(name);
- if (event == null)
- {
- return "??config??";
- }
-
- //
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- URLBuilder<UIComponent> urlBuilder = context.getURLBuilder();
- if (urlBuilder == null)
- {
- return "??builder??";
- }
-
- //
- String confirm = loadConfirmMesssage(event, context, beanId);
-
- //
- if (ajax)
- {
- return urlBuilder.createAjaxURL(this, event.getName(), confirm, beanId,
params);
- }
- else
- {
- try
- {
- return urlBuilder.createURL(this, event.getName(), confirm, beanId, params);
- }
- catch (Exception e)
- {
- log.error("Could not render component even URL for id=" + beanId +
", name=" + name, e);
- return "";
- }
- }
- }
-
- // julien : check if this is used effectively or not
- public String doAsync(String name, String beanId, Parameter[] params) throws
Exception
- {
- return event(name, beanId, new Parameter[]{new Parameter(AJAX_ASYNC,
"true")});
- }
-
- public <T> void broadcast(Event<T> event, Phase phase) throws Exception
- {
- if (config == null)
- {
- return;
- }
- org.exoplatform.webui.config.Event econfig =
config.getUIComponentEventConfig(event.getName());
- if (econfig == null)
- {
- return;
- }
- Phase executionPhase = econfig.getExecutionPhase();
- if (executionPhase == phase || executionPhase == Event.Phase.ANY)
- {
- for (EventListener<T> listener : econfig.getCachedEventListeners())
- {
- listener.execute(event);
- }
- }
- }
-
- public <T extends UIComponent> T createUIComponent(Class<T> type, String
configId, String componentId,
- UIComponent parent) throws
Exception
- {
- T uicomp = createUIComponent(type, configId, componentId);
- uicomp.setParent(parent);
- return uicomp;
- }
-
- public <T extends UIComponent> T createUIComponent(Class<T> type, String
configId, String componentId)
- throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- return createUIComponent(context, type, configId, componentId);
- }
-
- public <T extends UIComponent> T createUIComponent(WebuiRequestContext context,
Class<T> type, String configId,
- String componentId) throws
Exception
- {
- WebuiApplication app = (WebuiApplication)context.getApplication();
- T comp = app.createUIComponent(type, configId, componentId, context);
- return comp;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T findComponentById(String lookupId)
- {
- if (getId().equals(lookupId))
- {
- return (T)this;
- }
- return null;
- }
-
- public <T extends UIComponent> T findFirstComponentOfType(Class<T> type)
- {
- if (type.isInstance(this))
- {
- return type.cast(this);
- }
- return null;
- }
-
- public <T> void findComponentOfType(List<T> list, Class<T> type)
- {
- if (type.isInstance(this))
- {
- list.add(type.cast(this));
- }
- }
-
- public <T extends UIComponent> void setRenderSibling(Class<T> type)
- {
- if (uiparent instanceof UIContainer)
- {
- UIContainer uicontainer = (UIContainer)uiparent;
- List<UIComponent> children = uicontainer.getChildren();
- for (UIComponent child : children)
- {
- if (type.isInstance(child))
- {
- child.setRendered(true);
- }
- else
- {
- child.setRendered(false);
- }
- }
- }
- }
-
- public String getUIComponentName()
- {
- return UICOMPONENT;
- }
-
- public <T> T getApplicationComponent(Class<T> type)
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- ExoContainer container =
context.getApplication().getApplicationServiceContainer();
- return type.cast(container.getComponentInstanceOfType(type));
- }
-
- public Event<UIComponent> createEvent(String name, Phase phase,
WebuiRequestContext context) throws Exception
- {
- if (config == null)
- {
- return null;
- }
- org.exoplatform.webui.config.Event econfig =
config.getUIComponentEventConfig(name);
- if (econfig == null)
- {
- return null;
- }
- Phase executionPhase = econfig.getExecutionPhase();
- if (executionPhase == phase || executionPhase == Event.Phase.ANY)
- {
- Event<UIComponent> event = new Event<UIComponent>(this, name,
context);
- event.setExecutionPhase(phase);
- event.setEventListeners(econfig.getCachedEventListeners());
- return event;
- }
- return null;
- }
-
- private MonitorEvent<UIComponent> createMonitorEvent(Phase phase,
WebuiRequestContext context) throws Exception
- {
- if (config == null)
- {
- return null;
- }
- org.exoplatform.webui.config.Event econfig =
-
config.getUIComponentEventConfig(MonitorEvent.UICOMPONENT_LIFECYCLE_MONITOR_EVENT);
- if (econfig == null)
- {
- return null;
- }
- Phase executionPhase = econfig.getExecutionPhase();
- if (executionPhase == phase || executionPhase == Event.Phase.ANY)
- {
- MonitorEvent<UIComponent> mevent =
- new MonitorEvent<UIComponent>(this,
MonitorEvent.UICOMPONENT_LIFECYCLE_MONITOR_EVENT, context);
- mevent.setEventListeners(econfig.getCachedEventListeners());
- mevent.setStartExecutionTime(System.currentTimeMillis());
- mevent.setExecutionPhase(phase);
- return mevent;
- }
- return null;
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,110 +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.core;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.core.lifecycle.Lifecycle;
-
-import java.util.List;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tuan Nguyen
- * tuan08(a)users.sourceforge.net
- * May 7, 2006
- *
- * The decorator of a component
- */
-@ComponentConfig(lifecycle = UIComponentDecorator.UIComponentDecoratorLifecycle.class)
-@Serialized
-public class UIComponentDecorator extends UIComponent
-{
- /**
- * The component being decorated
- */
- protected UIComponent uicomponent_;
-
- public UIComponent getUIComponent()
- {
- return uicomponent_;
- }
-
- public void setUIComponent(UIComponent uicomponent)
- {
- if (uicomponent_ != null)
- uicomponent_.setRendered(false);
- uicomponent_ = uicomponent;
- if (uicomponent_ == null)
- return;
- uicomponent_.setParent(this);
- }
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T findComponentById(String id)
- {
- if (getId().equals(id))
- return (T)this;
- if (uicomponent_ == null)
- return null;
- return (T)uicomponent_.findComponentById(id);
- }
-
- public <T extends UIComponent> T findFirstComponentOfType(Class<T> type)
- {
- if (type.isInstance(this))
- return type.cast(this);
- if (uicomponent_ == null)
- return null;
- return uicomponent_.findFirstComponentOfType(type);
- }
-
- public <T> void findComponentOfType(List<T> list, Class<T> type)
- {
- if (type.isInstance(this))
- list.add(type.cast(this));
- if (uicomponent_ == null)
- return;
- uicomponent_.findComponentOfType(list, type);
- }
-
- public void renderChildren() throws Exception
- {
- if (uicomponent_ == null)
- return;
-
uicomponent_.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
- }
-
- static public class UIComponentDecoratorLifecycle extends
Lifecycle<UIComponentDecorator>
- {
-
- public void processRender(UIComponentDecorator uicomponent, WebuiRequestContext
context) throws Exception
- {
- context.getWriter().append("<div
class=\"").append(uicomponent.getId()).append("\"
id=\"").append(
- uicomponent.getId()).append("\">");
- if (uicomponent.uicomponent_ != null)
- {
- uicomponent.uicomponent_.processRender(context);
- }
- context.getWriter().append("</div>");
- }
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIContainer.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIContainer.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIContainer.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,395 +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.core;
-
-import org.exoplatform.webui.application.WebuiApplication;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** Created by The eXo Platform SAS May 7, 2006 */
-@ComponentConfig(lifecycle = UIContainerLifecycle.class)
-@Serialized
-public class UIContainer extends UIComponent
-{
-
- private List<UIComponent> children;
-
- public boolean hasChildren()
- {
- return children != null;
- }
-
- public void setChildren(List<UIComponent> ls)
- {
- this.children = ls;
- }
-
- public List<UIComponent> getChildren()
- {
- if (children == null)
- {
- children = new ArrayList<UIComponent>(3);
- }
- return children;
- }
-
- public void addChild(UIComponent uicomponent)
- {
- if (children == null)
- {
- children = new ArrayList<UIComponent>(3);
- }
- uicomponent.setParent(this);
- children.add(uicomponent);
- }
-
- public UIComponent removeChildById(String id)
- {
- if (children == null)
- {
- return null;
- }
- for (UIComponent child : children)
- {
- if (!id.equals(child.getId()))
- {
- continue;
- }
- child.setParent(null);
- children.remove(child);
- return child;
- }
- return null;
- }
-
- public <T extends UIComponent> T removeChild(Class<T> clazz)
- {
- if (children == null)
- {
- return null;
- }
- for (UIComponent child : children)
- {
- if (!clazz.isInstance(child))
- {
- continue;
- }
- child.setParent(null);
- children.remove(child);
- return clazz.cast(child);
- }
- return null;
- }
-
- // todo (julien) : this is not type safe
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T getChildById(String id)
- {
-
- if (children == null)
- {
- return null;
- }
- for (UIComponent child : children)
- {
- if (id.equals(child.getId()))
- {
- return (T)child;
- }
- }
- return null;
- }
-
- // todo (julien) : this is not type safe
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T getChild(int idx)
- {
- if (children == null)
- {
- return null;
- }
- if (children.size() <= idx)
- {
- return null;
- }
- return (T)children.get(idx);
- }
-
- public <T extends UIComponent> T getChild(Class<T> clazz)
- {
- if (children == null)
- {
- return null;
- }
- for (UIComponent uichild : children)
- {
- if (clazz.isInstance(uichild))
- {
- return clazz.cast(uichild);
- }
- }
- return null;
- }
-
- // todo (julien) : this is not type safe
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T replaceChild(String targetChildId, UIComponent
newComponent) throws Exception
- {
- if (children == null)
- {
- throw new Exception("Cannot find the child : " + targetChildId);
- }
- for (int i = 0; i < this.children.size(); i++)
- {
- UIComponent child = this.children.get(i);
- if (targetChildId.equals(child.getId()))
- {
- child.setParent(null);
- newComponent.setParent(this);
- children.set(i, newComponent);
- return (T)child;
- }
- }
- throw new Exception("Cannot find the child : " + targetChildId);
- }
-
- public <T extends UIComponent> T replaceChild(String targetChildId,
Class<T> type, String configId, String id)
- throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- WebuiApplication app = (WebuiApplication)context.getApplication();
- UIComponent comp = app.createUIComponent(type, configId, id, context);
- comp = replaceChild(targetChildId, comp);
- return type.cast(comp);
- }
-
- public <T extends UIComponent> T addChild(Class<T> type, String configId,
String id) throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- WebuiApplication app = (WebuiApplication)context.getApplication();
- T comp = app.createUIComponent(type, configId, id, context);
- addChild(comp);
- return comp;
- }
-
- // todo (julien) : this is not type safe
-
- @SuppressWarnings("unchecked")
- public <T extends UIComponent> T findComponentById(String id)
- {
- if (getId() != null)
- {
- if (getId().equals(id))
- {
- return (T)this;
- }
- }
- if (children == null)
- {
- return null;
- }
- for (UIComponent uichild : children)
- {
- UIComponent found = uichild.findComponentById(id);
- if (found != null)
- {
- return (T)found;
- }
- }
- return null;
- }
-
- /*@SuppressWarnings("unchecked")
- public <T extends UIComponent> T findRenderComponentById(String id) {
- if(!isRendered()) return null;
- if(getId().equals(id)) return (T)this ;
- if(children == null) return null ;
- for (UIComponent uichild : children) {
- UIComponent found = uichild.findComponentById(id) ;
- if(found != null) return (T)found ;
- }
- return null ;
- } */
-
- public <T extends UIComponent> T findFirstComponentOfType(Class<T> type)
- {
- if (type.isInstance(this))
- {
- return type.cast(this);
- }
- if (children == null)
- {
- return null;
- }
- for (UIComponent uichild : children)
- {
- T found = uichild.findFirstComponentOfType(type);
- if (found != null)
- {
- return found;
- }
- }
- return null;
- }
-
- public <T> void findComponentOfType(List<T> list, Class<T> type)
- {
- if (type.isInstance(this) && !list.contains(this))
- {
- list.add(type.cast(this));
- }
- if (children == null)
- {
- return;
- }
- for (UIComponent uichild : children)
- {
- uichild.findComponentOfType(list, type);
- }
- }
-
- public void setRenderedChild(String id)
- {
- List<UIComponent> list = getChildren();
- for (UIComponent child : list)
- {
- if (child.getId().equals(id))
- {
- child.setRendered(true);
- }
- else
- {
- child.setRendered(false);
- }
- }
- }
-
- public <T extends UIComponent> void setRenderedChild(Class<T> type)
- {
- List<UIComponent> list = getChildren();
- for (UIComponent child : list)
- {
- if (type.isInstance(child))
- {
- child.setRendered(true);
- }
- else
- {
- child.setRendered(false);
- }
- }
- }
-
- public void setRenderedChildrenOfTypes(Class<?>[] types)
- {
- List<UIComponent> list = getChildren();
- for (UIComponent child : list)
- {
- child.setRendered(false);
- for (Class<?> type : types)
- {
- if (type.isInstance(child))
- {
- child.setRendered(true);
- break;
- }
- }
- }
- }
-
- public void renderChild(String id) throws Exception
- {
- renderChild(getChildById(id));
- }
-
- public <T extends UIComponent> void renderChild(Class<T> clazz) throws
Exception
- {
- renderChild(getChild(clazz));
- }
-
- public void renderUIComponent(UIComponent uicomponent) throws Exception
- {
-
uicomponent.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
- }
-
- public void renderChild(int index) throws Exception
- {
- renderChild(getChild(index));
- }
-
- public void renderChild(UIComponent child) throws Exception
- {
- if (child.isRendered())
- {
-
child.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
- }
- }
-
- public void renderChildren() throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- renderChildren(context);
- }
-
- public void renderChildren(WebuiRequestContext context) throws Exception
- {
- List<UIComponent> list = getChildren();
- for (UIComponent child : list)
- {
- if (child.isRendered())
- {
- child.processRender(context);
- }
- }
- }
-
- static public class SelectTabActionListener extends EventListener<UIContainer>
- {
- public void execute(Event<UIContainer> event) throws Exception
- {
- WebuiRequestContext context = event.getRequestContext();
- UIContainer uiContainer = event.getSource();
- String renderTab = context.getRequestParameter(UIComponent.OBJECTID);
- if (renderTab == null)
- {
- return;
- }
- UIComponent uiComp = uiContainer.findComponentById(renderTab);
- if (uiComp != null)
- {
- for (UIComponent child : uiContainer.getChildren())
- {
- child.setRendered(false);
- }
- uiComp.setRendered(true);
- }
- }
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,153 +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.core;
-
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tran The Trong
- * trong.tran(a)exoplatform.com
- * @version: $Id$
- * Aug 14, 2006
- *
- * A component to display messages of different types, in a popup window
- */
-@ComponentConfig(template = "system:/groovy/webui/core/UIPopupMessages.gtmpl",
events = @EventConfig(listeners = UIPopupMessages.CloseActionListener.class))
-@Serialized
-public class UIPopupMessages extends UIPopupWindow
-{
- /**
- * The error messages
- */
- private List<ApplicationMessage> errors_;
-
- /**
- * The warning messages
- */
- private List<ApplicationMessage> warnings_;
-
- /**
- * The info messages
- */
- private List<ApplicationMessage> infos_;
-
- public UIPopupMessages()
- {
- errors_ = new ArrayList<ApplicationMessage>();
- warnings_ = new ArrayList<ApplicationMessage>();
- infos_ = new ArrayList<ApplicationMessage>();
- setShow(true);
- }
-
- public List<ApplicationMessage> getErrors()
- {
- return errors_;
- }
-
- public void setErrors(List<ApplicationMessage> errors_)
- {
- this.errors_ = errors_;
- }
-
- public List<ApplicationMessage> getInfos()
- {
- return infos_;
- }
-
- public void setInfos(List<ApplicationMessage> infos_)
- {
- this.infos_ = infos_;
- }
-
- public List<ApplicationMessage> getWarnings()
- {
- return warnings_;
- }
-
- public void setWarnings(List<ApplicationMessage> warnings_)
- {
- this.warnings_ = warnings_;
- }
-
- public void processRender(WebuiRequestContext context) throws Exception
- {
- super.processRender(context);
- }
-
- public void addMessage(ApplicationMessage msg)
- {
- switch (msg.getType())
- {
- case ApplicationMessage.ERROR :
- errors_.add(msg);
- break;
- case ApplicationMessage.WARNING :
- warnings_.add(msg);
- break;
- default :
- infos_.add(msg);
- }
- }
-
- public boolean hasMessage()
- {
- return (errors_.size() > 0 || warnings_.size() > 0 || infos_.size() > 0);
- }
-
- public void clearMessages()
- {
- errors_.clear();
- warnings_.clear();
- infos_.clear();
- }
-
- static public class CloseActionListener extends EventListener<UIPopupMessages>
- {
- public void execute(Event<UIPopupMessages> event) throws Exception
- {
- UIPopupMessages uiPopupMessage = event.getSource();
- uiPopupMessage.clearMessages();
- WebuiRequestContext context = event.getRequestContext();
- if (uiPopupMessage.getParent() == null)
- {
- context.addUIComponentToUpdateByAjax(uiPopupMessage);
- return;
- }
- if (!uiPopupMessage.isShow())
- return;
- UIComponent uiParent = uiPopupMessage.getParent();
- context.addUIComponentToUpdateByAjax(uiParent);
- Event<UIComponent> pEvent =
- uiParent.createEvent("ClosePopup", event.getExecutionPhase(),
event.getRequestContext());
- if (pEvent != null)
- pEvent.broadcast();
- }
- }
-}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,150 +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.core;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.commons.serialization.api.annotations.Serialized;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-
-/**
- * Created by The eXo Platform SARL
- * Author : Tran The Trong
- * trong.tran(a)exoplatform.com
- * @version: $Id$
- * Aug 11, 2006
- *
- * A component that creates an empty popup window
- */
-@ComponentConfig(template = "system:/groovy/webui/core/UIPopupWindow.gtmpl",
events = @EventConfig(listeners = UIPopupWindow.CloseActionListener.class, name =
"ClosePopup"))
-@Serialized
-public class UIPopupWindow extends UIComponentDecorator
-{
- /**
- * The width of the window
- */
- private int width_ = -1;
-
- /**
- * The height of the window
- */
- private int height_ = -1;
-
- /**
- * Whether to show the close button at the bottom of the window
- */
- private boolean showCloseButton = true;
-
- /**
- * The visibility status of the window
- */
- private boolean isShow = false;
-
- /**
- * Whether this window is resizable
- */
- private boolean isResizable = false;
-
- protected String closeEvent_ = "ClosePopup";
-
- private boolean isShowMask_ = false;
-
- public boolean isShowMask()
- {
- return isShowMask_;
- }
-
- public void setShowMask(boolean isShowMask)
- {
- isShowMask_ = isShowMask;
- }
-
- public int getWindowWidth()
- {
- return width_;
- }
-
- public int getWindowHeight()
- {
- return height_;
- }
-
- public void setWindowSize(int w, int h)
- {
- width_ = w;
- height_ = h;
- }
-
- public boolean isResizable()
- {
- return isResizable;
- }
-
- public void setResizable(boolean isResizable)
- {
- this.isResizable = isResizable;
- }
-
- public boolean isShow()
- {
- return isShow;
- }
-
- public void setShow(boolean isShow)
- {
- this.isShow = isShow;
- }
-
- static public class CloseActionListener extends EventListener<UIPopupWindow>
- {
- public void execute(Event<UIPopupWindow> event) throws Exception
- {
- UIPopupWindow uiPopupWindow = event.getSource();
- if (!uiPopupWindow.isShow())
- return;
- uiPopupWindow.setShow(false);
- WebuiRequestContext context = event.getRequestContext();
- context.addUIComponentToUpdateByAjax(uiPopupWindow);
- }
- }
-
- public boolean isShowCloseButton()
- {
- return showCloseButton;
- }
-
- public void setShowCloseButton(boolean showCloseButton)
- {
- this.showCloseButton = showCloseButton;
- }
-
- public String getCloseEvent()
- {
- return closeEvent_;
- }
-
- public void setCloseEvent(String closeEvent)
- {
- this.closeEvent_ = closeEvent;
- }
-
-}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,53 +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.core.lifecycle;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-
-/**
- * Created by The eXo Platform SAS
- * Aug 23, 2006
- *
- * Writes a decorator template with the given css class style
- */
-public class Decorator
-{
- //<%decorator.start(.., ..)%>
- final public void start(String cssClass, String style) throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- context.getWriter().append("<div
class=\"").append(cssClass).append("\">").append("<div
class=\"").append(style)
- .append("\" style=\"margin:
0px\">").append("<div
class=\"TopLeftCornerBoxDecorator\">").append(
- "<div
class=\"TopRightCornerBoxDecorator\">").append(
- "<div
class=\"TopCenterBoxDecorator\"><span></span></div>").append("</div>").append("</div>").append(
- "<div
class=\"MiddleLeftSideBoxDecorator\">").append("<div
class=\"MiddleRightSideBoxDecorator\">").append(
- "<div class=\"DecoratorBackground\">");
-
- }
-
- final public void end() throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
-
context.getWriter().append("</div>").append("</div>").append("</div>").append(
- "<div
class=\"BottomLeftCornerBoxDecorator\">").append("<div
class=\"BottomRightCornerBoxDecorator\">")
- .append("<div
class=\"BottomCenterBoxDecorator\"><span></span></div>").append("</div>").append("</div>")
- .append("</div>").append("</div>");
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,134 +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.core.lifecycle;
-
-import org.exoplatform.commons.utils.PropertyManager;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.groovyscript.text.TemplateService;
-import org.exoplatform.resolver.ResourceResolver;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.event.Event;
-
-/**
- * Created by The eXo Platform SAS May 7, 2006
- */
-public class Lifecycle<E extends UIComponent>
-{
-
- protected static Log log = ExoLogger.getLogger("portal:Lifecycle");
-
- private Decorator decorator_ = new Decorator();
-
- // public void init(UIComponent uicomponent, WebuiRequestContext context)
- // throws Exception {}
-
- public void processDecode(E uicomponent, WebuiRequestContext context) throws
Exception
- {
- }
-
- public void processAction(E uicomponent, WebuiRequestContext context) throws
Exception
- {
- String action = context.getRequestParameter(context.getActionParameterName());
- if (action == null)
- return;
- Event<UIComponent> event = uicomponent.createEvent(action,
Event.Phase.PROCESS, context);
- if (event != null)
- event.broadcast();
- }
-
- /**
- * That method is the most generic one for every UIComponent that is bound to
- * this Lifecycle object and the class that extends it without overriding the
- * method.
- *
- * The template associated to the specified UIComponent is rendered using
renderTemplate(). A WebuiBindingContext
- * context object provides the template with all the necessary objects to render.
- * (WebuiBindingContext extends the Map class)
- *
- */
- public void processRender(E uicomponent, WebuiRequestContext context) throws
Exception
- {
- String template = uicomponent.getTemplate();
-
- // Fail if we have no template
- if (template == null)
- {
- throw new IllegalStateException("uicomponent " + uicomponent + "
with class " + uicomponent.getClass().getName() +
- " has no template for rendering");
- }
-
- //
- ResourceResolver resolver = uicomponent.getTemplateResourceResolver(context,
template);
- WebuiBindingContext bcontext = new WebuiBindingContext(resolver,
context.getWriter(), uicomponent, context);
- bcontext.put(UIComponent.UICOMPONENT, uicomponent);
- bcontext.put(uicomponent.getUIComponentName(), uicomponent);
- renderTemplate(template, bcontext);
- }
-
- // public void destroy(UIComponent uicomponent) throws Exception {}
-
- /**
- * The method allows to use Groovy templates to render the portal components.
- *
- * <ol>
- * <li>Add a decorator object into the context</li>
- * <li>Get a reference to the TemplateService</li>
- * <li>If the system property "exo.product.developing" is set to
<code>true</code>, the templates are not cached</li>
- * <li>If the writer used to render the output is of type HtmlValidator, which
is the case in the Portal
- * environment, then it is also possible to validate the generated HTML (for debugging
purposes)</li>
- * <li>The template and the context are then merged to generate the HTML
fragment</li>
- * </ol>
- *
- */
- protected void renderTemplate(String template, WebuiBindingContext bcontext) throws
Exception
- {
- bcontext.put("decorator", decorator_);
- WebuiRequestContext context = bcontext.getRequestContext();
- ExoContainer pcontainer =
context.getApplication().getApplicationServiceContainer();
- TemplateService service =
(TemplateService)pcontainer.getComponentInstanceOfType(TemplateService.class);
- ResourceResolver resolver = bcontext.getResourceResolver();
-
- if (PropertyManager.isDevelopping())
- {
- WebuiRequestContext rootContext =
(WebuiRequestContext)context.getParentAppRequestContext();
- if (rootContext == null)
- rootContext = context;
- long lastAccess = rootContext.getUIApplication().getLastAccessApplication();
- if (resolver.isModified(template, lastAccess))
- {
- if (log.isDebugEnabled())
- log.debug("Invalidate the template: " + template);
- service.invalidateTemplate(template, resolver);
- }
- }
-
- try
- {
- service.merge(template, bcontext);
- }
- catch (NullPointerException e)
- {
- log.error("Template: " + template + " not found.");
- }
- }
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,38 +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.core.lifecycle;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.core.UIContainer;
-
-/**
- * Jul 10, 2006
- */
-public class UIContainerLifecycle extends Lifecycle<UIContainer>
-{
-
- public void processRender(UIContainer uicomponent, WebuiRequestContext context) throws
Exception
- {
- context.getWriter().append("<div
class=\"").append(uicomponent.getId()).append("\"
id=\"").append(
- uicomponent.getId()).append("\">");
- uicomponent.renderChildren(context);
- context.getWriter().append("</div>");
- }
-}
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,156 +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.core.lifecycle;
-
-import org.exoplatform.commons.utils.PropertyManager;
-import org.exoplatform.groovyscript.text.BindingContext;
-import org.exoplatform.resolver.ResourceResolver;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.resources.Orientation;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.core.UIComponentDecorator;
-import org.exoplatform.webui.core.UIContainer;
-
-import java.io.Writer;
-import java.util.List;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-@SuppressWarnings("serial")
-public class WebuiBindingContext extends BindingContext
-{
-
- protected static Log log =
ExoLogger.getLogger("portal:WebuiBindingContext");
-
- private UIComponent uicomponent_;
-
- private WebuiRequestContext rcontext_;
-
- public WebuiBindingContext(ResourceResolver resolver, Writer w, UIComponent
uicomponent, WebuiRequestContext context)
- {
- super(resolver, w);
- uicomponent_ = uicomponent;
- rcontext_ = context;
-
- // Add Orientation specific information
- Orientation orientation = context.getOrientation();
- this.put("orientation", orientation);
- this.put("isLT", orientation.isLT());
- this.put("isRT", orientation.isRT());
- this.put("dir", orientation.isLT() ? "ltr" : "rtl");
- }
-
- public UIComponent getUIComponent()
- {
- return uicomponent_;
- }
-
- public WebuiRequestContext getRequestContext()
- {
- return rcontext_;
- }
-
- public String getContextPath()
- {
- return rcontext_.getRequestContextPath();
- }
-
- public String getPortalContextPath()
- {
- return rcontext_.getPortalContextPath();
- }
-
- public BindingContext clone()
- {
- BindingContext newContext = new WebuiBindingContext(resolver_, writer_,
uicomponent_, rcontext_);
- newContext.putAll(this);
- newContext.setGroovyTemplateService(service_);
- return newContext;
- }
-
- public String appRes(String mesgKey) throws Exception
- {
- String value;
- try
- {
- ResourceBundle res = rcontext_.getApplicationResourceBundle();
- value = res.getString(mesgKey);
- }
- catch (MissingResourceException ex)
- {
- if (PropertyManager.isDevelopping())
- log.warn("Can not find resource bundle for key : " + mesgKey);
- value = mesgKey.substring(mesgKey.lastIndexOf('.') + 1);
- }
- return value;
- }
-
- public void renderChildren() throws Exception
- {
- if (uicomponent_ instanceof UIComponentDecorator)
- {
- UIComponentDecorator uiComponentDecorator = (UIComponentDecorator)uicomponent_;
- if (uiComponentDecorator.getUIComponent() == null)
- return;
- uiComponentDecorator.getUIComponent().processRender(rcontext_);
- return;
- }
- UIContainer uicontainer = (UIContainer)uicomponent_;
- List<UIComponent> children = uicontainer.getChildren();
- for (UIComponent child : children)
- {
- if (child.isRendered())
- {
- child.processRender(rcontext_);
- }
- }
- }
-
- public void renderChild(String id) throws Exception
- {
- if (!(uicomponent_ instanceof UIContainer))
- return;
- UIContainer uicontainer = (UIContainer)uicomponent_;
- UIComponent uiChild = uicontainer.getChildById(id);
- uiChild.processRender(rcontext_);
- }
-
- public void renderUIComponent(UIComponent uicomponent) throws Exception
- {
- uicomponent.processRender(rcontext_);
- }
-
- public void renderChild(int index) throws Exception
- {
- if (!(uicomponent_ instanceof UIContainer))
- return;
- UIContainer uicontainer = (UIContainer)uicomponent_;
- UIComponent uiChild = uicontainer.getChild(index);
- uiChild.processRender(rcontext_);
- }
-
- @SuppressWarnings("unused")
- public void userRes(String mesgKey)
- {
-
- }
-}
\ No newline at end of file
Deleted: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/Event.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/Event.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/Event.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,96 +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.event;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-
-import java.util.List;
-
-public class Event<T>
-{
-
- private String name_;
-
- private T source_;
-
- private Phase executionPhase_ = Phase.PROCESS;
-
- private WebuiRequestContext context_;
-
- private List<EventListener> listeners_;
-
- public Event(T source, String name, WebuiRequestContext context)
- {
- name_ = name;
- source_ = source;
- context_ = context;
- }
-
- public String getName()
- {
- return name_;
- }
-
- public T getSource()
- {
- return source_;
- }
-
- public Phase getExecutionPhase()
- {
- return executionPhase_;
- }
-
- public void setExecutionPhase(Phase phase)
- {
- executionPhase_ = phase;
- }
-
- public WebuiRequestContext getRequestContext()
- {
- return context_;
- }
-
- public void setRequestContext(WebuiRequestContext context)
- {
- context_ = context;
- }
-
- public List<EventListener> getEventListeners()
- {
- return listeners_;
- }
-
- public void setEventListeners(List<EventListener> listeners)
- {
- listeners_ = listeners;
- }
-
- final public void broadcast() throws Exception
- {
- for (EventListener<T> listener : listeners_)
- listener.execute(this);
- }
-
- static public enum Phase {
- ANY, DECODE, PROCESS, RENDER
- }
-
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/EventListener.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/EventListener.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/EventListener.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,31 +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.event;
-
-/**
- * Created by The eXo Platform SAS
- * May 10, 2006
- */
-abstract public class EventListener<T>
-{
- public static final String RESULT_OK = "OK";
-
- abstract public void execute(Event<T> event) throws Exception;
-}
\ No newline at end of file
Deleted:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/MonitorEvent.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/MonitorEvent.java 2010-07-22
08:00:54 UTC (rev 3675)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/MonitorEvent.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -1,85 +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.event;
-
-import org.exoplatform.webui.application.WebuiRequestContext;
-
-/**
- * Created by The eXo Platform SAS
- * Jun 10, 2006
- *
- * An event object used to monitor the lifecycle of a component
- */
-public class MonitorEvent<T> extends Event<T>
-{
-
- final static public String PORTAL_APPLICATION_LIFECYCLE_EVENT =
"portal.application.lifecycle.event";
-
- final static public String PORTAL_EXECUTION_LIFECYCLE_EVENT =
"portal.execution.lifecycle.event";
-
- final static public String PORTLET_APPLICATION_LIFECYCLE_EVENT =
"portlet.application.lifecycle.event";
-
- final static public String PORTLET_ACTION_LIFECYCLE_EVENT =
"portlet.action.lifecycle.event";
-
- final static public String PORTLET_RENDER_LIFECYCLE_EVENT =
"portlet.render.lifecycle.event";
-
- final static public String UICOMPONENT_LIFECYCLE_MONITOR_EVENT =
"uicomponent.lifecycle.monitor.event";
-
- private long startExecutionTime_;
-
- private long endExecutionTime_;
-
- private Throwable error_;
-
- public MonitorEvent(T source, String name, WebuiRequestContext context)
- {
- super(source, name, context);
- }
-
- public long getStartExecutionTime()
- {
- return startExecutionTime_;
- }
-
- public void setStartExecutionTime(long t)
- {
- startExecutionTime_ = t;
- }
-
- public long getEndExecutionTime()
- {
- return endExecutionTime_;
- }
-
- public void setEndExecutionTime(long t)
- {
- endExecutionTime_ = t;
- }
-
- public Throwable getError()
- {
- return error_;
- }
-
- public void setError(Throwable t)
- {
- error_ = t;
- }
-}
\ No newline at end of file
Deleted: portal/trunk/webui/core/src/main/resources/binding.xml
===================================================================
--- portal/trunk/webui/core/src/main/resources/binding.xml 2010-07-22 08:00:54 UTC (rev
3675)
+++ portal/trunk/webui/core/src/main/resources/binding.xml 2010-07-22 10:34:44 UTC (rev
3676)
@@ -1,101 +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.
-
--->
-
-<binding>
- <mapping name="param"
class="org.exoplatform.webui.config.Param">
- <value name="name" field="name" />
- <value name="value" field="value" />
- </mapping>
-
- <mapping name="init-params"
class="org.exoplatform.webui.config.InitParams">
- <collection item-type="org.exoplatform.webui.config.Param"
field="params" usage="optional" />
- </mapping>
-
- <mapping name="validator"
class="org.exoplatform.webui.config.Validator">
- <value name="type" field="type" />
- <structure usage="optional" field="initParams"/>
- </mapping>
-
- <mapping name="event"
class="org.exoplatform.webui.config.Event">
- <value name="event-name" field="name"/>
- <value usage="optional" name="execution-phase"
field="phase" />
- <structure usage="optional" field="initParams"/>
- <collection field="listeners" usage="optional"
item-type="java.lang.String">
- <value name="listener" style="element"/>
- </collection>
- </mapping>
-
-
- <mapping name="event-interceptor"
class="org.exoplatform.webui.config.EventInterceptor">
- <value name="type" field="type"/>
- <structure usage="optional" field="initParams"/>
- <collection field="interceptors" usage="optional"
item-type="java.lang.String">
- <value name="interceptor" style="element"/>
- </collection>
- </mapping>
-
-
- <!-- component object mapping -->
-
- <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" />
- <value name="template" field="template"
usage="optional" />
- <value name="decorator" field="decorator"
usage="optional" />
-
- <structure usage="optional" field="initParams"/>
-
- <collection item-type="org.exoplatform.webui.config.Validator"
- name="validators" field="validators"
usage="optional" />
- <collection item-type="org.exoplatform.webui.config.Event"
- name="events" field="events"
usage="optional" />
-
- <collection item-type="org.exoplatform.webui.config.EventInterceptor"
- name="event-interceptors" field="eventInterceptors"
usage="optional" />
- </mapping>
-
- <mapping name="application"
class="org.exoplatform.webui.config.Application">
- <structure usage="optional" field="initParams"/>
- <value name="ui-component-root" field="uiroot" />
- <value name="state-manager" field="stateManager" />
- <collection item-type="java.lang.String"
- name="application-lifecycle-listeners"
field="lifecycleListeners" usage="optional">
- <value name="listener" style="element"/>
- </collection>
-
- <collection item-type="org.exoplatform.webui.config.Event"
- name="events" field="events"
usage="optional" />
- </mapping>
-
- <!-- jsf-configuration object mapping -->
- <mapping name="webui-configuration"
class="org.exoplatform.webui.config.WebuiConfiguration">
- <collection field="annotationClasses"
name="annotation-classes"
- usage="optional"
item-type="java.lang.String">
- <value name="class" style="element"/>
- </collection>
-
- <collection
item-type="org.exoplatform.webui.config.metadata.ComponentMetaData"
- field="components" usage="optional" />
-
- <structure usage="optional" field="application"/>
- </mapping>
-</binding>
Property changes on: portal/trunk/webui/framework
___________________________________________________________________
Name: svn:ignore
+ target
*.iml
Added: portal/trunk/webui/framework/pom.xml
===================================================================
--- portal/trunk/webui/framework/pom.xml (rev 0)
+++ portal/trunk/webui/framework/pom.xml 2010-07-22 10:34:44 UTC (rev 3676)
@@ -0,0 +1,72 @@
+<!--
+
+ 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.
+
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui</artifactId>
+ <version>3.2.0-Beta01-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>exo.portal.webui.framework</artifactId>
+ <packaging>jar</packaging>
+ <name>GateIn Portal WebUI Framework</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.web</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jibx</groupId>
+ <artifactId>maven-jibx-plugin</artifactId>
+ <version>${org.jibx.version}</version>
+ <configuration>
+ <directory>src/main/resources</directory>
+ <includes>
+ <includes>binding.xml</includes>
+ </includes>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>bind</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Copied: portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/Util.java (from
rev 3618, portal/trunk/webui/core/src/main/java/org/exoplatform/webui/Util.java)
===================================================================
--- portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/Util.java
(rev 0)
+++ portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/Util.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,68 @@
+/**
+ * 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;
+
+import org.exoplatform.webui.config.InitParams;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 10, 2006
+ *
+ * A utility class that provides static methods to create new objects, of a given type
+ */
+public class Util
+{
+ /**
+ * The default parameters given to the constructor
+ */
+ static Class<?>[] CONSTRUCTOR_PARAMS = {InitParams.class};
+
+ /**
+ *
+ * @param type The type of the object to create, given as a String
+ * @param params The parameters to give to the constructor
+ * @return A new object of the given type
+ * @throws Exception
+ */
+ static public Object createObject(String type, InitParams params) throws Exception
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class<?> clazz = cl.loadClass(type);
+ return createObject(clazz, params);
+ }
+
+ /**
+ *
+ * @param <T> The type of the object to create
+ * @param type The type parameter given as a Class object
+ * @param params The parameters to give to the constructor
+ * @return The object of type T
+ * @throws Exception
+ */
+ static public <T> T createObject(Class<T> type, InitParams params) throws
Exception
+ {
+ if (params == null)
+ {
+ return type.getConstructor().newInstance();
+ }
+ Object[] args = {params};
+ return type.getConstructor(CONSTRUCTOR_PARAMS).newInstance(args);
+ }
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/ConfigurationManager.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,408 @@
+/**
+ * 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.application;
+
+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;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * May 10, 2006
+ * <p/>
+ * Manages the ComponentConfig of a list of components.
+ *
+ * @see ComponentConfig
+ */
+public class ConfigurationManager
+{
+ /**
+ * todo (julien) : this map should be synchronized somehow
+ * <p/>
+ * The components of which we manage the configuration
+ */
+ private Map<String, Component> configs_ = new HashMap<String,
Component>();
+
+ /** The logger. */
+ private final Logger log;
+
+ /** . */
+ private Application application_;
+
+ /**
+ * @param inputStream A stream that links the configuration file
+ * @throws Exception
+ */
+ 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);
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (config.getAnnotationClasses() != null)
+ {
+ for (String annotationClass : config.getAnnotationClasses())
+ {
+ //process annotation and get the Component
+ Component[] components = annotationToComponents(cl, annotationClass);
+ setComponentConfigs(components);
+ }
+ }
+ if (config.getComponents() != null)
+ {
+ for (ComponentMetaData componentMetaData : config.getComponents())
+ {
+ String key = componentMetaData.getType();
+ if (componentMetaData.getId() != null)
+ {
+ key = key + ":" + componentMetaData.getId();
+ }
+ configs_.put(key, new Component(componentMetaData));
+ }
+ }
+
+ application_ = config.getApplication();
+ }
+
+ /**
+ * Adds components to the list
+ *
+ * @param configs An array of Component
+ */
+ void setComponentConfigs(Component[] configs)
+ {
+ for (Component component : configs)
+ {
+ configs_.put(component.getKey(), component);
+ }
+ }
+
+ /**
+ * Gets the components of a given class
+ *
+ * @param clazz The class of the components
+ * @return the list of components
+ */
+ public List<Component> getComponentConfig(Class<?> clazz)
+ {
+ List<Component> configs = new ArrayList<Component>();
+ Collection<Component> values = configs_.values();
+ String type = clazz.getName();
+ for (Component comp : values)
+ {
+ if (comp.getType().equals(type))
+ {
+ configs.add(comp);
+ }
+ }
+ 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
+ *
+ * @param type The class of the component
+ * @param id The id of the component
+ * @return The component
+ */
+ public Component getComponentConfig(Class<?> type, String id)
+ {
+ String key = type.getName();
+ if (id != null)
+ {
+ key = key + ":" + id;
+ }
+
+ //
+ Component config = configs_.get(key);
+ if (config != null)
+ {
+ return config;
+ }
+
+ //
+ process(type);
+
+ //
+ return configs_.get(key);
+ }
+
+ public Application getApplication()
+ {
+ return application_;
+ }
+
+ /**
+ * Gets an array of Component from a ComponentConfig annotation
+ *
+ * @param cl the classloader to create the annotation
+ * @param annClass the annotation class
+ * @return The array of Component
+ * @throws Exception
+ */
+ Component[] annotationToComponents(ClassLoader cl, String annClass) throws Exception
+ {
+ Class<?> clazz = cl.loadClass(annClass);
+ return annotationToComponents(clazz);
+ }
+
+ /**
+ * Gets an array of Component from a ComponentConfig annotation
+ *
+ * @param clazz The annotation class from which to get the ComponentConfig
+ * @return The array of Component
+ * @throws Exception
+ */
+ Component[] annotationToComponents(Class<?> clazz) throws Exception
+ {
+ ComponentConfig annotation = clazz.getAnnotation(ComponentConfig.class);
+ if (annotation != null)
+ {
+ return new Component[]{toComponentConfig(annotation, clazz)};
+ }
+
+ ComponentConfigs annotations = clazz.getAnnotation(ComponentConfigs.class);
+ if (annotations != null)
+ {
+ ComponentConfig[] listAnnotations = annotations.value();
+ Component[] componentConfigs = new Component[listAnnotations.length];
+ for (int i = 0; i < componentConfigs.length; i++)
+ {
+ componentConfigs[i] = toComponentConfig(listAnnotations[i], clazz);
+ }
+ return componentConfigs;
+ }
+
+ return new Component[]{};
+ }
+
+ private Component toComponentConfig(ComponentConfig annotation, Class<?> clazz)
throws Exception
+ {
+ String template = null;
+ if (annotation.template().length() > 0)
+ {
+ template = annotation.template();
+ }
+
+ //
+ String id = null;
+ if (annotation.id().length() > 0)
+ {
+ id = annotation.id();
+ }
+
+ //
+ Class<?> type = annotation.type() == void.class ? clazz : annotation.type();
+
+ //
+ String lifecycle = null;
+ if (annotation.lifecycle() != void.class)
+ {
+ lifecycle = annotation.lifecycle().getName();
+ }
+
+ //
+ String decorator = null;
+ if (annotation.decorator().length() > 0)
+ {
+ decorator = annotation.decorator();
+ }
+
+ //
+ EventConfig[] eventAnnotations = annotation.events();
+ ArrayList<Event> events;
+ if (eventAnnotations.length != 0)
+ {
+ events = new ArrayList<Event>();
+ for (EventConfig eventAnnotation : eventAnnotations)
+ {
+ events.add(toEventConfig(eventAnnotation));
+ }
+ }
+ else
+ {
+ events = new ArrayList<Event>();
+ }
+
+ //
+ EventInterceptorConfig[] eventInterceptorAnnotations =
annotation.eventInterceptors();
+ ArrayList<EventInterceptor> eventInterceptors;
+ if (eventInterceptorAnnotations.length != 0)
+ {
+ eventInterceptors = new ArrayList<EventInterceptor>();
+ for (EventInterceptorConfig eventAnnotation : eventInterceptorAnnotations)
+ {
+ eventInterceptors.add(toEventInterceptorConfig(eventAnnotation));
+ }
+ }
+ else
+ {
+ eventInterceptors = new ArrayList<EventInterceptor>();
+ }
+
+ //
+ ValidatorConfig[] validatorAnnotations = annotation.validators();
+ ArrayList<Validator> validators;
+ if (validatorAnnotations.length != 0)
+ {
+ validators = new ArrayList<Validator>();
+ for (ValidatorConfig ele : validatorAnnotations)
+ {
+ validators.add(toValidator(ele));
+ }
+ }
+ else
+ {
+ validators = new ArrayList<Validator>();
+ }
+
+ //
+ return new Component(
+ clazz,
+ id,
+ type.getName(),
+ lifecycle,
+ template,
+ decorator,
+ toInitParams(annotation.initParams()),
+ validators,
+ events,
+ eventInterceptors);
+ }
+
+ private Event toEventConfig(EventConfig annotation) throws Exception
+ {
+ Event event = new Event();
+ event.setExecutionPhase(annotation.phase());
+ event.setConfirm(annotation.confirm());
+ event.setInitParams(toInitParams(annotation.initParams()));
+ ArrayList<String> listeners = new ArrayList<String>();
+ for (Class<?> clazz : annotation.listeners())
+ {
+ listeners.add(clazz.getName());
+ }
+ if (annotation.name().length() > 0)
+ {
+ event.setName(annotation.name());
+ }
+ else if (annotation.listeners().length > 0)
+ {
+ String name = annotation.listeners()[0].getSimpleName();
+ int idx = name.indexOf("ActionListener");
+ if (idx > -1)
+ {
+ name = name.substring(0, idx);
+ }
+ event.setName(name);
+ }
+ event.setListeners(listeners);
+ return event;
+ }
+
+ private EventInterceptor toEventInterceptorConfig(EventInterceptorConfig annotation)
throws Exception
+ {
+ EventInterceptor eventInterceptor = new EventInterceptor();
+ eventInterceptor.setType(annotation.type().getName());
+ ArrayList<String> list = new ArrayList<String>();
+ Collections.addAll(list, annotation.interceptors());
+ eventInterceptor.setInterceptors(list);
+ eventInterceptor.setInitParams(toInitParams(annotation.initParams()));
+ return eventInterceptor;
+ }
+
+ private Validator toValidator(ValidatorConfig annotation) throws Exception
+ {
+ Validator validator = new Validator();
+ validator.setType(annotation.type().getName());
+ validator.setInitParams(toInitParams(annotation.initParams()));
+ return validator;
+ }
+
+ private InitParams toInitParams(ParamConfig[] annotations)
+ {
+ if (annotations == null || annotations.length < 1)
+ {
+ return null;
+ }
+ ArrayList<Param> listParam = new ArrayList<Param>();
+ for (ParamConfig ele : annotations)
+ {
+ Param param = new Param();
+ param.setName(ele.name());
+ param.setValue(ele.value());
+ listParam.add(param);
+ }
+ InitParams initParams = new InitParams();
+ initParams.setParams(listParam);
+ return initParams;
+ }
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/StateManager.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/StateManager.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/StateManager.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/StateManager.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,31 @@
+/**
+ * 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.application;
+
+import org.exoplatform.webui.core.UIApplication;
+
+abstract public class StateManager
+{
+ abstract public UIApplication restoreUIRootComponent(WebuiRequestContext context)
throws Exception;
+
+ abstract public void storeUIRootComponent(WebuiRequestContext context) throws
Exception;
+
+ abstract public void expire(String sessionId, WebuiApplication app) throws Exception;
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiApplication.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiApplication.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiApplication.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiApplication.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,124 @@
+/**
+ * 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.application;
+
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.ApplicationLifecycle;
+import org.exoplatform.webui.Util;
+import org.exoplatform.webui.config.Component;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+
+import java.io.InputStream;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *Created by The eXo Platform SAS
+ * May 7, 2006
+ *
+ * This abstract class defines several methods to abstract the differnt type of web
application the
+ * eXo web framework can provide such as portal or portlet.
+ */
+abstract public class WebuiApplication extends Application
+{
+
+ private ConfigurationManager configManager_;
+
+ private StateManager stateManager_;
+
+ /**
+ * This initialisation goals is to first extract and parse the webui configuration XML
file
+ * defined inside the web.xml of the web application.
+ *
+ * The ConfigurationManager class is responsible of the parsing and then wrap all the
information
+ * about the UI configuration.
+ *
+ * One of the information is the real implementation of the StateManager object. That
object is
+ * extracted from the configuration and stored as a field in that class.
+ *
+ * Lifecycle phases are also extracted from the XML file, referenced in this
WebuiApplication class
+ * and initialized at the same time.
+ *
+ */
+ public void onInit() throws Exception
+ {
+ String configPath = getApplicationInitParam("webui.configuration");
+ InputStream is = getResourceResolver().getInputStream(configPath);
+ configManager_ = new ConfigurationManager(is);
+ String stateManagerClass = configManager_.getApplication().getStateManager();
+ StateManager stManager = (StateManager)Util.createObject(stateManagerClass, null);
+ setStateManager(stManager);
+ List<ApplicationLifecycle> lifecycleListeners =
+ configManager_.getApplication().getApplicationLifecycleListeners();
+ setApplicationLifecycle(lifecycleListeners);
+ for (ApplicationLifecycle lifecycle : lifecycleListeners)
+ lifecycle.onInit(this);
+ }
+
+ public ConfigurationManager getConfigurationManager()
+ {
+ return configManager_;
+ }
+
+ public StateManager getStateManager()
+ {
+ return stateManager_;
+ }
+
+ public void setStateManager(StateManager sm)
+ {
+ stateManager_ = sm;
+ }
+
+ abstract public String getApplicationInitParam(String name);
+
+ public <T> void broadcast(Event<T> event) throws Exception
+ {
+ List<EventListener> listeners =
configManager_.getApplication().getApplicationEventListeners(event.getName());
+ if (listeners == null)
+ return;
+ for (EventListener<T> listener : listeners)
+ listener.execute(event);
+ }
+
+ public <T extends UIComponent> T createUIComponent(Class<T> type, String
configId, String id,
+ WebuiRequestContext context) throws Exception
+ {
+ Component config = configManager_.getComponentConfig(type, configId);
+ if (config == null)
+ {
+ throw new Exception("Cannot find the configuration for the component "
+ type.getName() + ", configId "
+ + configId);
+ }
+ T uicomponent = Util.createObject(type, config.getInitParams());
+ uicomponent.setComponentConfig(id, config);
+ return uicomponent;
+ }
+
+ public Set<UIComponent> getDefaultUIComponentToUpdateByAjax(WebuiRequestContext
context)
+ {
+ Set<UIComponent> list = new LinkedHashSet<UIComponent>(3);
+ list.add(context.getUIApplication());
+ return list;
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
(from rev 3673,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,200 @@
+/**
+ * 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.application;
+
+import org.exoplatform.resolver.ApplicationResourceResolver;
+import org.exoplatform.resolver.ResourceResolver;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.RequestContext;
+import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIComponent;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 7, 2006
+ *
+ * The main class to manage the request context in a webui environment
+ *
+ * It adds:
+ * - some access to the root UI component (UIApplication)
+ * - access to the request and response objects
+ * - information about the current state of the request
+ * - the list of object to be updated in an AJAX way
+ * - an access to the ResourceResolver bound to an uri scheme
+ * - the reference on the StateManager object
+ */
+abstract public class WebuiRequestContext extends RequestContext
+{
+
+ protected UIApplication uiApplication_;
+
+ protected String sessionId_;
+
+ protected ResourceBundle appRes_;
+
+ private StateManager stateManager_;
+
+ private boolean responseComplete_ = false;
+
+ private boolean processRender_ = false;
+
+ private Set<UIComponent> uicomponentToUpdateByAjax;
+
+ public WebuiRequestContext(Application app)
+ {
+ super(app);
+ }
+
+ public String getSessionId()
+ {
+ return sessionId_;
+ }
+
+ protected void setSessionId(String id)
+ {
+ sessionId_ = id;
+ }
+
+ public UIApplication getUIApplication()
+ {
+ return uiApplication_;
+ }
+
+ public void setUIApplication(UIApplication uiApplication) throws Exception
+ {
+ uiApplication_ = uiApplication;
+ appRes_ = null;
+ }
+
+ public ResourceBundle getApplicationResourceBundle()
+ {
+ if (appRes_ == null)
+ {
+ try
+ {
+ Locale locale = getLocale();
+ appRes_ = getApplication().getResourceBundle(locale);
+ }
+ catch (Exception e)
+ {
+ throw new UndeclaredThrowableException(e);
+ }
+ }
+ return appRes_;
+ }
+
+ public String getActionParameterName()
+ {
+ return WebuiRequestContext.ACTION;
+ }
+
+ public String getUIComponentIdParameterName()
+ {
+ return UIComponent.UICOMPONENT;
+ }
+
+ @Override
+ public abstract URLBuilder<UIComponent> getURLBuilder();
+
+ public abstract String getRequestContextPath();
+
+ /**
+ * Returns the context path of the portal or null if it does not execute in the
context
+ * of an aggregated portal request.
+ *
+ * @return the portal context path
+ */
+ public abstract String getPortalContextPath();
+
+ abstract public <T> T getRequest() throws Exception;
+
+ abstract public <T> T getResponse() throws Exception;
+
+ public boolean isResponseComplete()
+ {
+ return responseComplete_;
+ }
+
+ public void setResponseComplete(boolean b)
+ {
+ responseComplete_ = b;
+ }
+
+ abstract public void sendRedirect(String url) throws Exception;
+
+ public boolean getProcessRender()
+ {
+ return processRender_;
+ }
+
+ public void setProcessRender(boolean b)
+ {
+ processRender_ = b;
+ }
+
+ public Set<UIComponent> getUIComponentToUpdateByAjax()
+ {
+ return uicomponentToUpdateByAjax;
+ }
+
+ public void addUIComponentToUpdateByAjax(UIComponent uicomponent)
+ {
+ if (uicomponentToUpdateByAjax == null)
+ {
+ uicomponentToUpdateByAjax = new LinkedHashSet<UIComponent>();
+ }
+ uicomponentToUpdateByAjax.add(uicomponent);
+ }
+
+ public ResourceResolver getResourceResolver(String uri)
+ {
+ Application app = getApplication();
+ while (app != null)
+ {
+ ApplicationResourceResolver appResolver = app.getResourceResolver();
+ ResourceResolver resolver = appResolver.getResourceResolver(uri);
+ if (resolver != null)
+ return resolver;
+ RequestContext pcontext = getParentAppRequestContext();
+ if (pcontext != null)
+ app = pcontext.getApplication();
+ else
+ app = null;
+ }
+ return null;
+ }
+
+ public StateManager getStateManager()
+ {
+ return stateManager_;
+ }
+
+ public void setStateManager(StateManager manager)
+ {
+ stateManager_ = manager;
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Application.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Application.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Application.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Application.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,123 @@
+/**
+ * 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.web.application.ApplicationLifecycle;
+import org.exoplatform.webui.Util;
+import org.exoplatform.webui.config.Event;
+import org.exoplatform.webui.config.InitParams;
+import org.exoplatform.webui.event.EventListener;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * May 7, 2006
+ */
+public class Application
+{
+
+ private InitParams initParams;
+
+ private String uiroot;
+
+ private String stateManager;
+
+ public InitParams getInitParams()
+ {
+ return initParams;
+ }
+
+ private ArrayList<String> lifecycleListeners;
+
+ private ArrayList<Event> events;
+
+ transient private Map<String, Event> eventMap;
+
+ public String getUIRootComponent()
+ {
+ return uiroot;
+ }
+
+ public String getStateManager()
+ {
+ return stateManager;
+ }
+
+ public ArrayList<String> getLifecyleListeners()
+ {
+ return lifecycleListeners;
+ }
+
+ public ArrayList<Event> getEvents()
+ {
+ return events;
+ }
+
+ public Event getApplicationEventConfig(String eventName)
+ {
+ if (eventMap != null)
+ return eventMap.get(eventName);
+ eventMap = new HashMap<String, Event>();
+ if (events == null)
+ return null;
+ for (Event event : events)
+ {
+ eventMap.put(event.getName(), event);
+ }
+ return eventMap.get(eventName);
+ }
+
+ public List<EventListener> getApplicationEventListeners(String eventName) throws
Exception
+ {
+ Event event = getApplicationEventConfig(eventName);
+ if (event == null)
+ return null;
+ List<EventListener> cachedListeners = event.getCachedEventListeners();
+ if (cachedListeners != null)
+ return cachedListeners;
+ cachedListeners = new ArrayList<EventListener>();
+ for (String listener : event.getListeners())
+ {
+ EventListener eventListener = (EventListener)Util.createObject(listener, null);
+ cachedListeners.add(eventListener);
+ }
+ event.setCachedEventListeners(cachedListeners);
+ return cachedListeners;
+ }
+
+ public List<ApplicationLifecycle> getApplicationLifecycleListeners() throws
Exception
+ {
+ List<ApplicationLifecycle> appLifecycles = new
ArrayList<ApplicationLifecycle>();
+ if (lifecycleListeners == null)
+ return appLifecycles;
+ for (String type : lifecycleListeners)
+ {
+ ApplicationLifecycle instance = (ApplicationLifecycle)Util.createObject(type,
null);
+ appLifecycles.add(instance);
+ }
+ return appLifecycles;
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Component.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Component.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,254 @@
+/**
+ * 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.Util;
+import org.exoplatform.commons.serialization.api.annotations.Converted;
+import org.exoplatform.webui.config.metadata.ComponentMetaData;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.lifecycle.Lifecycle;
+import org.exoplatform.webui.event.EventListener;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+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
+{
+
+ final ComponentHandle handle;
+
+ private final String id;
+
+ private final String type;
+
+ private final String lifecycle;
+
+ private final String template;
+
+ private final String decorator;
+
+ private final InitParams initParams;
+
+ private final List<Validator> validators;
+
+ private final List<Event> events;
+
+ private final List<EventInterceptor> eventInterceptors;
+
+ private Map<String, Event> eventMap;
+
+ private Lifecycle<UIComponent> componentLifecycle;
+
+ public Component(ComponentMetaData metaData)
+ {
+ 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 Component(
+ Class<?> owner,
+ String id,
+ String type,
+ String lifecycle,
+ String template,
+ String decorator,
+ InitParams initParams,
+ List<Validator> validators,
+ List<Event> events,
+ List<EventInterceptor> eventInterceptors)
+ {
+ this(
+ new ComponentHandle(owner, id == null ? type : type + ":" + id),
+ id,
+ type,
+ lifecycle,
+ template,
+ decorator,
+ initParams,
+ validators,
+ events,
+ eventInterceptors);
+ }
+
+ 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)
+ {
+ 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 getKey()
+ {
+ return handle.getKey();
+ }
+
+ 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 InitParams getInitParams()
+ {
+ return initParams;
+ }
+
+ public List<Validator> getValidators()
+ {
+ return validators;
+ }
+
+ public List<Event> getEvents()
+ {
+ return events;
+ }
+
+ public List<EventInterceptor> getEventInterceptors()
+ {
+ return eventInterceptors;
+ }
+
+ public Event getUIComponentEventConfig(String eventName) throws Exception
+ {
+ if (eventMap != null)
+ {
+ return eventMap.get(eventName);
+ }
+ eventMap = new HashMap<String, Event>();
+ if (events == null)
+ {
+ return null;
+ }
+ for (Event event : events)
+ {
+ createCachedEventListeners(event);
+ eventMap.put(event.getName(), event);
+ }
+ return eventMap.get(eventName);
+ }
+
+ public List<EventListener> getUIComponentEventListeners(String eventName) throws
Exception
+ {
+ Event event = getUIComponentEventConfig(eventName);
+ if (event == null)
+ {
+ return null;
+ }
+ List<EventListener> cachedListeners = event.getCachedEventListeners();
+ if (cachedListeners != null)
+ {
+ return cachedListeners;
+ }
+ cachedListeners = new ArrayList<EventListener>();
+ for (String listener : event.getListeners())
+ {
+ if (listener.indexOf(".") < 0)
+ {
+ listener = type + "$" + listener;
+ }
+ EventListener eventListener = (EventListener)Util.createObject(listener,
event.getInitParams());
+ cachedListeners.add(eventListener);
+ }
+ event.setCachedEventListeners(cachedListeners);
+ return cachedListeners;
+ }
+
+ private void createCachedEventListeners(Event event) throws Exception
+ {
+ List<EventListener> cachedListeners = new ArrayList<EventListener>();
+ for (String listener : event.getListeners())
+ {
+ if (listener.indexOf(".") < 0)
+ {
+ listener = type + "$" + listener;
+ }
+ EventListener eventListener = (EventListener)Util.createObject(listener,
event.getInitParams());
+ cachedListeners.add(eventListener);
+ }
+ event.setCachedEventListeners(cachedListeners);
+ }
+
+ public Lifecycle<UIComponent> getUIComponentLifecycle() throws Exception
+ {
+ if (componentLifecycle != null)
+ {
+ return componentLifecycle;
+ }
+ if (lifecycle != null)
+ {
+ componentLifecycle = (Lifecycle<UIComponent>)Util.createObject(lifecycle,
null);
+ }
+ else
+ {
+ componentLifecycle =
(Lifecycle<UIComponent>)Util.createObject(Lifecycle.class, null);
+ }
+ return componentLifecycle;
+ }
+
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentConfigConverter.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -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.commons.serialization.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);
+ }
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentHandle.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/ComponentHandle.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentHandle.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/ComponentHandle.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -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;
+ }
+}
Copied: portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Event.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Event.java)
===================================================================
--- portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Event.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Event.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,129 @@
+/**
+ * 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.event.EventListener;
+import org.exoplatform.webui.event.Event.Phase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 9, 2006
+ */
+public class Event
+{
+
+ private String name;
+
+ private String confirm;
+
+ private InitParams initParams;
+
+ private ArrayList<String> listeners;
+
+ transient private List<EventListener> eventListeners_;
+
+ private String phase = "process";
+
+ transient private Phase executionPhase_ = null;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getPhase()
+ {
+ return phase;
+ }
+
+ public void setPhase(String s)
+ {
+ phase = s;
+ }
+
+ public List<String> getListeners()
+ {
+ return listeners;
+ }
+
+ public void setListeners(ArrayList<String> listeners)
+ {
+ this.listeners = listeners;
+ }
+
+ public InitParams getInitParams()
+ {
+ return initParams;
+ }
+
+ public void setInitParams(InitParams initParams)
+ {
+ this.initParams = initParams;
+ }
+
+ public String getConfirm()
+ {
+ return confirm;
+ }
+
+ public void setConfirm(String confirm)
+ {
+ this.confirm = confirm;
+ }
+
+ public Phase getExecutionPhase()
+ {
+ if (executionPhase_ != null)
+ return executionPhase_;
+ try
+ {
+ executionPhase_ = Phase.valueOf(phase.toUpperCase());
+ }
+ catch (Exception e)
+ {
+ executionPhase_ = Phase.PROCESS;
+ }
+ return executionPhase_;
+ }
+
+ public void setExecutionPhase(Phase executionPhase)
+ {
+ this.executionPhase_ = executionPhase;
+ }
+
+ public List<EventListener> getCachedEventListeners() throws Exception
+ {
+ return eventListeners_;
+ }
+
+ public void setCachedEventListeners(List<EventListener> list)
+ {
+ eventListeners_ = list;
+ }
+
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/EventInterceptor.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/EventInterceptor.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/EventInterceptor.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/EventInterceptor.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,69 @@
+/**
+ * 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;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * May 4, 2006
+ */
+public class EventInterceptor
+{
+
+ private String type;
+
+ private InitParams initParams;
+
+ private ArrayList<String> interceptors;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public ArrayList<String> getInterceptors()
+ {
+ return interceptors;
+ }
+
+ public void setInterceptors(ArrayList<String> interceptors)
+ {
+ this.interceptors = interceptors;
+ }
+
+ public InitParams getInitParams()
+ {
+ return initParams;
+ }
+
+ public void setInitParams(InitParams initParams)
+ {
+ this.initParams = initParams;
+ }
+
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/InitParams.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/InitParams.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/InitParams.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/InitParams.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,57 @@
+/**
+ * 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;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * May 9, 2006
+ */
+public class InitParams
+{
+
+ private ArrayList<Param> params;
+
+ public Param getParam(String name)
+ {
+ if (params == null)
+ return null;
+ for (Param param : params)
+ {
+ if (name.equals(param.getName()))
+ return param;
+ }
+ return null;
+ }
+
+ public ArrayList<Param> getParams()
+ {
+ return params;
+ }
+
+ public void setParams(ArrayList<Param> params)
+ {
+ this.params = params;
+ }
+
+}
\ No newline at end of file
Copied: portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Param.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Param.java)
===================================================================
--- portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Param.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Param.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,117 @@
+/**
+ * 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 groovy.lang.Binding;
+import groovy.lang.GroovyShell;
+
+import org.exoplatform.resolver.ResourceResolver;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.xml.object.XMLObject;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import java.io.InputStream;
+
+public class Param
+{
+
+ /** . */
+ private static final Logger log = LoggerFactory.getLogger(Param.class);
+
+ private String name;
+
+ private String value;
+
+ private transient Object object;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public Object getMapXMLObject(WebuiRequestContext context) throws Exception
+ {
+ if (object != null)
+ return object;
+ ResourceResolver resolver = context.getResourceResolver(value);
+ InputStream is = resolver.getInputStream(value);
+ object = XMLObject.getObject(is);
+ is.close();
+ return object;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getMapGroovyObject(WebuiRequestContext context) throws Exception
+ {
+ try
+ {
+ if (object != null)
+ return object;
+ ResourceResolver resolver = context.getResourceResolver(value);
+ InputStream is = resolver.getInputStream(value);
+ //TODO if is == null throw an exception saying the it's impossible to find
the file
+ Binding binding = new Binding();
+ GroovyShell shell = new
GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
+ object = shell.evaluate(is);
+ is.close();
+ return object;
+ }
+ catch (Exception e)
+ {
+ log.error("A problem in the groovy script : " + value, e);
+ throw e;
+ }
+ }
+
+ public Object getFreshObject(WebuiRequestContext context) throws Exception
+ {
+ try
+ {
+ ResourceResolver resolver = context.getResourceResolver(value);
+ InputStream is = resolver.getInputStream(value);
+ Binding binding = new Binding();
+ GroovyShell shell = new
GroovyShell(Thread.currentThread().getContextClassLoader(), binding);
+ object = shell.evaluate(is);
+ is.close();
+ return object;
+ }
+ catch (Exception e)
+ {
+ log.error("A problem in the groovy script : " + value, e);
+ throw e;
+ }
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Validator.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/Validator.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Validator.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/Validator.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,55 @@
+/**
+ * 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;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * May 4, 2006
+ */
+public class Validator
+{
+
+ private String type;
+
+ private InitParams initParams;
+
+ public InitParams getInitParams()
+ {
+ return initParams;
+ }
+
+ public void setInitParams(InitParams initParams)
+ {
+ this.initParams = initParams;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/WebuiConfiguration.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,54 @@
+/**
+ * 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.config.metadata.ComponentMetaData;
+
+import java.util.ArrayList;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 4, 2006
+ */
+public class WebuiConfiguration
+{
+
+ private ArrayList<String> annotationClasses;
+
+ private ArrayList<ComponentMetaData> components;
+
+ private Application application;
+
+ public ArrayList<String> getAnnotationClasses()
+ {
+ return annotationClasses;
+ }
+
+ public ArrayList<ComponentMetaData> getComponents()
+ {
+ return components;
+ }
+
+ public Application getApplication()
+ {
+ return application;
+ }
+
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfig.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfig.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfig.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,51 @@
+/**
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Jul 4, 2006
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface ComponentConfig {
+
+ String id() default "";
+
+ Class type() default void.class;
+
+ String template() default "";
+
+ Class lifecycle() default void.class;
+
+ String decorator() default "";
+
+ ParamConfig[] initParams() default {};
+
+ ValidatorConfig[] validators() default {};
+
+ EventConfig[] events() default {};
+
+ EventInterceptorConfig[] eventInterceptors() default {};
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfigs.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfigs.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ComponentConfigs.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,36 @@
+/**
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Jul 4, 2006
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface ComponentConfigs {
+ ComponentConfig[] value() default {};
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventConfig.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventConfig.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventConfig.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,45 @@
+/**
+ * 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.annotation;
+
+import org.exoplatform.webui.event.Event.Phase;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Jul 4, 2006
+ */
+
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface EventConfig {
+ String name() default "";
+
+ String confirm() default "";
+
+ Class[] listeners();
+
+ Phase phase() default Phase.PROCESS;
+
+ ParamConfig[] initParams() default {};
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventInterceptorConfig.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventInterceptorConfig.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/EventInterceptorConfig.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,40 @@
+/**
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Jul 5, 2006
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface EventInterceptorConfig {
+ Class type();
+
+ String[] interceptors();
+
+ ParamConfig[] initParams() default {};
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ParamConfig.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ParamConfig.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ParamConfig.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,38 @@
+/**
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Jul 5, 2006
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface ParamConfig {
+ String name();
+
+ String value();
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ValidatorConfig.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ValidatorConfig.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/annotation/ValidatorConfig.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,38 @@
+/**
+ * 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Author : Nhu Dinh Thuan
+ * nhudinhthuan(a)exoplatform.com
+ * Jul 5, 2006
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+public @interface ValidatorConfig {
+ Class type();
+
+ ParamConfig[] initParams() default {};
+}
Added:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/config/metadata/ComponentMetaData.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -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
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIApplication.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -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.core;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.exception.MessageException;
+
+import java.io.Writer;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 8, 2006
+ */
+@Serialized
+abstract public class UIApplication extends UIContainer
+{
+
+ protected static Log log = ExoLogger.getLogger("portal:UIApplication");
+
+ private String owner;
+
+ private long lastAccessApplication_;
+
+ private UIPopupMessages uiPopupMessages_;
+ private static final String UIAPPLICATION = "uiapplication";
+
+ public UIApplication() throws Exception
+ {
+ uiPopupMessages_ = createUIComponent(UIPopupMessages.class, null, null);
+ uiPopupMessages_.setId("_" + uiPopupMessages_.hashCode());
+ }
+
+ public String getOwner()
+ {
+ return owner;
+ }
+
+ public void setOwner(String s)
+ {
+ owner = s;
+ }
+
+ public UIPopupMessages getUIPopupMessages()
+ {
+ return uiPopupMessages_;
+ }
+
+ public void addMessage(ApplicationMessage message)
+ {
+ uiPopupMessages_.addMessage(message);
+ }
+
+ public void clearMessages()
+ {
+ uiPopupMessages_.clearMessages();
+ }
+
+ public long getLastAccessApplication()
+ {
+ return lastAccessApplication_;
+ }
+
+ public void setLastAccessApplication(long time)
+ {
+ lastAccessApplication_ = time;
+ }
+
+ public String getUIComponentName()
+ {
+ return UIAPPLICATION;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T findComponentById(String lookupId)
+ {
+ if (uiPopupMessages_.getId().equals(lookupId))
+ return (T)uiPopupMessages_;
+ return (T)super.findComponentById(lookupId);
+ }
+
+ public void renderChildren() throws Exception
+ {
+ super.renderChildren();
+ if (uiPopupMessages_ == null)
+ return;
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ uiPopupMessages_.processRender(context);
+ }
+
+ public void processAction(WebuiRequestContext context) throws Exception
+ {
+ try
+ {
+ super.processAction(context);
+ }
+ catch (MessageException ex)
+ {
+ uiPopupMessages_.addMessage(ex.getDetailMessage());
+ }
+ catch (Throwable t)
+ {
+ Object[] args = {t.getMessage()};
+ ApplicationMessage msg =
+ new ApplicationMessage("UIApplication.msg.unknown-error", args,
ApplicationMessage.ERROR);
+ uiPopupMessages_.addMessage(msg);
+ log.error("Error during the processAction phase", t);
+ }
+ }
+
+ public void renderBlockToUpdate(UIComponent uicomponent, WebuiRequestContext context,
Writer w) throws Exception
+ {
+ w.write("<div class=\"BlockToUpdate\">");
+ w.append("<div
class=\"BlockToUpdateId\">").append(uicomponent.getId()).append("</div>");
+ w.write("<div class=\"BlockToUpdateData\">");
+ uicomponent.processRender(context);
+ w.write("</div>");
+ w.write("</div>");
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
(from rev 3675,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponent.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponent.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,494 @@
+/**
+ * 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.core;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.resolver.ResourceResolver;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.web.application.Parameter;
+import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.webui.application.WebuiApplication;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.config.Component;
+import org.exoplatform.webui.core.lifecycle.Lifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.event.MonitorEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** Created by The eXo Platform SAS May 7, 2006 */
+@Serialized
+abstract public class UIComponent
+{
+ private static final Log log = ExoLogger.getLogger("webui:UIComponent");
+
+ final static public String OBJECTID = "objectId";
+
+ final static public String UICOMPONENT = "uicomponent";
+
+ final static public String AJAX_ASYNC = "ajax_async";
+
+ private String id;
+
+ private boolean rendered = true;
+
+ protected UIComponent uiparent;
+
+ protected Component config;
+
+ private static final Lifecycle<UIComponent> DEFAULT_LIFECYCLE = new
Lifecycle<UIComponent>();
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ public UIComponent setId(String id)
+ {
+ if (id == null)
+ {
+ this.id = Integer.toString(hashCode());
+ }
+ else
+ {
+ this.id = id;
+ }
+ return this;
+ }
+
+ public String getName()
+ {
+ return getClass().getSimpleName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T getParent()
+ {
+ return (T)this.uiparent;
+ }
+
+ public void setParent(UIComponent uicomponent)
+ {
+ this.uiparent = uicomponent;
+ }
+
+ public boolean isRendered()
+ {
+ return this.rendered;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T setRendered(boolean b)
+ {
+ this.rendered = b;
+ return (T)this;
+ }
+
+ //
+ // public void processInit(WebuiRequestContext context) throws Exception {
+ // MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.INIT,
context);
+ // config.getUIComponentLifecycle().init(this, context) ;
+ // if(mevent != null) {
+ // mevent.setEndExecutionTime(System.currentTimeMillis()) ;
+ // mevent.broadcast() ;
+ // }
+ // }
+ //
+
+ public void processDecode(WebuiRequestContext context) throws Exception
+ {
+ MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.DECODE,
context);
+ getLifecycle().processDecode(this, context);
+ if (mevent != null)
+ {
+ mevent.setEndExecutionTime(System.currentTimeMillis());
+ mevent.broadcast();
+ }
+ }
+
+ public void processAction(WebuiRequestContext context) throws Exception
+ {
+ MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.PROCESS,
context);
+ getLifecycle().processAction(this, context);
+ if (mevent != null)
+ {
+ mevent.setEndExecutionTime(System.currentTimeMillis());
+ mevent.broadcast();
+ }
+ }
+
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.RENDER,
context);
+ getLifecycle().processRender(this, context);
+ if (mevent != null)
+ {
+ mevent.setEndExecutionTime(System.currentTimeMillis());
+ mevent.broadcast();
+ }
+ }
+
+ private Lifecycle<UIComponent> getLifecycle() throws Exception
+ {
+ if (config == null)
+ {
+ log.debug("No config was found for " + getClass().getSimpleName() +
" with id '" + id + "'. Using a default one.");
+ return DEFAULT_LIFECYCLE;
+ }
+ return config.getUIComponentLifecycle();
+ }
+
+ //
+ // public void processDestroy(WebuiRequestContext context) throws Exception {
+ // MonitorEvent<UIComponent> mevent = createMonitorEvent(Event.Phase.DESTROY,
context);
+ // config.getUIComponentLifecycle().init(this, context) ;
+ // if(mevent != null) {
+ // mevent.setEndExecutionTime(System.currentTimeMillis()) ;
+ // mevent.broadcast() ;
+ // }
+ // }
+
+ public Component getComponentConfig()
+ {
+ return this.config;
+ }
+
+ public void setComponentConfig(String componentId, Component config) throws Exception
+ {
+ this.config = config;
+ if (componentId == null || componentId.length() == 0)
+ {
+ componentId = config.getId();
+ }
+ if (componentId == null)
+ {
+ String type = config.getType();
+ componentId = type.substring(type.lastIndexOf('.') + 1);
+ }
+ setId(componentId);
+ }
+
+ public void setComponentConfig(Class<?> clazz, String id)
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ WebuiApplication app = (WebuiApplication)context.getApplication();
+ this.config = app.getConfigurationManager().getComponentConfig(clazz, id);
+ }
+
+ public String getTemplate()
+ {
+ return config != null ? config.getTemplate() : null;
+ }
+
+ public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context,
String template)
+ {
+ return context.getResourceResolver(template);
+ }
+
+ public <T extends UIComponent> T getAncestorOfType(Class<T> classType)
+ {
+ UIComponent parent = getParent();
+ while (parent != null)
+ {
+ if (classType.isInstance(parent))
+ {
+ return classType.cast(parent);
+ }
+ parent = parent.getParent();
+ }
+ return null;
+ }
+
+ protected String loadConfirmMesssage(org.exoplatform.webui.config.Event event,
WebuiRequestContext context,
+ String beanId)
+ {
+ String confirmKey = event.getConfirm();
+ if (confirmKey.length() < 1)
+ {
+ return confirmKey;
+ }
+ try
+ {
+ String confirm = context.getApplicationResourceBundle().getString(confirmKey);
+ return confirm.replaceAll("\\{0\\}", beanId);
+ }
+ catch (Exception e)
+ {
+ }
+ return confirmKey;
+ }
+
+ public String event(String name) throws Exception
+ {
+ return event(name, null);
+ }
+
+ public String event(String name, String beanId) throws Exception
+ {
+ return event(name, beanId, null);
+ }
+
+ /**
+ * Render an event ajax URL for a given bean.
+ *
+ * @param name the event name
+ * @param beanId the optional bean id
+ * @param params the optional event parameters
+ * @return the rendered URL
+ * @throws Exception any exception
+ */
+ public String event(String name, String beanId, Parameter[] params) throws Exception
+ {
+ return renderEventURL(true, name, beanId, params);
+ }
+
+ public String url(String name) throws Exception
+ {
+ return url(name, null);
+ }
+
+ public String url(String name, String beanId) throws Exception
+ {
+ return url(name, beanId, null);
+ }
+
+ /**
+ * Render an event URL for a given bean.
+ *
+ * @param name the event name
+ * @param beanId the optional bean id
+ * @param params the optional event parameters
+ * @return the rendered URL
+ * @throws Exception any exception
+ */
+ public String url(String name, String beanId, Parameter[] params) throws Exception
+ {
+ return renderEventURL(false, name, beanId, params);
+ }
+
+ /**
+ * Render an event URL of a given bean.
+ *
+ * @param ajax the url type, true for ajax, false otherwise
+ * @param name the event name
+ * @param beanId the optional bean id
+ * @param params the optional event parameters
+ * @return the rendered URL
+ * @throws Exception any exception
+ */
+ public String renderEventURL(boolean ajax, String name, String beanId, Parameter[]
params) throws Exception
+ {
+ org.exoplatform.webui.config.Event event = config.getUIComponentEventConfig(name);
+ if (event == null)
+ {
+ return "??config??";
+ }
+
+ //
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ URLBuilder<UIComponent> urlBuilder = context.getURLBuilder();
+ if (urlBuilder == null)
+ {
+ return "??builder??";
+ }
+
+ //
+ String confirm = loadConfirmMesssage(event, context, beanId);
+
+ //
+ if (ajax)
+ {
+ return urlBuilder.createAjaxURL(this, event.getName(), confirm, beanId,
params);
+ }
+ else
+ {
+ try
+ {
+ return urlBuilder.createURL(this, event.getName(), confirm, beanId, params);
+ }
+ catch (Exception e)
+ {
+ log.error("Could not render component even URL for id=" + beanId +
", name=" + name, e);
+ return "";
+ }
+ }
+ }
+
+ // julien : check if this is used effectively or not
+ public String doAsync(String name, String beanId, Parameter[] params) throws
Exception
+ {
+ return event(name, beanId, new Parameter[]{new Parameter(AJAX_ASYNC,
"true")});
+ }
+
+ public <T> void broadcast(Event<T> event, Phase phase) throws Exception
+ {
+ if (config == null)
+ {
+ return;
+ }
+ org.exoplatform.webui.config.Event econfig =
config.getUIComponentEventConfig(event.getName());
+ if (econfig == null)
+ {
+ return;
+ }
+ Phase executionPhase = econfig.getExecutionPhase();
+ if (executionPhase == phase || executionPhase == Event.Phase.ANY)
+ {
+ for (EventListener<T> listener : econfig.getCachedEventListeners())
+ {
+ listener.execute(event);
+ }
+ }
+ }
+
+ public <T extends UIComponent> T createUIComponent(Class<T> type, String
configId, String componentId,
+ UIComponent parent) throws
Exception
+ {
+ T uicomp = createUIComponent(type, configId, componentId);
+ uicomp.setParent(parent);
+ return uicomp;
+ }
+
+ public <T extends UIComponent> T createUIComponent(Class<T> type, String
configId, String componentId)
+ throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ return createUIComponent(context, type, configId, componentId);
+ }
+
+ public <T extends UIComponent> T createUIComponent(WebuiRequestContext context,
Class<T> type, String configId,
+ String componentId) throws
Exception
+ {
+ WebuiApplication app = (WebuiApplication)context.getApplication();
+ T comp = app.createUIComponent(type, configId, componentId, context);
+ return comp;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T findComponentById(String lookupId)
+ {
+ if (getId().equals(lookupId))
+ {
+ return (T)this;
+ }
+ return null;
+ }
+
+ public <T extends UIComponent> T findFirstComponentOfType(Class<T> type)
+ {
+ if (type.isInstance(this))
+ {
+ return type.cast(this);
+ }
+ return null;
+ }
+
+ public <T> void findComponentOfType(List<T> list, Class<T> type)
+ {
+ if (type.isInstance(this))
+ {
+ list.add(type.cast(this));
+ }
+ }
+
+ public <T extends UIComponent> void setRenderSibling(Class<T> type)
+ {
+ if (uiparent instanceof UIContainer)
+ {
+ UIContainer uicontainer = (UIContainer)uiparent;
+ List<UIComponent> children = uicontainer.getChildren();
+ for (UIComponent child : children)
+ {
+ if (type.isInstance(child))
+ {
+ child.setRendered(true);
+ }
+ else
+ {
+ child.setRendered(false);
+ }
+ }
+ }
+ }
+
+ public String getUIComponentName()
+ {
+ return UICOMPONENT;
+ }
+
+ public <T> T getApplicationComponent(Class<T> type)
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ ExoContainer container =
context.getApplication().getApplicationServiceContainer();
+ return type.cast(container.getComponentInstanceOfType(type));
+ }
+
+ public Event<UIComponent> createEvent(String name, Phase phase,
WebuiRequestContext context) throws Exception
+ {
+ if (config == null)
+ {
+ return null;
+ }
+ org.exoplatform.webui.config.Event econfig =
config.getUIComponentEventConfig(name);
+ if (econfig == null)
+ {
+ return null;
+ }
+ Phase executionPhase = econfig.getExecutionPhase();
+ if (executionPhase == phase || executionPhase == Event.Phase.ANY)
+ {
+ Event<UIComponent> event = new Event<UIComponent>(this, name,
context);
+ event.setExecutionPhase(phase);
+ event.setEventListeners(econfig.getCachedEventListeners());
+ return event;
+ }
+ return null;
+ }
+
+ private MonitorEvent<UIComponent> createMonitorEvent(Phase phase,
WebuiRequestContext context) throws Exception
+ {
+ if (config == null)
+ {
+ return null;
+ }
+ org.exoplatform.webui.config.Event econfig =
+
config.getUIComponentEventConfig(MonitorEvent.UICOMPONENT_LIFECYCLE_MONITOR_EVENT);
+ if (econfig == null)
+ {
+ return null;
+ }
+ Phase executionPhase = econfig.getExecutionPhase();
+ if (executionPhase == phase || executionPhase == Event.Phase.ANY)
+ {
+ MonitorEvent<UIComponent> mevent =
+ new MonitorEvent<UIComponent>(this,
MonitorEvent.UICOMPONENT_LIFECYCLE_MONITOR_EVENT, context);
+ mevent.setEventListeners(econfig.getCachedEventListeners());
+ mevent.setStartExecutionTime(System.currentTimeMillis());
+ mevent.setExecutionPhase(phase);
+ return mevent;
+ }
+ return null;
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,110 @@
+/**
+ * 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.core;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.core.lifecycle.Lifecycle;
+
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tuan Nguyen
+ * tuan08(a)users.sourceforge.net
+ * May 7, 2006
+ *
+ * The decorator of a component
+ */
+@ComponentConfig(lifecycle = UIComponentDecorator.UIComponentDecoratorLifecycle.class)
+@Serialized
+public class UIComponentDecorator extends UIComponent
+{
+ /**
+ * The component being decorated
+ */
+ protected UIComponent uicomponent_;
+
+ public UIComponent getUIComponent()
+ {
+ return uicomponent_;
+ }
+
+ public void setUIComponent(UIComponent uicomponent)
+ {
+ if (uicomponent_ != null)
+ uicomponent_.setRendered(false);
+ uicomponent_ = uicomponent;
+ if (uicomponent_ == null)
+ return;
+ uicomponent_.setParent(this);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T findComponentById(String id)
+ {
+ if (getId().equals(id))
+ return (T)this;
+ if (uicomponent_ == null)
+ return null;
+ return (T)uicomponent_.findComponentById(id);
+ }
+
+ public <T extends UIComponent> T findFirstComponentOfType(Class<T> type)
+ {
+ if (type.isInstance(this))
+ return type.cast(this);
+ if (uicomponent_ == null)
+ return null;
+ return uicomponent_.findFirstComponentOfType(type);
+ }
+
+ public <T> void findComponentOfType(List<T> list, Class<T> type)
+ {
+ if (type.isInstance(this))
+ list.add(type.cast(this));
+ if (uicomponent_ == null)
+ return;
+ uicomponent_.findComponentOfType(list, type);
+ }
+
+ public void renderChildren() throws Exception
+ {
+ if (uicomponent_ == null)
+ return;
+
uicomponent_.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
+ }
+
+ static public class UIComponentDecoratorLifecycle extends
Lifecycle<UIComponentDecorator>
+ {
+
+ public void processRender(UIComponentDecorator uicomponent, WebuiRequestContext
context) throws Exception
+ {
+ context.getWriter().append("<div
class=\"").append(uicomponent.getId()).append("\"
id=\"").append(
+ uicomponent.getId()).append("\">");
+ if (uicomponent.uicomponent_ != null)
+ {
+ uicomponent.uicomponent_.processRender(context);
+ }
+ context.getWriter().append("</div>");
+ }
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIContainer.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIContainer.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIContainer.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIContainer.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,395 @@
+/**
+ * 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.core;
+
+import org.exoplatform.webui.application.WebuiApplication;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** Created by The eXo Platform SAS May 7, 2006 */
+@ComponentConfig(lifecycle = UIContainerLifecycle.class)
+@Serialized
+public class UIContainer extends UIComponent
+{
+
+ private List<UIComponent> children;
+
+ public boolean hasChildren()
+ {
+ return children != null;
+ }
+
+ public void setChildren(List<UIComponent> ls)
+ {
+ this.children = ls;
+ }
+
+ public List<UIComponent> getChildren()
+ {
+ if (children == null)
+ {
+ children = new ArrayList<UIComponent>(3);
+ }
+ return children;
+ }
+
+ public void addChild(UIComponent uicomponent)
+ {
+ if (children == null)
+ {
+ children = new ArrayList<UIComponent>(3);
+ }
+ uicomponent.setParent(this);
+ children.add(uicomponent);
+ }
+
+ public UIComponent removeChildById(String id)
+ {
+ if (children == null)
+ {
+ return null;
+ }
+ for (UIComponent child : children)
+ {
+ if (!id.equals(child.getId()))
+ {
+ continue;
+ }
+ child.setParent(null);
+ children.remove(child);
+ return child;
+ }
+ return null;
+ }
+
+ public <T extends UIComponent> T removeChild(Class<T> clazz)
+ {
+ if (children == null)
+ {
+ return null;
+ }
+ for (UIComponent child : children)
+ {
+ if (!clazz.isInstance(child))
+ {
+ continue;
+ }
+ child.setParent(null);
+ children.remove(child);
+ return clazz.cast(child);
+ }
+ return null;
+ }
+
+ // todo (julien) : this is not type safe
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T getChildById(String id)
+ {
+
+ if (children == null)
+ {
+ return null;
+ }
+ for (UIComponent child : children)
+ {
+ if (id.equals(child.getId()))
+ {
+ return (T)child;
+ }
+ }
+ return null;
+ }
+
+ // todo (julien) : this is not type safe
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T getChild(int idx)
+ {
+ if (children == null)
+ {
+ return null;
+ }
+ if (children.size() <= idx)
+ {
+ return null;
+ }
+ return (T)children.get(idx);
+ }
+
+ public <T extends UIComponent> T getChild(Class<T> clazz)
+ {
+ if (children == null)
+ {
+ return null;
+ }
+ for (UIComponent uichild : children)
+ {
+ if (clazz.isInstance(uichild))
+ {
+ return clazz.cast(uichild);
+ }
+ }
+ return null;
+ }
+
+ // todo (julien) : this is not type safe
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T replaceChild(String targetChildId, UIComponent
newComponent) throws Exception
+ {
+ if (children == null)
+ {
+ throw new Exception("Cannot find the child : " + targetChildId);
+ }
+ for (int i = 0; i < this.children.size(); i++)
+ {
+ UIComponent child = this.children.get(i);
+ if (targetChildId.equals(child.getId()))
+ {
+ child.setParent(null);
+ newComponent.setParent(this);
+ children.set(i, newComponent);
+ return (T)child;
+ }
+ }
+ throw new Exception("Cannot find the child : " + targetChildId);
+ }
+
+ public <T extends UIComponent> T replaceChild(String targetChildId,
Class<T> type, String configId, String id)
+ throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ WebuiApplication app = (WebuiApplication)context.getApplication();
+ UIComponent comp = app.createUIComponent(type, configId, id, context);
+ comp = replaceChild(targetChildId, comp);
+ return type.cast(comp);
+ }
+
+ public <T extends UIComponent> T addChild(Class<T> type, String configId,
String id) throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ WebuiApplication app = (WebuiApplication)context.getApplication();
+ T comp = app.createUIComponent(type, configId, id, context);
+ addChild(comp);
+ return comp;
+ }
+
+ // todo (julien) : this is not type safe
+
+ @SuppressWarnings("unchecked")
+ public <T extends UIComponent> T findComponentById(String id)
+ {
+ if (getId() != null)
+ {
+ if (getId().equals(id))
+ {
+ return (T)this;
+ }
+ }
+ if (children == null)
+ {
+ return null;
+ }
+ for (UIComponent uichild : children)
+ {
+ UIComponent found = uichild.findComponentById(id);
+ if (found != null)
+ {
+ return (T)found;
+ }
+ }
+ return null;
+ }
+
+ /*@SuppressWarnings("unchecked")
+ public <T extends UIComponent> T findRenderComponentById(String id) {
+ if(!isRendered()) return null;
+ if(getId().equals(id)) return (T)this ;
+ if(children == null) return null ;
+ for (UIComponent uichild : children) {
+ UIComponent found = uichild.findComponentById(id) ;
+ if(found != null) return (T)found ;
+ }
+ return null ;
+ } */
+
+ public <T extends UIComponent> T findFirstComponentOfType(Class<T> type)
+ {
+ if (type.isInstance(this))
+ {
+ return type.cast(this);
+ }
+ if (children == null)
+ {
+ return null;
+ }
+ for (UIComponent uichild : children)
+ {
+ T found = uichild.findFirstComponentOfType(type);
+ if (found != null)
+ {
+ return found;
+ }
+ }
+ return null;
+ }
+
+ public <T> void findComponentOfType(List<T> list, Class<T> type)
+ {
+ if (type.isInstance(this) && !list.contains(this))
+ {
+ list.add(type.cast(this));
+ }
+ if (children == null)
+ {
+ return;
+ }
+ for (UIComponent uichild : children)
+ {
+ uichild.findComponentOfType(list, type);
+ }
+ }
+
+ public void setRenderedChild(String id)
+ {
+ List<UIComponent> list = getChildren();
+ for (UIComponent child : list)
+ {
+ if (child.getId().equals(id))
+ {
+ child.setRendered(true);
+ }
+ else
+ {
+ child.setRendered(false);
+ }
+ }
+ }
+
+ public <T extends UIComponent> void setRenderedChild(Class<T> type)
+ {
+ List<UIComponent> list = getChildren();
+ for (UIComponent child : list)
+ {
+ if (type.isInstance(child))
+ {
+ child.setRendered(true);
+ }
+ else
+ {
+ child.setRendered(false);
+ }
+ }
+ }
+
+ public void setRenderedChildrenOfTypes(Class<?>[] types)
+ {
+ List<UIComponent> list = getChildren();
+ for (UIComponent child : list)
+ {
+ child.setRendered(false);
+ for (Class<?> type : types)
+ {
+ if (type.isInstance(child))
+ {
+ child.setRendered(true);
+ break;
+ }
+ }
+ }
+ }
+
+ public void renderChild(String id) throws Exception
+ {
+ renderChild(getChildById(id));
+ }
+
+ public <T extends UIComponent> void renderChild(Class<T> clazz) throws
Exception
+ {
+ renderChild(getChild(clazz));
+ }
+
+ public void renderUIComponent(UIComponent uicomponent) throws Exception
+ {
+
uicomponent.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
+ }
+
+ public void renderChild(int index) throws Exception
+ {
+ renderChild(getChild(index));
+ }
+
+ public void renderChild(UIComponent child) throws Exception
+ {
+ if (child.isRendered())
+ {
+
child.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
+ }
+ }
+
+ public void renderChildren() throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ renderChildren(context);
+ }
+
+ public void renderChildren(WebuiRequestContext context) throws Exception
+ {
+ List<UIComponent> list = getChildren();
+ for (UIComponent child : list)
+ {
+ if (child.isRendered())
+ {
+ child.processRender(context);
+ }
+ }
+ }
+
+ static public class SelectTabActionListener extends EventListener<UIContainer>
+ {
+ public void execute(Event<UIContainer> event) throws Exception
+ {
+ WebuiRequestContext context = event.getRequestContext();
+ UIContainer uiContainer = event.getSource();
+ String renderTab = context.getRequestParameter(OBJECTID);
+ if (renderTab == null)
+ {
+ return;
+ }
+ UIComponent uiComp = uiContainer.findComponentById(renderTab);
+ if (uiComp != null)
+ {
+ for (UIComponent child : uiContainer.getChildren())
+ {
+ child.setRendered(false);
+ }
+ uiComp.setRendered(true);
+ }
+ }
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupMessages.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,153 @@
+/**
+ * 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.core;
+
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tran The Trong
+ * trong.tran(a)exoplatform.com
+ * @version: $Id$
+ * Aug 14, 2006
+ *
+ * A component to display messages of different types, in a popup window
+ */
+@ComponentConfig(template = "system:/groovy/webui/core/UIPopupMessages.gtmpl",
events = @EventConfig(listeners = UIPopupMessages.CloseActionListener.class))
+@Serialized
+public class UIPopupMessages extends UIPopupWindow
+{
+ /**
+ * The error messages
+ */
+ private List<ApplicationMessage> errors_;
+
+ /**
+ * The warning messages
+ */
+ private List<ApplicationMessage> warnings_;
+
+ /**
+ * The info messages
+ */
+ private List<ApplicationMessage> infos_;
+
+ public UIPopupMessages()
+ {
+ errors_ = new ArrayList<ApplicationMessage>();
+ warnings_ = new ArrayList<ApplicationMessage>();
+ infos_ = new ArrayList<ApplicationMessage>();
+ setShow(true);
+ }
+
+ public List<ApplicationMessage> getErrors()
+ {
+ return errors_;
+ }
+
+ public void setErrors(List<ApplicationMessage> errors_)
+ {
+ this.errors_ = errors_;
+ }
+
+ public List<ApplicationMessage> getInfos()
+ {
+ return infos_;
+ }
+
+ public void setInfos(List<ApplicationMessage> infos_)
+ {
+ this.infos_ = infos_;
+ }
+
+ public List<ApplicationMessage> getWarnings()
+ {
+ return warnings_;
+ }
+
+ public void setWarnings(List<ApplicationMessage> warnings_)
+ {
+ this.warnings_ = warnings_;
+ }
+
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ super.processRender(context);
+ }
+
+ public void addMessage(ApplicationMessage msg)
+ {
+ switch (msg.getType())
+ {
+ case ApplicationMessage.ERROR :
+ errors_.add(msg);
+ break;
+ case ApplicationMessage.WARNING :
+ warnings_.add(msg);
+ break;
+ default :
+ infos_.add(msg);
+ }
+ }
+
+ public boolean hasMessage()
+ {
+ return (errors_.size() > 0 || warnings_.size() > 0 || infos_.size() > 0);
+ }
+
+ public void clearMessages()
+ {
+ errors_.clear();
+ warnings_.clear();
+ infos_.clear();
+ }
+
+ static public class CloseActionListener extends EventListener<UIPopupMessages>
+ {
+ public void execute(Event<UIPopupMessages> event) throws Exception
+ {
+ UIPopupMessages uiPopupMessage = event.getSource();
+ uiPopupMessage.clearMessages();
+ WebuiRequestContext context = event.getRequestContext();
+ if (uiPopupMessage.getParent() == null)
+ {
+ context.addUIComponentToUpdateByAjax(uiPopupMessage);
+ return;
+ }
+ if (!uiPopupMessage.isShow())
+ return;
+ UIComponent uiParent = uiPopupMessage.getParent();
+ context.addUIComponentToUpdateByAjax(uiParent);
+ Event<UIComponent> pEvent =
+ uiParent.createEvent("ClosePopup", event.getExecutionPhase(),
event.getRequestContext());
+ if (pEvent != null)
+ pEvent.broadcast();
+ }
+ }
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIPopupWindow.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,150 @@
+/**
+ * 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.core;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+
+/**
+ * Created by The eXo Platform SARL
+ * Author : Tran The Trong
+ * trong.tran(a)exoplatform.com
+ * @version: $Id$
+ * Aug 11, 2006
+ *
+ * A component that creates an empty popup window
+ */
+@ComponentConfig(template = "system:/groovy/webui/core/UIPopupWindow.gtmpl",
events = @EventConfig(listeners = UIPopupWindow.CloseActionListener.class, name =
"ClosePopup"))
+@Serialized
+public class UIPopupWindow extends UIComponentDecorator
+{
+ /**
+ * The width of the window
+ */
+ private int width_ = -1;
+
+ /**
+ * The height of the window
+ */
+ private int height_ = -1;
+
+ /**
+ * Whether to show the close button at the bottom of the window
+ */
+ private boolean showCloseButton = true;
+
+ /**
+ * The visibility status of the window
+ */
+ private boolean isShow = false;
+
+ /**
+ * Whether this window is resizable
+ */
+ private boolean isResizable = false;
+
+ protected String closeEvent_ = "ClosePopup";
+
+ private boolean isShowMask_ = false;
+
+ public boolean isShowMask()
+ {
+ return isShowMask_;
+ }
+
+ public void setShowMask(boolean isShowMask)
+ {
+ isShowMask_ = isShowMask;
+ }
+
+ public int getWindowWidth()
+ {
+ return width_;
+ }
+
+ public int getWindowHeight()
+ {
+ return height_;
+ }
+
+ public void setWindowSize(int w, int h)
+ {
+ width_ = w;
+ height_ = h;
+ }
+
+ public boolean isResizable()
+ {
+ return isResizable;
+ }
+
+ public void setResizable(boolean isResizable)
+ {
+ this.isResizable = isResizable;
+ }
+
+ public boolean isShow()
+ {
+ return isShow;
+ }
+
+ public void setShow(boolean isShow)
+ {
+ this.isShow = isShow;
+ }
+
+ static public class CloseActionListener extends EventListener<UIPopupWindow>
+ {
+ public void execute(Event<UIPopupWindow> event) throws Exception
+ {
+ UIPopupWindow uiPopupWindow = event.getSource();
+ if (!uiPopupWindow.isShow())
+ return;
+ uiPopupWindow.setShow(false);
+ WebuiRequestContext context = event.getRequestContext();
+ context.addUIComponentToUpdateByAjax(uiPopupWindow);
+ }
+ }
+
+ public boolean isShowCloseButton()
+ {
+ return showCloseButton;
+ }
+
+ public void setShowCloseButton(boolean showCloseButton)
+ {
+ this.showCloseButton = showCloseButton;
+ }
+
+ public String getCloseEvent()
+ {
+ return closeEvent_;
+ }
+
+ public void setCloseEvent(String closeEvent)
+ {
+ this.closeEvent_ = closeEvent;
+ }
+
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Decorator.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,53 @@
+/**
+ * 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.core.lifecycle;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+
+/**
+ * Created by The eXo Platform SAS
+ * Aug 23, 2006
+ *
+ * Writes a decorator template with the given css class style
+ */
+public class Decorator
+{
+ //<%decorator.start(.., ..)%>
+ final public void start(String cssClass, String style) throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ context.getWriter().append("<div
class=\"").append(cssClass).append("\">").append("<div
class=\"").append(style)
+ .append("\" style=\"margin:
0px\">").append("<div
class=\"TopLeftCornerBoxDecorator\">").append(
+ "<div
class=\"TopRightCornerBoxDecorator\">").append(
+ "<div
class=\"TopCenterBoxDecorator\"><span></span></div>").append("</div>").append("</div>").append(
+ "<div
class=\"MiddleLeftSideBoxDecorator\">").append("<div
class=\"MiddleRightSideBoxDecorator\">").append(
+ "<div class=\"DecoratorBackground\">");
+
+ }
+
+ final public void end() throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+
context.getWriter().append("</div>").append("</div>").append("</div>").append(
+ "<div
class=\"BottomLeftCornerBoxDecorator\">").append("<div
class=\"BottomRightCornerBoxDecorator\">")
+ .append("<div
class=\"BottomCenterBoxDecorator\"><span></span></div>").append("</div>").append("</div>")
+ .append("</div>").append("</div>");
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/Lifecycle.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,134 @@
+/**
+ * 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.core.lifecycle;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.groovyscript.text.TemplateService;
+import org.exoplatform.resolver.ResourceResolver;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.event.Event;
+
+/**
+ * Created by The eXo Platform SAS May 7, 2006
+ */
+public class Lifecycle<E extends UIComponent>
+{
+
+ protected static Log log = ExoLogger.getLogger("portal:Lifecycle");
+
+ private Decorator decorator_ = new Decorator();
+
+ // public void init(UIComponent uicomponent, WebuiRequestContext context)
+ // throws Exception {}
+
+ public void processDecode(E uicomponent, WebuiRequestContext context) throws
Exception
+ {
+ }
+
+ public void processAction(E uicomponent, WebuiRequestContext context) throws
Exception
+ {
+ String action = context.getRequestParameter(context.getActionParameterName());
+ if (action == null)
+ return;
+ Event<UIComponent> event = uicomponent.createEvent(action,
Event.Phase.PROCESS, context);
+ if (event != null)
+ event.broadcast();
+ }
+
+ /**
+ * That method is the most generic one for every UIComponent that is bound to
+ * this Lifecycle object and the class that extends it without overriding the
+ * method.
+ *
+ * The template associated to the specified UIComponent is rendered using
renderTemplate(). A WebuiBindingContext
+ * context object provides the template with all the necessary objects to render.
+ * (WebuiBindingContext extends the Map class)
+ *
+ */
+ public void processRender(E uicomponent, WebuiRequestContext context) throws
Exception
+ {
+ String template = uicomponent.getTemplate();
+
+ // Fail if we have no template
+ if (template == null)
+ {
+ throw new IllegalStateException("uicomponent " + uicomponent + "
with class " + uicomponent.getClass().getName() +
+ " has no template for rendering");
+ }
+
+ //
+ ResourceResolver resolver = uicomponent.getTemplateResourceResolver(context,
template);
+ WebuiBindingContext bcontext = new WebuiBindingContext(resolver,
context.getWriter(), uicomponent, context);
+ bcontext.put(UIComponent.UICOMPONENT, uicomponent);
+ bcontext.put(uicomponent.getUIComponentName(), uicomponent);
+ renderTemplate(template, bcontext);
+ }
+
+ // public void destroy(UIComponent uicomponent) throws Exception {}
+
+ /**
+ * The method allows to use Groovy templates to render the portal components.
+ *
+ * <ol>
+ * <li>Add a decorator object into the context</li>
+ * <li>Get a reference to the TemplateService</li>
+ * <li>If the system property "exo.product.developing" is set to
<code>true</code>, the templates are not cached</li>
+ * <li>If the writer used to render the output is of type HtmlValidator, which
is the case in the Portal
+ * environment, then it is also possible to validate the generated HTML (for debugging
purposes)</li>
+ * <li>The template and the context are then merged to generate the HTML
fragment</li>
+ * </ol>
+ *
+ */
+ protected void renderTemplate(String template, WebuiBindingContext bcontext) throws
Exception
+ {
+ bcontext.put("decorator", decorator_);
+ WebuiRequestContext context = bcontext.getRequestContext();
+ ExoContainer pcontainer =
context.getApplication().getApplicationServiceContainer();
+ TemplateService service =
(TemplateService)pcontainer.getComponentInstanceOfType(TemplateService.class);
+ ResourceResolver resolver = bcontext.getResourceResolver();
+
+ if (PropertyManager.isDevelopping())
+ {
+ WebuiRequestContext rootContext =
(WebuiRequestContext)context.getParentAppRequestContext();
+ if (rootContext == null)
+ rootContext = context;
+ long lastAccess = rootContext.getUIApplication().getLastAccessApplication();
+ if (resolver.isModified(template, lastAccess))
+ {
+ if (log.isDebugEnabled())
+ log.debug("Invalidate the template: " + template);
+ service.invalidateTemplate(template, resolver);
+ }
+ }
+
+ try
+ {
+ service.merge(template, bcontext);
+ }
+ catch (NullPointerException e)
+ {
+ log.error("Template: " + template + " not found.");
+ }
+ }
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/UIContainerLifecycle.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,38 @@
+/**
+ * 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.core.lifecycle;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIContainer;
+
+/**
+ * Jul 10, 2006
+ */
+public class UIContainerLifecycle extends Lifecycle<UIContainer>
+{
+
+ public void processRender(UIContainer uicomponent, WebuiRequestContext context) throws
Exception
+ {
+ context.getWriter().append("<div
class=\"").append(uicomponent.getId()).append("\"
id=\"").append(
+ uicomponent.getId()).append("\">");
+ uicomponent.renderChildren(context);
+ context.getWriter().append("</div>");
+ }
+}
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/lifecycle/WebuiBindingContext.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,156 @@
+/**
+ * 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.core.lifecycle;
+
+import org.exoplatform.commons.utils.PropertyManager;
+import org.exoplatform.groovyscript.text.BindingContext;
+import org.exoplatform.resolver.ResourceResolver;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UIComponentDecorator;
+import org.exoplatform.webui.core.UIContainer;
+
+import java.io.Writer;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+@SuppressWarnings("serial")
+public class WebuiBindingContext extends BindingContext
+{
+
+ protected static Log log =
ExoLogger.getLogger("portal:WebuiBindingContext");
+
+ private UIComponent uicomponent_;
+
+ private WebuiRequestContext rcontext_;
+
+ public WebuiBindingContext(ResourceResolver resolver, Writer w, UIComponent
uicomponent, WebuiRequestContext context)
+ {
+ super(resolver, w);
+ uicomponent_ = uicomponent;
+ rcontext_ = context;
+
+ // Add Orientation specific information
+ Orientation orientation = context.getOrientation();
+ this.put("orientation", orientation);
+ this.put("isLT", orientation.isLT());
+ this.put("isRT", orientation.isRT());
+ this.put("dir", orientation.isLT() ? "ltr" : "rtl");
+ }
+
+ public UIComponent getUIComponent()
+ {
+ return uicomponent_;
+ }
+
+ public WebuiRequestContext getRequestContext()
+ {
+ return rcontext_;
+ }
+
+ public String getContextPath()
+ {
+ return rcontext_.getRequestContextPath();
+ }
+
+ public String getPortalContextPath()
+ {
+ return rcontext_.getPortalContextPath();
+ }
+
+ public BindingContext clone()
+ {
+ BindingContext newContext = new WebuiBindingContext(resolver_, writer_,
uicomponent_, rcontext_);
+ newContext.putAll(this);
+ newContext.setGroovyTemplateService(service_);
+ return newContext;
+ }
+
+ public String appRes(String mesgKey) throws Exception
+ {
+ String value;
+ try
+ {
+ ResourceBundle res = rcontext_.getApplicationResourceBundle();
+ value = res.getString(mesgKey);
+ }
+ catch (MissingResourceException ex)
+ {
+ if (PropertyManager.isDevelopping())
+ log.warn("Can not find resource bundle for key : " + mesgKey);
+ value = mesgKey.substring(mesgKey.lastIndexOf('.') + 1);
+ }
+ return value;
+ }
+
+ public void renderChildren() throws Exception
+ {
+ if (uicomponent_ instanceof UIComponentDecorator)
+ {
+ UIComponentDecorator uiComponentDecorator = (UIComponentDecorator)uicomponent_;
+ if (uiComponentDecorator.getUIComponent() == null)
+ return;
+ uiComponentDecorator.getUIComponent().processRender(rcontext_);
+ return;
+ }
+ UIContainer uicontainer = (UIContainer)uicomponent_;
+ List<UIComponent> children = uicontainer.getChildren();
+ for (UIComponent child : children)
+ {
+ if (child.isRendered())
+ {
+ child.processRender(rcontext_);
+ }
+ }
+ }
+
+ public void renderChild(String id) throws Exception
+ {
+ if (!(uicomponent_ instanceof UIContainer))
+ return;
+ UIContainer uicontainer = (UIContainer)uicomponent_;
+ UIComponent uiChild = uicontainer.getChildById(id);
+ uiChild.processRender(rcontext_);
+ }
+
+ public void renderUIComponent(UIComponent uicomponent) throws Exception
+ {
+ uicomponent.processRender(rcontext_);
+ }
+
+ public void renderChild(int index) throws Exception
+ {
+ if (!(uicomponent_ instanceof UIContainer))
+ return;
+ UIContainer uicontainer = (UIContainer)uicomponent_;
+ UIComponent uiChild = uicontainer.getChild(index);
+ uiChild.processRender(rcontext_);
+ }
+
+ @SuppressWarnings("unused")
+ public void userRes(String mesgKey)
+ {
+
+ }
+}
\ No newline at end of file
Copied: portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/Event.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/Event.java)
===================================================================
--- portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/Event.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/Event.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,96 @@
+/**
+ * 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.event;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+
+import java.util.List;
+
+public class Event<T>
+{
+
+ private String name_;
+
+ private T source_;
+
+ private Phase executionPhase_ = Phase.PROCESS;
+
+ private WebuiRequestContext context_;
+
+ private List<EventListener> listeners_;
+
+ public Event(T source, String name, WebuiRequestContext context)
+ {
+ name_ = name;
+ source_ = source;
+ context_ = context;
+ }
+
+ public String getName()
+ {
+ return name_;
+ }
+
+ public T getSource()
+ {
+ return source_;
+ }
+
+ public Phase getExecutionPhase()
+ {
+ return executionPhase_;
+ }
+
+ public void setExecutionPhase(Phase phase)
+ {
+ executionPhase_ = phase;
+ }
+
+ public WebuiRequestContext getRequestContext()
+ {
+ return context_;
+ }
+
+ public void setRequestContext(WebuiRequestContext context)
+ {
+ context_ = context;
+ }
+
+ public List<EventListener> getEventListeners()
+ {
+ return listeners_;
+ }
+
+ public void setEventListeners(List<EventListener> listeners)
+ {
+ listeners_ = listeners;
+ }
+
+ final public void broadcast() throws Exception
+ {
+ for (EventListener<T> listener : listeners_)
+ listener.execute(this);
+ }
+
+ static public enum Phase {
+ ANY, DECODE, PROCESS, RENDER
+ }
+
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/EventListener.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/EventListener.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/EventListener.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/EventListener.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,31 @@
+/**
+ * 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.event;
+
+/**
+ * Created by The eXo Platform SAS
+ * May 10, 2006
+ */
+abstract public class EventListener<T>
+{
+ public static final String RESULT_OK = "OK";
+
+ abstract public void execute(Event<T> event) throws Exception;
+}
\ No newline at end of file
Copied:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/MonitorEvent.java
(from rev 3618,
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/event/MonitorEvent.java)
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/MonitorEvent.java
(rev 0)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/event/MonitorEvent.java 2010-07-22
10:34:44 UTC (rev 3676)
@@ -0,0 +1,85 @@
+/**
+ * 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.event;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+
+/**
+ * Created by The eXo Platform SAS
+ * Jun 10, 2006
+ *
+ * An event object used to monitor the lifecycle of a component
+ */
+public class MonitorEvent<T> extends Event<T>
+{
+
+ final static public String PORTAL_APPLICATION_LIFECYCLE_EVENT =
"portal.application.lifecycle.event";
+
+ final static public String PORTAL_EXECUTION_LIFECYCLE_EVENT =
"portal.execution.lifecycle.event";
+
+ final static public String PORTLET_APPLICATION_LIFECYCLE_EVENT =
"portlet.application.lifecycle.event";
+
+ final static public String PORTLET_ACTION_LIFECYCLE_EVENT =
"portlet.action.lifecycle.event";
+
+ final static public String PORTLET_RENDER_LIFECYCLE_EVENT =
"portlet.render.lifecycle.event";
+
+ final static public String UICOMPONENT_LIFECYCLE_MONITOR_EVENT =
"uicomponent.lifecycle.monitor.event";
+
+ private long startExecutionTime_;
+
+ private long endExecutionTime_;
+
+ private Throwable error_;
+
+ public MonitorEvent(T source, String name, WebuiRequestContext context)
+ {
+ super(source, name, context);
+ }
+
+ public long getStartExecutionTime()
+ {
+ return startExecutionTime_;
+ }
+
+ public void setStartExecutionTime(long t)
+ {
+ startExecutionTime_ = t;
+ }
+
+ public long getEndExecutionTime()
+ {
+ return endExecutionTime_;
+ }
+
+ public void setEndExecutionTime(long t)
+ {
+ endExecutionTime_ = t;
+ }
+
+ public Throwable getError()
+ {
+ return error_;
+ }
+
+ public void setError(Throwable t)
+ {
+ error_ = t;
+ }
+}
\ No newline at end of file
Copied: portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/exception (from
rev 3618, portal/trunk/webui/core/src/main/java/org/exoplatform/webui/exception)
Copied: portal/trunk/webui/framework/src/main/resources/binding.xml (from rev 3618,
portal/trunk/webui/core/src/main/resources/binding.xml)
===================================================================
--- portal/trunk/webui/framework/src/main/resources/binding.xml
(rev 0)
+++ portal/trunk/webui/framework/src/main/resources/binding.xml 2010-07-22 10:34:44 UTC
(rev 3676)
@@ -0,0 +1,101 @@
+<!--
+
+ 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.
+
+-->
+
+<binding>
+ <mapping name="param"
class="org.exoplatform.webui.config.Param">
+ <value name="name" field="name" />
+ <value name="value" field="value" />
+ </mapping>
+
+ <mapping name="init-params"
class="org.exoplatform.webui.config.InitParams">
+ <collection item-type="org.exoplatform.webui.config.Param"
field="params" usage="optional" />
+ </mapping>
+
+ <mapping name="validator"
class="org.exoplatform.webui.config.Validator">
+ <value name="type" field="type" />
+ <structure usage="optional" field="initParams"/>
+ </mapping>
+
+ <mapping name="event"
class="org.exoplatform.webui.config.Event">
+ <value name="event-name" field="name"/>
+ <value usage="optional" name="execution-phase"
field="phase" />
+ <structure usage="optional" field="initParams"/>
+ <collection field="listeners" usage="optional"
item-type="java.lang.String">
+ <value name="listener" style="element"/>
+ </collection>
+ </mapping>
+
+
+ <mapping name="event-interceptor"
class="org.exoplatform.webui.config.EventInterceptor">
+ <value name="type" field="type"/>
+ <structure usage="optional" field="initParams"/>
+ <collection field="interceptors" usage="optional"
item-type="java.lang.String">
+ <value name="interceptor" style="element"/>
+ </collection>
+ </mapping>
+
+
+ <!-- component object mapping -->
+
+ <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" />
+ <value name="template" field="template"
usage="optional" />
+ <value name="decorator" field="decorator"
usage="optional" />
+
+ <structure usage="optional" field="initParams"/>
+
+ <collection item-type="org.exoplatform.webui.config.Validator"
+ name="validators" field="validators"
usage="optional" />
+ <collection item-type="org.exoplatform.webui.config.Event"
+ name="events" field="events"
usage="optional" />
+
+ <collection item-type="org.exoplatform.webui.config.EventInterceptor"
+ name="event-interceptors" field="eventInterceptors"
usage="optional" />
+ </mapping>
+
+ <mapping name="application"
class="org.exoplatform.webui.config.Application">
+ <structure usage="optional" field="initParams"/>
+ <value name="ui-component-root" field="uiroot" />
+ <value name="state-manager" field="stateManager" />
+ <collection item-type="java.lang.String"
+ name="application-lifecycle-listeners"
field="lifecycleListeners" usage="optional">
+ <value name="listener" style="element"/>
+ </collection>
+
+ <collection item-type="org.exoplatform.webui.config.Event"
+ name="events" field="events"
usage="optional" />
+ </mapping>
+
+ <!-- jsf-configuration object mapping -->
+ <mapping name="webui-configuration"
class="org.exoplatform.webui.config.WebuiConfiguration">
+ <collection field="annotationClasses"
name="annotation-classes"
+ usage="optional"
item-type="java.lang.String">
+ <value name="class" style="element"/>
+ </collection>
+
+ <collection
item-type="org.exoplatform.webui.config.metadata.ComponentMetaData"
+ field="components" usage="optional" />
+
+ <structure usage="optional" field="application"/>
+ </mapping>
+</binding>
Modified: portal/trunk/webui/pom.xml
===================================================================
--- portal/trunk/webui/pom.xml 2010-07-22 08:00:54 UTC (rev 3675)
+++ portal/trunk/webui/pom.xml 2010-07-22 10:34:44 UTC (rev 3676)
@@ -35,6 +35,7 @@
<name>GateIn Portal WebUI</name>
<modules>
+ <module>framework</module>
<module>core</module>
<module>eXo</module>
<module>portal</module>