Author: nbelaevski
Date: 2010-04-23 08:43:22 -0400 (Fri, 23 Apr 2010)
New Revision: 16799
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java
root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java
root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java
Log:
Dynamic CSS refactoring & fixes
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 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -21,18 +21,8 @@
package org.ajax4jsf.resource;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.HtmlDimensions;
-import org.ajax4jsf.util.NumericDataInputStream;
-import org.ajax4jsf.util.NumericDataOutputStream;
-import org.richfaces.resource.AbstractBaseResource;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
-import java.awt.*;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
import java.io.ByteArrayInputStream;
@@ -41,6 +31,18 @@
import java.io.InputStream;
import java.util.Map;
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.HtmlDimensions;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.ajax4jsf.util.NumericDataOutputStream;
+import org.richfaces.resource.AbstractBaseResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.3 $ $Date: 2007/02/01 15:31:57 $
@@ -53,11 +55,11 @@
super();
this.imageType = imageType;
}
-
+
public void populateParameters(Map<String, String> parameters){
-
+
}
-
+
public static enum ImageType {
GIF("gif") {
@Override
@@ -168,7 +170,7 @@
* @see org.richfaces.resource.AbstractBaseResource#getInputStream()
*/
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
Dimension dimension = getDimension();
int width = dimension.width;
int height = dimension.height;
@@ -186,10 +188,6 @@
try {
ImageIO.write(image, imageType.getFormatName(), baos);
- } catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
} finally {
try {
baos.close();
@@ -234,7 +232,7 @@
public void setTransient(boolean newTransientValue) {
throw new UnsupportedOperationException();
}
-
+
protected String getValueParameter(FacesContext context, String name) {
SkinFactory skinFactory = SkinFactory.getInstance();
@@ -256,7 +254,7 @@
}
return param;
}
-
+
protected Integer getColorValueParameter(FacesContext context, String name, boolean
useDefault) {
Skin skin;
if (useDefault) {
@@ -284,7 +282,7 @@
return Integer.valueOf(16);
}
}
-
+
protected Integer decodeColor(String value) {
if (value != null && value.length() != 0) {
return Integer.valueOf(HtmlColor.decode(value).getRGB());
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/resource/AnimatedTestResource.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -21,7 +21,18 @@
package org.richfaces.resource;
-import org.w3c.dom.Node;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
@@ -31,15 +42,9 @@
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataNode;
import javax.imageio.stream.ImageOutputStream;
-import java.awt.*;
-import java.awt.color.ColorSpace;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
+import org.w3c.dom.Node;
+
public class AnimatedTestResource extends TestResource2 {
private static final int DELAY_TIME = 50;
private static final int FRAMES_COUNT = 10;
@@ -82,7 +87,7 @@
}
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
GraphicsEnvironment environment =
GraphicsEnvironment.getLocalGraphicsEnvironment();
Dimension dimension = getDimension();
BufferedImage image = new BufferedImage(dimension.width, dimension.height,
ColorSpace.TYPE_RGB);
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CachedResourceImpl.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -21,16 +21,8 @@
package org.richfaces.resource;
-import org.ajax4jsf.io.ByteBuffer;
-import org.ajax4jsf.io.FastBufferInputStream;
-import org.ajax4jsf.io.FastBufferOutputStream;
-import org.richfaces.log.RichfacesLogger;
import static org.richfaces.resource.ResourceUtils.secondToMillis;
-import org.richfaces.util.Util;
-import org.slf4j.Logger;
-import javax.faces.application.Resource;
-import javax.faces.context.FacesContext;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -43,6 +35,16 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.faces.application.Resource;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.io.ByteBuffer;
+import org.ajax4jsf.io.FastBufferInputStream;
+import org.ajax4jsf.io.FastBufferOutputStream;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.util.Util;
+import org.slf4j.Logger;
+
/**
* @author Nick Belaevski
* @since 4.0
@@ -177,7 +179,7 @@
}
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
return new FastBufferInputStream(content);
}
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -76,7 +76,6 @@
this.resourceDelegate = resource;
}
- @Override
public InputStream getInputStream() throws IOException {
FacesContext ctx = FacesContext.getCurrentInstance();
InputStream stream = null;
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -76,6 +76,8 @@
if (prefixes.isEmpty()) {
buffer.append('}');
buffer.append(NEW_LINE);
+ } else {
+ prefixes.remove(prefixes.size() - 1);
}
}
Modified:
root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -24,6 +24,7 @@
package org.richfaces.resource;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
@@ -265,7 +266,7 @@
}
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
return inputStream;
}
@@ -379,7 +380,7 @@
}
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
throw new UnsupportedOperationException();
}
}
Modified:
root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/resource/CacheableResourceImpl.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -24,6 +24,7 @@
package org.richfaces.resource;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
@@ -44,7 +45,7 @@
* @see org.richfaces.resource.AbstractBaseResource#getInputStream()
*/
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(getContentToEcho());
}
Modified:
root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/resource/EmptyStreamResource.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -24,6 +24,7 @@
package org.richfaces.resource;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
/**
@@ -34,7 +35,7 @@
protected InputStream EMPTY_STREAM = new ByteArrayInputStream(new byte[0]);
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
return EMPTY_STREAM;
}
}
Modified:
root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/framework/trunk/impl/src/test/java/org/richfaces/resource/StateHolderResourceImpl.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -24,6 +24,7 @@
package org.richfaces.resource;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
@@ -39,7 +40,7 @@
private Object state = "";
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
try {
return new
ByteArrayInputStream(state.toString().getBytes("US-ASCII"));
} catch (UnsupportedEncodingException e) {
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -25,11 +25,11 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
-
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
@@ -55,7 +55,7 @@
private Object userData;
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FacesContext facesContext = FacesContext.getCurrentInstance();
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java 2010-04-23
07:09:12 UTC (rev 16798)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/resource/PushResource.java 2010-04-23
12:43:22 UTC (rev 16799)
@@ -21,16 +21,16 @@
package org.richfaces.resource;
-import org.richfaces.component.PushEventTracker;
-import org.richfaces.component.PushListenersManager;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import java.io.InputStream;
+import org.richfaces.component.PushEventTracker;
+import org.richfaces.component.PushListenersManager;
-import java.util.Map;
-
/**
* @author Nick Belaevski
* @since 4.0
@@ -45,7 +45,7 @@
}
@Override
- public InputStream getInputStream() {
+ public InputStream getInputStream() throws IOException {
return null;
}