[richfaces-svn-commits] JBoss Rich Faces SVN: r9127 - trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Jun 19 18:46:43 EDT 2008


Author: nbelaevski
Date: 2008-06-19 18:46:42 -0400 (Thu, 19 Jun 2008)
New Revision: 9127

Modified:
   trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java
Log:
http://jira.jboss.com/jira/browse/RF-3726

Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java	2008-06-19 22:46:38 UTC (rev 9126)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/TriangleIconBase.java	2008-06-19 22:46:42 UTC (rev 9127)
@@ -26,6 +26,7 @@
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.util.Date;
+import java.util.Map;
 
 import javax.faces.context.FacesContext;
 
@@ -44,6 +45,12 @@
  */
 public abstract class TriangleIconBase extends Java2Dresource {
 	
+	private static final String BORDER_COLOR_PARAMETER = "borderColor";
+
+	private static final String BACKGROUND_COLOR_PARAMETER = "backgroundColor";
+
+	private static final String ICON_COLOR_PARAMETER = "iconColor";
+
 	private static final Dimension DIMENSION = new Dimension(15, 15);
 	
 	protected static final String ICON_COLOR = "generalTextColor";
@@ -106,10 +113,15 @@
 	 * @param data - pass icon color and background color
 	 */
 	protected Object getDataToStore(FacesContext context, Object data) {
-		return storeData(context, ICON_COLOR, BACKGROUND_COLOR, BORDER_COLOR);
+		return storeData(context, ICON_COLOR, BACKGROUND_COLOR, BORDER_COLOR, data);
 	}
 		
-	protected Object storeData(FacesContext context, String colorSkinParam, String backgroundSkinParam, String borderSkinParam) {
+	private static final boolean isEmpty(String s) {
+		return s == null || s.length() == 0;
+	}
+	
+	protected Object storeData(FacesContext context, String colorSkinParam, String backgroundSkinParam, String borderSkinParam, 
+			Object data) {
 		Skin skin = SkinFactory.getInstance().getSkin(context);
 		Skin defaultSkin = SkinFactory.getInstance().getDefaultSkin(context);
 		
@@ -118,38 +130,62 @@
 		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);
+		String iconColorString = null;
+		String backgroundColorString = null;
+		String borderColorString = null;
+
+		if (data instanceof Map) {
+			Map map = (Map) data;
+			
+			iconColorString = (String) map.get(ICON_COLOR_PARAMETER);
+			backgroundColorString = (String) map.get(BACKGROUND_COLOR_PARAMETER);
+			borderColorString = (String) map.get(BORDER_COLOR_PARAMETER);
+		}
 		
-		if (color1 == null) {
-			color1 = "#FFFFFF";
+		if (isEmpty(iconColorString)) {
+			iconColorString = (String) skin.getParameter(context, colorSkinParam);
 		}
+
+		if (isEmpty(iconColorString)) {
+			iconColorString = (String) defaultSkin.getParameter(context, colorSkinParam);
+		}
 		
-		color = HtmlColor.decode(color1);
+		if (isEmpty(iconColorString)) {
+			iconColorString = "#FFFFFF";
+		}
 		
+		color = HtmlColor.decode(iconColorString);
+		
 		zipper.addColor(color);
 		
-		String color2 = (String) skin.getParameter(context, backgroundSkinParam);
-		if (null == color2 || "".equals(color2))
-			color2 = (String) defaultSkin.getParameter(context, backgroundSkinParam);
+		if (isEmpty(backgroundColorString)) {
+			backgroundColorString = (String) skin.getParameter(context, backgroundSkinParam);
+		}
 		
-		if (color2 == null) {
-			color2 = "#000000";
+		if (isEmpty(backgroundColorString)) {
+			backgroundColorString = (String) defaultSkin.getParameter(context, backgroundSkinParam);
+		}		
+		
+		if (isEmpty(backgroundColorString)) {
+			backgroundColorString = "#000000";
 		}
 		
-		color = HtmlColor.decode(color2);
+		color = HtmlColor.decode(backgroundColorString);
 		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";
+
+		if (isEmpty(borderColorString)) {
+			borderColorString = (String) skin.getParameter(context, borderSkinParam);
 		}
+
+		if (isEmpty(borderColorString)) {
+			borderColorString = (String) defaultSkin.getParameter(context, borderSkinParam);
+		}
+
+		if (isEmpty(borderColorString)) {
+			borderColorString = "#000000";
+		}
 		
-		color = HtmlColor.decode(color3);
+		color = HtmlColor.decode(borderColorString);
 		zipper.addColor(color);
 		
 		return ret;




More information about the richfaces-svn-commits mailing list