JBoss Rich Faces SVN: r15007 - branches/community/3.3.X/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2009-07-24 13:44:13 -0400 (Fri, 24 Jul 2009)
New Revision: 15007
Modified:
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.desc.xml
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.xml
Log:
RF-7532: rich:calendar component description review
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.desc.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.desc.xml 2009-07-24 17:29:01 UTC (rev 15006)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.desc.xml 2009-07-24 17:44:13 UTC (rev 15007)
@@ -3,14 +3,14 @@
<sectioninfo>
<keywordset>
<keyword>rich:calendar</keyword>
- </keywordset>
+ </keywordset>
<releaseinfo>3.1.0</releaseinfo>
</sectioninfo>
<section>
<title>Description</title>
- <para>The <emphasis role="bold">
- <property><rich:calendar></property>
- </emphasis> component is used for creating monthly calendar elements on a page.</para>
+ <para>
+ The <emphasis role="bold"><property><rich:calendar></property></emphasis> component is used for creating inputs for dates enriched with interactive calendar that allows navigate through monthes and years.
+ </para>
<figure>
<title><emphasis role="bold"> <property><rich:calendar></property></emphasis> component</title>
<mediaobject>
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.xml 2009-07-24 17:29:01 UTC (rev 15006)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/calendar.xml 2009-07-24 17:44:13 UTC (rev 15007)
@@ -57,10 +57,6 @@
<para>To create the simplest variant on a page use the following syntax:</para>
-
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
<programlisting role="XML"><![CDATA[...
<rich:calendar popup="false"/>
...]]></programlisting>
@@ -69,9 +65,7 @@
<section>
<title>Creating the Component Dynamically Using Java</title>
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
+
<programlisting role="JAVA"><![CDATA[import org.richfaces.component.html.HtmlCalendar;
...
HtmlCalendar myCalendar = new HtmlCalendar();
15 years, 3 months
JBoss Rich Faces SVN: r15006 - branches/community/3.3.X/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2009-07-24 13:29:01 -0400 (Fri, 24 Jul 2009)
New Revision: 15006
Modified:
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.desc.xml
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.xml
Log:
RF-7531:rich:beanValidator component description review
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.desc.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.desc.xml 2009-07-24 16:47:24 UTC (rev 15005)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.desc.xml 2009-07-24 17:29:01 UTC (rev 15006)
@@ -3,23 +3,21 @@
<sectioninfo>
<keywordset>
<keyword>rich:beanValidator</keyword>
- </keywordset>
+ <keyword>RichFaces</keyword>
+ </keywordset>
<releaseinfo>3.2.2</releaseinfo>
</sectioninfo>
<section>
<title>Description</title>
- <para>The<emphasis role="bold">
- <property><rich:beanValidator></property>
- </emphasis>is a component designed to provide validation using Hibernate model-based constraints</para>
-
-
-
-
+ <para>
+ The<emphasis role="bold"><property><rich:beanValidator></property></emphasis> component designed to provide validation using Hibernate model-based constraints.
+ </para>
</section>
+
<section>
- <title>Key Features</title>
- <itemizedlist>
- <listitem><para>Validation using Hibernate constraints</para></listitem>
- </itemizedlist>
+ <title>Key Features</title>
+ <itemizedlist>
+ <listitem><para>Validation using Hibernate constraints</para></listitem>
+ </itemizedlist>
</section>
</section>
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.xml 2009-07-24 16:47:24 UTC (rev 15005)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/beanValidator.xml 2009-07-24 17:29:01 UTC (rev 15006)
@@ -55,26 +55,17 @@
<section>
<title>Creating the Component with a Page Tag</title>
- <para>To create the simplest variant of the component on a page use the
- following syntax:</para>
-
-
<para>
- <emphasis role="bold">Example:</emphasis>
+ To create the simplest variant of the component on a page use the following syntax:
</para>
- <programlisting role="XML"><![CDATA[...
-<h:inputText value="#{validationBean.email}" id="email">
- <rich:beanValidator summary="Invalid email"/>
-</h:inputText>
-...]]></programlisting>
+
+ <programlisting role="XML"><![CDATA[<h:inputText value="#{validationBean.email}" id="email">
+ <rich:beanValidator summary="Invalid email"/>
+</h:inputText>]]></programlisting>
</section>
<section>
<title>Creating the Component Dynamically Using Java</title>
-
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
<programlisting role="JAVA"><![CDATA[import org.richfaces.component.html.HtmlCalendar;
...
HtmlbeanValidator mybeanValidator= new HtmlbeanValidator();
@@ -82,81 +73,94 @@
]]></programlisting>
</section>
- <!-- Start Details of Usage-->
+
<section>
<title>Details of Usage</title>
- <para> Starting from 3.2.2 GA version Rich Faces provides support for
- model-based constraints defined using Hibernate Validator.
- Thus it's possible to use Hibernate Validators the same as
- for Seam based applications. </para>
+ <para>Starting from 3.2.2 GA version Rich Faces provides support for model-based constraints defined using Hibernate Validator.
+ Thus it's possible to use Hibernate Validators the same as for Seam based applications.
+ </para>
+ <para>
+ The <emphasis role="bold"><property><rich:beanValidator></property></emphasis> component is defined in the same way as any JSF validator.
+ Look at the example below.
+ </para>
+ <programlisting role="XML"><![CDATA[<rich:panel>
+ <f:facet name="header">
+ <h:outputText value="#{validationBean.progressString}" id="progress"/>
+ </f:facet>
+ <h:panelGrid columns="3">
+ <h:outputText value="Name:" />
+ <h:inputText value="#{validationBean.name}" id="name">
+ <rich:beanValidator summary="Invalid name"/>
+ </h:inputText>
+ <rich:message for="name" />
- <para>The <emphasis role="bold">
- <property><rich:beanValidator></property>
- </emphasis> component is defined in the same way as any JSF
- validator. Look at the example below. </para>
+ <h:outputText value="Email:" />
+ <h:inputText value="#{validationBean.email}" id="email">
+ <rich:beanValidator summary="Invalid email"/>
+ </h:inputText>
+ <rich:message for="email" />
+
+ <h:outputText value="Age:" />
+ <h:inputText value="#{validationBean.age}" id="age">
+ <rich:beanValidator summary="Wrong age"/>
+ </h:inputText>
+ <rich:message for="age" />
+ <f:facet name="footer">
+ <a4j:commandButton value="Submit" action="#{validationBean.success}" reRender="progress"/>
+ </f:facet>
+ </h:panelGrid>
+</rich:panel>]]></programlisting>
- <programlisting role="XML"><![CDATA[...
-<rich:panel>
- <f:facet name="header">
- <h:outputText value="#{validationBean.progressString}" id="progress"/>
- </f:facet>
- <h:panelGrid columns="3">
- <h:outputText value="Name:" />
- <h:inputText value="#{validationBean.name}" id="name">
- <rich:beanValidator summary="Invalid name"/>
- </h:inputText>
- <rich:message for="name" />
- <h:outputText value="Email:" />
- <h:inputText value="#{validationBean.email}" id="email">
- <rich:beanValidator summary="Invalid email"/>
- </h:inputText>
- <rich:message for="email" />
- <f:facet name="footer">
- <a4j:commandButton value="Submit" action="#{validationBean.success}" reRender="progress"/>
- </f:facet>
- </h:panelGrid>
-</rich:panel>
-...]]></programlisting>
+ <para>
+ Please play close attention on the bean code that contains the constraints defined with Hibernate annotation which perform validation of the input data.
+ </para>
- <para>Please play close attention on the bean code that contains the
- constraints defined with Hibernate annotation which perform
- validation of the input data.</para>
+ <programlisting role="JAVA"><![CDATA[
- <programlisting role="JAVA"><![CDATA[
package org.richfaces.demo.validation;
import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
+import org.hibernate.validator.Max;
+import org.hibernate.validator.Min;
import org.hibernate.validator.NotEmpty;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
public class ValidationBean {
+ private String progressString="Fill the form please";
+
@NotEmpty
+ @Pattern(regex=".*[^\\s].*", message="This string contain only spaces")
@Length(min=3,max=12)
private String name;
@Email
@NotEmpty
private String email;
+ @NotNull
+ @Min(18)
+ @Max(100)
+ private Integer age;
+
public ValidationBean() {
}
- public String getName() {
- return name;
+ /* Corresponding Getters and Setters */
+
+ public void success() {
+ setProgressString(getProgressString() + "(Strored successfully)");
}
- public void setName(String name) {
- this.name = name;
+ public String getProgressString() {
+ return progressString;
}
- public String getEmail() {
- return email;
+ public void setProgressString(String progressString) {
+ this.progressString = progressString;
}
-
- public void setEmail(String email) {
- this.email = email;
- }
}]]></programlisting>
<para>The following figure shows what happens if validation fails</para>
15 years, 3 months
JBoss Rich Faces SVN: r15005 - branches/community/3.3.X/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-07-24 12:47:24 -0400 (Fri, 24 Jul 2009)
New Revision: 15005
Modified:
branches/community/3.3.X/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java
Log:
Fix RF-7417
Modified: branches/community/3.3.X/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java
===================================================================
--- branches/community/3.3.X/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java 2009-07-24 16:46:19 UTC (rev 15004)
+++ branches/community/3.3.X/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java 2009-07-24 16:47:24 UTC (rev 15005)
@@ -65,6 +65,7 @@
boolean seachInMyAlbums;
boolean searchInShared = true;
+ private SearchInformationHolder searchOptionsHolder;
/**
* Default constructor. During instantiation populate in field options all possible search options
@@ -99,6 +100,7 @@
* Method, that perform search, when user clicks by 'Find' button.
*/
public void search() {
+ searchOptionsHolder = null;
if(!isSearchOptionSelected()){
//If no options selected
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SEARCH_NO_OPTIONS_ERROR);
@@ -127,6 +129,7 @@
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, option.getName() + ":" + e.getMessage());
}
}
+ searchOptionsHolder = new SearchInformationHolder(new ArrayList<ISearchOption>(options),seachInMyAlbums, searchInShared);
}
/**
@@ -138,13 +141,13 @@
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SEARCH_NO_OPTIONS_ERROR);
return;
}
- Iterator<ISearchOption> it = options.iterator();
+ Iterator<ISearchOption> it = searchOptionsHolder.getOptions().iterator();
selectedKeyword = keyword.trim();
while (it.hasNext()) {
ISearchOption option = it.next();
try{
if (option.getSelected()) {
- option.search(searchAction, selectedKeyword , seachInMyAlbums, searchInShared);
+ option.search(searchAction, selectedKeyword , searchOptionsHolder.isSeachInMyAlbums(), searchOptionsHolder.isSearchInShared());
}
}catch(PhotoAlbumException e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, option.getName() + ":" + e.getMessage());
@@ -253,4 +256,28 @@
}
return isOptionSelected;
}
+}
+class SearchInformationHolder{
+ SearchInformationHolder(List<ISearchOption> options, boolean seachInMyAlbums, boolean searchInShared){
+ this.options = options;
+ this.seachInMyAlbums = seachInMyAlbums;
+ this.searchInShared = searchInShared;
+ }
+ List<ISearchOption> options;
+
+ boolean seachInMyAlbums;
+
+ boolean searchInShared;
+
+ public List<ISearchOption> getOptions() {
+ return options;
+ }
+
+ public boolean isSeachInMyAlbums() {
+ return seachInMyAlbums;
+ }
+
+ public boolean isSearchInShared() {
+ return searchInShared;
+ }
}
\ No newline at end of file
15 years, 3 months
JBoss Rich Faces SVN: r15003 - branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-07-24 09:21:35 -0400 (Fri, 24 Jul 2009)
New Revision: 15003
Modified:
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
Log:
contextMenu: onmousemove, onmouseout and onmouseover attributes don't work
https://jira.jboss.org/jira/browse/RF-7497
Modified: branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
===================================================================
--- branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-24 10:55:46 UTC (rev 15002)
+++ branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-24 13:21:35 UTC (rev 15003)
@@ -130,11 +130,18 @@
styleClass = "";
}
- writer.writeAttribute(HTML.onmousemove_ATTRIBUTE, layer.getAttributes().get("onmousemove"), null);
- writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, layer.getAttributes().get("onmouseout"), null);
- writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, layer.getAttributes().get("onmouseover"), null);
+ writeAttr(writer, HTML.onmousemove_ATTRIBUTE, layer.getAttributes().get("onmousemove"));
+ writeAttr(writer, HTML.onmouseout_ATTRIBUTE, layer.getAttributes().get("onmouseout"));
+ writeAttr(writer, HTML.onmouseover_ATTRIBUTE, layer.getAttributes().get("onmouseover"));
writer.writeAttribute(HTML.class_ATTRIBUTE, "rich-menu-list-border " + styleClass, null);
writer.writeAttribute(HTML.style_ATTRIBUTE, "display: none; z-index: 2; " + style, null);
}
+
+ private void writeAttr(ResponseWriter writer, final String name, final Object value) throws IOException {
+ if (value != null) {
+ writer.writeAttribute(name, value, null);
+ }
+
+ }
}
15 years, 3 months
JBoss Rich Faces SVN: r15002 - branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2009-07-24 06:55:46 -0400 (Fri, 24 Jul 2009)
New Revision: 15002
Modified:
branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/contextMenuDisablement.xml
branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/dataTableAjax.xml
Log:
https://jira.jboss.org/jira/browse/RF-7441 broken links are fixed
Modified: branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/contextMenuDisablement.xml
===================================================================
--- branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/contextMenuDisablement.xml 2009-07-24 10:41:23 UTC (rev 15001)
+++ branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/contextMenuDisablement.xml 2009-07-24 10:55:46 UTC (rev 15002)
@@ -20,7 +20,7 @@
<itemizedlist>
<listitem>
<para>
- <ulink url="https://jira.jboss.org/jira/browse/RF-5225">Jira</ulink>
+ <ulink url="http://jira.jboss.org/jira/browse/RF-5225">Jira</ulink>
</para>
</listitem>
</itemizedlist>
Modified: branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/dataTableAjax.xml
===================================================================
--- branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/dataTableAjax.xml 2009-07-24 10:41:23 UTC (rev 15001)
+++ branches/community/3.3.X/docs/migrationguide/en/src/main/docbook/included/dataTableAjax.xml 2009-07-24 10:55:46 UTC (rev 15002)
@@ -10,9 +10,9 @@
<title>Ajax request calls encode() methods of <rich:dataTable> even if it is not necessary</title>
<section>
<title>Description</title>
- <para>
- Any Ajax request reloads the list that is related to the <emphasis role="bold"><property><rich:dataTable></property></emphasis> component even if the Ajax request is related to another bean.
-It happens because the Ajax request checks whether the <emphasis role="bold"><property><rich:dataTable></property></emphasis> has nested <emphasis role="bold"><property><rich:outputPanel></property></emphasis> or <emphasis role="bold"><property><rich:messages></property></emphasis> components that should be updated.
+ <para>
+ Any Ajax request reloads the list that is related to the <emphasis role="bold"><property><rich:dataTable></property></emphasis> component even if the Ajax request is related to another bean.
+It happens because the Ajax request checks whether the <emphasis role="bold"><property><rich:dataTable></property></emphasis> has nested <emphasis role="bold"><property><rich:outputPanel></property></emphasis> or <emphasis role="bold"><property><rich:messages></property></emphasis> components that should be updated.
If there are no <emphasis role="bold"><property><rich:outputPanel></property></emphasis>, <emphasis role="bold"><property><rich:messages></property></emphasis> components inside the <emphasis role="bold"><property><rich:dataTable></property></emphasis> will not be updated, but anyway the <code>encode()</code> methods is called by the Ajax request.
</para>
</section>
@@ -21,9 +21,9 @@
<itemizedlist>
<listitem>
<para>
- <ulink url="https://jira.jboss.org/jira/browse/RF-3341">Jira</ulink>
+ <ulink url="http://jira.jboss.org/jira/browse/RF-3341">Jira</ulink>
</para>
- </listitem>
+ </listitem>
<listitem>
<para>
<ulink url="http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197996#...">RichFaces Forum</ulink>
@@ -35,17 +35,17 @@
<title>How to reproduce</title>
<para>
Place the following code on a page and click the button. The list in <code>myBean1.myList</code> will be reloaded.
- </para>
+ </para>
<programlisting role="XML"><![CDATA[...
-<h:form id="form1">
- <rich:dataTable id="myTable" value="#{myBean1.myList}" var="comp">
- ...
- </rich:dataTable>
-</h:form>
-<h:form id="form2">
- <h:outputText value="#{myBean2.test}"/>
- <a4j:commandButton event="onclick" reRender="form2" />
+<h:form id="form1">
+ <rich:dataTable id="myTable" value="#{myBean1.myList}" var="comp">
+ ...
+ </rich:dataTable>
</h:form>
+<h:form id="form2">
+ <h:outputText value="#{myBean2.test}"/>
+ <a4j:commandButton event="onclick" reRender="form2" />
+</h:form>
...]]></programlisting>
</section>
<section>
@@ -61,4 +61,4 @@
Wrap the zone of a page that should be processed and updated in the <emphasis role="bold"><property><a4j:region></property></emphasis> component with <code>renderRegionOnly="true"</code>. The <emphasis role="bold"><property><rich:dataTable></property></emphasis> should be outside of the <emphasis role="bold"><property><a4j:region></property></emphasis>.
</para>
</section>
-</section>
+</section>
15 years, 3 months
JBoss Rich Faces SVN: r15001 - in branches/community/3.3.X/docs/cdkguide/en/src/main/docbook: modules and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2009-07-24 06:41:23 -0400 (Fri, 24 Jul 2009)
New Revision: 15001
Modified:
branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/includes/ui_conf.xml
branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/modules/ide.xml
Log:
https://jira.jboss.org/jira/browse/RF-7441 broken links are fixed in cdk guide
Modified: branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/includes/ui_conf.xml
===================================================================
--- branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/includes/ui_conf.xml 2009-07-24 10:32:40 UTC (rev 15000)
+++ branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/includes/ui_conf.xml 2009-07-24 10:41:23 UTC (rev 15001)
@@ -218,7 +218,7 @@
<property>&html_events;</property>, <property>&ui_input_attributes;</property>, etc.).
</para>
<para>
- You could find all the entities in<ulink url="http://anonsvn.jboss.org/repos/richfaces/trunk/cdk/generator/src/main/res...">RichFaces repository</ulink>.
+ You could find all the entities in<ulink url="http://anonsvn.jboss.org/repos/richfaces/branches/community/3.3.X/cdk/gen...">RichFaces repository</ulink>.
</para>
<!--
Modified: branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/modules/ide.xml
===================================================================
--- branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/modules/ide.xml 2009-07-24 10:32:40 UTC (rev 15000)
+++ branches/community/3.3.X/docs/cdkguide/en/src/main/docbook/modules/ide.xml 2009-07-24 10:41:23 UTC (rev 15001)
@@ -159,7 +159,7 @@
Once you have built your projects for Eclipse IDE
you can easily migrate to NetBeans IDE.
You can get all necessary information at
- <ulink url="http://www.netbeans.org/kb/articles/import-eclipse.html">Automatically Import Your Projects From Eclipse to NetBeans IDE</ulink>
+ <ulink url="http://www.netbeans.org/kb/docs/java/import-eclipse.html">Automatically Import Your Projects From Eclipse to NetBeans IDE</ulink>
page.
</para>
</section>
15 years, 3 months
JBoss Rich Faces SVN: r15000 - branches/community/3.3.X/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2009-07-24 06:32:40 -0400 (Fri, 24 Jul 2009)
New Revision: 15000
Modified:
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/listShuttle.xml
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/messages.xml
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuGroup.xml
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuItem.xml
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/suggestionbox.xml
Log:
https://jira.jboss.org/jira/browse/RF-7441 broken links are fixed in dev guide
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/listShuttle.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/listShuttle.xml 2009-07-24 09:02:57 UTC (rev 14999)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/listShuttle.xml 2009-07-24 10:32:40 UTC (rev 15000)
@@ -49,7 +49,7 @@
</para>
<note>
<title>Note:</title>
- <para>Now the listener can not be called from the column facet. This is a temporary limitation. The additional information can be found in <ulink url="https://jira.jboss.org/jira/browse/RF-5327">RichFaces Jira</ulink>.</para>
+ <para>Now the listener can not be called from the column facet. This is a temporary limitation. The additional information can be found in <ulink url="http://jira.jboss.org/jira/browse/RF-5327">RichFaces Jira</ulink>.</para>
</note>
<para> The <emphasis>
<property>"sourceValue" </property>
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/messages.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/messages.xml 2009-07-24 09:02:57 UTC (rev 14999)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/messages.xml 2009-07-24 10:32:40 UTC (rev 15000)
@@ -288,7 +288,8 @@
<section>
<title>Relevant Resources Links</title>
<para><ulink
- url="http://livedemo.exadel.com/richfaces-demo/richfaces/messsages.jsf?c=messages"
+ url="http://livedemo.exadel.com/richfaces-demo/richfaces/messages.jsf?c=messag..."
+
>On the component LiveDemo page</ulink> you can see the example of <emphasis
role="bold">
<property><rich:messages></property>
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuGroup.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuGroup.xml 2009-07-24 09:02:57 UTC (rev 14999)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuGroup.xml 2009-07-24 10:32:40 UTC (rev 15000)
@@ -607,7 +607,7 @@
<title>Relevant resources links</title>
<para>
Some additional information about usage of component can be found
- <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/panelMenu.jsf?c=panel...">on the component Live Demo page</ulink>.
+ <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/panelMenu.jsf?c=panel...">on the component Live Demo page</ulink>.
</para>
</section>
</section>
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuItem.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuItem.xml 2009-07-24 09:02:57 UTC (rev 14999)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/panelMenuItem.xml 2009-07-24 10:32:40 UTC (rev 15000)
@@ -560,7 +560,7 @@
<section>
<title>Relevant resources links</title>
<para> Some additional information about usage of component can be found on this <ulink
- url="http://livedemo.exadel.com/richfaces-demo/richfaces/panelMenu.jsf?c=panel..."
+ url="http://livedemo.exadel.com/richfaces-demo/richfaces/panelMenu.jsf?c=panel..."
>LiveDemo page</ulink>. </para>
</section>
</section>
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/suggestionbox.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/suggestionbox.xml 2009-07-24 09:02:57 UTC (rev 14999)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/suggestionbox.xml 2009-07-24 10:32:40 UTC (rev 15000)
@@ -189,7 +189,7 @@
appearing in popup (for additional information, read JSF Reference)
and custom attribute managing Ajax requests sending (for additional
information, see <ulink
- url="http://www.jboss.org/projects/jbossajax4jsf">Ajax4JSF
+ url="http://www.jboss.org/community/wiki/Ajax4jsf">Ajax4JSF
Project</ulink>).</para>
<para>In addition to these attributes common for Ajax action components and
limiting requests quantity and frequency,
15 years, 3 months
JBoss Rich Faces SVN: r14999 - in root/framework/trunk: impl/src/main/java/org/ajax4jsf/application and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-24 05:02:57 -0400 (Fri, 24 Jul 2009)
New Revision: 14999
Removed:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
Modified:
root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java
Log:
Moving component APIs into ui-sandbox
Legacy resources API removal
Modified: root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -43,8 +43,6 @@
+ AjaxContext.class.getName();
private static final String DEFAULT_CONTEXT_CLASS = "org.ajax4jsf.context.AjaxContextImpl";
- public static final String HEAD_EVENTS_PARAMETER = "org.ajax4jsf.framework.HEAD_EVENTS_LIST";
-
/**
* Key for keep request state information in request-scope attributes.
*/
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -52,8 +52,6 @@
*/
public class AjaxViewHandler extends ViewHandlerWrapper {
- public static final String RESOURCES_PROCESSED = "org.ajax4jsf.framework.HEADER_PROCESSED";
-
public static final String STATE_MARKER_KEY = "org.ajax4jsf.view.state";
public static final String SERIALIZED_STATE_KEY = "org.ajax4jsf.view.serializedstate";
@@ -184,21 +182,6 @@
FilterServletResponseWrapper filterServletResponseWrapper = (FilterServletResponseWrapper)
requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
if (null != filterServletResponseWrapper) {
- if (!filterServletResponseWrapper.isError()) {
- if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
-
- ViewResources viewResources = new ViewResources();
-
- viewResources.initialize(context);
- viewResources.processHeadResources(context);
-
- requestMap.put(AjaxContext.HEAD_EVENTS_PARAMETER, viewResources.getHeadEvents());
-
- // Mark as processed.
- requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
- }
- }
-
// Save viewId for a parser selection
requestMap.put(AjaxViewHandler.VIEW_ID_KEY, context.getViewRoot().getViewId());
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -21,614 +21,573 @@
package org.ajax4jsf.context;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import javax.el.ExpressionFactory;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.component.QueueRegistry;
-import org.ajax4jsf.io.SAXResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBase;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.resource.ResourceRenderer;
-import org.ajax4jsf.resource.URIInternetResource;
-import org.ajax4jsf.util.ELUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-import org.richfaces.skin.SkinNotFoundException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
/**
* @author Nick Belaevski
*/
//TODO remove - https://jira.jboss.org/jira/browse/RFPL-42
public class ViewResources {
- private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
- private static final Object NULL = new Object();
-
- private String scriptStrategy;
-
- private String styleStrategy;
-
- private boolean useStdControlsSkinning;
-
- private boolean useStdControlsSkinningClasses;
-
- private HeadResponseWriter componentWriter;
-
- private HeadResponseWriter userWriter;
-
- private RenderKit renderKit;
-
- private Node[] headNodes = null;
-
- private static final String EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY = ViewResources.class.getName() + "EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY";
-
- private static final InternetResource EXTENDED_SKINNING_ON_RESOURCE = new InternetResourceBase() {
-
- private final String RESOURCE_KEY = this.getClass().getName();
-
- @Override
- public void encode(FacesContext context, Object data)
- throws IOException {
-
- encode(context, data, Collections.EMPTY_MAP);
- }
-
- @Override
- public void encode(FacesContext context, Object data,
- Map<String, Object> attributes) throws IOException {
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- if (requestMap.get(RESOURCE_KEY) == null) {
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM, null);
-
- if (!attributes.containsKey(HTML.TYPE_ATTR)) {
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- }
-
- for (Map.Entry<String, Object> entry : attributes.entrySet()) {
- writer.writeAttribute(entry.getKey(), entry.getValue(), null);
- }
-
- writer.writeText("window.RICH_FACES_EXTENDED_SKINNING_ON=true;", null);
-
- writer.endElement(HTML.SCRIPT_ELEM);
-
- requestMap.put(RESOURCE_KEY, Boolean.TRUE);
- }
- }
- };
-
- public void setScriptStrategy(String scriptsStrategy) {
- this.scriptStrategy = scriptsStrategy;
- }
-
- public void setStyleStrategy(String stylesStrategy) {
- this.styleStrategy = stylesStrategy;
- }
-
- public void setUseStdControlsSkinning(boolean stdControlsSkinning) {
- this.useStdControlsSkinning = stdControlsSkinning;
- }
-
- public void setUseStdControlsSkinningClasses(boolean stdControlsSkinningClasses) {
- this.useStdControlsSkinningClasses = stdControlsSkinningClasses;
- }
-
- public void setExtendedSkinningAllowed(boolean extendedSkinningAllowed) {
- this.extendedSkinningAllowed = extendedSkinningAllowed;
- }
-
- private static String SCRIPT = HTML.SCRIPT_ELEM;
- private static String SCRIPT_UC = SCRIPT.toUpperCase(Locale.US);
-
- private static String SRC = HTML.src_ATTRIBUTE;
- private static String SRC_UC = SRC.toUpperCase(Locale.US);
-
- private void mergeHeadResourceNode(List<Node> nodes, Set<String> renderedScripts, Node node) {
- boolean shouldAdd = true;
-
- String nodeName = node.getNodeName();
- if (SCRIPT.equals(nodeName) || SCRIPT_UC.equals(nodeName)) {
- if (node.getFirstChild() == null) {
- //no text content etc.
-
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- Node item = attributes.getNamedItem(SRC);
- if (item == null) {
- attributes.getNamedItem(SRC_UC);
- }
-
- if (item != null) {
- String src = item.getNodeValue();
- if (src != null) {
- if (renderedScripts.contains(src)) {
- shouldAdd = false;
- } else {
- renderedScripts.add(src);
- }
- }
- }
- }
- }
- }
-
- if (shouldAdd) {
- nodes.add(node);
- }
- }
-
- private Node[] mergeHeadResourceNodes() {
- List<Node> result = new ArrayList<Node>();
-
- Set<String> scripts = new HashSet<String>();
-
- for (Node node : componentWriter.getNodes()) {
- mergeHeadResourceNode(result, scripts, node);
- }
-
- for (Node node : userWriter.getNodes()) {
- mergeHeadResourceNode(result, scripts, node);
- }
-
- return result.toArray(new Node[result.size()]);
- }
-
- public Node[] getHeadEvents() {
- if (headNodes == null) {
- headNodes = mergeHeadResourceNodes();
- }
-
- return headNodes;
- }
-
- private static final Log log = LogFactory.getLog(ViewResources.class);
-
- //todo
-
- private static final Map<String, Object> EXTENDED_SKINNING = new HashMap<String, Object>(1);
-
- static {
- EXTENDED_SKINNING.put(HTML.media_ATTRIBUTE, "rich-extended-skinning");
- }
-
- public static final String SKINNING_STYLES_PATH = "/org/richfaces/renderkit/html/css/";
-
- public static final String QUEUE_SCRIPT_RESOURCE = "org.ajax4jsf.renderkit.html.scripts.QueueScript";
-
- private boolean extendedSkinningAllowed;
-
- private boolean processScripts;
-
- private boolean processStyles;
-
- private boolean useSkinning;
-
- private InternetResourceBuilder resourceBuilder;
-
- private boolean ajaxRequest;
-
- public static final String COMPONENT_RESOURCE_LINK_CLASS = "component";
-
- public static final String USER_RESOURCE_LINK_CLASS = "user";
-
- class HeadResponseWriter extends SAXResponseWriter {
-
- public Node[] getNodes() {
- return ((ResponseWriterContentHandler) getXmlConsumer()).getNodes();
- }
-
- public HeadResponseWriter(String linkClass) {
- super(new ResponseWriterContentHandler(linkClass));
-
- }
- }
-
- private void encodeResources(FacesContext context, ResourceRenderer renderer, Set<String> set) throws IOException {
-
- if (set != null) {
- URIInternetResource resourceImpl = new URIInternetResource();
-
- for (String uri : set) {
- resourceImpl.setUri(uri);
- renderer.encode(resourceImpl, context, null);
- }
- }
- }
-
- private boolean encodeSkinningResources(FacesContext context, InternetResourceBuilder resourceBuilder) throws IOException, FacesException {
- String resourceSuffix = null;
-
- if (useStdControlsSkinning) {
- if (useStdControlsSkinningClasses) {
- resourceSuffix = "_both.xcss";
- } else {
- resourceSuffix = ".xcss";
- }
- } else {
- if (useStdControlsSkinningClasses) {
- resourceSuffix = "_classes.xcss";
- } else {
- //no resources
- }
- }
-
- if (resourceSuffix != null) {
- resourceBuilder.createResource(
- this, SKINNING_STYLES_PATH.concat("basic").concat(resourceSuffix)).encode(context, null);
-
- if (extendedSkinningAllowed) {
- resourceBuilder.createResource(
- this, SKINNING_STYLES_PATH.concat("extended").concat(resourceSuffix)).encode(context, null, EXTENDED_SKINNING);
- }
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Find renderer for given component.
- *
- * @param context
- * @param comp
- * @param renderKit
- * @return
- */
- private Renderer getRenderer(FacesContext context, UIComponent comp) {
-
- String rendererType = comp.getRendererType();
- if (rendererType != null) {
- return (renderKit.getRenderer(comp.getFamily(), rendererType));
- } else {
- return (null);
- }
- }
-
- public void processHeadResources(FacesContext context) throws FacesException {
-
- RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- renderKit = rkFactory.getRenderKit(context, context
- .getViewRoot().getRenderKitId());
-
- boolean scriptsOff = false;
-
- processStyles = true;
- processScripts = true;
- useSkinning = false;
-
- ajaxRequest = AjaxContext.getCurrentInstance(context).isAjaxRequest(context);
-
- if (log.isDebugEnabled()) {
- log
- .debug("Process component tree for collect used scripts and styles");
- }
-
- String skinStyleSheetUri = null;
- String skinExtendedStyleSheetUri = null;
-
- Skin skin = null;
- try {
- skin = SkinFactory.getInstance().getSkin(context);
- // For a "NULL" skin, do not collect components stylesheets
- if ("false".equals(skin.getParameter(context,
- Skin.loadStyleSheets))) {
- processStyles = false;
- }
- // Set default style sheet for current skin.
- skinStyleSheetUri = (String) skin.getParameter(context,
- Skin.generalStyleSheet);
- // Set default style sheet for current skin.
- skinExtendedStyleSheetUri = (String) skin.getParameter(context,
- Skin.extendedStyleSheet);
- } catch (SkinNotFoundException e) {
- if (log.isWarnEnabled()) {
- log.warn("Current Skin is not found", e);
- }
- }
-
- resourceBuilder = InternetResourceBuilder.getInstance();
-
- ResponseWriter oldResponseWriter = context.getResponseWriter();
-
- componentWriter = new HeadResponseWriter("component");
- userWriter = new HeadResponseWriter("user");
-
- try {
- componentWriter.startDocument();
- userWriter.startDocument();
-
- context.setResponseWriter(componentWriter);
-
- // Check init parameters for a resources processing.
- if (null != scriptStrategy) {
- if (InternetResourceBuilder.LOAD_NONE
- .equals(scriptStrategy)) {
- scriptsOff = true;
- processScripts = false;
- } else if (InternetResourceBuilder.LOAD_ALL
- .equals(scriptStrategy)) {
- processScripts = false;
- // For an "ALL" strategy, it is not necessary to load scripts in the ajax request
- if (!ajaxRequest) {
- try {
- resourceBuilder
- .createResource(
- this,
- InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT).encode(context, null);
- resourceBuilder
- .createResource(
- this,
- InternetResourceBuilder.COMMON_UI_SCRIPT).encode(context, null);
-
- } catch (ResourceNotFoundException e) {
- if (log.isWarnEnabled()) {
- log
- .warn("No aggregated javaScript library found "
- + e.getMessage());
- }
- }
-
- }
- }
- }
-
- if (InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
- processStyles = false;
- } else if (InternetResourceBuilder.LOAD_ALL
- .equals(styleStrategy)) {
- processStyles = false;
- // For an "ALL" strategy, it is not necessary to load styles
- // in the ajax request
- if (!ajaxRequest) {
-
- try {
- useSkinning = encodeSkinningResources(context, resourceBuilder);
-
- resourceBuilder
- .createResource(this, InternetResourceBuilder.COMMON_STYLE).encode(context, null);
-
- } catch (ResourceNotFoundException e) {
- if (log.isWarnEnabled()) {
- log.warn("No stylesheet found "
- + e.getMessage());
- }
- }
-
- }
- } else {
- useSkinning = encodeSkinningResources(context, resourceBuilder);
- }
-
- //traverse components
- //traverse(context, context.getViewRoot());
-
- context.setResponseWriter(componentWriter);
-
- QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
- if (Boolean.valueOf(getInitParameterValue(context, "org.richfaces.queue.global.enabled"))) {
- queueRegistry.setShouldCreateDefaultGlobalQueue();
- }
-
- if (queueRegistry.hasQueuesToEncode()) {
- InternetResource queueScriptResource = resourceBuilder.getResource(QUEUE_SCRIPT_RESOURCE);
- queueScriptResource.encode(context, null);
- }
-
- // Append Skin StyleSheet after a
- if (null != skinStyleSheetUri) {
- String resourceURL = context.getApplication()
- .getViewHandler().getResourceURL(context,
- skinStyleSheetUri);
-
- URIInternetResource resourceImpl = new URIInternetResource();
- resourceImpl.setUri(resourceURL);
- resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
- resourceImpl.encode(context, null);
-
- useSkinning = true;
- }
-
- if (null != skinExtendedStyleSheetUri && extendedSkinningAllowed) {
- String resourceURL = context.getApplication().getViewHandler().getResourceURL(context,
- skinExtendedStyleSheetUri);
-
- URIInternetResource resourceImpl = new URIInternetResource();
- resourceImpl.setUri(resourceURL);
- resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
- resourceImpl.encode(context, null, EXTENDED_SKINNING);
-
- useSkinning = true;
- }
-
- if (useSkinning && extendedSkinningAllowed) {
- if (!ajaxRequest) {
- if (!scriptsOff) {
- //skinning levels aren't dynamic, page-level setting cannot be changed
- //by AJAX request
- EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
- } else {
-
- Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
- if (applicationMap.get(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY) == null) {
- //do it once per application life - strategies can be changed dynamically
- ResponseWriter writer = context.getResponseWriter();
- try {
- StringWriter stringWriter = new StringWriter();
-
- if (oldResponseWriter != null) {
- context.setResponseWriter(oldResponseWriter.cloneWithWriter(stringWriter));
- } else {
- context.setResponseWriter(this.renderKit.createResponseWriter(
- stringWriter, "text/html",
- "US-ASCII"));
- }
-
-
- EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
-
- stringWriter.flush();
-
- if (log.isInfoEnabled()) {
- log.info("Extended skinning is on and NONE scripts loading strategy was detected. " +
- "Do not forget that one of " + InternetResourceBuilder.SKINNING_SCRIPT + " or " +
- InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT + " resources should be presented " +
- "on the page together with the following code: \n" + stringWriter.getBuffer().toString() +
- "\nfor extended level of skinning to work.");
- }
- } finally {
- if (writer != null) {
- context.setResponseWriter(writer);
- }
- }
-
- applicationMap.put(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY, Boolean.TRUE);
- }
- }
- }
-
- if (processScripts) {
- InternetResource resource = resourceBuilder.createResource(null,
- InternetResourceBuilder.SKINNING_SCRIPT);
-
- resource.encode(context, null);
- }
- }
-
- componentWriter.endDocument();
- userWriter.endDocument();
- } catch (IOException e) {
- throw new FacesException(e.getLocalizedMessage(), e);
- } finally {
- if (oldResponseWriter != null) {
- context.setResponseWriter(oldResponseWriter);
- }
- }
- }
-
- private static String getInitParameterValue(FacesContext context, String parameterName) {
-
- String key = INIT_PARAMETER_PREFIX + parameterName;
-
- ExternalContext externalContext = context.getExternalContext();
- Map<String, Object> applicationMap = externalContext.getApplicationMap();
- Object mutex = externalContext.getRequest();
- Object parameterValue = null;
-
- synchronized (mutex) {
- parameterValue = applicationMap.get(key);
-
- if (parameterValue == null) {
-
- String initParameter = externalContext.getInitParameter(parameterName);
- if (initParameter != null) {
-
- if (ELUtils.isValueReference(initParameter)) {
- Application application = context.getApplication();
- ExpressionFactory expressionFactory = application.getExpressionFactory();
-
- parameterValue = expressionFactory.createValueExpression(context.getELContext(),
- initParameter,
- String.class);
- } else {
- parameterValue = initParameter;
- }
-
- } else {
- parameterValue = NULL;
- }
-
- applicationMap.put(key, parameterValue);
- }
- }
-
- return evaluate(context, parameterValue);
- }
-
- private static String evaluate(FacesContext context, Object parameterValue) {
- if (parameterValue == NULL || parameterValue == null) {
- return null;
- } else if (parameterValue instanceof ValueExpression) {
- ValueExpression expression = (ValueExpression) parameterValue;
-
- return (String) expression.getValue(context.getELContext());
- } else {
- return parameterValue.toString();
- }
- }
-
- public void initialize(FacesContext context) {
- boolean extendedSkinningAllowed = true;
- String skinningLevel = getInitParameterValue(context, InternetResourceBuilder.CONTROL_SKINNING_LEVEL);
- if (skinningLevel != null && skinningLevel.length() > 0) {
- if (InternetResourceBuilder.BASIC.equals(skinningLevel)) {
- extendedSkinningAllowed = false;
- } else if (!InternetResourceBuilder.EXTENDED.equals(skinningLevel)) {
- throw new IllegalArgumentException("Value: " + skinningLevel +
- " of " + InternetResourceBuilder.CONTROL_SKINNING_LEVEL
- + " init parameter is invalid! Only " + InternetResourceBuilder.EXTENDED
- + ", " + InternetResourceBuilder.BASIC + " can be used");
- }
- }
-
- this.setExtendedSkinningAllowed(extendedSkinningAllowed);
-
- this.setScriptStrategy(getInitParameterValue(context,
- InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM));
-
- boolean useStdControlsSkinning = false;
-
- String stdControlsSkinning = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
- if (stdControlsSkinning != null) {
- useStdControlsSkinning = InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
- }
-
- this.setUseStdControlsSkinning(useStdControlsSkinning);
-
- boolean useStdControlsSkinningClasses = true;
-
- String stdControlsSkinningClasses = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
- if (stdControlsSkinningClasses != null) {
- useStdControlsSkinningClasses = InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
- }
-
- this.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
-
- this.setStyleStrategy(getInitParameterValue(context,
- InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM));
-
-
- }
-
+// private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
+// private static final Object NULL = new Object();
+//
+// private String scriptStrategy;
+//
+// private String styleStrategy;
+//
+// private boolean useStdControlsSkinning;
+//
+// private boolean useStdControlsSkinningClasses;
+//
+// private HeadResponseWriter componentWriter;
+//
+// private HeadResponseWriter userWriter;
+//
+// private RenderKit renderKit;
+//
+// private Node[] headNodes = null;
+//
+// private static final String EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY = ViewResources.class.getName() + "EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY";
+//
+// private static final InternetResource EXTENDED_SKINNING_ON_RESOURCE = new InternetResourceBase() {
+//
+// private final String RESOURCE_KEY = this.getClass().getName();
+//
+// @Override
+// public void encode(FacesContext context, Object data)
+// throws IOException {
+//
+// encode(context, data, Collections.EMPTY_MAP);
+// }
+//
+// @Override
+// public void encode(FacesContext context, Object data,
+// Map<String, Object> attributes) throws IOException {
+//
+// Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+// if (requestMap.get(RESOURCE_KEY) == null) {
+// ResponseWriter writer = context.getResponseWriter();
+// writer.startElement(HTML.SCRIPT_ELEM, null);
+//
+// if (!attributes.containsKey(HTML.TYPE_ATTR)) {
+// writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+// }
+//
+// for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+// writer.writeAttribute(entry.getKey(), entry.getValue(), null);
+// }
+//
+// writer.writeText("window.RICH_FACES_EXTENDED_SKINNING_ON=true;", null);
+//
+// writer.endElement(HTML.SCRIPT_ELEM);
+//
+// requestMap.put(RESOURCE_KEY, Boolean.TRUE);
+// }
+// }
+// };
+//
+// public void setScriptStrategy(String scriptsStrategy) {
+// this.scriptStrategy = scriptsStrategy;
+// }
+//
+// public void setStyleStrategy(String stylesStrategy) {
+// this.styleStrategy = stylesStrategy;
+// }
+//
+// public void setUseStdControlsSkinning(boolean stdControlsSkinning) {
+// this.useStdControlsSkinning = stdControlsSkinning;
+// }
+//
+// public void setUseStdControlsSkinningClasses(boolean stdControlsSkinningClasses) {
+// this.useStdControlsSkinningClasses = stdControlsSkinningClasses;
+// }
+//
+// public void setExtendedSkinningAllowed(boolean extendedSkinningAllowed) {
+// this.extendedSkinningAllowed = extendedSkinningAllowed;
+// }
+//
+// private static String SCRIPT = HTML.SCRIPT_ELEM;
+// private static String SCRIPT_UC = SCRIPT.toUpperCase(Locale.US);
+//
+// private static String SRC = HTML.src_ATTRIBUTE;
+// private static String SRC_UC = SRC.toUpperCase(Locale.US);
+//
+// private void mergeHeadResourceNode(List<Node> nodes, Set<String> renderedScripts, Node node) {
+// boolean shouldAdd = true;
+//
+// String nodeName = node.getNodeName();
+// if (SCRIPT.equals(nodeName) || SCRIPT_UC.equals(nodeName)) {
+// if (node.getFirstChild() == null) {
+// //no text content etc.
+//
+// NamedNodeMap attributes = node.getAttributes();
+// if (attributes != null) {
+// Node item = attributes.getNamedItem(SRC);
+// if (item == null) {
+// attributes.getNamedItem(SRC_UC);
+// }
+//
+// if (item != null) {
+// String src = item.getNodeValue();
+// if (src != null) {
+// if (renderedScripts.contains(src)) {
+// shouldAdd = false;
+// } else {
+// renderedScripts.add(src);
+// }
+// }
+// }
+// }
+// }
+// }
+//
+// if (shouldAdd) {
+// nodes.add(node);
+// }
+// }
+//
+// private Node[] mergeHeadResourceNodes() {
+// List<Node> result = new ArrayList<Node>();
+//
+// Set<String> scripts = new HashSet<String>();
+//
+// for (Node node : componentWriter.getNodes()) {
+// mergeHeadResourceNode(result, scripts, node);
+// }
+//
+// for (Node node : userWriter.getNodes()) {
+// mergeHeadResourceNode(result, scripts, node);
+// }
+//
+// return result.toArray(new Node[result.size()]);
+// }
+//
+// public Node[] getHeadEvents() {
+// if (headNodes == null) {
+// headNodes = mergeHeadResourceNodes();
+// }
+//
+// return headNodes;
+// }
+//
+// private static final Log log = LogFactory.getLog(ViewResources.class);
+//
+// //todo
+//
+// private static final Map<String, Object> EXTENDED_SKINNING = new HashMap<String, Object>(1);
+//
+// static {
+// EXTENDED_SKINNING.put(HTML.media_ATTRIBUTE, "rich-extended-skinning");
+// }
+//
+// public static final String SKINNING_STYLES_PATH = "/org/richfaces/renderkit/html/css/";
+//
+// public static final String QUEUE_SCRIPT_RESOURCE = "org.ajax4jsf.renderkit.html.scripts.QueueScript";
+//
+// private boolean extendedSkinningAllowed;
+//
+// private boolean processScripts;
+//
+// private boolean processStyles;
+//
+// private boolean useSkinning;
+//
+// private InternetResourceBuilder resourceBuilder;
+//
+// private boolean ajaxRequest;
+//
+// public static final String COMPONENT_RESOURCE_LINK_CLASS = "component";
+//
+// public static final String USER_RESOURCE_LINK_CLASS = "user";
+//
+// class HeadResponseWriter extends SAXResponseWriter {
+//
+// public Node[] getNodes() {
+// return ((ResponseWriterContentHandler) getXmlConsumer()).getNodes();
+// }
+//
+// public HeadResponseWriter(String linkClass) {
+// super(new ResponseWriterContentHandler(linkClass));
+//
+// }
+// }
+//
+// private void encodeResources(FacesContext context, ResourceRenderer renderer, Set<String> set) throws IOException {
+//
+// if (set != null) {
+// URIInternetResource resourceImpl = new URIInternetResource();
+//
+// for (String uri : set) {
+// resourceImpl.setUri(uri);
+// renderer.encode(resourceImpl, context, null);
+// }
+// }
+// }
+//
+// private boolean encodeSkinningResources(FacesContext context, InternetResourceBuilder resourceBuilder) throws IOException, FacesException {
+// String resourceSuffix = null;
+//
+// if (useStdControlsSkinning) {
+// if (useStdControlsSkinningClasses) {
+// resourceSuffix = "_both.xcss";
+// } else {
+// resourceSuffix = ".xcss";
+// }
+// } else {
+// if (useStdControlsSkinningClasses) {
+// resourceSuffix = "_classes.xcss";
+// } else {
+// //no resources
+// }
+// }
+//
+// if (resourceSuffix != null) {
+// resourceBuilder.createResource(
+// this, SKINNING_STYLES_PATH.concat("basic").concat(resourceSuffix)).encode(context, null);
+//
+// if (extendedSkinningAllowed) {
+// resourceBuilder.createResource(
+// this, SKINNING_STYLES_PATH.concat("extended").concat(resourceSuffix)).encode(context, null, EXTENDED_SKINNING);
+// }
+//
+// return true;
+// }
+//
+// return false;
+// }
+//
+// /**
+// * Find renderer for given component.
+// *
+// * @param context
+// * @param comp
+// * @param renderKit
+// * @return
+// */
+// private Renderer getRenderer(FacesContext context, UIComponent comp) {
+//
+// String rendererType = comp.getRendererType();
+// if (rendererType != null) {
+// return (renderKit.getRenderer(comp.getFamily(), rendererType));
+// } else {
+// return (null);
+// }
+// }
+//
+// public void processHeadResources(FacesContext context) throws FacesException {
+//
+// RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+// .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+// renderKit = rkFactory.getRenderKit(context, context
+// .getViewRoot().getRenderKitId());
+//
+// boolean scriptsOff = false;
+//
+// processStyles = true;
+// processScripts = true;
+// useSkinning = false;
+//
+// ajaxRequest = AjaxContext.getCurrentInstance(context).isAjaxRequest(context);
+//
+// if (log.isDebugEnabled()) {
+// log
+// .debug("Process component tree for collect used scripts and styles");
+// }
+//
+// String skinStyleSheetUri = null;
+// String skinExtendedStyleSheetUri = null;
+//
+// Skin skin = null;
+// try {
+// skin = SkinFactory.getInstance().getSkin(context);
+// // For a "NULL" skin, do not collect components stylesheets
+// if ("false".equals(skin.getParameter(context,
+// Skin.loadStyleSheets))) {
+// processStyles = false;
+// }
+// // Set default style sheet for current skin.
+// skinStyleSheetUri = (String) skin.getParameter(context,
+// Skin.generalStyleSheet);
+// // Set default style sheet for current skin.
+// skinExtendedStyleSheetUri = (String) skin.getParameter(context,
+// Skin.extendedStyleSheet);
+// } catch (SkinNotFoundException e) {
+// if (log.isWarnEnabled()) {
+// log.warn("Current Skin is not found", e);
+// }
+// }
+//
+// resourceBuilder = InternetResourceBuilder.getInstance();
+//
+// ResponseWriter oldResponseWriter = context.getResponseWriter();
+//
+// componentWriter = new HeadResponseWriter("component");
+// userWriter = new HeadResponseWriter("user");
+//
+// try {
+// componentWriter.startDocument();
+// userWriter.startDocument();
+//
+// context.setResponseWriter(componentWriter);
+//
+// // Check init parameters for a resources processing.
+// if (null != scriptStrategy) {
+// if (InternetResourceBuilder.LOAD_NONE
+// .equals(scriptStrategy)) {
+// scriptsOff = true;
+// processScripts = false;
+// } else if (InternetResourceBuilder.LOAD_ALL
+// .equals(scriptStrategy)) {
+// processScripts = false;
+// // For an "ALL" strategy, it is not necessary to load scripts in the ajax request
+// if (!ajaxRequest) {
+// try {
+// resourceBuilder
+// .createResource(
+// this,
+// InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT).encode(context, null);
+// resourceBuilder
+// .createResource(
+// this,
+// InternetResourceBuilder.COMMON_UI_SCRIPT).encode(context, null);
+//
+// } catch (ResourceNotFoundException e) {
+// if (log.isWarnEnabled()) {
+// log
+// .warn("No aggregated javaScript library found "
+// + e.getMessage());
+// }
+// }
+//
+// }
+// }
+// }
+//
+// if (InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
+// processStyles = false;
+// } else if (InternetResourceBuilder.LOAD_ALL
+// .equals(styleStrategy)) {
+// processStyles = false;
+// // For an "ALL" strategy, it is not necessary to load styles
+// // in the ajax request
+// if (!ajaxRequest) {
+//
+// try {
+// useSkinning = encodeSkinningResources(context, resourceBuilder);
+//
+// resourceBuilder
+// .createResource(this, InternetResourceBuilder.COMMON_STYLE).encode(context, null);
+//
+// } catch (ResourceNotFoundException e) {
+// if (log.isWarnEnabled()) {
+// log.warn("No stylesheet found "
+// + e.getMessage());
+// }
+// }
+//
+// }
+// } else {
+// useSkinning = encodeSkinningResources(context, resourceBuilder);
+// }
+//
+// //traverse components
+// //traverse(context, context.getViewRoot());
+//
+// context.setResponseWriter(componentWriter);
+//
+// QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
+// if (Boolean.valueOf(getInitParameterValue(context, "org.richfaces.queue.global.enabled"))) {
+// queueRegistry.setShouldCreateDefaultGlobalQueue();
+// }
+//
+// if (queueRegistry.hasQueuesToEncode()) {
+// InternetResource queueScriptResource = resourceBuilder.getResource(QUEUE_SCRIPT_RESOURCE);
+// queueScriptResource.encode(context, null);
+// }
+//
+// // Append Skin StyleSheet after a
+// if (null != skinStyleSheetUri) {
+// String resourceURL = context.getApplication()
+// .getViewHandler().getResourceURL(context,
+// skinStyleSheetUri);
+//
+// URIInternetResource resourceImpl = new URIInternetResource();
+// resourceImpl.setUri(resourceURL);
+// resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
+// resourceImpl.encode(context, null);
+//
+// useSkinning = true;
+// }
+//
+// if (null != skinExtendedStyleSheetUri && extendedSkinningAllowed) {
+// String resourceURL = context.getApplication().getViewHandler().getResourceURL(context,
+// skinExtendedStyleSheetUri);
+//
+// URIInternetResource resourceImpl = new URIInternetResource();
+// resourceImpl.setUri(resourceURL);
+// resourceImpl.setRenderer(resourceBuilder.getStyleRenderer());
+// resourceImpl.encode(context, null, EXTENDED_SKINNING);
+//
+// useSkinning = true;
+// }
+//
+// if (useSkinning && extendedSkinningAllowed) {
+// if (!ajaxRequest) {
+// if (!scriptsOff) {
+// //skinning levels aren't dynamic, page-level setting cannot be changed
+// //by AJAX request
+// EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
+// } else {
+//
+// Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
+// if (applicationMap.get(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY) == null) {
+// //do it once per application life - strategies can be changed dynamically
+// ResponseWriter writer = context.getResponseWriter();
+// try {
+// StringWriter stringWriter = new StringWriter();
+//
+// if (oldResponseWriter != null) {
+// context.setResponseWriter(oldResponseWriter.cloneWithWriter(stringWriter));
+// } else {
+// context.setResponseWriter(this.renderKit.createResponseWriter(
+// stringWriter, "text/html",
+// "US-ASCII"));
+// }
+//
+//
+// EXTENDED_SKINNING_ON_RESOURCE.encode(context, null);
+//
+// stringWriter.flush();
+//
+// if (log.isInfoEnabled()) {
+// log.info("Extended skinning is on and NONE scripts loading strategy was detected. " +
+// "Do not forget that one of " + InternetResourceBuilder.SKINNING_SCRIPT + " or " +
+// InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT + " resources should be presented " +
+// "on the page together with the following code: \n" + stringWriter.getBuffer().toString() +
+// "\nfor extended level of skinning to work.");
+// }
+// } finally {
+// if (writer != null) {
+// context.setResponseWriter(writer);
+// }
+// }
+//
+// applicationMap.put(EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY, Boolean.TRUE);
+// }
+// }
+// }
+//
+// if (processScripts) {
+// InternetResource resource = resourceBuilder.createResource(null,
+// InternetResourceBuilder.SKINNING_SCRIPT);
+//
+// resource.encode(context, null);
+// }
+// }
+//
+// componentWriter.endDocument();
+// userWriter.endDocument();
+// } catch (IOException e) {
+// throw new FacesException(e.getLocalizedMessage(), e);
+// } finally {
+// if (oldResponseWriter != null) {
+// context.setResponseWriter(oldResponseWriter);
+// }
+// }
+// }
+//
+// private static String getInitParameterValue(FacesContext context, String parameterName) {
+//
+// String key = INIT_PARAMETER_PREFIX + parameterName;
+//
+// ExternalContext externalContext = context.getExternalContext();
+// Map<String, Object> applicationMap = externalContext.getApplicationMap();
+// Object mutex = externalContext.getRequest();
+// Object parameterValue = null;
+//
+// synchronized (mutex) {
+// parameterValue = applicationMap.get(key);
+//
+// if (parameterValue == null) {
+//
+// String initParameter = externalContext.getInitParameter(parameterName);
+// if (initParameter != null) {
+//
+// if (ELUtils.isValueReference(initParameter)) {
+// Application application = context.getApplication();
+// ExpressionFactory expressionFactory = application.getExpressionFactory();
+//
+// parameterValue = expressionFactory.createValueExpression(context.getELContext(),
+// initParameter,
+// String.class);
+// } else {
+// parameterValue = initParameter;
+// }
+//
+// } else {
+// parameterValue = NULL;
+// }
+//
+// applicationMap.put(key, parameterValue);
+// }
+// }
+//
+// return evaluate(context, parameterValue);
+// }
+//
+// private static String evaluate(FacesContext context, Object parameterValue) {
+// if (parameterValue == NULL || parameterValue == null) {
+// return null;
+// } else if (parameterValue instanceof ValueExpression) {
+// ValueExpression expression = (ValueExpression) parameterValue;
+//
+// return (String) expression.getValue(context.getELContext());
+// } else {
+// return parameterValue.toString();
+// }
+// }
+//
+// public void initialize(FacesContext context) {
+// boolean extendedSkinningAllowed = true;
+// String skinningLevel = getInitParameterValue(context, InternetResourceBuilder.CONTROL_SKINNING_LEVEL);
+// if (skinningLevel != null && skinningLevel.length() > 0) {
+// if (InternetResourceBuilder.BASIC.equals(skinningLevel)) {
+// extendedSkinningAllowed = false;
+// } else if (!InternetResourceBuilder.EXTENDED.equals(skinningLevel)) {
+// throw new IllegalArgumentException("Value: " + skinningLevel +
+// " of " + InternetResourceBuilder.CONTROL_SKINNING_LEVEL
+// + " init parameter is invalid! Only " + InternetResourceBuilder.EXTENDED
+// + ", " + InternetResourceBuilder.BASIC + " can be used");
+// }
+// }
+//
+// this.setExtendedSkinningAllowed(extendedSkinningAllowed);
+//
+// this.setScriptStrategy(getInitParameterValue(context,
+// InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM));
+//
+// boolean useStdControlsSkinning = false;
+//
+// String stdControlsSkinning = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
+// if (stdControlsSkinning != null) {
+// useStdControlsSkinning = InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
+// }
+//
+// this.setUseStdControlsSkinning(useStdControlsSkinning);
+//
+// boolean useStdControlsSkinningClasses = true;
+//
+// String stdControlsSkinningClasses = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
+// if (stdControlsSkinningClasses != null) {
+// useStdControlsSkinningClasses = InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
+// }
+//
+// this.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
+//
+// this.setStyleStrategy(getInitParameterValue(context,
+// InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM));
+//
+//
+// }
+//
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -23,7 +23,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.Date;
import java.util.Map;
import java.util.Properties;
@@ -46,7 +45,6 @@
import org.ajax4jsf.cache.ServletContextInitMap;
import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.ajax4jsf.webapp.BaseFilter;
-import org.ajax4jsf.webapp.CacheContent;
import org.ajax4jsf.webapp.WebXml;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -74,8 +72,6 @@
private ResourceLifecycle lifecycle;
- private InternetResourceBuilder resourceBuilder;
-
private WebXml webXml;
public InternetResourceService() {
@@ -125,7 +121,7 @@
}
}
- public boolean serviceResource(HttpServletRequest httpServletRequest,
+ /*public boolean serviceResource(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws ServletException,
IOException {
String resourceKey = webXml.getFacesResourceKey(httpServletRequest);
@@ -135,9 +131,9 @@
return true;
}
return false;
- }
+ }*/
- public void serviceResource(String resourceKey, HttpServletRequest request,
+ /*public void serviceResource(String resourceKey, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
InternetResource resource;// getInternetResource(request);
try {
@@ -240,7 +236,7 @@
} finally {
resourceContext.release();
}
- }
+ }*/
/**
* @param resource
@@ -326,15 +322,4 @@
request, response, getLifecycle());
}
- /**
- * @return the resourceBuilder
- */
- protected InternetResourceBuilder getResourceBuilder() {
- if (resourceBuilder == null) {
- // Create resource builder for this filter.
- resourceBuilder = InternetResourceBuilder.getInstance();
- }
- return resourceBuilder;
- }
-
}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -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.ajax4jsf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.nio.ByteBuffer;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-
-import org.ajax4jsf.css.CssCompressor;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.compiler.HtmlCompiler;
-import org.ajax4jsf.renderkit.compiler.PreparedTemplate;
-import org.ajax4jsf.renderkit.compiler.TemplateContext;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author shura
- *
- */
-public class TemplateCSSRenderer extends StyleRenderer {
-
- private static final String COMPILED_TEMPLATE_PROPERTY = "compiled-template";
-
- /** Parameter allows switch on/off comressing for css */
- private static final String COMPRESS_STYLE_PARAMETER = "org.ajax4jsf.COMPRESS_STYLE";
-
- private RendererBase renderer = new RendererBase() {
-
- protected Class<? extends UIComponent> getComponentClass() {
- // TODO Auto-generated method stub
- return UIComponent.class;
- }
-
- };
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource, org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context) throws IOException {
- PreparedTemplate template = null;
- CountingOutputWriter countingOutputWriter = new CountingOutputWriter();
- template = getTemplate(base, context);
- FacesContext facesContext = FacesContext.getCurrentInstance();
- boolean _CompressStyleOn = !"false".equals(facesContext.getExternalContext()
- .getInitParameter(COMPRESS_STYLE_PARAMETER));
- Writer writer = context.getWriter();
- int bytesLength;
- if(null != facesContext) {
- // Create responseWriter.
- String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
- if (null == defaultRenderKitId) {
- defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
- // TODO - handle response encoding
-
- ResponseWriter responseWriter = renderKit.createResponseWriter(countingOutputWriter,null,"UTF-8");
- facesContext.setResponseWriter(responseWriter);
- responseWriter.startDocument();
-
- // TODO - parameters and mock renderer/component ?
- // for first time, this template only allow skin or faces variables interaction
- template.encode(renderer,facesContext,null);
- responseWriter.endDocument();
- responseWriter.flush();
- responseWriter.close();
-
- if (_CompressStyleOn) {
- CssCompressor compressor = new CssCompressor(countingOutputWriter.getContent()); // Compressing css document and printing result in response stream
- bytesLength = compressor.compress(writer, -1);
- writer.flush();
- writer.close();
- } else {
- writer.write(countingOutputWriter.getContent().toString()); // Write not compressed style content
- bytesLength = countingOutputWriter.getWritten();
- writer.flush();
- writer.close();
- }
-
- } else {
- throw new FacesException("FacesContext for resource from template "+base.getKey()+" is null");
- }
- return bytesLength;
- }
-
- /**
- * @param base
- * @param context
- * @return
- * @throws IOException
- */
- public synchronized PreparedTemplate getTemplate(InternetResource base,
- ResourceContext context) throws IOException {
- PreparedTemplate template;
- // if(base.isCacheable()){
- template = (PreparedTemplate) base
- .getProperty(COMPILED_TEMPLATE_PROPERTY);
- // }
- if (null == template) {
- HtmlCompiler compiler = new HtmlCompiler();
- InputStream resourceAsStream = base.getResourceAsStream(context);
- if (null != resourceAsStream) {
- template = compiler.compile(resourceAsStream, base.getKey());
- base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
- resourceAsStream.close();
- } else {
- throw new IOException("CSS Template "+base.getKey()+" not found");
- }
- }
- return template;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#requireFacesContext()
- */
- public boolean requireFacesContext() {
- return true;
- }
-
- public Object getData(InternetResource base, FacesContext context, Object data) {
- ResourceContext resourceContext = new FacesResourceContext(context);
- PreparedTemplate template;
- try {
- template = getTemplate(base, resourceContext);
- } catch (IOException e) {
- return null;
- }
- UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
- TemplateContext templateContext = new TemplateContext(null,context,component);
- Object value = template.getValue(templateContext);
- if(null == value){
- SkinFactory skinFactory = SkinFactory.getInstance();
- int hashCode = skinFactory.getSkin(context).hashCode(context);
- int baseHashCode = skinFactory.getBaseSkin(context).hashCode(context);
- value = ByteBuffer.allocate(4*2).putInt(hashCode).putInt(baseHashCode).array();
- }
- return value;
- }
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -505,15 +505,15 @@
httpServletResponse.setContentLength(0);
} else
// check for resource request
- if (!getResourceService().serviceResource(httpServletRequest,
- httpServletResponse)) {
+ //if (!getResourceService().serviceResource(httpServletRequest,
+ // httpServletResponse)) {
// Not request to resource - perform filtering.
// first stage - detect/set encoding of request. Same as in
// Myfaces External Context.
setupRequestEncoding(httpServletRequest);
checkMyFacesExtensionsFilter(httpServletRequest);
processUploadsAndHandleRequest(httpServletRequest, httpServletResponse, chain);
- }
+ //}
} finally {
// Remove filter marker from response, to enable sequence calls ( for example, forward to error page )
request.removeAttribute(FILTER_PERFORMED);
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -40,12 +40,10 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.ContextInitParameters;
import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Node;
public abstract class BaseXMLFilter {
public static final String AJAX_EXPIRED = "Ajax-Expired";
@@ -204,8 +202,6 @@
}
String viewId = (String) request
.getAttribute(AjaxViewHandler.VIEW_ID_KEY);
- Node[] headEvents = (Node[]) request
- .getAttribute(AjaxContext.HEAD_EVENTS_PARAMETER);
HtmlParser parser = null;
// setup response
@@ -295,7 +291,7 @@
boolean forcenotrf = isForcenotrf();
if (forcenotrf || !servletResponseWrapper.isError()) {
- if (forcenotrf || (headEvents != null && headEvents.length != 0)) {
+ if (forcenotrf) {
if (contentTypeCharset != null) {
if (contentTypeCharset.indexOf("charset") < 0
&& null != characterEncoding) {
@@ -360,8 +356,6 @@
}
try {
- // Setup scripts and styles
- parser.setHeadNodes(headEvents);
// Process parsing.
long startTimeMills = System.currentTimeMillis();
servletResponseWrapper.parseContent(output, parser);
Modified: root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java 2009-07-24 08:56:25 UTC (rev 14998)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java 2009-07-24 09:02:57 UTC (rev 14999)
@@ -12,7 +12,6 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.resource.InternetResource;
import org.richfaces.test.AbstractFacesTest;
public class CompositeRendererTest extends AbstractFacesTest {
@@ -127,105 +126,6 @@
assertEquals("3", map.get("generic"));
}
- public final void testGetScripts() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
-
- inputContributor = new MockDecodeContributor(UIComponent.class, new String[] { "input_script" }, null);
- formContributor = new MockDecodeContributor(UIComponent.class, new String[] { "form_script" }, null);
- contributor = new MockDecodeContributor(UIComponent.class, null, null);
-
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
-
- InternetResource[] scripts = compositeRenderer.getScripts();
-
- assertEquals(2, scripts.length);
-
- assertTrue(scripts[0].getKey().contains("org/richfaces/renderkit/form_script"));
- assertTrue(scripts[1].getKey().contains("org/richfaces/renderkit/input_script"));
- }
-
- public final void testGetStyles() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
-
- inputContributor = new MockDecodeContributor(UIComponent.class, null, new String[] { "input_style" });
- formContributor = new MockDecodeContributor(UIComponent.class, null, new String[] { "form_style" });
- contributor = new MockDecodeContributor(UIComponent.class, null, null);
-
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(inputContributor);
- compositeRenderer.addContributor(formContributor);
-
- InternetResource[] scripts = compositeRenderer.getStyles();
-
- assertEquals(2, scripts.length);
-
- assertTrue(scripts[0].getKey().contains("org/richfaces/renderkit/input_style"));
- assertTrue(scripts[1].getKey().contains("org/richfaces/renderkit/form_style"));
- }
-
- public final void testGetScriptsClass() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
-
- inputContributor = new MockDecodeContributor(UIInput.class, new String[] { "input_script" }, null);
- formContributor = new MockDecodeContributor(NamingContainer.class, new String[] { "form_script" }, null);
- contributor = new MockDecodeContributor(UIComponent.class, null, null);
-
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
-
- InternetResource[] scripts = compositeRenderer.getScripts(UIInput.class);
-
- assertEquals(1, scripts.length);
-
- assertTrue(scripts[0].getKey().contains("org/richfaces/renderkit/input_script"));
-
- scripts = compositeRenderer.getScripts(NamingContainer.class);
-
- assertEquals(1, scripts.length);
-
- assertTrue(scripts[0].getKey().contains("org/richfaces/renderkit/form_script"));
-
- scripts = compositeRenderer.getStyles(String.class);
- assertNull(scripts);
- }
-
- public final void testGetStylesClass() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
-
- inputContributor = new MockDecodeContributor(UIInput.class, null, new String[] { "input_style" });
- formContributor = new MockDecodeContributor(NamingContainer.class, null, new String[] { "form_style" });
- contributor = new MockDecodeContributor(UIComponent.class, null, null);
-
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
-
- InternetResource[] styles = compositeRenderer.getStyles(UIInput.class);
-
- assertEquals(1, styles.length);
-
- assertTrue(styles[0].getKey().contains("org/richfaces/renderkit/input_style"));
-
- styles = compositeRenderer.getStyles(NamingContainer.class);
-
- assertEquals(1, styles.length);
- assertTrue(styles[0].getKey().contains("org/richfaces/renderkit/form_style"));
-
- styles = compositeRenderer.getStyles(String.class);
- assertNull(styles);
- }
-
public final void testGetScriptContributionsStringFacesContextUIComponent() {
MockDecodeContributor inputContributor;
MockDecodeContributor formContributor;
15 years, 3 months
JBoss Rich Faces SVN: r14998 - in root/framework/trunk: api/src/main/java/org/richfaces/component and 17 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-24 04:56:25 -0400 (Fri, 24 Jul 2009)
New Revision: 14998
Removed:
root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/InternetResourceBuilder.java
root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceProduser.java
root/framework/trunk/api/src/main/java/org/richfaces/component/ScriptExportable.java
root/framework/trunk/api/src/main/java/org/richfaces/event/AttributeHolder.java
root/framework/trunk/api/src/main/java/org/richfaces/event/AttributedEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/RenderPhaseComponentVisitor.java
root/framework/trunk/impl/src/main/java/META-INF/
root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/compiler/
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
root/framework/trunk/impl/src/main/java/org/richfaces/event/RenderPhaseComponentListener.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImage.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImageDisable.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxButtonPressGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/EditIcon.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SaveControlIcon.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonDown.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonImage.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonUp.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconDown.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconUp.java
root/framework/trunk/impl/src/main/java/org/richfaces/util/RenderPhaseComponentVisitorUtils.java
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/DebugOutputMaker.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/component/RenderPhaseUIDataAdaptorVisitor.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/ApplicationContext.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java
root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js
Log:
Moving component APIs into ui-sandbox
Legacy resources API removal
Gradients updated for new resources API
Deleted: root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/InternetResourceBuilder.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/InternetResourceBuilder.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/InternetResourceBuilder.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,210 +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.ajax4jsf.resource;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletException;
-
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class InternetResourceBuilder {
-
- private static final Log log = LogFactory.getLog(InternetResourceBuilder.class);
- public static final String LOAD_NONE = "NONE";
- public static final String LOAD_ALL = "ALL";
-
- public static final String SKINNING_SCRIPT = "/org/richfaces/renderkit/html/scripts/skinning.js";
-
- public static final String COMMON_FRAMEWORK_SCRIPT = "/org/ajax4jsf/framework.pack.js";
- public static final String COMMON_UI_SCRIPT = "/org/richfaces/ui.pack.js";
- public static final String COMMON_STYLE_PREFIX = "/org/richfaces/skin";
- public static final String COMMON_STYLE_EXTENSION = ".xcss";
- public static final String COMMON_STYLE = COMMON_STYLE_PREFIX + COMMON_STYLE_EXTENSION;
- public static final String LOAD_STYLE_STRATEGY_PARAM = "org.richfaces.LoadStyleStrategy";
- public static final String LOAD_SCRIPT_STRATEGY_PARAM = "org.richfaces.LoadScriptStrategy";
-
- public static final String STD_CONTROLS_SKINNING_PARAM = "org.richfaces.CONTROL_SKINNING";
- public static final String STD_CONTROLS_SKINNING_CLASSES_PARAM = "org.richfaces.CONTROL_SKINNING_CLASSES";
- public static final String ENABLE = "enable";
-
- public static final String CONTROL_SKINNING_LEVEL = "org.richfaces.CONTROL_SKINNING_LEVEL";
- public static final String BASIC = "basic";
- public static final String EXTENDED = "extended";
-
- /**
- * Get application start time for check resources modification time.
- *
- * @return application start time in msec's
- */
- public abstract long getStartTime();
-
- /**
- * @param cacheable
- * @param session
- * @param mime
- * @return
- * @throws FacesException
- */
- public abstract InternetResource createUserResource(boolean cacheable,
- boolean session, String mime) throws FacesException;
-
- /**
- * @param key
- * @param resource
- */
- public abstract void addResource(String key, InternetResource resource);
-
- /**
- * @param path
- * @return
- * @throws ResourceNotFoundException
- */
- public abstract InternetResource getResource(String path)
- throws ResourceNotFoundException;
-
- /**
- * @param key
- * @return
- */
- public abstract Object getResourceDataForKey(String key);
-
- /**
- * @param key
- * @return
- * @throws ResourceNotFoundException
- */
- public abstract InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException;
-
- /**
- * @param resource
- * @param context
- * @param storeData
- * @return
- */
- public abstract String getUri(InternetResource resource,
- FacesContext context, Object storeData);
-
- /**
- * @param base
- * @param path
- * @return
- * @throws FacesException
- */
- public abstract InternetResource createResource(Object base, String path)
- throws FacesException;
-
- /**
- * @throws ServletException
- */
- public abstract void init()
- throws FacesException;
-
- /**
- * static instance variable.
- */
- private static Map<ClassLoader, InternetResourceBuilder> instances =
- Collections.synchronizedMap(new HashMap<ClassLoader, InternetResourceBuilder> ());
-
- /**
- * Get ( or create if nessesary ) instance of builder for current
- * loader. check content of file
- * META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder
- * for name of class to instantiate, othrthise create
- * {@link ResourceBuilderImpl} instance.
- *
- * @return current builder instance.
- */
- public static InternetResourceBuilder getInstance() {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InternetResourceBuilder instance = (InternetResourceBuilder) instances
- .get(loader);
- if (null == instance) {
- try {
- // Default service implementation
- String serviceClassName = "org.ajax4jsf.resource.ResourceBuilderImpl";
- String resource = "META-INF/services/"
- + InternetResourceBuilder.class.getName();
- InputStream in = URLToStreamHelper.urlToStreamSafe(
- loader.getResource(resource));
- if (null != in) {
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
- serviceClassName = reader.readLine();
- reader.close();
- in.close();
- }
- Class<?> builderClass = loader.loadClass(serviceClassName);
- instance = (InternetResourceBuilder) builderClass.newInstance();
- if (log.isDebugEnabled()) {
- log.debug("Create instance of InternetBuilder from class "
- + serviceClassName);
- }
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.error(
- "Can't create instance of InternetBuilder service",
- e);
- throw new FacesException(
- "Error on create instance of InternetBuilder service",
- e);
- }
- // TODO - detect default instance.
- // instance = new ResourceBuilderImpl();
- }
- instances.put(loader, instance);
- }
- if (log.isDebugEnabled()) {
- log.debug("Return instance of internet resource builder "
- + instance.toString());
- }
- return instance;
- }
-
- /**
- * Package-wide method for reset instance in Junit tests.
- *
- * @param instance
- */
- public static void setInstance(InternetResourceBuilder instance) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- instances.put(loader, instance);
- }
-
- public InternetResourceBuilder() {
- super();
- }
-
- public abstract ResourceRenderer getStyleRenderer();
-
- public abstract ResourceRenderer getScriptRenderer();
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceProduser.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceProduser.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/resource/ResourceProduser.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,38 +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.ajax4jsf.resource;
-
-
-/**
- * Interface for all Renderers ( or other classes ? ) for
- * generate internet resources.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
- *
- */
-public interface ResourceProduser {
- /**
- * @param path - local path to internet resource.
- * @return resource instance
- */
- public InternetResource getResource( String path) throws ResourceNotFoundException;
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/ScriptExportable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/ScriptExportable.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/ScriptExportable.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,30 +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.component;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface ScriptExportable {
- public String getScriptVar();
- public void setScriptVar(String s);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/AttributeHolder.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/AttributeHolder.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/AttributeHolder.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,54 +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.event;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Base interface holding attributes that can lately
- * be applied on {@link UIComponent}
- * @author Maksim Kaszynski
- *
- */
-public interface AttributeHolder {
-
- /**
- *
- * @param name
- * @param value
- */
- public abstract void setAttribute(String name, Object value);
-
- /**
- *
- * @param name
- * @return
- */
- public abstract Object getAttribute(String name);
-
- /**
- * Copy attributes from event map to component
- * @param component
- */
- public abstract void applyAttributes(UIComponent component);
-
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/AttributedEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/AttributedEvent.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/AttributedEvent.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,97 +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.event;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-
-/**
- * Base class for events carrying component attributes.
- * By using it, renderer-specific attributes can
- * be applied when event is broadcast
- * @author Maksim Kaszynski
- *
- */
-public abstract class AttributedEvent extends FacesEvent implements AttributeHolder{
-
- private static final long serialVersionUID = 1L;
-
- private Map<String, Object> attributes = new HashMap<String, Object>();
-
- public AttributedEvent(UIComponent component) {
- super(component);
- }
-
- public AttributedEvent(UIComponent component, Map<String, Object> attributes) {
- super(component);
- this.attributes.putAll(attributes);
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.event.AttributeHolder#setAttribute(java.lang.String, java.lang.Object)
- */
- public void setAttribute(String name, Object value) {
- attributes.put(name, value);
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.event.AttributeHolder#getAttribute(java.lang.String)
- */
- public Object getAttribute(String name) {
- return attributes.get(name);
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.event.AttributeHolder#applyAttributes(javax.faces.component.UIComponent)
- */
- public void applyAttributes(UIComponent component) {
-
- Map<String, Object> attrs = component.getAttributes();
-
- for(Iterator<Map.Entry<String, Object>> iterator = attributes.entrySet().iterator();
- iterator.hasNext(); ) {
-
- Map.Entry<String, Object> entry = iterator.next();
-
- String key = entry.getKey();
- Object value = entry.getValue();
-
- if (value == null) {
- attrs.remove(key);
- } else {
- attrs.put(key, value);
- }
- }
- }
-
- /**
- * copy attributes to event source
- */
- public void applyAttributes() {
- applyAttributes(getComponent());
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/RenderPhaseComponentVisitor.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/RenderPhaseComponentVisitor.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/RenderPhaseComponentVisitor.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,36 +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.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.PhaseEvent;
-
-public interface RenderPhaseComponentVisitor {
-
- Object beforeRoot(PhaseEvent event);
-
- void beforeComponent(UIComponent component, PhaseEvent event, Object state);
-
- void afterComponent(UIComponent component, PhaseEvent event, Object state);
-
- void afterRoot(PhaseEvent event, Object state);
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -25,6 +25,8 @@
import java.util.Map;
import javax.faces.FacesException;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
@@ -37,12 +39,10 @@
import org.ajax4jsf.context.ViewResources;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.webapp.BaseFilter;
import org.ajax4jsf.webapp.FilterServletResponseWrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.richfaces.event.RenderPhaseComponentListener;
/**
@@ -91,7 +91,6 @@
riRoot = facesContext.getViewRoot();
} else {
riRoot = super.createView(facesContext, viewId);
- riRoot.addPhaseListener(new RenderPhaseComponentListener());
// Reset ajax request status for a navigation case.
if(null != facesContext.getViewRoot()){
ajaxContext.setAjaxRequest(false);
@@ -137,19 +136,20 @@
* java.lang.String)
*/
public String getResourceURL(FacesContext context, String url) {
- String resourceURL;
if (url.startsWith(InternetResource.RESOURCE_URI_PREFIX)) {
- InternetResource resource = InternetResourceBuilder
- .getInstance()
- .createResource(
- null,
- url
- .substring(InternetResource.RESOURCE_URI_PREFIX_LENGTH));
- resourceURL = resource.getUri(context, null);
- } else {
- resourceURL = super.getResourceURL(context, url);
+ ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
+ String resourceURL = url.substring(InternetResource.RESOURCE_URI_PREFIX_LENGTH);
+
+ Resource resource = resourceHandler.createResource(resourceURL);
+
+ if (resource != null) {
+ return resource.getRequestPath();
+ } else {
+ return super.getResourceURL(context, resourceURL);
+ }
}
- return resourceURL;
+
+ return super.getResourceURL(context, url);
}
/*
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/DebugOutputMaker.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/DebugOutputMaker.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/application/DebugOutputMaker.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -31,6 +31,7 @@
import java.util.TreeMap;
import javax.faces.FacesException;
+import javax.faces.application.Resource;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
@@ -42,8 +43,6 @@
import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
@@ -229,12 +228,13 @@
public void writeLog(FacesContext context, PrintWriter out) throws FacesException {
String logname = context.getExternalContext().getInitParameter(LOGFILE_PARAM);
if (null != logname) {
- InternetResource logResource = InternetResourceBuilder.getInstance().createResource(this,logname);
+ Resource logResource = context.getApplication().getResourceHandler().createResource(logname);
out.print("<h2 onclick=\"toggle('log')\" class=\"a4j_debug\">");
writeToggleMark(out, "log");
out
.println("Faces log: </h2><div id='log' style='display: none;' class='log a4j_debug'>");
- out.print("<iframe name='log' class='log' src='"+logResource.getUri(context,null)+"'><a href='src='"+logResource.getUri(context,null)+"'>Faces log file </a> </iframe>");
+ String logResourceRequestPath = logResource.getRequestPath();
+ out.print("<iframe name='log' class='log' src='"+logResourceRequestPath+"'><a href='src='"+logResourceRequestPath+"'>Faces log file </a> </iframe>");
out.println("</div>");
}
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/component/RenderPhaseUIDataAdaptorVisitor.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/component/RenderPhaseUIDataAdaptorVisitor.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/component/RenderPhaseUIDataAdaptorVisitor.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -20,40 +20,18 @@
*/
package org.ajax4jsf.component;
-import javax.faces.component.UIComponent;
-import javax.faces.event.PhaseEvent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
-import org.richfaces.event.RenderPhaseComponentVisitor;
+public class RenderPhaseUIDataAdaptorVisitor implements SystemEventListener {
-public class RenderPhaseUIDataAdaptorVisitor implements
- RenderPhaseComponentVisitor {
-
- /* (non-Javadoc)
- * @see org.richfaces.event.ComponentPhaseEventHandler#beforePhaseBegin(javax.faces.event.PhaseEvent)
- */
- public Object beforeRoot(PhaseEvent event) {
- return null;
+ public boolean isListenerForSource(Object source) {
+ return source instanceof UIDataAdaptor;
}
- /* (non-Javadoc)
- * @see org.richfaces.event.ComponentPhaseEventHandler#componentBegin(javax.faces.component.UIComponent, javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void beforeComponent(UIComponent component, PhaseEvent event,
- Object state) {
- if (component instanceof UIDataAdaptor) {
- ((UIDataAdaptor) component).beforeRenderResponse(event.getFacesContext());
-
- }
+ public void processEvent(SystemEvent event) throws AbortProcessingException {
+ ((UIDataAdaptor) event.getSource()).beforeRenderResponse(FacesContext.getCurrentInstance());
}
-
- /* (non-Javadoc)
- * @see org.richfaces.event.ComponentPhaseEventHandler#bcomponentEnd(javax.faces.component.UIComponent, javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void afterComponent(UIComponent component, PhaseEvent event,
- Object state) {}
-
- /* (non-Javadoc)
- * @see org.richfaces.event.ComponentPhaseEventHandler#beforePhaseEnd(javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void afterRoot(PhaseEvent event, Object state) {}
}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,58 +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.ajax4jsf.javascript;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * Resource for AJAX client-side script. Render one time per page.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
- *
- */
-public class AjaxScript extends ClientScript {
-
- private static final Log _log = LogFactory.getLog(AjaxScript.class);
-
- /**
- * Set JavaScript renderer and modification time to application-startup time.
- */
- public AjaxScript() {
- super();
- if (_log.isDebugEnabled()) {
- _log.debug("AjaxScript() - Created instance of AjaxScript resource"); //$NON-NLS-1$
- }
- }
-
-
- /**
- * @return Returns the javaScript.
- */
- public String getJavaScript() {
- return "scripts/AJAX.js";
- }
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,46 +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.ajax4jsf.javascript;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * @author shura
- *
- */
-public class DnDScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- return "scripts/dnd.js";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#isUsePrototype()
- */
- protected boolean isUsePrototype() {
- return true;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,55 +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.ajax4jsf.javascript;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * Resource for Drag ' Drop client javascript
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
- *
- */
-public class ImageCacheScript extends ClientScript {
-
-
-
- /**
- *
- */
- public ImageCacheScript() {
- super();
- usePrototype=true;
-// setRenderer(new ScriptRenderer());
-// setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- // TODO Auto-generated method stub
- return "scripts/imagecache.js";
- }
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/PrototypeScript.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,38 +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.ajax4jsf.javascript;
-
-import org.ajax4jsf.resource.ClientScript;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
- *
- */
-public class PrototypeScript extends ClientScript {
-
- public String getJavaScript() {
- return "scripts/prototype.js";
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/javascript/SmartPositionScript.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,45 +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.ajax4jsf.javascript;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SmartPositionScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- // TODO Auto-generated method stub
- return "scripts/smartposition.js";
- }
-
- protected boolean isUsePrototype() {
-
- return true;
- }
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -21,8 +21,6 @@
package org.ajax4jsf.renderkit;
-import org.ajax4jsf.javascript.AjaxScript;
-import org.ajax4jsf.resource.InternetResource;
/**
@@ -34,61 +32,5 @@
*/
public abstract class AjaxComponentRendererBase extends RendererBase {
-// private InternetResource ajaxScript = getResource("/com/exadel/vcp/framework/ajax/scripts/AJAX.js");
- private static final String AJAX_SCRIPT = AjaxScript.class.getName();
-
- private InternetResource[] scripts = null;
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
- */
-// public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
-// LinkedHashSet scripts = new LinkedHashSet() ; // Collections.singleton(ajaxScript.getUri(context, null));
-// scripts.add(ajaxScript.getUri(context, component));
-// String[] additionalScripts = getAdditionalScripts();
-// if (null != additionalScripts) {
-// for (int i = 0; i < additionalScripts.length; i++) {
-// String resource = additionalScripts[i];
-// scripts.add(getResource(resource).getUri(context, component));
-// }
-// }
-// return scripts;
-// }
-
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.HeaderResourcesRendererBase#getScripts()
- */
- protected InternetResource[] getScripts() {
- // Lazy create
- synchronized (this) {
- if (scripts == null) {
- InternetResource[] additionalScripts = getAdditionalScripts();
- // Custom scripts
- if (null != additionalScripts) {
- scripts = new InternetResource[additionalScripts.length+1];
- System.arraycopy(additionalScripts,0,scripts,1,additionalScripts.length);
- } else {
- scripts = new InternetResource[1];
- }
- // Ajax script
- scripts[0] = getResource(AJAX_SCRIPT);
- }
- }
-
- return scripts;
- }
-
-
-
- /**
- * Hoock method for append custom ajax scripts
- * @return
- */
- protected InternetResource[] getAdditionalScripts() {
- return null;
- }
-
-
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -30,7 +30,6 @@
import javax.faces.render.RenderKitFactory;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResourceBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -58,8 +57,6 @@
_log.debug("ChameleonRenderKitFactory(RenderKitFactory) - Chameleon RenderKit factory instantiated"); //$NON-NLS-1$
}
this.defaultFactory = defaultFactory;
- // Init resources builder before use.
- InternetResourceBuilder.getInstance().init();
}
/**
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -72,11 +72,6 @@
*/
public void addRenderer(String family, String rendererType,
Renderer renderer) {
- if (renderer instanceof ChameleonRenderer) {
-// ChameleonRenderer chameleonRenderer = (ChameleonRenderer) renderer;
-// chameleonRenderer.setConfiguration(getConfiguration().getRendererConfiguration(family,rendererType));
-
- }
renderers.put(key(family, rendererType), renderer);
}
/**
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,37 +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.ajax4jsf.renderkit;
-
-import org.ajax4jsf.resource.ResourceProduser;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
- *
- */
-public interface ChameleonRenderer extends ResourceProduser{
-
-
-
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -23,16 +23,12 @@
import java.io.IOException;
-import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.richfaces.skin.Skin;
@@ -46,8 +42,7 @@
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
*
*/
-public abstract class RendererBase extends Renderer implements
- ChameleonRenderer {
+public abstract class RendererBase extends Renderer {
/**
* logger for common cases.
@@ -57,7 +52,7 @@
private static final RendererUtils utils = RendererUtils.getInstance();
private SkinFactory skinFactory = null;
- private InternetResourceBuilder resourceBuilder = null;
+
/* (non-Javadoc)
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
@@ -138,27 +133,6 @@
}
}
- /**
- * Base stub method for produce internet resource ( image, script ... )
- * since resources must be implemented in "lightweight" pattern, it instances
- * put in internal map to caching.
- * @param resourceURI - relative ( to renderer class ) uri to resource in jar or
- * key for generate ( in Java2D , for example ).
- * @return - resource instance for this uri.
- * @throws ResourceNotFoundException - if reqested resource not instantiated.
- */
- public InternetResource getResource(String resourceURI ) throws FacesException {
- return getResourceBuilder().createResource(this,resourceURI);
- }
-
- private InternetResourceBuilder getResourceBuilder(){
- if (resourceBuilder == null) {
- resourceBuilder = InternetResourceBuilder.getInstance();
-
- }
-
- return resourceBuilder;
- }
//==========================================================
// Protected common methods - for all Renderer's
@@ -238,14 +212,6 @@
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
}
- /**
- * Append new resource to renderer cache.
- * @param key
- * @param resource
- */
- protected void addResource(String key, InternetResource resource) {
- getResourceBuilder().addResource(key,resource);
- }
/**
* Render all children for given component.
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -21,7 +21,6 @@
package org.ajax4jsf.renderkit;
-import java.awt.Dimension;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.Arrays;
@@ -47,9 +46,6 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.javascript.JSEncoder;
import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.renderkit.compiler.TemplateContext;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.util.HtmlDimensions;
/**
@@ -561,10 +557,10 @@
if (o instanceof String ) {
return (0 == ((String)o).length());
}
- if (o instanceof Collection) {
+ if (o instanceof Collection<?>) {
return ((Collection<?>)o).isEmpty();
}
- if (o instanceof Map) {
+ if (o instanceof Map<?, ?>) {
return ((Map<?, ?>)o).isEmpty();
}
if (o.getClass().isArray()) {
@@ -814,18 +810,6 @@
return "";
}
- public void encodeDimensions(FacesContext context, UIComponent component,
- InternetResource resource) throws IOException {
- if (resource instanceof Java2Dresource) {
- Java2Dresource j2d = (Java2Dresource) resource;
- Dimension dim = j2d.getDimensions(context, component);
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute("width", String.valueOf(dim.width), "width");
- writer.writeAttribute("height", String.valueOf(dim.height),
- "height");
- }
- }
-
public String encodePx(String value) {
return HtmlDimensions.formatPx(HtmlDimensions.decode(value));
}
@@ -944,23 +928,6 @@
}
/**
- *
- * @param context
- * @param value
- * @return URL of target resource (src, href, etc)
- */
- public String encodeResourceURL(TemplateContext context, Object value) {
- if (value == null) {
- return "";
- }
- FacesContext facesContext = context.getFacesContext();
- value = facesContext.getApplication().getViewHandler().getResourceURL(
- facesContext, value.toString());
- return facesContext.getExternalContext().encodeResourceURL(
- (String) value);
- }
-
- /**
* Simplified version of {@link encodeId}
*
* @param context
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,182 +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.ajax4jsf.resource;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.javascript.PrototypeScript;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Resource for AJAX client-side script. Render one time per page.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/01/26 14:15:18 $
- *
- */
-public abstract class ClientScript extends JarResource {
-
- private static final Log log = LogFactory.getLog(ClientScript.class);
-
- protected boolean usePrototype = false;
- /**
- * Set JavaScript renderer and modification time to application-startup time.
- */
- public ClientScript() {
- super();
- InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
- setRenderer(resourceBuilder.getScriptRenderer());
- String key = this.getClass().getName();
- try {
- // Search already registered resource for this class.
- InternetResource resource = resourceBuilder.getResource(key);
- this.setKey(resource.getKey());
- } catch(ResourceNotFoundException ex){
- // If script not registered, append it to builder.
- setLastModified(new Date(resourceBuilder.getStartTime()));
- resourceBuilder.addResource(key,this);
- }
- String script ;
- if (getJavaScript().startsWith("/")) {
- // remove lead / for classloader covention.
- script = getJavaScript().substring(1);
- } else {
- script = this.getClass().getPackage().getName().replace('.', '/')+"/"
- + getJavaScript();
- }
- setPath(script);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#getLastModified()
- */
- public Date getLastModified(ResourceContext resourceContext) {
-
- if (isCacheable(resourceContext)) {
- return super.getLastModified(resourceContext);
- } else {
- return new Date(System.currentTimeMillis()+1000L);
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return true;
- }
-
- /**
- * @return Returns the javaScript.
- */
- public abstract String getJavaScript();
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map<String, Object> attributes) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encode(context, data, attributes);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encodeBegin(javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map<String, Object> attrs) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encodeBegin(context, component, attrs);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO, getKey()));
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encodeEnd(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException {
- if (isNotAjaxRequest(context)) {
- super.encodeEnd(context, component);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO, getKey()));
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encode(context, data);
- }else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
- }
- }
-
- /**
- * @return Returns the usePrototype.
- */
- protected boolean isUsePrototype() {
- return usePrototype;
- }
-
-
- private boolean isNotAjaxRequest(FacesContext context){
- return true;//! AjaxRendererUtils.isAjaxRequest(context);
- }
-
- private void encodePrototype(FacesContext context) throws IOException{
- if (isUsePrototype()) {
- InternetResourceBuilder.getInstance().createResource(null,PrototypeScript.class.getName()).encode(context,null);
- }
-
- }
-
-
- /**
- * @param usePrototype the usePrototype to set
- */
- public void setUsePrototype(boolean usePrototype) {
- this.usePrototype = usePrototype;
- }
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,65 +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.ajax4jsf.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
- *
- */
-public class GifRenderer extends ImageRenderer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/gif";
- }
-
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image,"gif",outputStream);
- outputStream.flush();
- outputStream.close();
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_ARGB;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,101 +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.ajax4jsf.resource;
-
-import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
- *
- */
-public abstract class ImageRenderer extends BaseResourceRenderer {
-
- private static final String _tag = "img";
- private static final String _hrefAttr = "src";
- private static final String[][] _commonAttrs = {
-
- };
- /**
- * @return Returns the commonAttrs.
- */
- protected String[][] getCommonAttrs() {
- return null ; //_commonAttrs;
- }
-
- /**
- * @return Returns the hrefAttr.
- */
- protected String getHrefAttr() {
- return _hrefAttr;
- }
-
- /**
- * @return Returns the tag.
- */
- protected String getTag() {
- return _tag;
- }
-
- /**
- * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
- * @param context - current faces context.
- * @param image - imaje to send
- */
- public abstract void sendImage(ResourceContext context,RenderedImage image) throws IOException;
-
- /**
- * @return type of image for create {@link BufferedImage}
- */
- public abstract int getImageType();
-
- /**
- * Create blank {@link BufferedImage} for paint.
- * Type of image determined by current renderer.
- * @param width
- * @param height
- * @return new image
- */
- public BufferedImage createImage(int width,int height){
- return new BufferedImage(width,height,getImageType());
- }
-
- protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
- if (resource instanceof Java2Dresource) {
- Java2Dresource j2d = (Java2Dresource) resource;
- Dimension dim = j2d.getDimensions(context, data);
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute("width", String.valueOf(dim.width), "width");
- writer.writeAttribute("height", String.valueOf(dim.height), "height");
- }
- }
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -216,8 +216,10 @@
* java.lang.Object)
*/
public String getUri(final FacesContext context, Object data) {
- return InternetResourceBuilder.getInstance().getUri(this, context,
- getDataToStore(context, data));
+ /*return InternetResourceBuilder.getInstance().getUri(this, context,
+ getDataToStore(context, data));*/
+
+ return null;
}
/**
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -24,26 +24,117 @@
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
+import java.awt.image.IndexColorModel;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import javax.faces.FacesException;
+import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
+import javax.imageio.ImageIO;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.ResourceContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.ajax4jsf.util.NumericDataOutputStream;
+import org.richfaces.resource.AbstractBaseResource;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.3 $ $Date: 2007/02/01 15:31:57 $
*
*/
-public class Java2Dresource extends InternetResourceBase {
- private static final Log log = LogFactory.getLog(Java2Dresource.class);
+public abstract class Java2Dresource extends AbstractBaseResource implements StateHolder {
+ private ImageType imageType;
+
+ public Java2Dresource(ImageType imageType) {
+ super();
+ this.imageType = imageType;
+ }
+
+ public static enum ImageType {
+ GIF("gif") {
+ @Override
+ public BufferedImage createImage(int width, int height) {
+ return createARGBImage(width, height);
+ }
+ },
+ PNG("png") {
+ @Override
+ public BufferedImage createImage(int width, int height) {
+ return createARGBImage(width, height);
+ }
+ },
+ PNG8("png") {
+ @Override
+ public BufferedImage createImage(int width, int height) {
+ return new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED,
+ SAFE_WEB_COLORS_MODEL);
+ }
+ },
+
+ //TODO - add common png8
+
+ JPEG("jpeg") {
+ @Override
+ public BufferedImage createImage(int width, int height) {
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ }
+ };
+
+ /**
+ * Default web safe colors color model
+ */
+ protected static final IndexColorModel SAFE_WEB_COLORS_MODEL;
+
+ // Build web safe 6x6x6 cube color model.
+ static {
+ byte[] webLevels = { 0, 51, 102, (byte) 153, (byte) 204, (byte) 255 };
+ int colorsNumber = webLevels.length * webLevels.length * webLevels.length; /* 216 colors */
+
+ byte[] r = new byte[colorsNumber];
+ byte[] g = new byte[colorsNumber];
+ byte[] b = new byte[colorsNumber];
+ r[0] = g[0] = b[0] = 0;
+ for (int i = 0; i < webLevels.length; i++) {
+ for (int j = 0; j < webLevels.length; j++) {
+ for (int k = 0; k < webLevels.length; k++) {
+ int colorNum = i * webLevels.length * webLevels.length + j
+ * webLevels.length + k;
+ r[colorNum] = webLevels[i];
+ g[colorNum] = webLevels[j];
+ b[colorNum] = webLevels[k];
+ }
+ }
+ }
+
+ SAFE_WEB_COLORS_MODEL = new IndexColorModel(8, colorsNumber, r, g, b, 0);
+ }
+
+ private static BufferedImage createARGBImage(int width, int height) {
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ }
+
+ private String formatName;
+
+ private String mimeType;
+
+ private ImageType(String formatName) {
+ this.formatName = formatName;
+ this.mimeType = "image/" + formatName;
+ }
+
+ protected abstract BufferedImage createImage(int width, int height);
+
+ protected String getFormatName() {
+ return formatName;
+ }
+
+ protected String getMimeType() {
+ return mimeType;
+ }
+ }
+
/**
* Primary calculation of image dimensions - used when HTML code is
* generated to render IMG's width and height Subclasses should override
@@ -52,84 +143,85 @@
* @param facesContext
* @return dimensions of the image to be displayed on page
*/
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return new Dimension(1, 1);
- }
-
+ public abstract Dimension getDimension();
+
/**
- * Secondary calculation is used basically by {@link getImage} method
+ * Template method for create image as Applet-like paint.
*
- * @param resourceContext
- * @return
+ * @param graphics2D -
+ * graphics to paint.
*/
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return new Dimension(1, 1);
- }
+ protected void paint(Graphics2D graphics2D, Dimension dimension) {
+ // TODO Auto-generated method stub
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- // TODO Auto-generated method stub
- return super.getResourceAsStream(context);
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResourceBase#send(javax.faces.context.FacesContext,
- * java.lang.Object)
+ /* (non-Javadoc)
+ * @see org.richfaces.resource.AbstractBaseResource#getInputStream()
*/
- public void send(ResourceContext context) throws IOException {
- ImageRenderer renderer = (ImageRenderer) getRenderer(null);
- try {
- RenderedImage image = getImage(context);
- if (null != image) {
- renderer.sendImage(context, image);
+ @Override
+ public InputStream getInputStream() {
+ Dimension dimension = getDimension();
+ int width = dimension.width;
+ int height = dimension.height;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ if (width > 0 && height > 0) {
+ BufferedImage image = imageType.createImage(width, height);
+ Graphics2D g2d = image.createGraphics();
+
+ try {
+ paint(g2d, dimension);
+ } finally {
+ g2d.dispose();
+ }
+
+ try {
+ ImageIO.write(image, imageType.getFormatName(), baos);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ try {
+ baos.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
- }
- } catch (Exception e) {
- throw new FacesException(Messages
- .getMessage(Messages.SEND_IMAGE_ERROR_2), e);
}
+
+ return new ByteArrayInputStream(baos.toByteArray());
}
- /**
- * Create {@link RenderedImage} for send to client. can be used as Java2d or
- * Java Advanced Imaging.
- *
- * @param context
- * @return image to send.
- */
- protected RenderedImage getImage(ResourceContext context) {
- ImageRenderer renderer = (ImageRenderer) getRenderer(null);
- Dimension imageDimensions = getDimensions(context);
- BufferedImage image = null;
- if (imageDimensions.getHeight() > 0.0
- && imageDimensions.getWidth() > 0.0) {
- image = renderer.createImage(imageDimensions.width,
- imageDimensions.height);
- Graphics2D graphics = image.createGraphics();
- paint(context, graphics);
- graphics.dispose();
+ @Override
+ public String getContentType() {
+ return imageType.getMimeType();
+ }
+
+ protected void writeState(FacesContext context, NumericDataOutputStream stream) {
+ }
+
+ protected void readState(FacesContext context, NumericDataInputStream stream) {
+
+ }
- }
- return image;
+ public boolean isTransient() {
+ return false;
}
- /**
- * Template method for create image as Applet-like paint.
- *
- * @param context -
- * current resource context.
- * @param graphics2D -
- * graphics to paint.
- */
- protected void paint(ResourceContext context, Graphics2D graphics2D) {
- // TODO Auto-generated method stub
+ public void restoreState(FacesContext context, Object state) {
+ readState(context, new NumericDataInputStream((byte[]) state));
+ }
+ public Object saveState(FacesContext context) {
+ NumericDataOutputStream stream = new NumericDataOutputStream();
+ writeState(context, stream);
+ return stream.getBytes();
}
+
+ public void setTransient(boolean newTransientValue) {
+ throw new UnsupportedOperationException();
+ }
}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,66 +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.ajax4jsf.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
- *
- */
-public class JpegRenderer extends ImageRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/jpeg";
- }
-
- public void sendImage(ResourceContext context, RenderedImage image) throws IOException {
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image, "jpeg", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_RGB;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,125 +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.ajax4jsf.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.IndexColorModel;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
- *
- */
-public class Png8Renderer extends ImageRenderer {
-
- /**
- * Default web safe colors color model
- */
- public static IndexColorModel webColorModel;
-
- // Build web safe 6x6x6 cube color model.
- static {
- byte[] webLevels = { 0, 51, 102, (byte) 153, (byte) 204, (byte) 255 };
- byte[] r = new byte[256];
- byte[] g = new byte[256];
- byte[] b = new byte[256];
- r[0] = g[0] = b[0] = 0;
- for (int i = 0; i < webLevels.length; i++) {
- for (int j = 0; j < webLevels.length; j++) {
- for (int k = 0; k < webLevels.length; k++) {
- int colorNum = i * webLevels.length * webLevels.length + j
- * webLevels.length + k + 1;
- r[colorNum] = webLevels[i];
- g[colorNum] = webLevels[j];
- b[colorNum] = webLevels[k];
- }
- }
- }
- webColorModel = new IndexColorModel(8, webLevels.length
- * webLevels.length * webLevels.length + 1, r, g, b, 0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#sendImage(org.ajax4jsf.resource.ResourceContext,
- * java.awt.image.RenderedImage)
- */
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- // PNGEncodeParam param = new PNGEncodeParam.Palette();
- // param.setBitDepth(8);
- // param.setInterlacing(true);
- // String[] encoders = ImageCodec.getEncoderNames(image,null);
- // ImageEncoder encoder =
- // ImageCodec.createImageEncoder("png",context.getOutputStream(),param);
- // encoder.encode(image);
- try {
- ImageIO.write(image, "png", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#getImageType()
- */
- public int getImageType() {
- return BufferedImage.TYPE_BYTE_INDEXED;
- // return BufferedImage.TYPE_INT_ARGB;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#createImage(int, int)
- */
- public BufferedImage createImage(int width, int height) {
-
- // return new BufferedImage(width,height,getImageType());//,colorModel);
- return new BufferedImage(width, height, getImageType(), webColorModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/png";
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,63 +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.ajax4jsf.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:05 $
- *
- */
-public class PngRenderer extends ImageRenderer {
-
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image, "png", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/png";
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_ARGB;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,494 +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.ajax4jsf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
-import javax.servlet.ServletContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.webapp.WebXml;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.VersionBean;
-import org.richfaces.util.Util;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Produce instances of InternetResource's for any types - jar resource, dynamic
- * created image, component-incapsulated etc. Realised as singleton class to
- * support cache, configuration etc.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
- *
- */
-public class ResourceBuilderImpl extends InternetResourceBuilder {
-
- private static final Log log = LogFactory.getLog(ResourceBuilderImpl.class);
-
-
- private static final ResourceRenderer defaultRenderer = new MimeRenderer(null);
-
- private Map<String, ResourceRenderer> renderers;
- /**
- * keep resources instances . TODO - put this map to application-scope
- * attribute, for support clastering environment.
- */
- private Map<String, InternetResource> resources = Collections.synchronizedMap(new HashMap<String, InternetResource>());
-
- private long _startTime;
-
- private static final ResourceRenderer scriptRenderer = new ScriptRenderer();
-
- private static final ResourceRenderer styleRenderer = new StyleRenderer();
-
- static {
- // renderers.put(".htc",new BehaviorRenderer());
- // set in-memory caching ImageIO
- Thread thread = Thread.currentThread();
- ClassLoader initialTCCL = thread.getContextClassLoader();
-
- try {
- ClassLoader systemCL = ClassLoader.getSystemClassLoader();
- thread.setContextClassLoader(systemCL);
- ImageIO.setUseCache(false);
- } finally {
- thread.setContextClassLoader(initialTCCL);
- }
-
- }
-
- public WebXml getWebXml(FacesContext context) {
- WebXml webXml = WebXml.getInstance(context);
- if (null == webXml) {
- throw new FacesException(
- "Resources framework is not initialised, check web.xml for Filter configuration");
- }
- return webXml;
- }
-
- public ResourceBuilderImpl() {
- super();
- _startTime = System.currentTimeMillis();
- renderers = new HashMap<String, ResourceRenderer>();
- // append known renderers for extentions.
- renderers.put(".gif", new GifRenderer());
- ResourceRenderer renderer = new JpegRenderer();
- renderers.put(".jpeg", renderer);
- renderers.put(".jpg", renderer);
- renderers.put(".png", new PngRenderer());
- renderers.put(".js", getScriptRenderer());
- renderers.put(".css", getStyleRenderer());
- renderers.put(".log", new LogfileRenderer());
- renderers.put(".html", new HTMLRenderer());
- renderers.put(".xhtml", new MimeRenderer("application/xhtml+xml"));
- renderers.put(".xml", new MimeRenderer("text/xml"));
- renderers.put(".xcss", new TemplateCSSRenderer());
- renderers.put(".swf", new MimeRenderer("application/x-shockwave-flash"));
- }
-
- /**
- * @throws FacesException
- */
- protected void registerResources() throws FacesException {
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Enumeration<URL> e = loader
- .getResources("META-INF/resources-config.xml");
- while (e.hasMoreElements()) {
- URL resource = e.nextElement();
- registerConfig(resource);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- private void registerConfig(URL resourceConfig) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Process resources configuration file "
- + resourceConfig.toExternalForm());
- }
-
- InputStream in = URLToStreamHelper.urlToStream(resourceConfig);
- try {
- Digester digester = new Digester();
- digester.setValidating(false);
- digester.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId,
- String systemId) throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
- });
- digester.setNamespaceAware(false);
- digester.setUseContextClassLoader(true);
- digester.push(this);
- digester.addObjectCreate("resource-config/resource", "class",
- JarResource.class);
- digester.addObjectCreate("resource-config/resource/renderer",
- "class", HTMLRenderer.class);
- digester.addCallMethod(
- "resource-config/resource/renderer/content-type",
- "setContentType", 0);
- digester.addSetNext("resource-config/resource/renderer",
- "setRenderer", ResourceRenderer.class.getName());
- digester.addCallMethod("resource-config/resource/name",
- "setKey", 0);
- digester.addCallMethod("resource-config/resource/path",
- "setPath", 0);
- digester.addCallMethod("resource-config/resource/cacheable",
- "setCacheable", 0);
- digester.addCallMethod(
- "resource-config/resource/session-aware",
- "setSessionAware", 0);
- digester.addCallMethod("resource-config/resource/property",
- "setProperty", 2);
- digester.addCallParam("resource-config/resource/property/name",
- 0);
- digester.addCallParam(
- "resource-config/resource/property/value", 1);
- digester.addCallMethod("resource-config/resource/content-type",
- "setContentType", 0);
- digester.addSetNext("resource-config/resource", "addResource",
- InternetResource.class.getName());
- digester.parse(in);
- } finally {
- in.close();
- }
- } catch (IOException e) {
- throw new FacesException(e);
- } catch (SAXException e) {
- throw new FacesException(e);
- }
- }
-
- /**
- */
- public void init() throws FacesException {
- // TODO - mace codec configurable.
- registerResources();
- }
-
- /**
- * Base point for creating resource. Must detect type and build appropriate
- * instance. Currently - make static resource for ordinary request, or
- * instance of class.
- *
- * @param base
- * base object for resource ( resourcess in classpath will be get
- * relative to it package )
- * @param path
- * key - path to resource, resource class name etc.
- * @return
- * @throws FacesException
- */
- public InternetResource createResource(Object base, String path)
- throws FacesException {
- // TODO - detect type of resource ( for example, resources location path
- // in Skin
- try {
- return getResource(path);
- } catch (ResourceNotFoundException e) {
- try {
- return getResource(buildKey(base, path));
- } catch (ResourceNotFoundException e1) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_INFO,
- path));
- }
- }
- }
- // path - is class name ?
- InternetResource res;
- try {
- Class<?> resourceClass = Class.forName(path);
- res = createDynamicResource(path, resourceClass);
- } catch (Exception e) {
- try {
- res = createJarResource(base, path);
- } catch (ResourceNotFoundException ex) {
- res = createStaticResource(path);
- }
- // TODO - if resource not found, create static ?
- }
- return res;
- }
-
- private String buildKey(Object base, String path) {
- if (path.startsWith("/")) {
- return path.substring(1);
- }
- if (null == base) {
- return path;
- }
- StringBuffer packageName = new StringBuffer(base.getClass()
- .getPackage().getName().replace('.', '/'));
- return packageName.append("/").append(path).toString();
- }
-
- public String getUri(InternetResource resource, FacesContext context,
- Object storeData) {
-
- return Util.encodeResourceData(resource.getKey(), storeData, VersionBean._version.getResourceVersion());
- }
-
- /**
- * @param key
- * @return
- */
- public InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException {
-
- return getResource(Util.getResourceName(key));
- }
-
- public Object getResourceDataForKey(String key) {
- return Util.getResourceData(key);
- }
-
- public InternetResource getResource(String path)
- throws ResourceNotFoundException {
-
- InternetResource internetResource = (InternetResource) resources
- .get(path);
- if (null == internetResource) {
- throw new ResourceNotFoundException("Resource not registered : "
- + path);
- } else {
- return internetResource;
- }
- }
-
- public void addResource(InternetResource resource) {
- resources.put(resource.getKey(), resource);
- ResourceRenderer renderer = resource.getRenderer(null);
- if (renderer == null) {
- setRenderer(resource, resource.getKey());
- }
- }
-
- public void addResource(String key, InternetResource resource) {
- resources.put(key, resource);
- resource.setKey(key);
- // TODO - set renderer ?
- }
-
- // public String getFacesResourceKey(HttpServletRequest request) {
- // return getWebXml(context).getFacesResourceKey(request);
- // }
-
- public String getFacesResourceURL(FacesContext context, String url, boolean isGlobal) {
- return getWebXml(context).getFacesResourceURL(context, url, isGlobal);
- }
-
- /**
- * Build resource for link to static context in webapp.
- *
- * @param path
- * @return
- * @throws FacesException
- */
- protected InternetResource createStaticResource(String path)
- throws ResourceNotFoundException, FacesException {
- FacesContext context = FacesContext.getCurrentInstance();
- if (null != context) {
- if (context.getExternalContext().getContext() instanceof ServletContext) {
- ServletContext servletContext = (ServletContext) context
- .getExternalContext().getContext();
- InputStream in = servletContext.getResourceAsStream(path);
- if (null != in) {
- InternetResourceBase res = new StaticResource(path);
- setRenderer(res, path);
- res.setLastModified(new Date(getStartTime()));
- addResource(path, res);
- try {
- in.close();
- } catch (IOException e) {
- }
- return res;
- }
- }
- }
- throw new ResourceNotFoundException(Messages.getMessage(
- Messages.STATIC_RESOURCE_NOT_FOUND_ERROR, path));
- }
-
- private void setRenderer(InternetResource res, String path)
- throws FacesException {
- int lastPoint = path.lastIndexOf('.');
- if (lastPoint > 0) {
- String ext = path.substring(lastPoint);
- ResourceRenderer resourceRenderer = getRendererByExtension(ext);
- if (null != resourceRenderer) {
- res.setRenderer(resourceRenderer);
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.NO_RESOURCE_REGISTERED_ERROR_2, path,
- renderers.keySet()));
- }
-
- // String mimeType = servletContext.getMimeType(path);
- res.setRenderer(defaultRenderer);
- }
- }
- }
-
- /**
- * @param ext
- * @return
- */
- protected ResourceRenderer getRendererByExtension(String ext) {
- return renderers
- .get(ext);
- }
-
- /**
- * Create resurce to send from classpath relative to base class.
- *
- * @param base
- * @param path
- * @return
- * @throws FacesException
- */
- protected InternetResource createJarResource(Object base, String path)
- throws ResourceNotFoundException, FacesException {
- String key = buildKey(base, path);
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (null != loader.getResource(key)) {
- JarResource res = new JarResource(key);
- setRenderer(res, path);
- res.setLastModified(new Date(getStartTime()));
- addResource(key, res);
- return res;
- } else {
- throw new ResourceNotFoundException(Messages.getMessage(
- Messages.NO_RESOURCE_EXISTS_ERROR, key));
- }
-
- }
-
- /**
- * Create resource by instatiate given class.
- *
- * @param path
- * @param instatiate
- * @return
- */
- protected InternetResource createDynamicResource(String path,
- Class<?> instatiate) throws ResourceNotFoundException {
- if (InternetResource.class.isAssignableFrom(instatiate)) {
- InternetResource resource;
- try {
- resource = (InternetResource) instatiate.newInstance();
- addResource(path, resource);
- } catch (Exception e) {
- String message = Messages.getMessage(
- Messages.INSTANTIATE_RESOURCE_ERROR, instatiate
- .toString());
- log.error(message, e);
- throw new ResourceNotFoundException(message, e);
- }
- return resource;
- }
- throw new FacesException(Messages
- .getMessage(Messages.INSTANTIATE_CLASS_ERROR));
- }
-
- /**
- * Create resource by instatiate {@link UserResource} class with given
- * properties ( or got from cache ).
- *
- * @param cacheable
- * @param session
- * @param mime
- * @return
- * @throws FacesException
- */
- public InternetResource createUserResource(boolean cacheable,
- boolean session, String mime) throws FacesException {
- String path = getUserResourceKey(cacheable, session, mime);
- InternetResource userResource;
- try {
- userResource = getResource(path);
- } catch (ResourceNotFoundException e) {
- userResource = new UserResource(cacheable, session, mime);
- addResource(path, userResource);
- }
- return userResource;
- }
-
- /**
- * Generate resource key for user-generated resource with given properties.
- *
- * @param cacheable
- * @param session
- * @param mime
- * @return
- */
- private String getUserResourceKey(boolean cacheable, boolean session,
- String mime) {
- StringBuffer pathBuffer = new StringBuffer(UserResource.class.getName());
- pathBuffer.append(cacheable ? "/c" : "/n");
- pathBuffer.append(session ? "/s" : "/n");
- if (null != mime) {
- pathBuffer.append('/').append(mime.hashCode());
- }
- String path = pathBuffer.toString();
- return path;
- }
-
- /**
- * @return Returns the startTime for application.
- */
- public long getStartTime() {
- return _startTime;
- }
-
- @Override
- public ResourceRenderer getScriptRenderer() {
- return scriptRenderer;
- }
-
- @Override
- public ResourceRenderer getStyleRenderer() {
- return styleRenderer;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,292 +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.ajax4jsf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-
-/**
- * Class for create and send resources from template ( at most, used for CSS files )
- * @author shura (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
- *
- * @deprecated
- */
-public class TemplateCSSResource implements InternetResource {
-
- private String templateName;
- private InternetResource _resource;
- private static TemplateCSSRenderer templateCSSRenderer = new TemplateCSSRenderer();
-
- public TemplateCSSResource(){
-
- }
- /**
- * @param templateName
- */
- public TemplateCSSResource(String templateName) {
- super();
- setPath(templateName);
- }
- /**
- * @param templateName
- * @throws FacesException
- */
- public void setPath(String templateName) throws FacesException {
- // remove leaded / - as need for ClassLoader.getResource call.
- this.templateName = templateName.startsWith("/")?templateName.substring(1):templateName;
- // Self-register resource in system.
- InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
- _resource = resourceBuilder.createResource(null,this.templateName);
- _resource.setRenderer(templateCSSRenderer);
- try {
- // Attempt to compile template at init time. Due to client-side caching,
- // without registering resources requests can be not call rendering template.
- templateCSSRenderer.getTemplate(_resource, null);
- } catch (Exception e) {
- // Do nothing - template will be compiled at rendering time.
- // TODO log error.
- }
- }
-
- /**
- * @param context
- * @param data
- * @param attributes
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encode(FacesContext, java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map<String, Object> attributes) throws IOException {
- _resource.encode(context, data, attributes);
- }
-
- /**
- * @param context
- * @param data
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encode(FacesContext, java.lang.Object)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- _resource.encode(context, data);
- }
-
- /**
- * @param context
- * @param component
- * @param attrs
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encodeBegin(FacesContext, java.lang.Object, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map<String, Object> attrs) throws IOException {
- _resource.encodeBegin(context, component, attrs);
- }
-
- /**
- * @param context
- * @param component
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encodeEnd(FacesContext, java.lang.Object)
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException {
- _resource.encodeEnd(context, component);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getContentLength(ResourceContext)
- */
- public int getContentLength(ResourceContext resourceContext) {
- return _resource.getContentLength(resourceContext);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getContentType(ResourceContext)
- */
- public String getContentType(ResourceContext resourceContext) {
- return _resource.getContentType(resourceContext);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getExpired(ResourceContext)
- */
- public long getExpired(ResourceContext resourceContext) {
- return _resource.getExpired(resourceContext);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getKey()
- */
- public String getKey() {
- return _resource.getKey();
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getLastModified(ResourceContext)
- */
- public Date getLastModified(ResourceContext resourceContext) {
- return _resource.getLastModified(resourceContext);
- }
-
- /**
- * @param key
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- return _resource.getProperty(key);
- }
-
- /**
- * @param context
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getResourceAsStream(org.ajax4jsf.resource.ResourceContext)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- return _resource.getResourceAsStream(context);
- }
-
- /**
- * @param context
- * @param data
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext, java.lang.Object)
- */
- public String getUri(FacesContext context, Object data) {
- return _resource.getUri(context, data);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#isCacheable(ResourceContext)
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return _resource.isCacheable(resourceContext);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#isSessionAware()
- */
- public boolean isSessionAware() {
- return _resource.isSessionAware();
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
- */
- public boolean requireFacesContext() {
- return _resource.requireFacesContext();
- }
-
- /**
- * @param context
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#send(org.ajax4jsf.resource.ResourceContext)
- */
- public void send(ResourceContext context) throws IOException {
- _resource.send(context);
- }
-
- /**
- * @param response
- * @see org.ajax4jsf.resource.InternetResource#sendHeaders(org.ajax4jsf.resource.ResourceContext)
- */
- public void sendHeaders(ResourceContext response) {
- _resource.sendHeaders(response);
- }
-
- /**
- * @param key
- * @see org.ajax4jsf.resource.InternetResource#setKey(java.lang.String)
- */
- public void setKey(String key) {
- _resource.setKey(key);
- }
-
- /**
- * @param key
- * @param value
- * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object, java.lang.Object)
- */
- public void setProperty(Object key, Object value) {
- _resource.setProperty(key, value);
- }
-
- /**
- * @param renderer
- * @see org.ajax4jsf.resource.InternetResource#setRenderer(org.ajax4jsf.resource.ResourceRenderer)
- */
- public void setRenderer(ResourceRenderer renderer) {
- _resource.setRenderer(renderer);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getRenderer(ResourceContext)
- */
- public ResourceRenderer getRenderer(ResourceContext resourceContext) {
- return _resource.getRenderer(null);
- }
-
- /**
- * @param cacheable
- * @see org.ajax4jsf.resource.InternetResource#setCacheable(boolean)
- */
- public void setCacheable(boolean cacheable) {
- _resource.setCacheable(cacheable);
- }
-
- /**
- * @param expired
- * @see org.ajax4jsf.resource.InternetResource#setExpired(long)
- */
- public void setExpired(long expired) {
- _resource.setExpired(expired);
- }
-
- /**
- * @param lastModified
- * @see org.ajax4jsf.resource.InternetResource#setLastModified(java.util.Date)
- */
- public void setLastModified(Date lastModified) {
- _resource.setLastModified(lastModified);
- }
-
- /**
- * @param sessionAware
- * @see org.ajax4jsf.resource.InternetResource#setSessionAware(boolean)
- */
- public void setSessionAware(boolean sessionAware) {
- _resource.setSessionAware(sessionAware);
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,279 +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.ajax4jsf.resource.cached;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.UUID;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceBuilderImpl;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This class is intended to generate predictable URIs for all resources handled by RichFaces.
- * It creates mapping between resource key/data value and generated random string of known format
- * for all resource requests. By default {@link UUID#toString()} is used. Mapping is maintained by LRU map
- * having default capacity of {@value #DEFAULT_CAPACITY} so be aware that stale entries can be removed and
- * application users will get errors then.
- *
- * How to use: add to application classpath META-INF/services/org.ajax4jsf.resource.InternetResourceBuilder
- * file with the following content <code>org.ajax4jsf.resource.cached.CachedResourceBuilder</code>
- *
- * Limitations:
- *
- * <ol>
- * <li>Doesn't work in clustered environments</li>
- * <li>All resource URIs become invalid after server restart that can cause cache issues</li>
- * <li>
- * Diagnostic of resource loading errors becomes somewhat harder. Variant of code where random key
- * is appended to resource name doesn't satisfy the requirement of no path depth > 8 as requested
- * by users (see <a href="https://jira.jboss.org/jira/browse/RF-3586">RF-3586</a> for more info)
- * </li>
- * </ol>
- *
- * @author Alexander Smirnov
- * @author Nick Belaevski
- */
-public class CachedResourceBuilder extends ResourceBuilderImpl {
-
- private static final Log log = LogFactory.getLog(CachedResourceBuilder.class);
-
- protected static final int DEFAULT_CAPACITY = 10000;
-
- private ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
-
- private DualLRUMap cache;
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#decrypt(byte[])
- */
- protected byte[] decrypt(byte[] data) {
- // dummy - data not send via internet.
- return data;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#encrypt(byte[])
- */
- protected byte[] encrypt(byte[] data) {
- // dummy - data not send via internet.
- return data;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#getResourceDataForKey(java.lang.String)
- */
- public Object getResourceDataForKey(String key) {
- ResourceBean bean = null;
- try {
- readWriteLock.readLock().lock();
- bean = (ResourceBean) cache.get(key);
- } finally {
- readWriteLock.readLock().unlock();
- }
-
- if (null == bean) {
- throw new ResourceNotFoundException("Resource for key " + key
- + "not present in cache");
- }
-
- return bean.getData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#getResourceForKey(java.lang.String)
- */
- public InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException {
- ResourceBean bean = null;
- try {
- readWriteLock.readLock().lock();
- bean = (ResourceBean) cache.get(key);
- } finally {
- readWriteLock.readLock().unlock();
- }
-
- if (null == bean) {
- throw new ResourceNotFoundException("Resource for key " + key
- + "not present in cache");
- }
-
- return super.getResourceForKey(bean.getKey());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#getUri(org.ajax4jsf.resource.InternetResource,
- * javax.faces.context.FacesContext, java.lang.Object)
- */
- public String getUri(InternetResource resource, FacesContext facesContext,
- Object data) {
- ResourceBean bean;
- if (null == data) {
- bean = new ResourceBean(resource.getKey());
- } else {
- if (data instanceof byte[]) {
- // Special case for simple bytes array data.
- bean = new ResourceBytesDataBean(resource.getKey(),
- (byte[]) data);
- } else {
- bean = new ResourceDataBean(resource.getKey(), data);
- }
- }
-
- String key = null;
-
- try {
- readWriteLock.readLock().lock();
-
- key = (String) cache.getKey(bean);
-
- if (key != null) {
- // Refresh LRU
- cache.get(key);
- }
- } finally {
- readWriteLock.readLock().unlock();
- }
-
- if (key == null) {
- try {
- readWriteLock.writeLock().lock();
-
- key = (String) cache.getKey(bean);
- if (null == key) {
- key = createNextKey();
- while (cache.containsKey(key)) {
- key = createNextKey();
- }
-
- cache.put(key, bean);
- } else {
- // Refresh LRU
- cache.get(key);
- }
-
- } finally {
- readWriteLock.writeLock().unlock();
- }
- }
-
- boolean isGlobal = !resource.isSessionAware();
-
- String resourceURL = getFacesResourceURL(facesContext, key, isGlobal);
- if (!isGlobal) {
- resourceURL = facesContext.getExternalContext().encodeResourceURL(
- resourceURL);
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
- resource.getKey(), resourceURL));
- }
- return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceBuilderImpl#init(javax.servlet.ServletContext,
- * java.lang.String)
- */
- public void init() throws FacesException {
- super.init();
-
- Properties properties = getProperties("cache.properties");
- int capacity = getCapacity(properties);
- if (capacity <= 0) {
- capacity = DEFAULT_CAPACITY;
- log.info("Using default capacity: " + DEFAULT_CAPACITY);
- }
-
- cache = new DualLRUMap(capacity);
- }
-
- /**
- * Get properties file from classpath
- *
- * @param name
- * @return
- */
- protected Properties getProperties(String name) {
- Properties properties = new Properties();
- InputStream props = URLToStreamHelper.urlToStreamSafe(CachedResourceBuilder.class
- .getResource(name));
- if (null != props) {
- try {
- properties.load(props);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
- name), e);
- } finally {
- try {
- props.close();
- } catch (IOException e) {
- // Can be ignored
- }
- }
- }
- return properties;
-
- }
-
- protected String createNextKey() {
- return UUID.randomUUID().toString();
- }
-
- protected int getCapacity(Properties properties) {
- // Create cache manager.
- int capacity = 0;
- String capacityString = properties.getProperty("cache.capacity");
- if (null != capacityString) {
- try {
- capacity = Integer.parseInt(capacityString);
- } catch (NumberFormatException e) {
- log.warn("Error parsing value of parameters cache capacity", e);
- }
- }
-
- return capacity;
- }
-}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/ApplicationContext.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/ApplicationContext.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/ApplicationContext.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -26,7 +26,7 @@
public static ApplicationContext getInstance(FacesContext context) {
ExternalContext externalContext = context.getExternalContext();
- Map<String, Object> applicationMap = externalContext.getRequestMap();
+ Map<String, Object> applicationMap = externalContext.getApplicationMap();
ApplicationContext applicationContext = (ApplicationContext) applicationMap.get(APPLICATION_ATTRIBUTE_NAME);
if (applicationContext == null) {
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/event/RenderPhaseComponentListener.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/event/RenderPhaseComponentListener.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/event/RenderPhaseComponentListener.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,82 +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.event;
-
-import java.util.Collection;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
-
-import org.richfaces.util.RenderPhaseComponentVisitorUtils;
-
-public class RenderPhaseComponentListener implements PhaseListener {
-
- /**
- *
- */
- private static final long serialVersionUID = -2437433246178955788L;
-
- public void afterPhase(PhaseEvent event) {
- }
-
- private void processComponents(PhaseEvent event, UIComponent component,
- RenderPhaseComponentVisitor[] handlers, Object[] states) {
- for (int i = 0; i < handlers.length; i++) {
- handlers[i].beforeComponent(component, event, states[i]);
- }
- Collection<UIComponent> facets = component.getFacets().values();
- for (UIComponent facet : facets) {
- processComponents(event, facet, handlers, states);
- }
- Collection<UIComponent> children = component.getChildren();
- for (UIComponent child : children) {
- processComponents(event, child, handlers, states);
- }
- for (int i = 0; i < handlers.length; i++) {
- handlers[i].afterComponent(component, event, states[i]);
- }
- }
-
- public void beforePhase(PhaseEvent event) {
- FacesContext facesContext = event.getFacesContext();
- RenderPhaseComponentVisitor[] handlers = RenderPhaseComponentVisitorUtils.getVisitors(facesContext);
- UIViewRoot viewRoot = facesContext.getViewRoot();
- if (viewRoot != null && handlers != null) {
- Object[] states = new Object[handlers.length];
- for (int i = 0; i < handlers.length; i++) {
- states[i] = handlers[i].beforeRoot(event);
- }
- processComponents(event, viewRoot, handlers, states);
- for (int i = 0; i < handlers.length; i++) {
- handlers[i].afterRoot(event, states[i]);
- }
- }
- }
-
- public PhaseId getPhaseId() {
- return PhaseId.RENDER_RESPONSE;
- }
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -24,15 +24,12 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
-import org.ajax4jsf.resource.InternetResource;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
@@ -90,42 +87,6 @@
};
- private static final Command MERGE_STYLE_DEPENDENCIES = new Command() {
-
- protected void execute(RendererContributor renderer,
- FacesContext facesContext, UIComponent component,
- Object argument) {
-
- String[] styleDependencies = renderer.getStyleDependencies();
- if (styleDependencies != null) {
- Set<String> styles = (Set<String>) argument;
-
- for (int i = 0; i < styleDependencies.length; i++) {
- styles.add(styleDependencies[i]);
- }
- }
- }
-
- };
-
- private static final Command MERGE_SCRIPT_DEPENDENCIES = new Command() {
-
- protected void execute(RendererContributor renderer,
- FacesContext facesContext, UIComponent component,
- Object argument) {
-
- String[] scriptDependencies = renderer.getScriptDependencies();
- if (scriptDependencies != null) {
- Set<String> scripts = (Set<String>) argument;
-
- for (int i = 0; i < scriptDependencies.length; i++) {
- scripts.add(scriptDependencies[i]);
- }
- }
- }
-
- };
-
private static final Command GET_SCRIPT_CONTRIBUTIONS = new Command() {
protected void execute(RendererContributor renderer,
@@ -154,42 +115,6 @@
MERGE_OPTIONS_COMMAND.execute(renderers.iterator(), context, component, scriptOptions, acceptableClass);
}
- protected InternetResource[] getScripts() {
- return getResources(null, MERGE_SCRIPT_DEPENDENCIES);
- }
-
- protected InternetResource[] getStyles() {
- return getResources(null, MERGE_STYLE_DEPENDENCIES);
- }
-
- protected InternetResource[] getScripts(Class<?> clazz) {
- return getResources(clazz, MERGE_SCRIPT_DEPENDENCIES);
- }
-
- protected InternetResource[] getStyles(Class<?> clazz) {
- return getResources(clazz, MERGE_STYLE_DEPENDENCIES);
- }
-
- private InternetResource[] getResources(Class<?> acceptableClass, Command command) {
- Set<String> scriptsSet = new LinkedHashSet<String>();
-
- command.execute(renderers.iterator(), null, null, scriptsSet, acceptableClass);
-
- if (!scriptsSet.isEmpty()) {
-
- Iterator<String> iterator = scriptsSet.iterator();
- InternetResource[] result = new InternetResource[scriptsSet.size()];
-
- for (int i = 0; i < result.length; i++) {
- result[i] = getResource(iterator.next());
- }
-
- return result;
- }
-
- return null;
- }
-
protected String getScriptContributions(String varString, FacesContext context, UIComponent component) {
return getScriptContributions(varString, context, component, component.getClass());
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -20,8 +20,8 @@
public class Base2WayGradient extends BaseGradient {
-
-
+
+
/**
* @param horizontal
*/
@@ -143,76 +143,69 @@
// TODO Auto-generated constructor stub
}
-
+
protected void drawBackGradient(Graphics2D g2d, Rectangle2D rectangle, BiColor colors, int height) {
if (colors != null) {
- GradientPaint gragient = new GradientPaint(0, (float)(rectangle.getHeight()-height), colors.getBottomColor(), 0, (float) rectangle.getHeight(), colors.getTopColor());
- g2d.setPaint(gragient);
- g2d.fill(rectangle);
+ GradientPaint gragient = new GradientPaint(0, (float)(rectangle.getHeight()-height), colors.getBottomColor(), 0, (float) rectangle.getHeight(), colors.getTopColor());
+ g2d.setPaint(gragient);
+ g2d.fill(rectangle);
}
- }
+ }
-
+
@Override
- protected void paintGradient(Graphics2D g2d, Data data) {
- Integer headerBackgroundColor = data.getHeaderBackgroundColor();
- Integer headerGradientColor = data.getHeaderGradientColor();
+ protected void paintGradient(Graphics2D g2d, Dimension dim) {
+ if (headerBackgroundColor != null && headerGradientColor != null) {
+ BiColor biColor = new GradientType.BiColor(headerBackgroundColor, headerGradientColor);
+ BiColor firstLayer = gradientType.getFirstLayerColors(biColor);
+ BiColor secondLayer = gradientType.getSecondLayerColors(biColor);
- if (headerBackgroundColor != null && headerGradientColor != null) {
- BiColor biColor = new GradientType.BiColor(headerBackgroundColor, headerGradientColor);
+ if (isHorizontal()) {
+ //x -> y, y -> x
+ g2d.transform(new AffineTransform(0, 1, 1, 0, 0, 0));
+ dim.setSize(dim.height, dim.width);
+ }
- GradientType type = data.getGradientType();
- BiColor firstLayer = type.getFirstLayerColors(biColor);
- BiColor secondLayer = type.getSecondLayerColors(biColor);
+ int localGradientHeight = getGradientHeight();
+ if (localGradientHeight < 0) {
+ localGradientHeight = dim.height/2;
+ }
- Dimension dim = getDimensions(null, data);
+ Rectangle2D rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ localGradientHeight);
- if (isHorizontal()) {
- //x -> y, y -> x
- g2d.transform(new AffineTransform(0, 1, 1, 0, 0, 0));
- dim.setSize(dim.height, dim.width);
- }
-
- int localGradientHeight = getGradientHeight();
- if (localGradientHeight < 0) {
- localGradientHeight = dim.height/2;
- }
-
- Rectangle2D rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- localGradientHeight);
+ drawGradient(g2d, rect, firstLayer, localGradientHeight);
- drawGradient(g2d, rect, firstLayer, localGradientHeight);
-
- rect = new Rectangle2D.Float(
- 0,
- localGradientHeight,
- dim.width,
- dim.height);
-
- drawBackGradient(g2d, rect, firstLayer, localGradientHeight);
-
- int smallGradientHeight = localGradientHeight / 2;
-
- rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- smallGradientHeight);
+ rect = new Rectangle2D.Float(
+ 0,
+ localGradientHeight,
+ dim.width,
+ dim.height);
- drawGradient(g2d, rect, secondLayer, smallGradientHeight);
+ drawBackGradient(g2d, rect, firstLayer, localGradientHeight);
- rect = new Rectangle2D.Float(
- 0,
- dim.height-smallGradientHeight,
- dim.width,
- dim.height);
-
- drawBackGradient(g2d, rect, secondLayer, smallGradientHeight);
- }
+ int smallGradientHeight = localGradientHeight / 2;
+
+ rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ smallGradientHeight);
+
+ drawGradient(g2d, rect, secondLayer, smallGradientHeight);
+
+ rect = new Rectangle2D.Float(
+ 0,
+ dim.height-smallGradientHeight,
+ dim.width,
+ dim.height);
+
+ drawBackGradient(g2d, rect, secondLayer, smallGradientHeight);
+ }
}
-
+
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -28,17 +28,14 @@
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
-import java.io.Serializable;
-import java.util.Date;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.PngRenderer;
-import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
+import org.ajax4jsf.util.HtmlDimensions;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.ajax4jsf.util.NumericDataOutputStream;
import org.richfaces.renderkit.html.images.GradientType;
import org.richfaces.renderkit.html.images.GradientType.BiColor;
import org.richfaces.skin.Skin;
@@ -51,79 +48,113 @@
*/
public class BaseGradient extends Java2Dresource {
- private final int width;
- private final int height;
- private final int gradientHeight;
- private final String baseColor;
- private final String gradientColor;
- private final boolean horizontal;
+ private final int width;
+ private final int height;
+ private final int gradientHeight;
+ private final String baseColor;
+ private final String gradientColor;
+ private final boolean horizontal;
- public BaseGradient(int width, int height, int gradientHeight, String baseColor, String gradientColor, boolean horizontal) {
- super();
- this.width = width;
- this.height = height;
- this.gradientHeight = gradientHeight;
- this.baseColor = baseColor != null ? baseColor : Skin.headerBackgroundColor;
- this.gradientColor = gradientColor != null ? gradientColor : Skin.headerGradientColor;
- this.horizontal = horizontal;
+ protected Integer headerBackgroundColor;
+ protected Integer headerGradientColor;
+ protected GradientType gradientType;
- setRenderer(new PngRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- public BaseGradient(int width, int height, int gradientHeight) {
- this(width, height, gradientHeight, null, null, false);
- }
+ private void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Integer baseIntColor = null;
+ Integer headerIntColor = null;
+ String gradientTypeString = null;
- public BaseGradient(int width, int height, int gradientHeight, String baseColor, String gradientColor) {
- this(width, height, gradientHeight, baseColor, gradientColor, false);
- }
+ if (baseIntColor == null) {
+ baseIntColor = getColorValueParameter(context, baseColor, false);
+ }
- public BaseGradient(int width, int height) {
- this(width, height, height);
- }
+ if (headerIntColor == null) {
+ headerIntColor = getColorValueParameter(context, gradientColor, false);
+ }
- public BaseGradient(int width, int height, String baseColor, String gradientColor) {
- this(width, height, height, baseColor, gradientColor);
- }
+ if (!(baseIntColor == null && headerIntColor == null)) {
+ if (baseIntColor == null) {
+ baseIntColor = getColorValueParameter(context, baseColor, true);
+ }
- public BaseGradient() {
- this(30, 50, 20);
- }
+ if (headerIntColor == null) {
+ headerIntColor = getColorValueParameter(context, gradientColor, true);
+ }
+ }
- public BaseGradient(String baseColor, String gradientColor) {
- this(30, 50, 20, baseColor, gradientColor);
- }
-
- public BaseGradient(int width, int height, int gradientHeight, boolean horizontal) {
- this(width, height, gradientHeight, null, null, horizontal);
- }
-
- public BaseGradient(int width, int height, boolean horizontal) {
- this(width, height, horizontal ? width : height, null, null, horizontal);
- }
-
- public BaseGradient(int width, int height, String baseColor, String gradientColor, boolean horizontal) {
- this(width, height, horizontal ? width : height, baseColor, gradientColor, horizontal);
- }
+ this.headerBackgroundColor = baseIntColor;
+ this.headerGradientColor = headerIntColor;
- public BaseGradient(boolean horizontal) {
- this(30, 50, 20, null, null, horizontal);
- }
-
- public BaseGradient(String baseColor, String gradientColor, boolean horizontal) {
- this(30, 50, 20, baseColor, gradientColor, horizontal);
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return new Dimension(width, height);
- }
+ if (gradientTypeString == null || gradientTypeString.length() == 0) {
+ gradientTypeString = getValueParameter(context, Skin.gradientType);
+ }
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return new Dimension(width, height);
- }
+ this.gradientType = GradientType.getByParameter(gradientTypeString);
+ }
+
+ 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;
+ this.baseColor = baseColor != null ? baseColor : Skin.headerBackgroundColor;
+ this.gradientColor = gradientColor != null ? gradientColor : Skin.headerGradientColor;
+ this.horizontal = horizontal;
- /**
+ initialize();
+ }
+
+ public BaseGradient(int width, int height, int gradientHeight) {
+ this(width, height, gradientHeight, null, null, false);
+ }
+
+ public BaseGradient(int width, int height, int gradientHeight, String baseColor, String gradientColor) {
+ this(width, height, gradientHeight, baseColor, gradientColor, false);
+ }
+
+ public BaseGradient(int width, int height) {
+ this(width, height, height);
+ }
+
+ public BaseGradient(int width, int height, String baseColor, String gradientColor) {
+ this(width, height, height, baseColor, gradientColor);
+ }
+
+ public BaseGradient() {
+ this(30, 50, 20);
+ }
+
+ public BaseGradient(String baseColor, String gradientColor) {
+ this(30, 50, 20, baseColor, gradientColor);
+ }
+
+ public BaseGradient(int width, int height, int gradientHeight, boolean horizontal) {
+ this(width, height, gradientHeight, null, null, horizontal);
+ }
+
+ public BaseGradient(int width, int height, boolean horizontal) {
+ this(width, height, horizontal ? width : height, null, null, horizontal);
+ }
+
+ public BaseGradient(int width, int height, String baseColor, String gradientColor, boolean horizontal) {
+ this(width, height, horizontal ? width : height, baseColor, gradientColor, horizontal);
+ }
+
+ public BaseGradient(boolean horizontal) {
+ this(30, 50, 20, null, null, horizontal);
+ }
+
+ public BaseGradient(String baseColor, String gradientColor, boolean horizontal) {
+ this(30, 50, 20, baseColor, gradientColor, horizontal);
+ }
+
+ public Dimension getDimension() {
+ return new Dimension(width, height);
+ }
+
+ /**
* @return the gradientHeight
*/
protected int getGradientHeight() {
@@ -152,222 +183,139 @@
}
protected void drawGradient(Graphics2D g2d, Shape shape, BiColor colors, int height) {
- if (colors != null) {
- GradientPaint gragient = new GradientPaint(0, 0, colors.getTopColor(), 0, height, colors.getBottomColor());
- g2d.setPaint(gragient);
- g2d.fill(shape);
+ if (colors != null) {
+ GradientPaint gragient = new GradientPaint(0, 0, colors.getTopColor(), 0, height, colors.getBottomColor());
+ g2d.setPaint(gragient);
+ g2d.fill(shape);
+ }
}
- }
- protected void paint(ResourceContext resourceContext, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+ @Override
+ protected void paint(Graphics2D graphics2d, Dimension dimension) {
+ super.paint(graphics2d, dimension);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- Data data = (Data) restoreData(resourceContext);
- if (data != null) {
- paintGradient(g2d, data);
- }
- }
+ graphics2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ paintGradient(graphics2d, dimension);
+ }
+
/**
* @param g2d
* @param data
*/
- protected void paintGradient(Graphics2D g2d, Data data) {
- Integer headerBackgroundColor = data.getHeaderBackgroundColor();
- Integer headerGradientColor = data.getHeaderGradientColor();
+ protected void paintGradient(Graphics2D g2d, Dimension dim) {
+ if ((headerBackgroundColor != null || headerGradientColor != null) && gradientType != null) {
+ BiColor biColor = new GradientType.BiColor(headerBackgroundColor, headerGradientColor);
- if (headerBackgroundColor != null && headerGradientColor != null) {
- BiColor biColor = new GradientType.BiColor(headerBackgroundColor, headerGradientColor);
+ BiColor firstLayer = gradientType.getFirstLayerColors(biColor);
+ BiColor secondLayer = gradientType.getSecondLayerColors(biColor);
- GradientType type = data.getGradientType();
- BiColor firstLayer = type.getFirstLayerColors(biColor);
- BiColor secondLayer = type.getSecondLayerColors(biColor);
+ if (horizontal) {
+ //x -> y, y -> x
+ g2d.transform(new AffineTransform(0, 1, 1, 0, 0, 0));
+ dim.setSize(dim.height, dim.width);
+ }
- Dimension dim = getDimensions(null, data);
+ int localGradientHeight = this.gradientHeight;
+ if (localGradientHeight < 0) {
+ localGradientHeight = dim.height;
+ }
- if (horizontal) {
- //x -> y, y -> x
- g2d.transform(new AffineTransform(0, 1, 1, 0, 0, 0));
- dim.setSize(dim.height, dim.width);
- }
-
- int localGradientHeight = this.gradientHeight;
- if (localGradientHeight < 0) {
- localGradientHeight = dim.height;
- }
-
- Rectangle2D rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- dim.height);
+ Rectangle2D rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ dim.height);
- drawGradient(g2d, rect, firstLayer, localGradientHeight);
-
- int smallGradientHeight = localGradientHeight / 2;
-
- rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- smallGradientHeight);
+ drawGradient(g2d, rect, firstLayer, localGradientHeight);
- drawGradient(g2d, rect, secondLayer, smallGradientHeight);
- }
- }
+ int smallGradientHeight = localGradientHeight / 2;
- protected void restoreData(Data data, Zipper2 zipper2) {
- if (zipper2.hasMore()) {
- data.setHeaderBackgroundColor(Integer.valueOf(zipper2.nextIntColor()));
- data.setHeaderGradientColor(Integer.valueOf(zipper2.nextIntColor()));
- data.setGradientType(GradientType.values()[zipper2.nextByte()]);
- }
- }
+ rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ smallGradientHeight);
- protected Object deserializeData(byte[] objectArray) {
- Data data = createData();
- if (objectArray != null) {
- Zipper2 zipper2 = new Zipper2(objectArray);
- restoreData(data, zipper2);
+ drawGradient(g2d, rect, secondLayer, smallGradientHeight);
+ }
}
- return data;
- }
+ @Override
+ protected void readState(FacesContext context, NumericDataInputStream stream) {
+ super.readState(context, stream);
- protected Data createData() {
- return new Data();
- }
-
- private Integer decodeColor(String value) {
- if (value !=null && value.length() != 0) {
- return Integer.valueOf(HtmlColor.decode(value).getRGB());
- } else {
- return null;
+ this.headerBackgroundColor = stream.readInt();
+ this.headerGradientColor = stream.readInt();
+ this.gradientType = GradientType.values()[stream.readByte()];
}
- }
- protected void saveData(FacesContext context, Data data, Object parameterData) {
- Integer baseIntColor = null;
- Integer headerIntColor = null;
- String gradientTypeString = null;
+ @Override
+ protected void writeState(FacesContext context,
+ NumericDataOutputStream stream) {
+ super.writeState(context, stream);
- if (baseIntColor == null) {
- baseIntColor = getColorValueParameter(context, baseColor, false);
+ stream.writeInt(this.headerBackgroundColor);
+ stream.writeInt(this.headerGradientColor);
+ stream.writeByte((byte) this.gradientType.ordinal());
}
-
- if (headerIntColor == null) {
- headerIntColor = getColorValueParameter(context, gradientColor, false);
+
+ private Integer decodeColor(String value) {
+ if (value !=null && value.length() != 0) {
+ return Integer.valueOf(HtmlColor.decode(value).getRGB());
+ } else {
+ return null;
+ }
}
- if (!(baseIntColor == null && headerIntColor == null)) {
- if (baseIntColor == null) {
- baseIntColor = getColorValueParameter(context, baseColor, true);
- }
-
- if (headerIntColor == null) {
- headerIntColor = getColorValueParameter(context, gradientColor, true);
- }
+ public boolean isCacheable() {
+ return true;
}
- data.setHeaderBackgroundColor(baseIntColor);
- data.setHeaderGradientColor(headerIntColor);
+ protected String getValueParameter(FacesContext context, String name) {
+ SkinFactory skinFactory = SkinFactory.getInstance();
- if (gradientTypeString == null || gradientTypeString.length() == 0) {
- gradientTypeString = getValueParameter(context, Skin.gradientType);
- }
+ Skin skin = skinFactory.getSkin(context);
+ String value = (String) skin.getParameter(context, name);
- data.setGradientType(GradientType.getByParameter(gradientTypeString));
- }
+ if (value == null || value.length() == 0) {
+ skin = skinFactory.getDefaultSkin(context);
+ value = (String) skin.getParameter(context, name);
+ }
- protected Object getDataToStore(FacesContext context, Object data) {
- Data dataObject = createData();
- saveData(context, dataObject, data);
-
- return dataObject.toByteArray();
- }
-
- public boolean isCacheable() {
- return true;
- }
-
-
- protected String getValueParameter(FacesContext context, String name) {
- SkinFactory skinFactory = SkinFactory.getInstance();
-
- Skin skin = skinFactory.getSkin(context);
- String value = (String) skin.getParameter(context, name);
-
- if (value == null || value.length() == 0) {
- skin = skinFactory.getDefaultSkin(context);
- value = (String) skin.getParameter(context, name);
+ return value;
}
- return value;
- }
+ protected Integer getColorValueParameter(FacesContext context, String name, boolean useDefault) {
+ Skin skin;
+ if (useDefault) {
+ skin = SkinFactory.getInstance().getDefaultSkin(context);
+ } else {
+ skin = SkinFactory.getInstance().getSkin(context);
+ }
- protected Integer getColorValueParameter(FacesContext context, String name, boolean useDefault) {
- Skin skin;
- if (useDefault) {
- skin = SkinFactory.getInstance().getDefaultSkin(context);
- } else {
- skin = SkinFactory.getInstance().getSkin(context);
+ return decodeColor((String) skin.getParameter(context,name));
}
- return decodeColor((String) skin.getParameter(context,name));
- }
+ protected Integer getHeight(FacesContext context, String heightParamName) {
+ SkinFactory skinFactory = SkinFactory.getInstance();
+ Skin skin = skinFactory.getSkin(context);
- protected static class Data implements Serializable {
- public Data() {
- }
+ String height = (String) skin.getParameter(context, heightParamName);
+ if (height == null || height.length() == 0) {
+ skin = skinFactory.getDefaultSkin(context);
+ height = (String) skin.getParameter(context, heightParamName);
+ }
- /**
- *
- */
- private static final long serialVersionUID = 1732700513743861250L;
- private Integer headerBackgroundColor;
- private Integer headerGradientColor;
- private GradientType gradientType;
-
- public byte[] toByteArray() {
- if (headerBackgroundColor != null && headerGradientColor != null && gradientType != null) {
- byte[] ret = new byte[7];
- new Zipper2(ret).addColor(headerBackgroundColor.intValue()).addColor(headerGradientColor.intValue()).
- addByte((byte) gradientType.ordinal());
- return ret;
- } else {
- return null;
- }
- }
-
- public Integer getHeaderBackgroundColor() {
- return headerBackgroundColor;
- }
-
- public void setHeaderBackgroundColor(Integer headerBackgroundColor) {
- this.headerBackgroundColor = headerBackgroundColor;
- }
-
- public Integer getHeaderGradientColor() {
- return headerGradientColor;
- }
-
- public void setHeaderGradientColor(Integer headerGradientColor) {
- this.headerGradientColor = headerGradientColor;
- }
-
- public GradientType getGradientType() {
- return gradientType;
- }
-
- public void setGradientType(GradientType gradientType) {
- this.gradientType = gradientType;
- }
-
+ if (height != null && height.length() != 0) {
+ return Integer.valueOf(HtmlDimensions.decode(height).intValue());
+ } else {
+ return Integer.valueOf(16);
+ }
}
-
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -28,19 +28,12 @@
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.Map;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.PngRenderer;
-import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.HtmlDimensions;
-import org.ajax4jsf.util.Zipper2;
+import org.ajax4jsf.util.NumericDataInputStream;
import org.richfaces.renderkit.html.images.GradientAlignment;
import org.richfaces.renderkit.html.images.GradientType;
import org.richfaces.renderkit.html.images.GradientType.BiColor;
@@ -54,278 +47,209 @@
*/
public class CustomizeableGradient extends Java2Dresource {
- private Dimension dimension = new Dimension(20, 500);
+ protected Dimension dimension = new Dimension(20, 500);
- public CustomizeableGradient() {
- super();
+ protected Integer gradientColor;
+ protected Integer baseColor;
+ protected Integer gradientHeight = 22;
- setRenderer(new PngRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimension;
- }
+ protected GradientType gradientType;
+ protected GradientAlignment gradientAlignment;
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimension;
- }
+ public CustomizeableGradient() {
+ super(ImageType.PNG);
+
+ String gradientTypeString = safeTrim(getValueParameter(FacesContext.getCurrentInstance(), Skin.gradientType));
+ if (gradientTypeString != null && gradientTypeString.length() != 0) {
+ gradientType = GradientType.getByParameter(gradientTypeString);
+ }
+ }
- private void drawRectangle(Graphics2D g2d, Rectangle2D rect, BiColor biColor, boolean useTop) {
- if (biColor != null) {
- Color color = useTop ? biColor.getTopColor() : biColor.getBottomColor();
- g2d.setColor(color);
- g2d.fill(rect);
+ public Dimension getDimension() {
+ return dimension;
}
- }
- private void drawGradient(Graphics2D g2d, Rectangle2D rectangle, BiColor colors, int height) {
- if (colors != null) {
- GradientPaint gragient = new GradientPaint(0, 0, colors.getTopColor(), 0, height, colors.getBottomColor());
- g2d.setPaint(gragient);
- g2d.fill(rectangle);
+ private void drawRectangle(Graphics2D g2d, Rectangle2D rect, BiColor biColor, boolean useTop) {
+ if (biColor != null) {
+ Color color = useTop ? biColor.getTopColor() : biColor.getBottomColor();
+ g2d.setColor(color);
+ g2d.fill(rect);
+ }
}
- }
- protected void paint(ResourceContext resourceContext, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
+ private void drawGradient(Graphics2D g2d, Rectangle2D rectangle, BiColor colors, int height) {
+ if (colors != null) {
+ GradientPaint gragient = new GradientPaint(0, 0, colors.getTopColor(), 0, height, colors.getBottomColor());
+ g2d.setPaint(gragient);
+ g2d.fill(rectangle);
+ }
+ }
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ protected void paint(Graphics2D g2d, Dimension dim) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- Data dataToStore = (Data) restoreData(resourceContext);
- if (dataToStore != null) {
- BiColor biColor = new GradientType.BiColor(dataToStore.getGradientColor(), dataToStore.getBaseColor());
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
- GradientType type = dataToStore.getGradientType();
- BiColor firstLayer = type.getFirstLayerColors(biColor);
- BiColor secondLayer = type.getSecondLayerColors(biColor);
+ if ((gradientColor != null || baseColor != null) && gradientType != null &&
+ gradientAlignment != null) {
- Dimension dim = getDimensions(resourceContext);
- int gradientHeight = dataToStore.getGradientHeight();
-
- Rectangle2D rect =
- new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- dim.height);
+ paintGradient(g2d, dim);
+ }
+ }
- GradientAlignment gradientAlignment = dataToStore.getGradientAlignment();
- int topRectangleHeight = gradientAlignment.getTopRectangleHeight(dim.height, gradientHeight);
- int bottomRectangleHeight = gradientAlignment.getBottomRectangleHeight(dim.height, gradientHeight);
+ protected void paintGradient(Graphics2D g2d, Dimension dim) {
+ BiColor biColor = new GradientType.BiColor(gradientColor, baseColor);
+ BiColor firstLayer = gradientType.getFirstLayerColors(biColor);
+ BiColor secondLayer = gradientType.getSecondLayerColors(biColor);
- rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- topRectangleHeight);
+ Rectangle2D rect =
+ new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ dim.height);
- drawRectangle(g2d, rect, firstLayer, true);
- drawRectangle(g2d, rect, secondLayer, true);
+ int topRectangleHeight = gradientAlignment.getTopRectangleHeight(dim.height, gradientHeight);
+ int bottomRectangleHeight = gradientAlignment.getBottomRectangleHeight(dim.height, gradientHeight);
- rect = new Rectangle2D.Float(
- 0,
- dim.height - bottomRectangleHeight,
- dim.width,
- dim.height);
+ rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ topRectangleHeight);
- drawRectangle(g2d, rect, firstLayer, false);
- drawRectangle(g2d, rect, secondLayer, false);
+ drawRectangle(g2d, rect, firstLayer, true);
+ drawRectangle(g2d, rect, secondLayer, true);
- g2d.transform(AffineTransform.getTranslateInstance(0, topRectangleHeight));
+ rect = new Rectangle2D.Float(
+ 0,
+ dim.height - bottomRectangleHeight,
+ dim.width,
+ dim.height);
- rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- dim.height);
+ drawRectangle(g2d, rect, firstLayer, false);
+ drawRectangle(g2d, rect, secondLayer, false);
- drawGradient(g2d, rect, firstLayer, gradientHeight);
+ g2d.transform(AffineTransform.getTranslateInstance(0, topRectangleHeight));
- rect = new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- gradientHeight / 2);
+ rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ dim.height);
- drawGradient(g2d, rect, secondLayer, gradientHeight / 2);
- }
- }
+ drawGradient(g2d, rect, firstLayer, gradientHeight);
- protected Object deserializeData(byte[] objectArray) {
- Data data = new Data();
- if (objectArray != null) {
- Zipper2 zipper2 = new Zipper2(objectArray);
+ rect = new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ gradientHeight / 2);
- data.setGradientType(GradientType.values()[zipper2.nextByte()]);
- data.setGradientAlignment(GradientAlignment.values()[zipper2.nextByte()]);
- data.setGradientHeight(zipper2.nextInt());
- data.setBaseColor(Integer.valueOf(zipper2.nextIntColor()));
-
- if (zipper2.hasMore()) {
- data.setGradientColor(Integer.valueOf(zipper2.nextIntColor()));
- } else {
- data.setGradientColor(data.getBaseColor());
- }
+ drawGradient(g2d, rect, secondLayer, gradientHeight / 2);
}
+
+ private Integer decodeColor(String value) {
+ if (value !=null && value.length() != 0) {
+ return Integer.valueOf(HtmlColor.decode(value).getRGB());
+ } else {
+ return null;
+ }
+ }
- return data;
- }
+ @Override
+ protected void readState(FacesContext context, NumericDataInputStream stream) {
+ super.readState(context, stream);
- private Integer decodeColor(String value) {
- if (value !=null && value.length() != 0) {
- return Integer.valueOf(HtmlColor.decode(value).getRGB());
- } else {
- return null;
+ this.baseColor = stream.readIntColor();
+ this.gradientColor = stream.readIntColor();
+ this.gradientHeight = stream.readInt();
+ this.gradientAlignment = GradientAlignment.values()[stream.readByte()];
+ this.gradientType = GradientType.values()[stream.readByte()];
}
- }
- private Integer decodeHeight(String value) {
- if (value !=null && value.length() != 0) {
- return HtmlDimensions.decode(value).intValue();
- } else {
- return null;
+ protected void writeState(FacesContext context, org.ajax4jsf.util.NumericDataOutputStream stream) {
+ super.writeState(context, stream);
+
+ stream.writeIntColor(this.baseColor);
+ stream.writeIntColor(this.gradientColor);
+ stream.writeInt(this.gradientHeight);
+ stream.writeByte((byte) this.gradientAlignment.ordinal());
+ stream.writeByte((byte) this.gradientType.ordinal());
+ };
+
+ protected static String safeTrim(String s) {
+ return s != null ? s.trim() : null;
}
- }
-
- protected static String safeTrim(String s) {
- return s != null ? s.trim() : null;
- }
- protected Object getDataToStore(FacesContext context, Object parameterData) {
- Data data = new Data();
+ public boolean isCacheable() {
+ return true;
+ }
- Integer baseIntColor = null;
- Integer gradientIntColor = null;
- Integer gradientHeight = null;
+ protected String getValueParameter(FacesContext context, String name) {
+ SkinFactory skinFactory = SkinFactory.getInstance();
- String gradientTypeString = null;
- String alignmentString = null;
+ Skin skin = skinFactory.getSkin(context);
+ String value = (String) skin.getParameter(context, name);
- if (parameterData instanceof Map<?, ?>) {
- Map<?, ?> map = (Map<?, ?>) parameterData;
+ if (value == null || value.length() == 0) {
+ skin = skinFactory.getDefaultSkin(context);
+ value = (String) skin.getParameter(context, name);
+ }
- gradientTypeString = safeTrim((String) map.get(Skin.gradientType));
- alignmentString = safeTrim((String) map.get("valign"));
- baseIntColor = decodeColor((String) map.get("baseColor"));
- gradientIntColor = decodeColor((String) map.get("gradientColor"));
- gradientHeight = decodeHeight((String) map.get("gradientHeight"));
+ return value;
}
- data.setBaseColor(baseIntColor);
- if (gradientIntColor != null) {
- data.setGradientColor(gradientIntColor);
- } else {
- data.setGradientColor(baseIntColor);
+ public Integer getGradientColor() {
+ return gradientColor;
}
+
+ public void setGradientColor(Integer headerBackgroundColor) {
+ this.gradientColor = headerBackgroundColor;
+ }
+
+ public void setGradientColorString(String colorString) {
+ setGradientColor(decodeColor(colorString));
+ }
+
+ public Integer getBaseColor() {
+ return baseColor;
+ }
+
+ public void setBaseColor(Integer headerGradientColor) {
+ this.baseColor = headerGradientColor;
+ }
- if (gradientHeight == null) {
- gradientHeight = 22;
+ public void setBaseColorString(String colorString) {
+ setBaseColor(decodeColor(colorString));
}
- data.setGradientHeight(gradientHeight);
- if (gradientTypeString == null || gradientTypeString.length() == 0) {
- gradientTypeString = safeTrim(getValueParameter(context, Skin.gradientType));
+ public GradientType getGradientType() {
+ return gradientType;
}
- data.setGradientType(GradientType.getByParameter(gradientTypeString));
- data.setGradientAlignment(GradientAlignment.getByParameter(alignmentString));
+ public void setGradientType(GradientType gradientType) {
+ this.gradientType = gradientType;
+ }
- return data.toByteArray();
- }
-
- public boolean isCacheable() {
- return true;
- }
-
- protected String getValueParameter(FacesContext context, String name) {
- SkinFactory skinFactory = SkinFactory.getInstance();
-
- Skin skin = skinFactory.getSkin(context);
- String value = (String) skin.getParameter(context, name);
-
- if (value == null || value.length() == 0) {
- skin = skinFactory.getDefaultSkin(context);
- value = (String) skin.getParameter(context, name);
+ public GradientAlignment getGradientAlignment() {
+ return gradientAlignment;
}
- return value;
- }
-
- protected static class Data implements Serializable {
- public Data() {
+ public void setGradientAlignment(GradientAlignment gradientAlignment) {
+ this.gradientAlignment = gradientAlignment;
}
- /**
- *
- */
- private static final long serialVersionUID = 1732700513743861250L;
- private Integer gradientColor;
- private Integer baseColor;
- private Integer gradientHeight;
-
- private GradientType gradientType;
- private GradientAlignment gradientAlignment;
-
- public byte[] toByteArray() {
- if (baseColor != null && gradientColor != null && gradientHeight != null && gradientAlignment != null && gradientType != null) {
- byte[] ret = new byte[12];
- new Zipper2(ret)
- .addByte((byte) gradientType.ordinal())
- .addByte((byte) gradientAlignment.ordinal())
- .addInt(gradientHeight.intValue())
- .addColor(baseColor.intValue())
- .addColor(gradientColor.intValue());
-
- return ret;
- } else {
- return null;
- }
- }
-
- public Integer getGradientColor() {
- return gradientColor;
- }
-
- public void setGradientColor(Integer headerBackgroundColor) {
- this.gradientColor = headerBackgroundColor;
- }
-
- public Integer getBaseColor() {
- return baseColor;
- }
-
- public void setBaseColor(Integer headerGradientColor) {
- this.baseColor = headerGradientColor;
- }
-
- public GradientType getGradientType() {
- return gradientType;
- }
-
- public void setGradientType(GradientType gradientType) {
- this.gradientType = gradientType;
- }
-
- public GradientAlignment getGradientAlignment() {
- return gradientAlignment;
- }
-
- public void setGradientAlignment(GradientAlignment gradientAlignment) {
- this.gradientAlignment = gradientAlignment;
- }
-
public Integer getGradientHeight() {
- return gradientHeight;
+ return gradientHeight;
}
public void setGradientHeight(Integer gradientHeight) {
- this.gradientHeight = gradientHeight;
+ this.gradientHeight = gradientHeight;
}
- }
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -25,12 +25,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlDimensions;
-import org.ajax4jsf.util.Zipper2;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.ajax4jsf.util.NumericDataOutputStream;
import org.richfaces.renderkit.html.BaseGradient;
import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
/**
* Created 23.02.2008
@@ -41,102 +39,52 @@
public abstract class BaseControlBackgroundImage extends BaseGradient {
- private static final Dimension DIMENSION = new Dimension(1, 1);
+ private static final Dimension DEFAULT_DIMENSION = new Dimension(1, 1);
- public BaseControlBackgroundImage(String baseColor, String gradientColor, int width) {
+ private Dimension dimension = null;
+
+ //TODO - lazy initialize?
+ private Integer height = getHeight(FacesContext.getCurrentInstance(), Skin.generalSizeFont);
+
+ public BaseControlBackgroundImage(String baseColor, String gradientColor, int width) {
super(width, -1, baseColor, gradientColor);
}
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- Data data2 = (Data) data;
- if (data != null) {
- return new Dimension(super.getDimensions(facesContext, data).width, data2.getHeight());
- } else {
- return DIMENSION;
- }
+ @Override
+ public Dimension getDimension() {
+ if (dimension != null) {
+ return dimension;
+ }
+
+ return DEFAULT_DIMENSION;
}
@Override
- protected Dimension getDimensions(ResourceContext resourceContext) {
- Data data = (Data) restoreData(resourceContext);
- if (data != null) {
- return new Dimension(super.getDimensions(resourceContext).width, data.getHeight());
- } else {
- return DIMENSION;
- }
+ protected void writeState(FacesContext context,
+ NumericDataOutputStream stream) {
+ super.writeState(context, stream);
+
+ stream.writeInt(this.height);
}
- protected final Integer getHeight(FacesContext context, String heightParamName) {
- SkinFactory skinFactory = SkinFactory.getInstance();
- Skin skin = skinFactory.getSkin(context);
-
- String height = (String) skin.getParameter(context, heightParamName);
- if (height == null || height.length() == 0) {
- skin = skinFactory.getDefaultSkin(context);
- height = (String) skin.getParameter(context, heightParamName);
- }
-
- if (height != null && height.length() != 0) {
- return Integer.valueOf(HtmlDimensions.decode(height).intValue());
- } else {
- return Integer.valueOf(16);
- }
+ @Override
+ protected void readState(FacesContext context, NumericDataInputStream stream) {
+ super.readState(context, stream);
+
+ this.height = stream.readInt();
}
- protected Integer getHeight(FacesContext context) {
- return getHeight(context, Skin.generalSizeFont);
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ super.restoreState(context, state);
+
+ //TODO - create a special method?
+ this.gradientType = GradientType.PLAIN;
}
-
- public boolean isCacheable() {
- return true;
- }
-
@Override
- protected org.richfaces.renderkit.html.BaseGradient.Data createData() {
- return new Data();
+ public Object saveState(FacesContext context) {
+ return super.saveState(context);
}
- @Override
- protected void saveData(FacesContext context, org.richfaces.renderkit.html.BaseGradient.Data data, Object parameterData) {
- super.saveData(context, data, parameterData);
- Data d = ((Data) data);
- d.setGradientType(GradientType.PLAIN);
- d.setHeight(getHeight(context));
- }
-
- protected void restoreData(org.richfaces.renderkit.html.BaseGradient.Data data, Zipper2 zipper2) {
- if (zipper2.hasMore()) {
- ((Data) data).setHeight(zipper2.nextInt());
- super.restoreData(data, zipper2);
- }
- }
-
- protected static class Data extends BaseGradient.Data {
-
- /**
- *
- */
- private static final long serialVersionUID = -1499766195614003931L;
-
- private Integer height;
-
- @Override
- public byte[] toByteArray() {
- byte[] bs = super.toByteArray();
- byte[] result = new byte[(bs != null ? bs.length : 0) + 4];
- new Zipper2(result).addInt(height).addBytes(bs);
-
- return result;
- }
-
- public Integer getHeight() {
- return height;
- }
-
- public void setHeight(Integer height) {
- this.height = height;
- }
-
- };
}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,139 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-
-/**
- * implementation of the default CANCEL icon renderer
- * @author Anton Belevich
- * @since 3.2.0
- *
- */
-public class CancelControlIcon extends Java2Dresource {
-
- protected static final String ICON_COLOR = "#971715";
- protected static final String ICON_BORDER = "#FFFFFF";
- protected static final String ALTERNATE_COLOR = "#ED6161";
-
- private static final Dimension dimensions = new Dimension(11, 11);
-
- public CancelControlIcon() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
- Zipper2 zipper = new Zipper2(objectArray);
- return new Color[] {zipper.nextColor(), zipper.nextColor()};
- }
-
- protected Object getDataToStore(FacesContext context, Object data){
-
- byte [] ret = new byte[6];
-
- Color color = null;
- Zipper2 zipper = new Zipper2(ret);
-
- color = HtmlColor.decode(ICON_COLOR);
- zipper.addColor(color);
-
- color = HtmlColor.decode(ICON_BORDER);
- zipper.addColor(color);
-
- return ret;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- Color [] data = (Color[]) restoreData(context);
-
- Color iconColor = data[0];
- Color iconBorder = data[1];
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
-// g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-// g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_DEFAULT);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
-
- g2d.setColor(iconColor);
-
- Color altenateColor = HtmlColor.decode(ALTERNATE_COLOR);
- GradientPaint gradient = new GradientPaint(2,3,altenateColor,3,9,iconColor);
- g2d.setPaint(gradient);
-
- // draw cross
- g2d.drawLine(2, 3, 7, 8);
- g2d.drawLine(3, 3, 7, 7);
- g2d.drawLine(3, 2, 8, 7);
-
- g2d.drawLine(2, 7, 7, 2);
- g2d.drawLine(3, 7, 7, 3);
- g2d.drawLine(3, 8, 8, 3);
-
- //draw border
- g2d.setColor(iconBorder);
- g2d.drawLine(1, 3, 3, 5);
- g2d.drawLine(3, 5, 1, 7);
- g2d.drawLine(1, 7, 3, 9);
- g2d.drawLine(3, 9, 5, 7);
- g2d.drawLine(5, 7, 7, 9);
- g2d.drawLine(7, 9, 9, 7);
- g2d.drawLine(9, 7, 7, 5);
- g2d.drawLine(7, 5, 9, 3);
- g2d.drawLine(9, 3, 7, 1);
- g2d.drawLine(7, 1, 5, 3);
- g2d.drawLine(5, 3, 3, 1);
- g2d.drawLine(3, 1, 1, 3);
-
-
- }
-}
-
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImage.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImage.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,164 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author Anton Belevich
- * @since 3.2.0
- * ComboBox down image renderer
- */
-public class ComboBoxArrowImage extends Java2Dresource{
-
-
- protected static final String ICON_COLOR = "generalTextColor";
- protected static final String BACKGROUND_COLOR = "tabBackgroundColor";
- protected static final String BORDER_COLOR = "generalBackgroundColor";
-
- protected static final String DISABLED_ICON_COLOR = "tabDisabledTextColor";
- protected static final String DISABLED_BACKGROUND_COLOR = "tabBackgroundColor";
- protected static final String DISABLED_BORDER_COLOR = "generalBackgroundColor";
-
- private static final Dimension dimensions = new Dimension(15, 15);
-
- public ComboBoxArrowImage() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
- Zipper2 zipper = new Zipper2(objectArray);
- return new Color[] {zipper.nextColor(), zipper.nextColor(), zipper.nextColor()};
- }
-
- protected Object getDataToStore(FacesContext context, Object data) {
- return storeData(context, ICON_COLOR, BACKGROUND_COLOR, BORDER_COLOR);
- }
-
- protected Object storeData(FacesContext context, String colorSkinParam, String backgroundSkinParam, String borderSkinParam) {
-
- Skin skin = SkinFactory.getInstance().getSkin(context);
- Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
-
- byte [] ret = new byte[9];
-
- Color color = null;
- Zipper2 zipper = new Zipper2(ret);
-
- String color1 = (String) skin.getParameter(context, colorSkinParam);
-
- if (null == color1 || "".equals(color1)) {
- color1 = (String) defaultSkin.getParameter(context, colorSkinParam);
- }
-
- if (color1 == null) {
- color1 = "#FFFFFF";
- }
-
- color = HtmlColor.decode(color1);
-
- zipper.addColor(color);
-
- String color2 = (String) skin.getParameter(context, backgroundSkinParam);
- if (null == color2 || "".equals(color2))
- color2 = (String) defaultSkin.getParameter(context, backgroundSkinParam);
-
- if (color2 == null) {
- color2 = "#000000";
- }
-
- color = HtmlColor.decode(color2);
- zipper.addColor(color);
-
- String color3 = (String) skin.getParameter(context, borderSkinParam);
- if (null == color3 || "".equals(color3))
- color3 = (String) defaultSkin.getParameter(context, backgroundSkinParam);
-
- if (color3 == null) {
- color3 = "#000000";
- }
-
- color = HtmlColor.decode(color3);
- zipper.addColor(color);
-
- return ret;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- Color [] data = (Color[]) restoreData(context);
- Color textColor = data[0];
-// Color backgroundColor = data[1];
- Color borderColor = data[2];
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- if (textColor != null && borderColor != null && g2d != null) {
-
- g2d.setColor(textColor);
- g2d.translate(7, 5);
- paintBaseTriangle(g2d);
- g2d.translate(-7, -5);
-
- g2d.setColor(borderColor);
- g2d.drawLine(4, 5, 10, 5);
- g2d.drawLine(11, 6, 7, 10);
- g2d.drawLine(7, 10, 3, 6);
- }
- }
-
- protected void paintBaseTriangle(Graphics2D g2d) {
- for (int i = 0; i < 7; i++) {
- g2d.drawLine(-3 + i, 1, -3 + i, 1 + (i < 4 ? i : 6 - i));
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImageDisable.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImageDisable.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxArrowImageDisable.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,36 +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.renderkit.html.images;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Anton Belevich
- * @since 3.2.0
- * ComboBox disable arrow image renderer
- *
- */
-public class ComboBoxArrowImageDisable extends ComboBoxArrowImage{
-
- protected Object storeData(FacesContext context, String colorSkinParam, String backgroundSkinParam, String borderSkinParam) {
- return super.storeData(context, DISABLED_ICON_COLOR, BACKGROUND_COLOR, DISABLED_BORDER_COLOR);
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxButtonPressGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxButtonPressGradient.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/ComboBoxButtonPressGradient.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,36 +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.renderkit.html.images;
-
-import org.richfaces.renderkit.html.BaseGradient;
-import org.richfaces.skin.Skin;
-
-/**
- * @author Anton Belevich
- * @since 3.2.0
- */
-public class ComboBoxButtonPressGradient extends BaseGradient{
-
- public ComboBoxButtonPressGradient() {
- super(7,15 , 9, Skin.headerBackgroundColor, "headerGradientColor");
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/EditIcon.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/EditIcon.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/EditIcon.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,93 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-
-/**
- * implementation of the EDIT icon renderer
- * @author Anton Belevich
- * @since 3.2.0
- *
- */
-public class EditIcon extends Java2Dresource {
-
- protected static final String ICON_COLOR = "#FF0000";
-
- private static final Dimension dimensions = new Dimension(4, 4);
-
- public EditIcon() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
- Zipper2 zipper = new Zipper2(objectArray);
- return new Color[] {zipper.nextColor()};
- }
-
- protected Object getDataToStore(FacesContext context, Object data){
-
- byte [] ret = new byte[3];
-
- Color color = null;
- Zipper2 zipper = new Zipper2(ret);
-
- color = HtmlColor.decode(ICON_COLOR);
- zipper.addColor(color);
-
- return ret;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- Color [] data = (Color[]) restoreData(context);
- Color iconColor = data[0];
-
- g2d.setColor(iconColor);
- g2d.drawLine(0, 0, 0, 4);
- g2d.drawLine(0, 0, 4, 0);
- g2d.drawLine(1, 0, 1, 2);
- g2d.drawLine(2, 0, 2, 1);
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,45 +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.renderkit.html.images;
-
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-
-public class InputErrorIcon extends OneColorBasedResource {
-
- public InputErrorIcon() {
- super(6, 11, "warningColor");
- }
-
- /**
- * @see Java2Dresource#paint(ResourceContext, Graphics2D)
- */
- protected void paint(ResourceContext context, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setColor(getBasicColor());
- g2d.fillRect(3, 2, 2, 6);
- g2d.fillRect(3, 9, 2, 2);
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,122 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBase;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-import org.richfaces.skin.SkinFactory;
-
-public abstract class OneColorBasedResource extends Java2Dresource {
-
- private Dimension dimension;
-
- private String basicColorParamName;
-
- private Color basicColor;
-
- public OneColorBasedResource(int width, int height, final String basicColorParamName) {
- this.basicColorParamName = basicColorParamName;
- this.dimension = new Dimension(width, height);
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- /**
- * @see Java2Dresource#getDimensions(ResourceContext)
- */
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimension;
- }
-
- /**
- * @see Java2Dresource#getDimensions(FacesContext, Object)
- */
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimension;
- }
-
- /**
- * @see Java2Dresource#isCacheable(ResourceContext)
- */
- public boolean isCacheable(ResourceContext ctx) {
- return true;
- }
-
- /**
- * Gets value of basicColor field.
- * @return value of basicColor field
- */
- public Color getBasicColor() {
- return basicColor;
- }
-
- /**
- * @see InternetResourceBase#getDataToStore(FacesContext, Object)
- */
- protected Object getDataToStore(FacesContext context, Object data) {
- byte[] retVal = null;
- if (basicColor == null) {
- basicColor = getColorValueParameter(context, basicColorParamName);
- }
-
- if (basicColor != null) {
- retVal = new byte[3 * 1];
- new Zipper2(retVal).addColor(basicColor);
-
- return retVal;
- } else {
- return null;
- }
- }
-
- /**
- * @see InternetResourceBase#deserializeData(byte[])
- */
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray != null) {
- Zipper2 zipper2 = new Zipper2(objectArray);
- basicColor = zipper2.nextColor();
- }
-
- return objectArray;
- }
-
- private Color getColorValueParameter(FacesContext context, String name) {
- Color retVal = null;
- String color = (String) SkinFactory.getInstance().getSkin(context).getParameter(context, name);
- if (color != null && !color.trim().equals("")) {
- retVal = HtmlColor.decode(color);
- }
- return retVal;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SaveControlIcon.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SaveControlIcon.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SaveControlIcon.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,142 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-
-/**
- * implementation of the default OK icon renderer
- * @author Anton Belevich
- * @since 3.2.0
- *
- */
-public class SaveControlIcon extends Java2Dresource {
-
- protected static final String ICON_COLOR = "#5BC248";
- protected static final String ICON_SHADOW = "#006406";
- protected static final String ICON_BORDER = "#FFFFFF";
-
- private static final Dimension dimensions = new Dimension(11, 11);
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
- public SaveControlIcon() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
- Zipper2 zipper = new Zipper2(objectArray);
- return new Color[] {zipper.nextColor(), zipper.nextColor(), zipper.nextColor()};
- }
-
- protected Object getDataToStore(FacesContext context, Object data){
-
- byte [] ret = new byte[9];
-
- Color color = null;
- Zipper2 zipper = new Zipper2(ret);
-
- color = HtmlColor.decode(ICON_COLOR);
- zipper.addColor(color);
-
- color = HtmlColor.decode(ICON_SHADOW);
- zipper.addColor(color);
-
- color = HtmlColor.decode(ICON_BORDER);
- zipper.addColor(color);
-
- return ret;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- Color [] data = (Color[]) restoreData(context);
-
- Color iconColor = data[0];
- Color iconShadow = data[1];
- Color borderColor = data[2];
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- g2d.setColor(iconColor);
- g2d.drawLine(1, 6, 4, 9);
- g2d.drawLine(4, 9, 4, 8);
- g2d.drawLine(4, 8, 2, 6);
- g2d.drawLine(2, 5, 5, 8);
- g2d.drawLine(5, 8, 5, 6);
- g2d.drawLine(5, 6, 9, 2);
- g2d.drawLine(9, 2, 9, 3);
- g2d.drawLine(9, 3, 5, 7);
-
- //draw shadow
- g2d.setColor(iconShadow);
- g2d.drawLine(3, 5, 4, 6);
- g2d.drawLine(5, 9, 6, 8);
- g2d.drawLine(6, 8, 6, 7);
- g2d.drawLine(6, 7, 9, 4);
-
- // draw border
- g2d.setColor(borderColor);
- g2d.drawLine(0, 6, 4, 10);
- g2d.drawLine(4, 10, 5,10);
- g2d.drawLine(5,10,7,8);
- g2d.drawLine(7,8,7,7);
- g2d.drawLine(7,7,10,4);
- g2d.drawLine(10,4,10,1);
- g2d.drawLine(10,1,9,1);
- g2d.drawLine(9,1,5,5);
- g2d.drawLine(5,5,4,5);
- g2d.drawLine(4,5,3,4);
- g2d.drawLine(3,4,2,4);
- g2d.drawLine(2,4,0,6);
-
-
-
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,66 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-
-public abstract class SliderArrowBase extends Java2Dresource{
- private static final Dimension dimensions = new Dimension(7, 8);
-
- public SliderArrowBase() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- Integer color = (Integer) restoreData(context);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setColor(new Color(color.intValue()));
- g2d.drawLine(0,2,6,2);
- g2d.drawLine(1,3,5,3);
- g2d.drawLine(2,4,4,4);
- g2d.drawLine(3,5,3,5);
- }
-
- public boolean isCacheable() {
- return true;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowImage.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,56 +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.renderkit.html.images;
-
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.util.HtmlColor;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-public class SliderArrowImage extends SliderArrowBase {
- protected Object getDataToStore(FacesContext context, Object data) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
-
- String skinParameter = "generalTextColor";
- String tmp = (String) skin.getParameter(context, skinParameter);
- if (null == tmp || "".equals(tmp)) {
- Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
- tmp = (String) defaultSkin.getParameter(context, skinParameter);
- }
- int intValue = HtmlColor.decode(tmp ==null? "#000000":tmp).getRGB();
- // Serialize data as byte[]
- ByteBuffer buff = ByteBuffer.allocate(1*4);
- IntBuffer intBuffer = buff.asIntBuffer();
- intBuffer.put(intValue);
- return buff.array();
- }
-
- protected Object deserializeData(byte[] objectArray) {
- // restore color value from a byte[] array.
- int i = ByteBuffer.wrap(objectArray).asIntBuffer().get();
- return new Integer(i);
- }
-}
\ No newline at end of file
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonDown.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonDown.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonDown.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,71 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-public class SpinnerButtonDown extends SpinnerButtonImage {
- private static final Dimension dimensions = new Dimension(14, 7);
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
- Color[] color = (Color []) restoreData(context);
- Color triangleColor = color[0];
- Color borderColor = color[1];
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- g2d.setColor(triangleColor);
- g2d.drawLine(5,2,9,2);
- g2d.drawLine(6,3,8,3);
- g2d.drawLine(7,4,7,4);
-
- g2d.setColor(borderColor);
- g2d.drawLine(5, 1, 9, 1);
- g2d.drawLine(10, 2, 7, 5);
- g2d.drawLine(7, 5, 4, 2);
-
-
- }
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,30 +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.renderkit.html.images;
-
-import org.richfaces.renderkit.html.BaseGradient;
-
-public class SpinnerButtonGradient extends BaseGradient {
- public SpinnerButtonGradient() {
- super(30, 50, 20, "headerGradientColor", "headerBackgroundColor");
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonImage.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonImage.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonImage.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,82 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-public abstract class SpinnerButtonImage extends Java2Dresource {
-
- public SpinnerButtonImage() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
- Zipper2 zipper = new Zipper2(objectArray);
- return new Color[] {zipper.nextColor(), zipper.nextColor()};
- }
-
- protected Object getDataToStore(FacesContext context, Object data) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
- byte[] ret = new byte[6];
- Zipper2 zipper = new Zipper2(ret);
-
- String skinParameterTextColor = "generalTextColor";
- String generalTextColor = (String) skin.getParameter(context, skinParameterTextColor);
- if (null == generalTextColor || "".equals(generalTextColor)) {
- Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
- generalTextColor = (String) defaultSkin.getParameter(context, skinParameterTextColor);
- }
-
- Integer color = HtmlColor.decode( generalTextColor == null ? "#000000":generalTextColor ).getRGB();
-
- zipper.addColor(color);
-
- String skinParameterBackgroundColor = "controlBackgroundColor";
- String generalBackgroundColor = (String) skin.getParameter(context, skinParameterBackgroundColor);
-
- if (null == generalBackgroundColor || "".equals(generalBackgroundColor)) {
- Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
- generalBackgroundColor = (String) defaultSkin.getParameter(context, skinParameterBackgroundColor);
- }
-
- color = HtmlColor.decode( generalTextColor == null ? "#FFFFFF":generalBackgroundColor ).getRGB();
- zipper.addColor(color);
-
- return ret;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonUp.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonUp.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonUp.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,71 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-public class SpinnerButtonUp extends SpinnerButtonImage {
- private static final Dimension dimensions = new Dimension(14, 7);
-
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return dimensions;
- }
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return dimensions;
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
-
- Color [] data = (Color []) restoreData(context);
- Color textColor = data[0];
- Color borderColor = data[1];
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- g2d.setColor(textColor);
- g2d.drawLine(5,5,9,5);
- g2d.drawLine(6,4,8,4);
- g2d.drawLine(7,3,7,3);
-
- g2d.setColor(borderColor);
- g2d.drawLine(5, 6, 9, 6);
- g2d.drawLine(10, 5, 7, 2);
- g2d.drawLine(7, 2, 4, 5);
-
- }
-
-}
-
-
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,33 +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.renderkit.html.images;
-
-import org.richfaces.renderkit.html.BaseGradient;
-
-public class SpinnerFieldGradient extends BaseGradient {
-
- public SpinnerFieldGradient() {
- super(30, 50, 12, "additionalBackgroundColor", "controlBackgroundColor");
- }
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,182 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.util.Date;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.GifRenderer;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.Zipper2;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author Siarhej Chalipau
- *
- */
-public abstract class TriangleIconBase extends Java2Dresource {
-
- private static final Dimension DIMENSION = new Dimension(15, 15);
-
- protected static final String ICON_COLOR = "generalTextColor";
- //protected static final String BACKGROUND_COLOR = "tabBackgroundColor";
- protected static final String BORDER_COLOR = "generalBackgroundColor";
-
- protected static final String DISABLED_ICON_COLOR = "tabDisabledTextColor";
- //protected static final String DISABLED_BACKGROUND_COLOR = "tabBackgroundColor";
- protected static final String DISABLED_BORDER_COLOR = "generalBackgroundColor";
-
- public TriangleIconBase() {
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- abstract protected void paintImage(ResourceContext context, Graphics2D g2d, Color textColor, Color borderColor);
-
- protected void paintBaseTriangle(Graphics2D g2d) {
- for (int i = 0; i < 7; i++) {
- g2d.drawLine(-3 + i, 1, -3 + i, 1 + (i < 4 ? i : 6 - i));
- }
- }
-
- protected void paint(ResourceContext context, Graphics2D g2d) {
-
- Color [] data = (Color[]) restoreData(context);
- Color textColor = data[0];
- Color borderColor = data[1];
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
-// g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
-// g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
-
- if (textColor != null && borderColor != null && g2d != null) {
- paintImage(context, g2d, textColor, borderColor);
- }
-
- }
-
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return DIMENSION;
- }
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return DIMENSION;
- }
-
- /**
- * @param data - pass icon color and background color
- */
- protected Object getDataToStore(FacesContext context, Object data) {
- return getDataToStore(context, null, ICON_COLOR, null,
- BORDER_COLOR);
- }
-
- protected String getParameterValue(FacesContext context, Skin skin, Skin defaultSkin,
- String parameterName, String defaultParameterName) {
-
- String value = null;
-
- if (parameterName != null && parameterName.length() != 0) {
- value = (String) skin.getParameter(context, parameterName);
- if (value == null || value.length() == 0) {
- value = (String) defaultSkin.getParameter(context, parameterName);
- }
- }
-
- if (value == null || value.length() == 0) {
- if (defaultParameterName != null && defaultParameterName.length() != 0) {
- value = (String) skin.getParameter(context, defaultParameterName);
- if (value == null || value.length() == 0) {
- value = (String) defaultSkin.getParameter(context, defaultParameterName);
- }
- }
- }
-
- if (value == null) {
- return "#FFFFFF";
- }
-
- return value;
- }
-
- protected Object getDataToStore(FacesContext context,
- String iconColorParam,
- String defaultIconColorParam,
- String borderColorParam,
- String defaultBorderColorParam) {
- SkinFactory skinFactory = SkinFactory.getInstance();
- Skin skin = skinFactory.getSkin(context);
- Skin defaultSkin = skinFactory.getDefaultSkin(context);
-
- byte [] ret = new byte[6];
-
- Color color = null;
- Zipper2 zipper = new Zipper2(ret);
-
- String color1 = getParameterValue(context, skin, defaultSkin,
- iconColorParam,
- defaultIconColorParam);
-
- color = HtmlColor.decode(color1);
-
- zipper.addColor(color);
-
- String color2 = getParameterValue(context, skin, defaultSkin,
- borderColorParam,
- defaultBorderColorParam);
-
- color = HtmlColor.decode(color2);
- zipper.addColor(color);
-
- return ret;
- }
-
- protected Object deserializeData(byte[] objectArray) {
- if (objectArray == null) {
- return null;
- }
-
- Zipper2 zipper = new Zipper2(objectArray);
-
- return new Color[] {zipper.nextColor(), zipper.nextColor()};
- }
-
- public boolean isCacheable() {
- return true;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconDown.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconDown.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconDown.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,49 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author Siarhej Chalipau
- *
- */
-public class TriangleIconDown extends TriangleIconBase {
-
- protected void paintImage(ResourceContext context, Graphics2D g2d,
- Color textColor, Color borderColor) {
-
- g2d.setColor(textColor);
- g2d.translate(7, 5);
- paintBaseTriangle(g2d);
- g2d.translate(-7, -5);
-
- g2d.setColor(borderColor);
- g2d.drawLine(4, 5, 10, 5);
- g2d.drawLine(11, 6, 7, 10);
- g2d.drawLine(7, 10, 3, 6);
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconUp.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconUp.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconUp.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,44 +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.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author Siarhej Chalipau
- *
- */
-public class TriangleIconUp extends TriangleIconDown {
-
- protected void paintImage(ResourceContext context, Graphics2D g2d,
- Color textColor, Color borderColor) {
-
- g2d.translate(0, 14);
- g2d.scale(1, -1);
-
- super.paintImage(context, g2d, textColor, borderColor);
- }
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -39,6 +39,7 @@
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.ResourceContext;
+import org.richfaces.context.ApplicationContext;
import org.richfaces.util.RichfacesLogger;
import org.richfaces.util.Util;
import org.slf4j.Logger;
@@ -57,6 +58,8 @@
private String version;
+ private Date lastModified = null;
+
public AbstractBaseResource() {
super();
@@ -90,29 +93,37 @@
*/
//TODO optimize/review?
protected Date getLastModified(FacesContext context) {
- Date lastModified = null;
- Class<? extends AbstractBaseResource> thisClass = getClass();
- ClassLoader classLoader = thisClass.getClassLoader();
- if (classLoader == null) {
- classLoader = ClassLoader.getSystemClassLoader();
- }
-
- if (classLoader != null) {
- URL classResource = classLoader.getResource(thisClass.getName().replace('.', '/') + ".class");
- URLConnection connection;
- try {
- connection = classResource.openConnection();
- connection.setUseCaches(false);
- long classLastModifiedDate = connection.getLastModified();
- if (classLastModifiedDate > 0) {
- lastModified = new Date(classLastModifiedDate);
+ if (lastModified == null) {
+ Class<? extends AbstractBaseResource> thisClass = getClass();
+ ClassLoader classLoader = thisClass.getClassLoader();
+ if (classLoader == null) {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
+
+ if (classLoader != null) {
+ URL classResource = classLoader.getResource(thisClass.getName().replace('.', '/') + ".class");
+ URLConnection connection;
+ try {
+ connection = classResource.openConnection();
+ connection.setUseCaches(false);
+ long classLastModifiedDate = connection.getLastModified();
+ if (classLastModifiedDate > 0) {
+ lastModified = new Date(classLastModifiedDate);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
}
+ //TODO - originally lastModified was set during resource creation.
+ //as resources can be managed beans this approach does not seem good
+ if (lastModified == null) {
+ lastModified = (Date) ApplicationContext.getInstance(context).
+ getAttribute(ResourceHandlerImpl.HANDLER_START_TIME_ATTRIBUTE);
+ }
+
return lastModified;
}
@@ -144,6 +155,8 @@
@Override
public String getRequestPath() {
+ //TODO - cache resource request path in request scope
+
FacesContext context = FacesContext.getCurrentInstance();
ResourceCodec resourceCodec = ResourceHandlerImpl.getResourceCodec(context);
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -37,11 +37,13 @@
import javax.faces.component.StateHolder;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.cache.CacheFactory;
import org.ajax4jsf.cache.CacheManager;
+import org.richfaces.context.ApplicationContext;
import org.richfaces.util.RichfacesLogger;
import org.richfaces.util.Util;
import org.richfaces.util.RequestStateManager.BooleanRequestStateVariable;
@@ -55,7 +57,26 @@
public static final String RICHFACES_RESOURCE_IDENTIFIER = "/rfRes/";
+ public static final String HANDLER_START_TIME_ATTRIBUTE = ResourceHandlerImpl.class.getName() +
+ ":StartTime";
+
private static final Logger LOGGER = RichfacesLogger.RESOURCE.getLogger();
+
+ //TODO - review - do we need this?
+ static {
+ // set in-memory caching ImageIO
+ Thread thread = Thread.currentThread();
+ ClassLoader initialTCCL = thread.getContextClassLoader();
+
+ try {
+ ClassLoader systemCL = ClassLoader.getSystemClassLoader();
+ thread.setContextClassLoader(systemCL);
+ ImageIO.setUseCache(false);
+ } finally {
+ thread.setContextClassLoader(initialTCCL);
+ }
+ }
+
private ResourceHandler defaultHandler;
@@ -69,12 +90,13 @@
getClass().getName()));
}
- initializeCache();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ initializeCache(facesContext);
+ markStartTime(facesContext);
}
- private void initializeCache() {
+ private void initializeCache(FacesContext facesContext) {
CacheManager cacheManager = CacheManager.getInstance();
- FacesContext facesContext = FacesContext.getCurrentInstance();
Map<?, ?> envMap = facesContext.getExternalContext().getInitParameterMap();
CacheFactory cacheFactory = cacheManager.getCacheFactory(envMap);
@@ -83,6 +105,11 @@
this.cache.start();
}
+ private void markStartTime(FacesContext facesContext) {
+ ApplicationContext applicationContext = ApplicationContext.getInstance(facesContext);
+ applicationContext.setAttribute(HANDLER_START_TIME_ATTRIBUTE, new Date());
+ }
+
private static final String RESOURCE_CODEC_ATTRIBUTE_NAME =
ResourceHandlerImpl.class.getName() + ":ResourceCodec";
@@ -332,7 +359,7 @@
}
}
}
-
+ //TODO flush resource
//TODO dispose resource
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/TestResource2.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -25,19 +25,10 @@
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.Date;
-import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.util.HtmlColor;
import org.ajax4jsf.util.NumericDataInputStream;
import org.ajax4jsf.util.NumericDataOutputStream;
@@ -45,81 +36,56 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
-public class TestResource2 extends AbstractBaseResource implements StateHolder {
+public class TestResource2 extends Java2Dresource {
protected Color color;
public TestResource2() {
+ super(ImageType.PNG);
FacesContext context = FacesContext.getCurrentInstance();
Skin skin = SkinFactory.getInstance().getSkin(context);
Object parameter = skin.getParameter(context, Skin.headerGradientColor);
this.color = HtmlColor.decode(parameter.toString());
}
- @Override
- public String getContentType() {
- return "image/png";
- }
-
protected Dimension dimension = new Dimension(20, 150);
@Override
- public InputStream getInputStream() {
- GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
- BufferedImage image = new BufferedImage(dimension.width, dimension.height, ColorSpace.TYPE_RGB);
- Graphics2D g2d = environment.createGraphics(image);
+ protected void paint(Graphics2D graphics2d, Dimension dim) {
+ super.paint(graphics2d, dim);
- try {
- g2d.setPaint(new GradientPaint(0, 0, Color.WHITE, dimension.width, dimension.height, color));
- g2d.fillRect(0, 0, dimension.width, dimension.height);
- } finally {
- g2d.dispose();
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- ImageIO.write(image, "png", baos);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return new ByteArrayInputStream(baos.toByteArray());
+ graphics2d.setPaint(new GradientPaint(0, 0, Color.WHITE, dim.width, dim.height, color));
+ graphics2d.fillRect(0, 0, dim.width, dim.height);
}
- public boolean isTransient() {
- return false;
- }
-
- public void restoreState(FacesContext context, Object state) {
- byte[] bytes = (byte[]) state;
- this.color = new NumericDataInputStream(bytes).readColor();
- }
-
- public Object saveState(FacesContext context) {
- return new NumericDataOutputStream().writeColor(color).getBytes();
- }
-
- public void setTransient(boolean newTransientValue) {
- }
-
@Override
- public String getEntityTag(FacesContext context) {
- return ResourceUtils.formatWeakTag(Integer.toHexString(color.getRGB() & 0xFFFFFF));
+ protected void readState(FacesContext context, NumericDataInputStream stream) {
+ super.readState(context, stream);
+ this.color = stream.readColor();
}
@Override
- protected Date getExpired(FacesContext context) {
- return null;//new Date(System.currentTimeMillis() + 10000);
+ protected void writeState(FacesContext context,
+ NumericDataOutputStream stream) {
+ super.writeState(context, stream);
+ stream.writeColor(this.color);
}
@Override
- protected Date getLastModified(FacesContext context) {
- return new Date();
+ public String getEntityTag(FacesContext context) {
+ return ResourceUtils.formatWeakTag(Integer.toHexString(color.getRGB() & 0xFFFFFF));
}
-
+
@Override
public String getVersion() {
return VersionBean._version.getResourceVersion();
}
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.Java2Dresource#getDimension()
+ */
+ @Override
+ public Dimension getDimension() {
+ return dimension;
+ }
}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/util/RenderPhaseComponentVisitorUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/util/RenderPhaseComponentVisitorUtils.java 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/util/RenderPhaseComponentVisitorUtils.java 2009-07-24 08:56:25 UTC (rev 14998)
@@ -1,103 +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.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.util.ServicesUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.event.RenderPhaseComponentVisitor;
-
-public class RenderPhaseComponentVisitorUtils{
-
- private static final Log log = LogFactory.getLog(RenderPhaseComponentVisitorUtils.class);
-
- private static final String KEY = RenderPhaseComponentVisitorUtils.class.getName();
-
- private RenderPhaseComponentVisitorUtils() {}
-
- public static RenderPhaseComponentVisitor[] getVisitors(FacesContext context) {
- Map<String, Object> applicationMap = context.getExternalContext().getApplicationMap();
- RenderPhaseComponentVisitor[] visitors;
- synchronized(applicationMap) {
- visitors = (RenderPhaseComponentVisitor[])applicationMap.get(KEY);
- if (visitors == null) {
- visitors = init();
- applicationMap.put(KEY, visitors);
- }
- }
- return visitors;
- }
-
- private static RenderPhaseComponentVisitor[] init() {
- LinkedList<RenderPhaseComponentVisitor> list = new LinkedList<RenderPhaseComponentVisitor>();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- String resource = "META-INF/services/org.richfaces.component.RenderPhaseComponentVisitor";
- try {
- Enumeration<URL> resources = loader.getResources(resource);
- while (resources.hasMoreElements()) {
- InputStream stream = URLToStreamHelper.urlToStreamSafe(resources.nextElement());
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
- try {
- String handlerClassName = null;
- while ((handlerClassName = reader.readLine()) != null) {
- if (handlerClassName.length() > 0) {
- try {
- Class<?> handlerClass = ServicesUtils.loadClass(
- loader, handlerClassName);
- Object handler = handlerClass.newInstance();
- list.add((RenderPhaseComponentVisitor) handler);
- } catch (Exception e) {
- throw new FacesException(
- "Error create instance for class "
- + handlerClassName, e);
- }
- }
- }
-
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug(e.getLocalizedMessage(), e);
- }
- }
- }
- }
- } catch (IOException e) {
- throw new FacesException("Error load resource "+ resource, e);
- }
- return list.toArray(new RenderPhaseComponentVisitor[list.size()]);
- }
-}
Modified: root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml 2009-07-24 08:56:25 UTC (rev 14998)
@@ -9,6 +9,11 @@
-->
</factory>
<application>
+ <system-event-listener>
+ <system-event-listener-class>org.ajax4jsf.component.RenderPhaseUIDataAdaptorVisitor</system-event-listener-class>
+ <system-event-class>javax.faces.event.PreRenderComponentEvent</system-event-class>
+ <source-class>org.ajax4jsf.component.UIDataAdaptor</source-class>
+ </system-event-listener>
<!--
<variable-resolver>org.richfaces.skin.SkinVariableResolver</variable-resolver>
<property-resolver>org.richfaces.skin.SkinPropertyResolver</property-resolver>
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js 2009-07-24 08:52:05 UTC (rev 14997)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js 2009-07-24 08:56:25 UTC (rev 14998)
@@ -13,7 +13,7 @@
var input = jQuery("input[name='" + parameterName + "']", form);
if (input.length == 0) {
- var newInput = jQuery("<input type='hidden' name='" + parameterName + "' id='" + parameterName + "' value='" + parameterValue + "' />");
+ var newInput = jQuery("<input type='hidden' name='" + parameterName + "' id='" + parameterName + "' />").val(parameterValue);
if (parameterName === 'javax.faces.portletbridge.STATE_ID' /* fix for fileUpload in portlets */) {
input = newInput.prependTo(form);
} else {
15 years, 3 months