empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1384823 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: components/LabelTag.java components/ValueTag.java utils/TagEncodingHelper.java
Date Fri, 14 Sep 2012 15:31:39 GMT
Author: doebele
Date: Fri Sep 14 15:31:39 2012
New Revision: 1384823

URL: http://svn.apache.org/viewvc?rev=1384823&view=rev
Log:
EMPIREDB-157 
JSF2 add class style for negative numeric values

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java?rev=1384823&r1=1384822&r2=1384823&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/LabelTag.java
Fri Sep 14 15:31:39 2012
@@ -67,7 +67,7 @@ public class LabelTag extends UIOutput /
         if (labelComponent == null)
         {
             String forInput   = helper.getTagAttributeString("for");
-            String styleClass = helper.getTagStyleClass(DataType.UNKNOWN);
+            String styleClass = helper.getTagStyleClass(DataType.UNKNOWN, null);
             String style      = helper.getTagAttributeString("style");
             // createLabelComponent 
             labelComponent = helper.createLabelComponent(context, forInput, styleClass, style,
getColon());

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java?rev=1384823&r1=1384822&r2=1384823&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/ValueTag.java
Fri Sep 14 15:31:39 2012
@@ -25,7 +25,9 @@ import javax.faces.component.UIOutput;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
+import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
+import org.apache.empire.data.DataType;
 import org.apache.empire.jsf2.controls.InputControl;
 import org.apache.empire.jsf2.utils.TagEncodingHelper;
 import org.slf4j.Logger;
@@ -83,7 +85,20 @@ public class ValueTag extends UIOutput /
         if (StringUtils.isEmpty(tag))
             tag="span";
         writer.startElement(tag, this);
-        helper.writeAttribute(writer, "class", helper.getTagStyleClass());
+        // Detect type and additional style
+        String addlStyle = null;
+        DataType dataType = vi.getColumn().getDataType();
+        if (dataType.isNumeric())
+        {   try {
+                Object val = helper.getDataValue(true);
+                if (val!=null && ObjectUtils.getInteger(val)<0)
+                    addlStyle = "eValNeg";
+            } catch(Exception e) {
+                log.warn("Unable to detect sign of numeric value {}. Message is {}!", vi.getColumn().getName(),
e.getMessage());
+            }
+        }
+        // render attributes
+        helper.writeAttribute(writer, "class", helper.getTagStyleClass(dataType, addlStyle));
         helper.writeAttribute(writer, "style", map.get("style"));
         helper.writeAttribute(writer, "title", helper.getValueTooltip(title));
         return tag;

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java?rev=1384823&r1=1384822&r2=1384823&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
Fri Sep 14 15:31:39 2012
@@ -326,8 +326,6 @@ public class TagEncodingHelper implement
         public String getStyleClass(String addlStyle)
         {
             String style = getTagStyleClass(addlStyle);
-            // if (isReadOnly())
-            //     style += " eInpDis";
             return style; 
         }
 
@@ -1333,11 +1331,11 @@ public class TagEncodingHelper implement
         return getTagStyleClass(tagCssStyle, typeClass, addlStyle, userStyle);
     }
 
-    public final String getTagStyleClass(DataType dataType)
+    public final String getTagStyleClass(DataType dataType, String addlStyle)
     {
         String userStyle = getTagAttributeString("styleClass");
         String typeClass = getDataTypeClass(dataType);
-        return getTagStyleClass(tagCssStyle, typeClass, null, userStyle);
+        return getTagStyleClass(tagCssStyle, typeClass, addlStyle, userStyle);
     }
 
     public final String getTagStyleClass(String addlStyle)



Mime
View raw message