JBoss Rich Faces SVN: r18204 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 17:31:25 -0400 (Thu, 22 Jul 2010)
New Revision: 18204
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java
Log:
https://jira.jboss.org/browse/RF-8959
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java 2010-07-22 20:10:13 UTC (rev 18203)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/TagLibProcessor.java 2010-07-22 21:31:25 UTC (rev 18204)
@@ -73,7 +73,7 @@
taglibModel.setTlibVersion(tlibVersion);
}
// Default prefix for library
- String preffix = tagLibrary.preffix();
+ String preffix = tagLibrary.prefix();
if(!Strings.isEmpty(preffix)){
library.setPrefix(preffix);
} else if (Strings.isEmpty(library.getPrefix())) {
15 years, 12 months
JBoss Rich Faces SVN: r18203 - in root/cdk/trunk/plugins/generator: src/main/java/org/richfaces/cdk and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 16:10:13 -0400 (Thu, 22 Jul 2010)
New Revision: 18203
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
Modified:
root/cdk/trunk/plugins/generator/pom.xml
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
Log:
https://jira.jboss.org/browse/RF-8964
Modified: root/cdk/trunk/plugins/generator/pom.xml
===================================================================
--- root/cdk/trunk/plugins/generator/pom.xml 2010-07-22 19:39:26 UTC (rev 18202)
+++ root/cdk/trunk/plugins/generator/pom.xml 2010-07-22 20:10:13 UTC (rev 18203)
@@ -166,16 +166,6 @@
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.google.code.javaparser</groupId>
<artifactId>javaparser</artifactId>
<scope>test</scope>
@@ -205,11 +195,11 @@
<!--
<dependency> <groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assisted-inject</artifactId> </dependency>
- -->
+ --><!--
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b4</version>
</dependency>
- </dependencies>
+ --></dependencies>
</project>
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java 2010-07-22 20:10:13 UTC (rev 18203)
@@ -0,0 +1,100 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CDKHandler extends Handler {
+
+ private final Logger log;
+
+ public CDKHandler(Logger log) {
+ this.log = log;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.logging.Handler#close()
+ */
+ @Override
+ public void close() throws SecurityException {
+ // do nothing
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.logging.Handler#flush()
+ */
+ @Override
+ public void flush() {
+ // do nothing
+
+ }
+
+ @Override
+ public boolean isLoggable(LogRecord record) {
+ int level = record.getLevel().intValue();
+ if (level >= Level.SEVERE.intValue()) {
+ return log.isErrorEnabled();
+ } else if (level >= Level.WARNING.intValue()) {
+ return log.isWarnEnabled();
+ } else if (level >= Level.INFO.intValue()) {
+ return log.isInfoEnabled();
+ } else {
+ return log.isDebugEnabled();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
+ */
+ @Override
+ public void publish(LogRecord record) {
+ int level = record.getLevel().intValue();
+ if (level >= Level.SEVERE.intValue()) {
+ log.error(record.getMessage(), record.getThrown());
+ } else if (level >= Level.WARNING.intValue()) {
+ log.warn(record.getMessage(), record.getThrown());
+ } else if (level >= Level.INFO.intValue()) {
+ log.info(record.getMessage(), record.getThrown());
+ } else {
+ log.debug(record.getMessage(), record.getThrown());
+ }
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-07-22 19:39:26 UTC (rev 18202)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-07-22 20:10:13 UTC (rev 18203)
@@ -32,6 +32,7 @@
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
+import java.util.logging.Level;
import org.richfaces.cdk.apt.AptModule;
import org.richfaces.cdk.generate.java.ClassGeneratorModule;
@@ -79,6 +80,8 @@
private Map<String, String> options = Maps.newHashMap();
+ private java.util.logging.Logger logger;
+
public Generator() {
EmptyFileManager emptyFileManager = new EmptyFileManager();
for (Sources source : Sources.values()) {
@@ -96,6 +99,25 @@
public void setLog(Logger log) {
this.log = log;
+ // setup freemaker logger.
+ try {
+ freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_JAVA);
+ freemarker.log.Logger.setCategoryPrefix(JavaLogger.CDK_LOG + ".");
+ logger = java.util.logging.Logger.getLogger(JavaLogger.CDK_LOG);
+ logger.addHandler(new CDKHandler(log));
+ if (log.isDebugEnabled()) {
+ logger.setLevel(Level.ALL);
+ } else if (log.isInfoEnabled()) {
+ logger.setLevel(Level.INFO);
+ } else if (log.isWarnEnabled()) {
+ logger.setLevel(Level.WARNING);
+ } else {
+ logger.setLevel(Level.SEVERE);
+ }
+ } catch (ClassNotFoundException e) {
+ log.error(e);
+ // DO Nothing, JDK 6 has built-in Logger facility;
+ }
}
public void addOutputFolder(Outputs type, File outputFolder) {
@@ -114,8 +136,7 @@
public void init() {
injector =
Guice.createInjector(Stage.PRODUCTION, new CdkConfigurationModule(), new AptModule(), new ModelModule(),
- new ClassGeneratorModule(), new TemplateModule(),
- new XmlModule(), new TaglibModule());
+ new ClassGeneratorModule(), new TemplateModule(), new XmlModule(), new TaglibModule());
if (!log.isDebugEnabled()) {
try {
@@ -178,7 +199,6 @@
Names.bindProperties(binder(), options);
}
-
}
public String getNamespace() {
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-07-22 19:39:26 UTC (rev 18202)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-07-22 20:10:13 UTC (rev 18203)
@@ -9,7 +9,6 @@
import java.util.Collections;
import java.util.List;
-import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
/**
@@ -75,14 +74,9 @@
// configure CDK workers.
// setupPlugins(generator);
- try {
-
// Build JSF library.
// LibraryBuilder builder = LibraryBuilder.createInstance(context);
- generator.init();
- } catch (CdkException e) {
- throw new MojoExecutionException("CDK build error", e);
- }
+ generator.init();
}
/**
@@ -100,16 +94,16 @@
return new CdkClassLoader(this.getClass().getClassLoader());
}
- private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
+ private Iterable<File> findFacesConfigFiles() {
return Collections.emptySet();
}
- private Iterable<File> findJavaFiles() throws MojoExecutionException {
+ private Iterable<File> findJavaFiles() {
return Collections.emptySet();
}
- private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ private Iterable<File> findTemplateFiles() {
return Collections.emptySet();
}
}
15 years, 12 months
JBoss Rich Faces SVN: r18202 - in root: examples-sandbox/trunk/components/inputnumberslider-demo/src/main/webapp and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-07-22 15:39:26 -0400 (Thu, 22 Jul 2010)
New Revision: 18202
Added:
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
Modified:
root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java
root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/webapp/index.xhtml
root/ui-sandbox/inputs/trunk/inputnumberslider/pom.xml
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/config/faces-config.xml
root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
Log:
developing of inputnumberslider
Modified: root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java
===================================================================
--- root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java 2010-07-22 19:04:38 UTC (rev 18201)
+++ root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java 2010-07-22 19:39:26 UTC (rev 18202)
@@ -28,4 +28,13 @@
@SessionScoped
public class Bean {
+ private int value;
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
}
Modified: root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/webapp/index.xhtml
===================================================================
--- root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/webapp/index.xhtml 2010-07-22 19:04:38 UTC (rev 18201)
+++ root/examples-sandbox/trunk/components/inputnumberslider-demo/src/main/webapp/index.xhtml 2010-07-22 19:39:26 UTC (rev 18202)
@@ -34,7 +34,8 @@
</h:head>
<h:body>
<h:form id="form">
- <ins:inputnumberslider />
+ <ins:inputnumberslider value="#{bean.value}" />
+ <h:outputText value="#{bean.value}" />
</h:form>
</h:body>
</html>
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/pom.xml
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/pom.xml 2010-07-22 19:04:38 UTC (rev 18201)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/pom.xml 2010-07-22 19:39:26 UTC (rev 18202)
@@ -53,6 +53,11 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
+ <!-- todo remove this dependency or move to test scope -->
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.richfaces.cdk</groupId>
<artifactId>annotations</artifactId>
<scope>provided</scope>
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/config/faces-config.xml
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/config/faces-config.xml 2010-07-22 19:04:38 UTC (rev 18201)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/config/faces-config.xml 2010-07-22 19:39:26 UTC (rev 18202)
@@ -34,10 +34,10 @@
<cdk:generate>true</cdk:generate>
<cdk:base-class>javax.faces.component.UIInput</cdk:base-class>
<cdk:component-family>javax.faces.Input</cdk:component-family>
- <cdk:renderer-id>org.richfaces.InputNumberSliderRenderer</cdk:renderer-id>
+ <cdk:renderer-type>org.richfaces.InputNumberSliderRenderer</cdk:renderer-type>
<cdk:tag>
- <cdk:name>inputnumberslider</cdk:name>
- <cdk:type>Facelets</cdk:type>
+ <cdk:tag-name>inputnumberslider</cdk:tag-name>
+ <cdk:tag-type>Facelets</cdk:tag-type>
</cdk:tag>
</component-extension>
</component>
Added: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js (rev 0)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-07-22 19:39:26 UTC (rev 18202)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+(function(richfaces, jQuery) {
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.InputNumberSlider = richfaces.BaseComponent.extendClass({
+
+ name: "InputNumberSlider",
+
+ init: function (id) {
+ this.id = id;
+ },
+
+ publicFunction: function () {
+ // ...
+ },
+
+ __privateFunction: function () {
+ // ...
+ }
+
+ // __overrideMethod: function () {
+ // // if you need to use method from parent class use link to parent prototype
+ // // like in previous solution with extend method
+ // this.$super.__overrideMethod.call(this, ...params...);
+ //
+ // //...
+ // }
+ });
+}(window.RichFaces, jQuery));
\ No newline at end of file
Property changes on: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
___________________________________________________________________
Name: svn:executable
+ *
Modified: root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml
===================================================================
--- root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-22 19:04:38 UTC (rev 18201)
+++ root/ui-sandbox/inputs/trunk/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-07-22 19:39:26 UTC (rev 18202)
@@ -27,22 +27,29 @@
xmlns:cc="http://richfaces.org/cdk/jsf/composite">
<cc:interface>
<cdk:class>org.richfaces.renderkit.html.InputNumberSliderRenderer</cdk:class>
- <cdk:superclass>javax.faces.render.Renderer</cdk:superclass>
+ <cdk:superclass>org.richfaces.renderkit.InputRendererBase</cdk:superclass>
<cdk:component-family>javax.faces.Input</cdk:component-family>
<cdk:renderer-type>org.richfaces.InputNumberSliderRenderer</cdk:renderer-type>
<cdk:resource-dependency name="inputNumberSlider.ecss" />
+ <cdk:resource-dependency library="javax.faces" name="jsf.js" />
+ <cdk:resource-dependency name="jquery.js" />
+ <cdk:resource-dependency name="richfaces.js" />
+ <cdk:resource-dependency name="richfaces.js" />
+ <cdk:resource-dependency name="richfaces-base-component.js" />
+ <cdk:resource-dependency name="inputNumberSlider.js" />
</cc:interface>
<cc:implementation>
<span id="#{clientId}" class="rf-ins">
<span class="sldr_size">
- <span class="sldr_min">10</span>
+ <span class="sldr_min">0</span>
<span class="sldr_max">100</span>
<span class="sldr_track">
<img src="#{facesContext.application.resourceHandler.createResource('handler.gif').requestPath}"
width="7" height="8" alt="" border="0" class="sldr_handler" />
</span>
</span>
- <input class="sldr_field" size="3" value="10" type="text" />
+ <input id="#{clientId}:i" name="#{clientId}" class="sldr_field" size="3" value="10" type="text" />
+ <script type="text/javascript">RichFaces.ui.InputNumberSlider('#{clientId}');</script>
</span>
</cc:implementation>
</cdk:root>
15 years, 12 months
JBoss Rich Faces SVN: r18201 - root/cdk/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 15:04:38 -0400 (Thu, 22 Jul 2010)
New Revision: 18201
Modified:
root/cdk/trunk/pom.xml
Log:
https://jira.jboss.org/browse/RF-8730
Modified: root/cdk/trunk/pom.xml
===================================================================
--- root/cdk/trunk/pom.xml 2010-07-22 16:25:19 UTC (rev 18200)
+++ root/cdk/trunk/pom.xml 2010-07-22 19:04:38 UTC (rev 18201)
@@ -39,17 +39,6 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <autoVersionSubmodules>true</autoVersionSubmodules>
- <tagBase>https://svn.jboss.org/repos/richfaces/root/cdk/tags</tagBase>
- <!-- As we need access to our own artifacts -->
- <preparationGoals>install</preparationGoals>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<inherited>false</inherited>
<configuration>
15 years, 12 months
JBoss Rich Faces SVN: r18200 - in root/core/trunk: impl/src/main/java/org/richfaces/renderkit/html and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-22 12:25:19 -0400 (Thu, 22 Jul 2010)
New Revision: 18200
Removed:
root/core/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java
Modified:
root/core/trunk/api/src/main/java/org/richfaces/skin/Skin.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java
Log:
Added getIntegerParameter() method into Skin
Dynamic resources code updated
Unit test failure fixed
Modified: root/core/trunk/api/src/main/java/org/richfaces/skin/Skin.java
===================================================================
--- root/core/trunk/api/src/main/java/org/richfaces/skin/Skin.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/api/src/main/java/org/richfaces/skin/Skin.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -304,6 +304,10 @@
*/
public Integer getColorParameter(FacesContext context, String name, Object defaultValue);
+ public Integer getIntegerParameter(FacesContext context, String name);
+
+ public Integer getIntegerParameter(FacesContext context, String name, Object defaultValue);
+
/**
* @param name
* @return
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -31,22 +31,26 @@
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.renderkit.html.images.GradientType;
import org.richfaces.renderkit.html.images.GradientType.BiColor;
import org.richfaces.resource.DynamicResource;
import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 02.02.2007
*/
@DynamicResource
-public class BaseGradient extends Java2Dresource {
+public class BaseGradient implements Java2DUserResource, StateHolderResource {
protected Integer headerBackgroundColor;
protected Integer headerGradientColor;
@@ -61,7 +65,6 @@
public BaseGradient(int width, int height, int gradientHeight, String baseColor, String gradientColor,
boolean horizontal) {
- super(ImageType.PNG);
this.width = width;
this.height = height;
this.gradientHeight = gradientHeight;
@@ -118,34 +121,14 @@
private void initialize() {
FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ this.headerBackgroundColor = skin.getColorParameter(context, baseColor);
+ this.headerGradientColor = skin.getColorParameter(context, gradientColor);
- Integer baseIntColor = null;
- Integer headerIntColor = null;
String gradientTypeString = null;
-
- if (baseIntColor == null) {
- baseIntColor = getColorValueParameter(context, baseColor, false);
- }
-
- if (headerIntColor == null) {
- headerIntColor = getColorValueParameter(context, gradientColor, false);
- }
-
- if (!(baseIntColor == null && headerIntColor == null)) {
- if (baseIntColor == null) {
- baseIntColor = getColorValueParameter(context, baseColor, true);
- }
-
- if (headerIntColor == null) {
- headerIntColor = getColorValueParameter(context, gradientColor, true);
- }
- }
-
- this.headerBackgroundColor = baseIntColor;
- this.headerGradientColor = headerIntColor;
-
if (gradientTypeString == null || gradientTypeString.length() == 0) {
- gradientTypeString = getValueParameter(context, Skin.GRADIENT_TYPE);
+ gradientTypeString = (String) skin.getParameter(context, Skin.GRADIENT_TYPE);
}
this.gradientType = GradientType.getByParameter(gradientTypeString);
@@ -199,10 +182,7 @@
}
}
- @Override
- protected void paint(Graphics2D graphics2d, Dimension dimension) {
- super.paint(graphics2d, dimension);
-
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
@@ -257,19 +237,31 @@
}
public void readState(FacesContext context, DataInput dataInput) throws IOException {
- super.readState(context, dataInput);
this.headerBackgroundColor = dataInput.readInt();
this.headerGradientColor = dataInput.readInt();
this.gradientType = GradientType.values()[dataInput.readByte()];
}
- @Override
public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
- super.writeState(context, dataOutput);
-
dataOutput.writeInt(this.headerBackgroundColor);
dataOutput.writeInt(this.headerGradientColor);
dataOutput.writeByte((byte) this.gradientType.ordinal());
}
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -29,6 +29,7 @@
import org.richfaces.renderkit.html.BaseGradient;
import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
/**
* Created 23.02.2008
@@ -39,8 +40,7 @@
public abstract class BaseControlBackgroundImage extends BaseGradient {
- //TODO - lazy initialize?
- private Integer height = getHeight(FacesContext.getCurrentInstance(), Skin.GENERAL_SIZE_FONT);
+ private Integer height = null;
public BaseControlBackgroundImage(String baseColor, String gradientColor, int width) {
super(width, -1, baseColor, gradientColor);
@@ -56,6 +56,8 @@
DataOutput stream) throws IOException {
super.writeState(context, stream);
+ this.height = getHeight(context, Skin.GENERAL_SIZE_FONT);
+
stream.writeInt(this.height);
}
@@ -69,4 +71,9 @@
this.gradientType = GradientType.PLAIN;
}
+ public Integer getHeight(FacesContext context, String parameterName) {
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+ return skin.getIntegerParameter(context, parameterName);
+ }
+
}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -21,16 +21,16 @@
package org.richfaces.renderkit.html.images;
+import javax.faces.context.FacesContext;
+
import org.richfaces.skin.Skin;
-import javax.faces.context.FacesContext;
-
public class StandardButtonBgImage extends BaseControlBackgroundImage {
public StandardButtonBgImage() {
super(Skin.ADDITIONAL_BACKGROUND_COLOR, "trimColor", 9);
}
protected Integer getHeight(FacesContext context) {
- return (int) (1.7 * super.getHeight(context, Skin.BUTTON_SIZE_FONT));
+ return (int) (1.7 * getHeight(context, Skin.BUTTON_SIZE_FONT));
}
}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -21,16 +21,16 @@
package org.richfaces.renderkit.html.images;
+import javax.faces.context.FacesContext;
+
import org.richfaces.skin.Skin;
-import javax.faces.context.FacesContext;
-
public class StandardButtonPressedBgImage extends BaseControlBackgroundImage {
public StandardButtonPressedBgImage() {
super("trimColor", Skin.ADDITIONAL_BACKGROUND_COLOR, 9);
}
protected Integer getHeight(FacesContext context) {
- return (int) (1.7 * super.getHeight(context, Skin.BUTTON_SIZE_FONT));
+ return (int) (1.7 * getHeight(context, Skin.BUTTON_SIZE_FONT));
}
}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -1,168 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.resource;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.GraphicsEnvironment;
-import java.awt.color.ColorSpace;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-
-import javax.imageio.IIOImage;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageTypeSpecifier;
-import javax.imageio.ImageWriteParam;
-import javax.imageio.ImageWriter;
-import javax.imageio.metadata.IIOMetadata;
-import javax.imageio.metadata.IIOMetadataNode;
-import javax.imageio.stream.ImageOutputStream;
-
-import org.w3c.dom.Node;
-
-public class AnimatedTestResource extends TestResource2 {
- private static final int DELAY_TIME = 50;
- private static final int FRAMES_COUNT = 10;
-
- private static ImageWriter getImageWriter() {
- ImageWriter result = null;
- Iterator<ImageWriter> imageWriters = ImageIO.getImageWritersByFormatName("gif");
-
- while (imageWriters.hasNext() && (result == null)) {
- ImageWriter imageWriter = imageWriters.next();
-
- if (imageWriter.canWriteSequence()) {
- result = imageWriter;
- }
- }
-
- return result;
- }
-
- private static Node getOrCreateChild(Node root, String name) {
- Node result = null;
-
- for (Node node = root.getFirstChild(); (node != null) && (result == null); node = node.getNextSibling()) {
- if (name.equals(node.getNodeName())) {
- result = node;
- }
- }
-
- if (result == null) {
- result = new IIOMetadataNode(name);
- root.appendChild(result);
- }
-
- return result;
- }
-
- @Override
- public String getContentType() {
- return "image/gif";
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
- Dimension dimension = getDimension();
- BufferedImage image = new BufferedImage(dimension.width, dimension.height, ColorSpace.TYPE_RGB);
- Graphics2D g2d = environment.createGraphics(image);
- ImageWriter sequenceCapableImageWriter = getImageWriter();
-
- if (sequenceCapableImageWriter == null) {
- throw new IllegalStateException("No sequence-capable image writers exit");
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ImageOutputStream imageOutputStream = null;
-
- try {
- imageOutputStream = ImageIO.createImageOutputStream(baos);
- sequenceCapableImageWriter.setOutput(imageOutputStream);
-
- ImageWriteParam defaultImageWriteParam = sequenceCapableImageWriter.getDefaultWriteParam();
- ImageTypeSpecifier imageTypeSpecifier = ImageTypeSpecifier.createFromBufferedImageType(image.getType());
- IIOMetadata imageMetaData = sequenceCapableImageWriter.getDefaultImageMetadata(imageTypeSpecifier,
- defaultImageWriteParam);
- String metaFormatName = imageMetaData.getNativeMetadataFormatName();
- Node root = imageMetaData.getAsTree(metaFormatName);
- IIOMetadataNode graphicsControlExtensionNode = (IIOMetadataNode) getOrCreateChild(root,
- "GraphicControlExtension");
-
- // http://java.sun.com/javase/6/docs/api/javax/imageio/metadata/doc-files/gi...
- graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
- graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
- graphicsControlExtensionNode.setAttribute("transparentColorFlag", "FALSE");
- graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(DELAY_TIME));
- graphicsControlExtensionNode.setAttribute("transparentColorIndex", "0");
-
- boolean loopContinuously = false;
- Node applicationExtensionsNode = getOrCreateChild(root, "ApplicationExtensions");
- IIOMetadataNode netscapeExtension = new IIOMetadataNode("ApplicationExtension");
-
- netscapeExtension.setAttribute("applicationID", "NETSCAPE");
- netscapeExtension.setAttribute("authenticationCode", "2.0");
-
- byte numLoops = (byte) (loopContinuously ? 0x0 : 0x1);
-
- netscapeExtension.setUserObject(new byte[]{0x1, numLoops, 0x0});
- applicationExtensionsNode.appendChild(netscapeExtension);
- imageMetaData.setFromTree(metaFormatName, root);
- sequenceCapableImageWriter.prepareWriteSequence(null);
-
- for (int i = 1; i <= FRAMES_COUNT; i++) {
- g2d.setPaint(new GradientPaint(0, i * dimension.height / FRAMES_COUNT, Color.WHITE, 0,
- dimension.height, getColor()));
- g2d.fillRect(0, 0, dimension.width, dimension.height);
- sequenceCapableImageWriter.writeToSequence(new IIOImage(image, null, imageMetaData),
- defaultImageWriteParam);
- }
-
- sequenceCapableImageWriter.endWriteSequence();
- } catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (imageOutputStream != null) {
- try {
- imageOutputStream.close();
- } catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- g2d.dispose();
- sequenceCapableImageWriter.dispose();
- }
-
- return new ByteArrayInputStream(baos.toByteArray());
- }
-}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -1,105 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.resource;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.HtmlColor;
-import org.richfaces.VersionBean;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-@DynamicResource
-public class TestResource2 extends Java2Dresource implements VersionedResource {
-
- private static final int MASK_FOR_COLOR_WITHOUT_ALPHA_CHANNEL = 0x00FFFFFF;
-
- private Color color;
-
- private Dimension dimension = new Dimension(20, 150);
-
- public TestResource2() {
- super(ImageType.PNG);
- FacesContext context = FacesContext.getCurrentInstance();
- Skin skin = SkinFactory.getInstance().getSkin(context);
- Object parameter = skin.getParameter(context, Skin.HEADER_GRADIENT_COLOR);
- this.color = HtmlColor.decode(parameter.toString());
- }
-
- @Override
- protected void paint(Graphics2D graphics2d, Dimension dim) {
- super.paint(graphics2d, dim);
-
- graphics2d.setPaint(new GradientPaint(0, 0, Color.WHITE, dim.width, dim.height, color));
- graphics2d.fillRect(0, 0, dim.width, dim.height);
- }
-
- @Override
- public void readState(FacesContext context, DataInput stream) throws IOException {
- super.readState(context, stream);
- this.color = new Color(stream.readInt());
- }
-
- @Override
- public void writeState(FacesContext context, DataOutput stream) throws IOException {
- super.writeState(context, stream);
- stream.writeInt(this.color.getRGB());
- }
-
- @Override
- public String getEntityTag(FacesContext context) {
- return ResourceUtils.formatWeakTag(getColorWitoutAlphaChanel());
- }
-
- private String getColorWitoutAlphaChanel() {
- return Integer.toHexString(color.getRGB() & MASK_FOR_COLOR_WITHOUT_ALPHA_CHANNEL);
- }
-
- public String getVersion() {
- return VersionBean.VERSION.getResourceVersion();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.Java2Dresource#getDimension()
- */
- @Override
- public Dimension getDimension() {
- return dimension;
- }
-
- public Color getColor() {
- return color;
- }
-
- public void setColor(Color color) {
- this.color = color;
- }
-}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -26,6 +26,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.HtmlDimensions;
/**
* @author Nick Belaevski
@@ -48,6 +49,19 @@
}
}
+ protected Integer decodeInteger(Object value) {
+ if (value instanceof Number) {
+ return Integer.valueOf(((Number) value).intValue());
+ } else {
+ String stringValue = (String) value;
+ if (stringValue != null && stringValue.length() != 0) {
+ return (int) HtmlDimensions.decode(stringValue).doubleValue();
+ } else {
+ return null;
+ }
+ }
+ }
+
public Integer getColorParameter(FacesContext context, String name) {
return decodeColor(getParameter(context, name));
}
@@ -56,4 +70,11 @@
return decodeColor(getParameter(context, name, defaultValue));
}
+ public Integer getIntegerParameter(FacesContext context, String name) {
+ return decodeInteger(getParameter(context, name));
+ }
+
+ public Integer getIntegerParameter(FacesContext context, String name, Object defaultValue) {
+ return decodeInteger(getParameter(context, name, defaultValue));
+ }
}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java 2010-07-22 16:06:49 UTC (rev 18199)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinBean.java 2010-07-22 16:25:19 UTC (rev 18200)
@@ -149,4 +149,18 @@
public Integer getColorParameter(FacesContext context, String name, Object defaultValue) {
return getSkin().getColorParameter(context, name, defaultValue);
}
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Skin#getIntegerParameter(javax.faces.context.FacesContext, java.lang.String)
+ */
+ public Integer getIntegerParameter(FacesContext context, String name) {
+ return getSkin().getIntegerParameter(context, name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Skin#getIntegerParameter(javax.faces.context.FacesContext, java.lang.String, java.lang.Object)
+ */
+ public Integer getIntegerParameter(FacesContext context, String name, Object defaultValue) {
+ return getSkin().getIntegerParameter(context, name, defaultValue);
+ }
}
15 years, 12 months
JBoss Rich Faces SVN: r18199 - root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-07-22 12:06:49 -0400 (Thu, 22 Jul 2010)
New Revision: 18199
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
Log:
https://jira.jboss.org/browse/RF-8875
bug fix
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-22 15:35:18 UTC (rev 18198)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-22 16:06:49 UTC (rev 18199)
@@ -123,10 +123,10 @@
if (event.type=="mouseover") {
var index = this.items.index(element);
if (index!=this.index) {
- this.selectItem(index);
+ selectItem.call(this, index);
}
} else {
- this.changeValue(event, this.getSelectedItemValue());
+ this.__changeValue(event, getSelectedItemValue.call(this));
rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
this.hide(event);
}
@@ -172,8 +172,8 @@
var _this = this;
var ajaxSuccess = function (event) {
updateItemsList.call(_this, _this.inputValue, event.componentData && event.componentData[_this.id]);
- if (_this.options.selectFirst) {
- _this.selectItem(0);
+ if (_this.isVisible && _this.options.selectFirst) {
+ selectItem.call(_this, 0);
}
}
@@ -223,11 +223,11 @@
var item = this.items.eq(this.index);
item.addClass(this.options.selectedItemClass);
scrollToSelectedItem.call(this);
- !noAutoFill && autoFill.call(this, this.inputValue, this.getSelectedItemValue());
+ !noAutoFill && autoFill.call(this, this.inputValue, getSelectedItemValue.call(this));
};
var changeValue = function (event, value) {
- this.selectItem();
+ selectItem.call(this);
if (typeof value == "undefined") {
// called from show method, not actually value changed
@@ -252,7 +252,7 @@
this.index = -1;
this.inputValue = value;
if (this.options.selectFirst) {
- this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ selectItem.call(this, 0, false, event.which == rf.KEYS.BACKSPACE);
}
};
@@ -272,17 +272,18 @@
* public API functions
*/
name:"AutoComplete",
- selectItem: selectItem,
- changeValue: changeValue,
- getSelectedItemValue: getSelectedItemValue,
/*
* Protected methods
*/
+ __changeValue: changeValue,
+ /*
+ * Override abstract protected methods
+ */
__onKeyUp: function () {
- this.selectItem(-1, true);
+ selectItem.call(this, -1, true);
},
__onKeyDown: function () {
- this.selectItem(1, true);
+ selectItem.call(this, 1, true);
},
__onPageUp: function () {
@@ -293,7 +294,7 @@
__onBeforeShow: function (event) {
},
__onEnter: function (event) {
- this.changeValue(event, this.getSelectedItemValue());
+ this.__changeValue(event, getSelectedItemValue.call(this));
rf.getDomElement(this.fieldId).blur();
rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
rf.getDomElement(this.fieldId).focus();
@@ -301,13 +302,13 @@
__onShow: function (event) {
if (this.items && this.items.length>0) {
//??TODO it's nessesary only if not changed value
- if (this.options.selectFirst) {
- this.selectItem(0);
+ if (this.index!=0 && this.options.selectFirst) {
+ selectItem.call(this, 0);
}
}
},
__onHide: function () {
- this.selectItem();
+ selectItem.call(this);
},
/*
* Destructor
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-22 15:35:18 UTC (rev 18198)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-22 16:06:49 UTC (rev 18199)
@@ -136,14 +136,14 @@
//TODO: is it needed to chesk keys?
if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
if (flag) {
- this.changeValue(event, value);
+ this.__changeValue(event, value);
onShow.call(this, event, true);
}
}
};
var onShow = function (event, noChangeValue) {
- !noChangeValue && this.changeValue(event);
+ !noChangeValue && this.__changeValue(event);
this.show(event);
};
@@ -266,7 +266,7 @@
}
},
/*
- * Protected abstract methods
+ * abstract protected methods
*/
__onKeyUp: function () {
},
15 years, 12 months
JBoss Rich Faces SVN: r18198 - root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-07-22 11:35:18 -0400 (Thu, 22 Jul 2010)
New Revision: 18198
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
Log:
https://jira.jboss.org/browse/RF-8875
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-22 15:33:47 UTC (rev 18197)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-22 15:35:18 UTC (rev 18198)
@@ -39,13 +39,18 @@
return newCache;
};
+ var getItemValue = function (item) {
+ return this.values[this.cache[this.key].index(item)];
+ };
+
var isCached = function (key) {
return this.cache[key];
- }
+ };
$.extend(rf.utils.Cache.prototype, (function () {
return {
getItems: getItems,
+ getItemValue: getItemValue,
isCached: isCached
};
})());
@@ -87,7 +92,8 @@
minChars:1,
selectFirst:true,
ajaxMode:true,
- attachToBody:true
+ attachToBody:true,
+ tokens: ", "
};
var ID = {
@@ -130,9 +136,6 @@
var updateItemsList = function (value, fetchValues) {
this.items = $(rf.getDomElement(this.id+ID.ITEMS)).find(".rf-ac-i");
if (this.items.length>0) {
- var parent = this.items.first().parent();
- parent.data(fetchValues);
-
this.cache = new rf.utils.Cache(value, this.items, fetchValues || getData);
}
};
@@ -142,13 +145,13 @@
this.items.slice(0, this.index).each(function() {
offset += this.offsetHeight;
});
- var itemsContainer = this.items.first().parent().parent();
- if(offset < itemsContainer.scrollTop()) {
- itemsContainer.scrollTop(offset);
+ var parentContainer = $(rf.getDomElement(this.id+ID.ITEMS)).parent();
+ if(offset < parentContainer.scrollTop()) {
+ parentContainer.scrollTop(offset);
} else {
offset+=this.items.get(this.index).offsetHeight;
- if(offset - itemsContainer.scrollTop() > itemsContainer.get(0).clientHeight) {
- itemsContainer.scrollTop(offset - itemsContainer.innerHeight());
+ if(offset - parentContainer.scrollTop() > parentContainer.get(0).clientHeight) {
+ parentContainer.scrollTop(offset - parentContainer.innerHeight());
}
}
};
@@ -164,6 +167,8 @@
var callAjax = function(event) {
+ $(rf.getDomElement(this.id+ID.ITEMS)).removeData().empty();
+
var _this = this;
var ajaxSuccess = function (event) {
updateItemsList.call(_this, _this.inputValue, event.componentData && event.componentData[_this.id]);
@@ -173,7 +178,7 @@
}
var ajaxError = function () {
- alert("error");
+ //alert("error");
}
this.isFirstAjax = false;
@@ -254,7 +259,7 @@
var getSelectedItemValue = function () {
if ( this.index>=0) {
var element = this.items.eq(this.index);
- return element.parent().data()[this.index] || getData(element)[0];
+ return this.cache.getItemValue(element);
}
return undefined;
};
@@ -311,7 +316,9 @@
//TODO: add all unbind
this.items = null;
this.cache = null;
- rf.Event.unbind(rf.getDomElement(this.id+ID.ITEMS).parentNode, this.namespace);
+ var itemsContainer = rf.getDomElement(this.id+ID.ITEMS);
+ $(itemsContainer).removeData();
+ rf.Event.unbind(itemsContainer.parentNode, this.namespace);
$super.destroy.call(this);
}
};
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-22 15:33:47 UTC (rev 18197)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-22 15:35:18 UTC (rev 18198)
@@ -62,12 +62,16 @@
};
var bindEventHandlers = function() {
+
+ var inputEventHandlers = {};
+
if (this.options.buttonId) {
- rf.Event.bindById(this.options.buttonId, "mousedown"+this.namespace, onButtonShow, this);
- rf.Event.bindById(this.options.buttonId, "mouseup"+this.namespace, onSelectMouseUp, this);
+ inputEventHandlers["mousedown"+this.namespace] = onButtonShow;
+ inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
+ rf.Event.bindById(this.options.buttonId, inputEventHandlers, this);
}
- var inputEventHandlers = {};
+ inputEventHandlers = {};
inputEventHandlers["focus"+this.namespace] = onFocus;
inputEventHandlers["blur"+this.namespace] = onBlur;
inputEventHandlers["click"+this.namespace] = onClick;
@@ -75,7 +79,6 @@
rf.Event.bindById(this.fieldId, inputEventHandlers, this);
inputEventHandlers = {};
- //inputEventHandlers["click"+this.namespace] = onSelectClick;
inputEventHandlers["mousedown"+this.namespace] = onSelectMouseDown;
inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
rf.Event.bindById(this.selectId, inputEventHandlers, this);
@@ -288,7 +291,7 @@
rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
this.scrollElements = null;
}
- rf.Event.unbindById(this.options.buttonId, this.namespace);
+ this.options.buttonId && rf.Event.unbindById(this.options.buttonId, this.namespace);
rf.Event.unbindById(this.fieldId, this.namespace);
rf.Event.unbindById(this.selectId, this.namespace);
$super.destroy.call(this);
15 years, 12 months
JBoss Rich Faces SVN: r18197 - in root/core/trunk/impl/src/main: resources/META-INF and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-22 11:33:47 -0400 (Thu, 22 Jul 2010)
New Revision: 18197
Added:
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryPreRenderViewListener.java
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml
Log:
Skin system refactoring
Modified: root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java 2010-07-22 13:49:01 UTC (rev 18196)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java 2010-07-22 15:33:47 UTC (rev 18197)
@@ -26,7 +26,7 @@
/**
* @author nick belaevski
*/
-final class CompositeSkinImpl implements Skin {
+final class CompositeSkinImpl extends AbstractSkin {
private int hashCode = 0;
@@ -103,20 +103,4 @@
return parameterValue;
}
- /* (non-Javadoc)
- * @see org.richfaces.skin.Skin#getColorParameter(javax.faces.context.FacesContext, java.lang.String)
- */
- public Integer getColorParameter(FacesContext context, String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.skin.Skin#getColorParameter(javax.faces.context.FacesContext, java.lang.String, java.lang.Object)
- */
- public Integer getColorParameter(FacesContext context, String name, Object defaultValue) {
- // TODO Auto-generated method stub
- return null;
- }
-
}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-07-22 13:49:01 UTC (rev 18196)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-07-22 15:33:47 UTC (rev 18197)
@@ -165,6 +165,11 @@
return skin;
}
+ static void clearSkinCaches(FacesContext context) {
+ context.getAttributes().remove(BASE_SKIN_KEY);
+ context.getAttributes().remove(SKIN_KEY);
+ }
+
// protected Properties getDefaultSkinProperties() {
// if (defaultSkinProperties == null) {
// defaultSkinProperties = loadProperties(DEFAULT_SKIN_NAME,DEFAULT_SKIN_PATHS);
Added: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryPreRenderViewListener.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryPreRenderViewListener.java (rev 0)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryPreRenderViewListener.java 2010-07-22 15:33:47 UTC (rev 18197)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.skin;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SkinFactoryPreRenderViewListener implements SystemEventListener {
+
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ SkinFactoryImpl.clearSkinCaches(FacesContext.getCurrentInstance());
+ }
+
+ public boolean isListenerForSource(Object source) {
+ return true;
+ }
+
+}
Modified: root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml 2010-07-22 13:49:01 UTC (rev 18196)
+++ root/core/trunk/impl/src/main/resources/META-INF/faces-config.xml 2010-07-22 15:33:47 UTC (rev 18197)
@@ -19,6 +19,10 @@
-->
<!-- state-manager>org.ajax4jsf.application.AjaxStateManager</state-manager -->
<el-resolver>org.richfaces.skin.SkinPropertiesELResolver</el-resolver>
+ <system-event-listener>
+ <system-event-listener-class>org.richfaces.skin.SkinFactoryPreRenderViewListener</system-event-listener-class>
+ <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
+ </system-event-listener>
</application>
<!-- lifecycle>
<phase-listener>org.ajax4jsf.event.AjaxPhaseListener</phase-listener>
15 years, 12 months
JBoss Rich Faces SVN: r18196 - root/tests/metamer/trunk/application/src/main/webapp/WEB-INF.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-22 09:49:01 -0400 (Thu, 22 Jul 2010)
New Revision: 18196
Modified:
root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml
Log:
https://jira.jboss.org/browse/RF-8968
Modified: root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2010-07-22 12:51:30 UTC (rev 18195)
+++ root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2010-07-22 13:49:01 UTC (rev 18196)
@@ -13,7 +13,7 @@
<param-value>server</param-value>
</context-param>
<context-param>
- <param-name>org.richfaces.SKIN</param-name>
+ <param-name>org.richfaces.skin</param-name>
<param-value>#{richBean.skin}</param-value>
</context-param>
<servlet>
15 years, 12 months
JBoss Rich Faces SVN: r18195 - in root/core/trunk: impl/src/main/java/org/ajax4jsf/context and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-22 08:51:30 -0400 (Thu, 22 Jul 2010)
New Revision: 18195
Added:
root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java
Removed:
root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/BaseSkinImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java
Modified:
root/core/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
root/core/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
Log:
https://jira.jboss.org/browse/RF-8968
Skins refactoring
Modified: root/core/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java
===================================================================
--- root/core/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/api/src/main/java/org/richfaces/skin/SkinFactory.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -21,10 +21,10 @@
package org.richfaces.skin;
-import org.richfaces.application.ServiceTracker;
-
import javax.faces.context.FacesContext;
+import org.richfaces.application.ServiceTracker;
+
/**
* Base factory class ( implement Singleton design pattern ). Produce self
* instance to build current skin configuration. At present, realised as lazy
@@ -35,18 +35,7 @@
*/
public abstract class SkinFactory {
- public static final String BASE_SKIN_PARAMETER = "org.richfaces.BASE_SKIN";
-
/**
- * Name of web application init parameter for current skin . Can be simple
- * String for non-modified name, or EL-expression for calculate current
- * skin. If EL evaluated to <code>String</code> - used as skin name, if to
- * instance of {@link Skin } - used this instance. by default -
- * "org.exadel.chameleon.SKIN"
- */
- public static final String SKIN_PARAMETER = "org.richfaces.SKIN";
-
- /**
* Initialize skin factory. TODO - make call from init() method of any
* servlet or custom faces element method ??? If exist resource
* META-INF/services/org.richfaces.skin.SkinFactory , create
@@ -55,10 +44,15 @@
* instance of default factory ( as usual in JSF ). If any error occurs in
* instantiate custom factory, return default.
*/
+ @Deprecated
public static final SkinFactory getInstance() {
- return ServiceTracker.getService(FacesContext.getCurrentInstance(), SkinFactory.class);
+ return getInstance(FacesContext.getCurrentInstance());
}
+ public static final SkinFactory getInstance(FacesContext context) {
+ return ServiceTracker.getService(context, SkinFactory.class);
+ }
+
/**
* Get default {@link Skin} implementation.
*
@@ -89,4 +83,7 @@
* @return
*/
public abstract Theme getTheme(FacesContext facesContext, String name);
+
+ public abstract Skin getSkin(FacesContext context, String name);
+
}
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -30,6 +30,7 @@
import org.ajax4jsf.util.ELUtils;
import org.richfaces.application.ServiceTracker;
+import org.richfaces.skin.Skin;
/**
* This class hold all methods for get application init parameters. Created for
@@ -50,14 +51,24 @@
* If is it equals "true" , framework should proparate exception to client-side.
*/
public static final String HANDLE_VIEW_EXPIRED_ON_CLIENT = "org.ajax4jsf.handleViewExpiredOnClient";
- public static final String STD_CONTROLS_SKINNING_PARAM = "org.richfaces.ENABLE_CONTROL_SKINNING";
- public static final String STD_CONTROLS_SKINNING_CLASSES_PARAM = "org.richfaces.ENABLE_CONTROL_SKINNING_CLASSES";
+ public static final String STD_CONTROLS_SKINNING_PARAM = "org.richfaces.enableControlSkinning";
+ public static final String STD_CONTROLS_SKINNING_CLASSES_PARAM = "org.richfaces.enableControlSkinningClasses";
public static final String[] QUEUE_ENABLED = {"org.richfaces.queue.enabled"};
//TODO - better name
- public static final String RESOURCES_TTL = "org.richfaces.RESOURCE_DEFAULT_TTL";
- public static final String RESOURCES_CACHE_SIZE = "org.richfaces.RESOURCE_CACHE_SIZE";
+ public static final String RESOURCES_TTL = "org.richfaces.resourceDefaultTTL";
+ public static final String RESOURCES_CACHE_SIZE = "org.richfaces.resourceCacheSize";
+ /**
+ * Name of web application init parameter for current skin . Can be simple
+ * String for non-modified name, or EL-expression for calculate current
+ * skin. If EL evaluated to <code>String</code> - used as skin name, if to
+ * instance of {@link Skin } - used this instance. by default -
+ * "org.exadel.chameleon.SKIN"
+ */
+ public static final String SKIN = "org.richfaces.skin";
+ public static final String BASE_SKIN = "org.richfaces.baseSkin";
+
private static final String[] RESOURCES_TTL_ARRAY = { RESOURCES_TTL };
private static final String[] RESOURCES_CACHE_SIZE_ARRAY = { RESOURCES_CACHE_SIZE };
@@ -101,7 +112,7 @@
* @return value of STD_CONTROLS_SKINNING_PARAM parameter if present.
*/
public static boolean isStandardControlSkinningEnabled(FacesContext context) {
- String paramValue = evaluateInitParameter(context, STD_CONTROLS_SKINNING_PARAM);
+ Object paramValue = evaluateInitParameter(context, STD_CONTROLS_SKINNING_PARAM);
return getBooleanValue(paramValue, true);
}
@@ -120,10 +131,18 @@
* @return value of STD_CONTROLS_SKINNING_CLASSES_PARAM parameter if present.
*/
public static boolean isStandardControlSkinningClassesEnabled(FacesContext context) {
- String paramValue = evaluateInitParameter(context, STD_CONTROLS_SKINNING_CLASSES_PARAM);
+ Object paramValue = evaluateInitParameter(context, STD_CONTROLS_SKINNING_CLASSES_PARAM);
return getBooleanValue(paramValue, false);
}
+ public static Object getSkin(FacesContext context) {
+ return evaluateInitParameter(context, SKIN);
+ }
+
+ public static Object getBaseSkin(FacesContext context) {
+ return evaluateInitParameter(context, BASE_SKIN);
+ }
+
static int getInteger(FacesContext context, String[] paramNames, int defaultValue) {
String initParameter = getInitParameter(context, paramNames);
@@ -193,7 +212,7 @@
return concurrentStorage;
}
- private static String evaluateInitParameter(FacesContext context, String parameterName) {
+ private static Object evaluateInitParameter(FacesContext context, String parameterName) {
InitParametersStorage expressionsMap = getExpressionsMap(context);
String parameterKey = INIT_PARAM_PREFIX + parameterName;
@@ -223,7 +242,7 @@
return evaluateInitParameterExpression(context, parameterValue);
}
- private static String evaluateInitParameterExpression(FacesContext context, Object parameterValue) {
+ private static Object evaluateInitParameterExpression(FacesContext context, Object parameterValue) {
if (parameterValue == NULL || parameterValue == null) {
return null;
} else if (parameterValue instanceof ValueExpression) {
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractChainableSkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -1,159 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author nick belaevski
- * @since 3.2
- */
-public abstract class AbstractChainableSkinImpl extends BasicSkinImpl {
- private static final Operation RESOLVE = new Operation() {
- public Object doExternalCall(FacesContext context, Skin impl, String name) {
-
- // TODO add warning because substitution can work incorrect and cyclic references
- // won't be caught
- return impl.getParameter(context, name);
- }
-
- public Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name) {
- return impl.localResolveSkinParameter(context, name);
- }
- };
- private static final Operation CONTAINS = new Operation() {
- private Object wrapBoolean(boolean value) {
- return value ? Boolean.TRUE : null;
- }
-
- public Object doExternalCall(FacesContext context, Skin impl, String name) {
- return wrapBoolean(impl.containsProperty(name));
- }
-
- public Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name) {
- return wrapBoolean(impl.localContainsProperty(context, name));
- }
- };
-
- AbstractChainableSkinImpl(Map<Object, Object> properties) {
- super(properties);
- }
-
- protected abstract Skin getBaseSkin(FacesContext context);
-
- protected Object localResolveSkinParameter(FacesContext context, String name) {
- return getSkinParams().get(name);
- }
-
- protected boolean localContainsProperty(FacesContext context, String name) {
- return getSkinParams().containsKey(name);
- }
-
- protected Object executeOperation(FacesContext context, Operation operation, String name, int[] singleInt) {
- if (singleInt[0]++ > 1000) {
- throw new FacesException(Messages.getMessage(Messages.SKIN_CYCLIC_REFERENCE, name));
- }
-
- Object object = operation.doLocalCall(context, this, name);
-
- if (object == null) {
- Skin baseSkin = getBaseSkin(context);
-
- if (baseSkin != null) {
- if (baseSkin instanceof AbstractChainableSkinImpl) {
- AbstractChainableSkinImpl skinImpl = (AbstractChainableSkinImpl) baseSkin;
-
- object = operation.doChainedCall(context, skinImpl, name, singleInt);
- } else {
- object = operation.doExternalCall(context, baseSkin, name);
- }
- }
- }
-
- return object;
- }
-
- protected Object resolveSkinParameter(FacesContext context, String name, int[] singleInt) {
- return executeOperation(context, RESOLVE, name, singleInt);
- }
-
- protected boolean containsProperty(FacesContext context, String name, int[] singleInt) {
- return Boolean.TRUE.equals(executeOperation(context, CONTAINS, name, singleInt));
- }
-
- protected Object resolveSkinParameter(FacesContext context, String name) {
- int[] singleInt = new int[]{0};
- Object resolvedParameter = resolveSkinParameter(context, name, singleInt);
-
- while (resolvedParameter instanceof String) {
- String string = (String) resolvedParameter;
-
- if ((string.length() > 0) && (string.charAt(0) == '&')) {
- resolvedParameter = resolveSkinParameter(context, string.substring(1), singleInt);
-
- if (resolvedParameter == null) {
- throw new FacesException(Messages.getMessage(Messages.SKIN_ILLEGAL_REFERENCE, name));
- }
- } else {
- break;
- }
- }
-
- return resolvedParameter;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.skin.Skin#containsProperty(java.lang.String)
- */
- public boolean containsProperty(String name) {
- return containsProperty(FacesContext.getCurrentInstance(), name, new int[]{0});
- }
-
- @Override
- public int hashCode(FacesContext context) {
- int hash = super.hashCode(context);
- Skin baseSkin = getBaseSkin(context);
-
- if (baseSkin != null) {
- hash = 31 * hash + baseSkin.hashCode(context);
- }
-
- return hash;
- }
-
- private abstract static class Operation {
- public Object doChainedCall(FacesContext context, AbstractChainableSkinImpl impl, String name,
- int[] singleInt) {
- return impl.executeOperation(context, this, name, singleInt);
- }
-
- public abstract Object doLocalCall(FacesContext context, AbstractChainableSkinImpl impl, String name);
-
- public abstract Object doExternalCall(FacesContext context, Skin impl, String name);
- }
-}
Added: root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java (rev 0)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkin.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.skin;
+
+import java.awt.Color;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.util.HtmlColor;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AbstractSkin implements Skin {
+
+ protected Integer decodeColor(Object value) {
+ if (value instanceof Color) {
+ return ((Color) value).getRGB();
+ } else if (value instanceof Integer) {
+ return ((Integer) value).intValue();
+ } else {
+ String stringValue = (String) value;
+ if (stringValue != null && stringValue.length() != 0) {
+ return Integer.valueOf(HtmlColor.decode(stringValue).getRGB());
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public Integer getColorParameter(FacesContext context, String name) {
+ return decodeColor(getParameter(context, name));
+ }
+
+ public Integer getColorParameter(FacesContext context, String name, Object defaultValue) {
+ return decodeColor(getParameter(context, name, defaultValue));
+ }
+
+}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/BaseSkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/BaseSkinImpl.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/BaseSkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author nick belaevski
- * @since 3.2
- */
-
-public class BaseSkinImpl extends AbstractChainableSkinImpl {
-
- private SkinFactoryImpl factoryImpl;
-
- BaseSkinImpl(Map<Object, Object> properties, SkinFactoryImpl factory) {
- super(properties);
-
- this.factoryImpl = factory;
- }
-
- protected Skin getBaseSkin(FacesContext context) {
- Object object = getLocalParameter(context, Skin.BASE_SKIN);
- Skin skin = null;
-
- if (object != null) {
- skin = factoryImpl.getSkinByName(context, object, true);
- }
-
- if (skin == null) {
- skin = factoryImpl.getDefaultSkin(context);
- }
-
- return skin;
- }
-
-}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -1,181 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import java.awt.Color;
-import java.util.Map;
-
-import javax.el.Expression;
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.util.HtmlColor;
-
-/**
- * Singleton ( in respect as collection of different skins ) for produce
- * instances properties for all used skins.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:41 $
- */
-public abstract class BasicSkinImpl implements Skin {
-
- private int hashCode = 0;
-
- private final Map<Object, Object> skinParams;
-
- /**
- * Skin can instantiate only by factory method.
- *
- * @param skinName
- */
- BasicSkinImpl(Map<Object, Object> properties) {
- this.skinParams = properties;
- }
-
- protected Map<Object, Object> getSkinParams() {
- return skinParams;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String)
- */
- public Object getParameter(FacesContext context, String name) {
- return getValueReference(context, resolveSkinParameter(context, name));
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.skin.Skin#getParameter(javax.faces.context.FacesContext, java.lang.String, java.lang.String, java.lang.Object)
- */
- public Object getParameter(FacesContext context, String name, Object defaultValue) {
- Object value = getValueReference(context, resolveSkinParameter(context, name));
-
- if (null == value) {
- value = defaultValue;
- }
-
- return value;
- }
-
- protected Integer decodeColor(Object value) {
- if (value instanceof Color) {
- return ((Color) value).getRGB();
- } else if (value instanceof Integer) {
- return ((Integer) value).intValue();
- } else {
- String stringValue = (String) value;
- if (stringValue != null && stringValue.length() != 0) {
- return Integer.valueOf(HtmlColor.decode(stringValue).getRGB());
- } else {
- return null;
- }
- }
- }
-
- public Integer getColorParameter(FacesContext context, String name) {
- return decodeColor(getParameter(context, name));
- }
-
- public Integer getColorParameter(FacesContext context, String name, Object defaultValue) {
- return decodeColor(getParameter(context, name, defaultValue));
- }
-
- protected Object getLocalParameter(FacesContext context, String name) {
- return getValueReference(context, skinParams.get(name));
- }
-
- protected abstract Object resolveSkinParameter(FacesContext context, String name);
-
- /**
- * Calculate concrete value for property - if it stored as @see ValueBinding ,
- * return interpreted value.
- *
- * @param context
- * @param property
- * @return
- */
- protected Object getValueReference(FacesContext context, Object property) {
- if (property instanceof ValueExpression) {
- ValueExpression value = (ValueExpression) property;
-
- return value.getValue(context.getELContext());
- }
-
- return property;
- }
-
- public String toString() {
- return this.getClass().getSimpleName() + ": " + skinParams.toString();
- }
-
- protected int computeHashCode(FacesContext context) {
- int localHash = hashCode;
- if (localHash == 0) {
- boolean hasDynamicValues = false;
-
- for (Map.Entry<Object, Object> entry : skinParams.entrySet()) {
- String key = (String) entry.getKey();
- Object value = entry.getValue();
-
- if (value instanceof Expression) {
- hasDynamicValues = true;
- }
-
- Object parameter = getValueReference(context, value);
-
- localHash = 31 * localHash + key.hashCode();
- localHash = 31 * localHash + ((parameter != null) ? parameter.hashCode() : 0);
- }
-
- if (!hasDynamicValues) {
- hashCode = localHash;
- }
- }
-
- return localHash;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.skin.Skin#hashCode(javax.faces.context.FacesContext)
- */
- public int hashCode(FacesContext context) {
- if (hashCode != 0) {
- return hashCode;
- }
-
- Map<Object, Object> attributesMap = context.getAttributes();
-
- Integer requestCode = (Integer) attributesMap.get(this);
-
- if (null == requestCode) {
- requestCode = new Integer(computeHashCode(context));
-
- // store hash for this skin as request-skope parameter - not calculate on next calls for same request
- attributesMap.put(this, requestCode);
- }
-
- return requestCode.intValue();
- }
-}
Added: root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java (rev 0)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/CompositeSkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author nick belaevski
+ */
+final class CompositeSkinImpl implements Skin {
+
+ private int hashCode = 0;
+
+ private Skin[] skinsChain;
+
+ /**
+ * @param properties
+ */
+ CompositeSkinImpl(Skin... skinsChain) {
+ // TODO Auto-generated constructor stub
+
+ this.skinsChain = skinsChain;
+ }
+
+ public boolean containsProperty(String name) {
+ for (Skin skin : skinsChain) {
+ if (skin == null) {
+ continue;
+ }
+
+ if (skin.containsProperty(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public int hashCode(FacesContext context) {
+ int hash = hashCode;
+
+ if (hash == 0) {
+ for (Skin skin : skinsChain) {
+ if (skin == null) {
+ continue;
+ }
+
+ hash = 31 * hash + skin.hashCode(context);
+ }
+
+ hashCode = hash;
+ }
+
+ return hash;
+ }
+
+ //for unit tests
+ void resetCachedHashCode() {
+ hashCode = 0;
+ }
+
+ public Object getParameter(FacesContext context, String name) {
+ for (Skin skin : skinsChain) {
+ if (skin == null) {
+ continue;
+ }
+
+ Object value = skin.getParameter(context, name);
+ if (value != null) {
+ return value;
+ }
+ }
+
+ return null;
+ }
+
+ public Object getParameter(FacesContext context, String name, Object defaultValue) {
+ Object parameterValue = getParameter(context, name);
+
+ if (parameterValue == null) {
+ parameterValue = defaultValue;
+ }
+
+ return parameterValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Skin#getColorParameter(javax.faces.context.FacesContext, java.lang.String)
+ */
+ public Integer getColorParameter(FacesContext context, String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.skin.Skin#getColorParameter(javax.faces.context.FacesContext, java.lang.String, java.lang.Object)
+ */
+ public Integer getColorParameter(FacesContext context, String name, Object defaultValue) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/DefaultSkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author nick belaevski
- * @since 3.2
- */
-public class DefaultSkinImpl extends AbstractChainableSkinImpl {
-
- DefaultSkinImpl(Map<Object, Object> properties) {
- super(properties);
- }
-
- protected Skin getBaseSkin(FacesContext context) {
- return null;
- }
-}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -21,19 +21,6 @@
package org.richfaces.skin;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.util.ELUtils;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
-import javax.el.ELContext;
-import javax.el.ExpressionFactory;
-import javax.el.ValueExpression;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -42,7 +29,24 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.context.ContextInitParameters;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.ajax4jsf.util.ELUtils;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* Implementation of {@link SkinFactory} with building skins from properties
* files.
@@ -50,15 +54,10 @@
* @author shura
*/
public class SkinFactoryImpl extends SkinFactory {
- /**
- * Name of web application init parameter for current default
- * {@link javax.faces.render.RenderKit } interaction. by default -
- * org.exadel.chameleon.RENDERKIT_DEFINITION . TODO Possible Values
- */
- public static final String RENDER_KIT_PARAMETER = "org.ajax4jsf.RENDERKIT_DEFINITION";
- private static final String A4J_BASE_SKIN_PARAMETER = "org.ajax4jsf.BASE_SKIN";
- private static final String A4J_SKIN_PARAMETER = "org.ajax4jsf.SKIN";
+ private static final String SKIN_KEY = SkinFactoryImpl.class.getName() + ":skin";
+
+ private static final String BASE_SKIN_KEY = SkinFactoryImpl.class.getName() + ":baseSkin";
// private static final String DEFAULT_CONFIGURATION_RESOURCE = "META-INF/skins/DEFAULT.configuration.properties";
@@ -84,72 +83,86 @@
*/
private static final String[] SKINS_PATHS = {DEFAULT_SKIN_PATH, USER_SKIN_PATH};
private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
- private ValueExpression baseSkinBinding = null;
- private String baseSkinName = null;
- private ValueExpression skinBinding = null;
// private Properties defaultSkinProperties = null;
- private String skinName = null;
// private static final String[] CONFIGURATIONS_PATHS = {
// "META-INF/skins/%s.configuration.properties",
// "%s.configuration.properties" };
// private static final String[] DEFAULT_CONFIGURATION_PATHS = { "META-INF/skins/DEFAULT.configuration.properties" };
- private Map<String, Skin> skins = new HashMap<String, Skin>();
- private Map<String, Skin> baseSkins = new HashMap<String, Skin>();
- private Map<String, Properties> sourceProperties = new HashMap<String, Properties>();
+ private ConcurrentMap<String, FutureTask<Skin>> skins = new ConcurrentHashMap<String, FutureTask<Skin>>();
private Map<String, Theme> themes = new HashMap<String, Theme>();
- protected Skin getSkinByName(FacesContext facesContext, Object currentSkinOrName, boolean isBase) {
- if (null == currentSkinOrName) {
- throw new SkinNotFoundException(Messages.getMessage(Messages.NULL_SKIN_NAME_ERROR));
+ private final class SkinBuilder implements Callable<Skin> {
+
+ private String skinName;
+
+ SkinBuilder(String skinName) {
+ super();
+ this.skinName = skinName;
}
- Skin currentSkin = null;
-
- // user binding return skin instance.
- if (currentSkinOrName instanceof Skin) {
- currentSkin = (Skin) currentSkinOrName;
- } else {
- String currentSkinName = currentSkinOrName.toString();
- Map<String, Skin> skinsMap = isBase ? baseSkins : skins;
-
- synchronized (skinsMap) {
- currentSkin = skinsMap.get(currentSkinName);
-
- // LAZY creation for skins, since, in case of EL expressions
- // for skin name, we don't can know all names of existing skins.
- if (currentSkin == null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.CREATE_SKIN_INFO, currentSkinName));
- }
-
- currentSkin = buildSkin(facesContext, currentSkinName, isBase);
- skinsMap.put(currentSkinName, currentSkin);
- }
+ public Skin call() throws Exception {
+ return buildSkin(FacesContext.getCurrentInstance(), skinName);
+ }
+
+ }
+
+ @Override
+ public Skin getSkin(FacesContext context, String name) {
+ if (null == name) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.NULL_SKIN_NAME_ERROR));
+ }
+
+ FutureTask<Skin> skinFuture = skins.get(name);
+ if (skinFuture == null) {
+ FutureTask<Skin> newSkinFuture = new FutureTask<Skin>(new SkinBuilder(name));
+ skinFuture = skins.putIfAbsent(name, newSkinFuture);
+
+ if (skinFuture == null) {
+ skinFuture = newSkinFuture;
}
}
-
- return currentSkin;
+
+ try {
+ skinFuture.run();
+ return skinFuture.get();
+ } catch (InterruptedException e) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR), e);
+ } catch (ExecutionException e) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR), e);
+ }
}
-
+
public Skin getDefaultSkin(FacesContext context) {
- return getSkinByName(context, DEFAULT_SKIN_NAME, false);
+ return getSkin(context, DEFAULT_SKIN_NAME);
}
public Skin getSkin(FacesContext context) {
-
- // TODO - cache skin for current thread ? or for current Faces Lifecycle
- // Phase ?
- Object currentSkinOrName = getSkinOrName(context, false);
-
- return getSkinByName(context, currentSkinOrName, false);
+ Skin skin = (Skin) context.getAttributes().get(SKIN_KEY);
+ if (skin == null) {
+ Skin mainSkin = getSkinOrName(context, false);
+ Skin baseSkin = getSkinOrName(context, true);
+ Skin defaultSkin = getDefaultSkin(context);
+
+ skin = new CompositeSkinImpl(mainSkin, baseSkin, defaultSkin);
+ context.getAttributes().put(SKIN_KEY, skin);
+ }
+
+ return skin;
}
public Skin getBaseSkin(FacesContext context) {
- Object currentSkinOrName = getSkinOrName(context, true);
-
- return getSkinByName(context, currentSkinOrName, true);
+ Skin skin = (Skin) context.getAttributes().get(BASE_SKIN_KEY);
+ if (skin == null) {
+ Skin baseSkin = getSkinOrName(context, true);
+ Skin defaultSkin = getDefaultSkin(context);
+
+ skin = new CompositeSkinImpl(baseSkin, defaultSkin);
+ context.getAttributes().put(BASE_SKIN_KEY, skin);
+ }
+
+ return skin;
}
// protected Properties getDefaultSkinProperties() {
@@ -169,78 +182,25 @@
* parameter ) or {@link Skin } as result of evaluation EL
* expression.
*/
- protected Object getSkinOrName(FacesContext context, boolean useBase) {
-
- // Detect skin name
- ValueExpression binding;
- String skin;
-
- synchronized (this) {
- if (useBase) {
- binding = baseSkinBinding;
- skin = baseSkinName;
- } else {
- binding = skinBinding;
- skin = skinName;
- }
-
- if ((binding == null) && (skin == null)) {
- String currentSkinName = context.getExternalContext().getInitParameter(useBase
- ? BASE_SKIN_PARAMETER : SKIN_PARAMETER);
-
- if (null == currentSkinName) {
-
- // Check for a old ( deprecated ) parameter name.
- currentSkinName = context.getExternalContext().getInitParameter(useBase
- ? A4J_BASE_SKIN_PARAMETER : A4J_SKIN_PARAMETER);
-
- if (null != currentSkinName) {
- LOG.warn("Init parameter for a skin name changed to "
- + (useBase ? BASE_SKIN_PARAMETER : SKIN_PARAMETER));
- }
- }
-
- if (currentSkinName == null) {
-
- // not set - usr default.
- return DEFAULT_SKIN_NAME;
- }
-
- if (ELUtils.isValueReference(currentSkinName)) {
-
- // For EL expression as skin name
- binding =
- context.getApplication().getExpressionFactory().createValueExpression(context.getELContext(),
- currentSkinName, Object.class);
- } else {
- skin = currentSkinName;
- }
-
- if (useBase) {
- baseSkinBinding = binding;
- baseSkinName = skin;
- } else {
- skinBinding = binding;
- skinName = skin;
- }
- }
-
- // }
+ protected Skin getSkinOrName(FacesContext context, boolean useBase) {
+ Object skinObject = useBase ? ContextInitParameters.getBaseSkin(context) : ContextInitParameters.getSkin(context);
+
+ Skin result = null;
+
+ if (skinObject instanceof Skin) {
+ result = (Skin) skinObject;
+ } else if (skinObject != null) {
+ result = getSkin(context, (String) skinObject);
}
-
- if (binding != null) {
- return binding.getValue(context.getELContext());
- } else {
- return skin;
- }
+
+ return result;
}
private void processProperties(FacesContext context, Map<Object, Object> properties) {
ELContext elContext = context.getELContext();
// replace all EL-expressions by prepared ValueBinding ?
- ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- Application app = factory.getApplication();
+ Application app = context.getApplication();
for (Entry<Object, Object> entry : properties.entrySet()) {
Object propertyObject = entry.getValue();
@@ -272,32 +232,11 @@
* @throws SkinNotFoundException -
* if no skin properies found for name.
*/
- protected Skin buildSkin(FacesContext context, String name, boolean isBase) throws SkinNotFoundException {
- Properties skinParams;
+ protected Skin buildSkin(FacesContext context, String name) throws SkinNotFoundException {
+ Properties skinParams = loadProperties(name, SKINS_PATHS);
+ processProperties(context, skinParams);
- synchronized (sourceProperties) {
- skinParams = sourceProperties.get(name);
-
- if (skinParams == null) {
- skinParams = loadProperties(name, SKINS_PATHS);
- processProperties(context, skinParams);
-
- // skinParams = Collections.unmodifiableMap(skinParams);
- sourceProperties.put(name, skinParams);
- }
- }
-
- BasicSkinImpl skinImpl;
-
- if (DEFAULT_SKIN_NAME.equals(name)) {
- skinImpl = new DefaultSkinImpl(skinParams);
- } else if (isBase) {
- skinImpl = new BaseSkinImpl(skinParams, this);
- } else {
- skinImpl = new SkinImpl(skinParams, this);
- }
-
- return skinImpl;
+ return new SkinImpl(skinParams);
}
/**
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -1,56 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.skin;
-
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author nick belaevski
- * @since 3.2
- */
-public class SkinImpl extends AbstractChainableSkinImpl {
-
- private SkinFactoryImpl factoryImpl;
-
- SkinImpl(Map<Object, Object> properties, SkinFactoryImpl factoryImpl) {
- super(properties);
-
- this.factoryImpl = factoryImpl;
- }
-
- protected Skin getBaseSkin(FacesContext context) {
- Object object = getLocalParameter(context, Skin.BASE_SKIN);
- Skin skin = null;
-
- if (object != null) {
- skin = factoryImpl.getSkinByName(context, object, false);
- }
-
- if (skin == null) {
- skin = factoryImpl.getBaseSkin(context);
- }
-
- return skin;
- }
-}
Copied: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java (from rev 18177, root/core/trunk/impl/src/main/java/org/richfaces/skin/BasicSkinImpl.java)
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java (rev 0)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinImpl.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -0,0 +1,247 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.skin;
+
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * Singleton ( in respect as collection of different skins ) for produce
+ * instances properties for all used skins.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:41 $
+ */
+final class SkinImpl extends AbstractSkin {
+
+ private static class MutableInteger {
+ private int value;
+
+ public int getAndIncrement() {
+ return value++;
+ }
+
+ public int getAndDecrement() {
+ return value--;
+ }
+ }
+
+ private MutableInteger getCounter(FacesContext context) {
+ Map<Object, Object> attr = context.getAttributes();
+
+ MutableInteger counter = (MutableInteger) attr.get(MutableInteger.class);
+ if (counter == null) {
+ counter = new MutableInteger();
+ attr.put(MutableInteger.class, counter);
+ }
+
+ return counter;
+ }
+
+ private abstract static class Operation {
+
+ public abstract Object executeLocal(FacesContext facesContext, SkinImpl skin, String name);
+
+ public abstract Object executeBase(FacesContext facesContext, Skin skin, String name);
+
+ }
+
+ private static final Operation RESOLVE = new Operation() {
+
+ public Object executeLocal(FacesContext facesContext, SkinImpl skin, String name) {
+ Object resolvedParameter = skin.getLocalParameter(facesContext, name);
+
+ while (resolvedParameter instanceof String) {
+ String string = (String) resolvedParameter;
+
+ if ((string.length() > 0) && (string.charAt(0) == '&')) {
+ SkinFactory skinFactory = SkinFactory.getInstance(facesContext);
+ resolvedParameter = skinFactory.getSkin(facesContext).getParameter(facesContext, string.substring(1));
+
+ if (resolvedParameter == null) {
+ throw new FacesException(Messages.getMessage(Messages.SKIN_ILLEGAL_REFERENCE, name));
+ }
+ } else {
+ break;
+ }
+ }
+
+ return resolvedParameter;
+ }
+
+ @Override
+ public Object executeBase(FacesContext facesContext, Skin skin, String name) {
+ return skin.getParameter(facesContext, name);
+ }
+
+ };
+
+ private static final Operation CONTAINS = new Operation() {
+
+ public Object executeLocal(FacesContext facesContext, SkinImpl skin, String name) {
+ return skin.localContainsProperty(facesContext, name) ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ @Override
+ public Object executeBase(FacesContext facesContext, Skin skin, String name) {
+ return skin.containsProperty(name);
+ }
+
+ };
+
+ private final Map<Object, Object> skinParams;
+
+ /**
+ * Skin can instantiate only by factory method.
+ *
+ * @param skinName
+ */
+ SkinImpl(Map<Object, Object> properties) {
+ this.skinParams = properties;
+ }
+
+ protected Map<Object, Object> getSkinParams() {
+ return skinParams;
+ }
+
+ public Object getParameter(FacesContext context, String name) {
+ return getValueReference(context, resolveSkinParameter(context, name));
+ }
+
+ public Object getParameter(FacesContext context, String name, Object defaultValue) {
+ Object value = getValueReference(context, resolveSkinParameter(context, name));
+
+ if (null == value) {
+ value = defaultValue;
+ }
+
+ return value;
+ }
+
+ protected Object getLocalParameter(FacesContext context, String name) {
+ return getValueReference(context, skinParams.get(name));
+ }
+
+ /**
+ * Calculate concrete value for property - if it stored as @see ValueBinding ,
+ * return interpreted value.
+ *
+ * @param context
+ * @param property
+ * @return
+ */
+ protected Object getValueReference(FacesContext context, Object property) {
+ if (property instanceof ValueExpression) {
+ ValueExpression value = (ValueExpression) property;
+
+ return value.getValue(context.getELContext());
+ }
+
+ return property;
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName() + ": " + skinParams.toString();
+ }
+
+ protected Skin getBaseSkin(FacesContext context) {
+ String baseSkinName = (String) getLocalParameter(context, Skin.BASE_SKIN);
+ if (baseSkinName != null) {
+ SkinFactory skinFactory = SkinFactory.getInstance(context);
+ return skinFactory.getSkin(context, baseSkinName);
+ }
+ return null;
+ }
+
+ protected Object localResolveSkinParameter(FacesContext context, String name) {
+ return getSkinParams().get(name);
+ }
+
+ protected boolean localContainsProperty(FacesContext context, String name) {
+ return getSkinParams().containsKey(name);
+ }
+
+ protected Object executeOperation(FacesContext context, Operation operation, String name) {
+ MutableInteger counter = getCounter(context);
+
+ try {
+ if (counter.getAndIncrement() > 100) {
+ throw new FacesException(Messages.getMessage(Messages.SKIN_CYCLIC_REFERENCE, name));
+ }
+
+ Object result = operation.executeLocal(context, this, name);
+ if (result != null) {
+ return result;
+ }
+
+ Skin baseSkin = getBaseSkin(context);
+ if (baseSkin != null) {
+ return operation.executeBase(context, baseSkin, name);
+ }
+
+ } finally {
+ counter.getAndDecrement();
+ }
+
+ return null;
+ }
+
+ protected boolean containsProperty(FacesContext context, String name) {
+ return Boolean.TRUE.equals(executeOperation(context, CONTAINS, name));
+ }
+
+ protected Object resolveSkinParameter(FacesContext context, String name) {
+ return executeOperation(context, RESOLVE, name);
+ }
+
+ public boolean containsProperty(String name) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return containsProperty(facesContext, name);
+ }
+
+ public int hashCode(FacesContext context) {
+ int hash = 0;
+ for (Map.Entry<Object, Object> entry : skinParams.entrySet()) {
+ String key = (String) entry.getKey();
+ Object value = entry.getValue();
+
+ Object parameter = getValueReference(context, value);
+
+ hash = 31 * hash + key.hashCode();
+ hash = 31 * hash + ((parameter != null) ? parameter.hashCode() : 0);
+ }
+
+ Skin baseSkin = getBaseSkin(context);
+
+ if (baseSkin != null) {
+ hash = 31 * hash + baseSkin.hashCode(context);
+ }
+
+ return hash;
+ }
+
+}
Modified: root/core/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java
===================================================================
--- root/core/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java 2010-07-22 12:45:33 UTC (rev 18194)
+++ root/core/trunk/impl/src/test/java/org/richfaces/skin/SkinTestCase.java 2010-07-22 12:51:30 UTC (rev 18195)
@@ -31,6 +31,7 @@
import javax.faces.FacesException;
+import org.ajax4jsf.context.ContextInitParameters;
import org.jboss.test.faces.AbstractFacesTest;
/**
@@ -67,13 +68,13 @@
String skinName = skinParameters.skinName();
if (skinName != null && skinName.length() != 0) {
- facesServer.addInitParameter(SkinFactory.SKIN_PARAMETER, skinName);
+ facesServer.addInitParameter(ContextInitParameters.SKIN, skinName);
}
String baseSkinName = skinParameters.baseSkinName();
if (baseSkinName != null && baseSkinName.length() != 0) {
- facesServer.addInitParameter(SkinFactory.BASE_SKIN_PARAMETER, baseSkinName);
+ facesServer.addInitParameter(ContextInitParameters.BASE_SKIN, baseSkinName);
}
}
} catch (Exception e) {
@@ -248,22 +249,17 @@
});
Skin skin = factory.getSkin(facesContext);
- Map<Object, Object> attributesMap = facesContext.getAttributes();
// test properties
int hash = skin.hashCode(facesContext);
- assertTrue(attributesMap.containsKey(skin));
assertEquals(hash, skin.hashCode(facesContext));
- attributesMap.remove(skin);
- assertEquals(hash, skin.hashCode(facesContext));
- // setup Value binding mock for different value - hash must differ.
- attributesMap.remove(skin);
-
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
Map map = (Map) requestMap.get("test");
+ ((CompositeSkinImpl) skin).resetCachedHashCode();
+
map.put("bean", "other.test.value");
assertFalse(hash == skin.hashCode(facesContext));
}
15 years, 12 months