You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/10/30 16:18:49 UTC

svn commit: r831324 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ core/src/main/java/org/apache/myfaces/tobago/webapp/ sandbox/src/main/java/org/apache/m...

Author: lofwyr
Date: Fri Oct 30 15:18:42 2009
New Revision: 831324

URL: http://svn.apache.org/viewvc?rev=831324&view=rev
Log:
TOBAGO-812: Refactor Style Handling of components

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlStyleMap.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
    myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java
    myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/opera/tag/BoxRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
    myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/AbstractUITree.java Fri Oct 30 15:18:42 2009
@@ -24,7 +24,6 @@
 import javax.faces.application.FacesMessage;
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
 import javax.faces.validator.Validator;
 import javax.faces.validator.ValidatorException;
@@ -32,7 +31,7 @@
 import java.util.Iterator;
 import java.util.List;
 
-public abstract class AbstractUITree extends UIInput implements NamingContainer, LayoutComponent {
+public abstract class AbstractUITree extends javax.faces.component.UIInput implements NamingContainer, LayoutComponent {
 
   public static final String MESSAGE_NOT_LEAF = "tobago.tree.MESSAGE_NOT_LEAF";
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java Fri Oct 30 15:18:42 2009
@@ -161,11 +161,7 @@
   public static final String STATE = "state";
   public static final String STATE_PREVIEW = "statePreview";
   public static final String STYLE = "style";
-  public static final String STYLE_BODY = "style_body";
   public static final String STYLE_CLASS = "styleClass";
-  public static final String STYLE_HEADER = "style_header";
-  public static final String STYLE_INNER = "style_inner";
-  public static final String STYLE_FILES = "styleFiles";
   public static final String SUPPRESS_TOOLBAR_CONTAINER = "suppressToolbarContainer";
   public static final String SWITCH_TYPE = "switchType";
   public static final String TAB_INDEX = "tabIndex";

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlStyleMap.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlStyleMap.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlStyleMap.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlStyleMap.java Fri Oct 30 15:18:42 2009
@@ -17,65 +17,163 @@
  * limitations under the License.
  */
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.layout.Display;
+import org.apache.myfaces.tobago.layout.Measure;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.io.Serializable;
 
-// TODO: write setter for height, width, etc.
-public class HtmlStyleMap extends HashMap<String, Object> {
+public class HtmlStyleMap implements Serializable {
 
-  private static final Log LOG = LogFactory.getLog(HtmlStyleMap.class);
-  private static final long serialVersionUID = 342607693971417143L;
+  private static final long serialVersionUID = 2L;
 
-  public Object put(String s, Object o) {
-    if (o instanceof String && (s.equals("height") || s.equals("width"))) {
-      String str = (String) o;
-      if (str.endsWith("px")) {
-        LOG.error("width or height should not end with 'px'. Will ignored.", new Exception());
-        o = Integer.parseInt(str.substring(0, str.length() - 2));
-      }
-    }
-    return super.put(s, o);
+  private Measure width;
+  private Measure height;
+  private Measure left;
+  private Measure top;
+  private Display display;
+  // todo: class or enum instead of String
+  private String position;
+
+  // todo: class or enum instead of String
+  private String overflow;
+  private Measure paddingTop;
+  private Measure paddingBottom;
+
+  public HtmlStyleMap() {
   }
 
-  public Integer getInt(Object o) {
-    Object object = get(o);
-    if (object instanceof Integer) {
-      return (Integer) object;
-    }
-    if (object == null) {
-      return null;
-    }
-    String string = object.toString();
-    LOG.warn("Getting int value via parsing the object.toString()");
-    try {
-      return Integer.parseInt(string);
-    } catch (NumberFormatException e) {
-      LOG.warn("TODO: Fix measure issue in HtmlStyleMap: '" + object + "'");
-      if (string.endsWith("px")) {
-        return Integer.parseInt(string.substring(0, string.length() - 2));
-      }
-      throw e;
-    }
+  public HtmlStyleMap(HtmlStyleMap map) {
+    this.width = map.width;
+    this.height = map.height;
+    this.left = map.left;
+    this.top = map.top;
+    this.display = map.display;
+    this.position = map.position;
+    this.overflow = map.overflow;
+    this.paddingTop = map.paddingTop;
+    this.paddingBottom = map.paddingBottom;
   }
 
-  public String toString() {
-    if (entrySet().isEmpty()) {
-      return null;
-    }
+  public String encode() {
     StringBuilder buf = new StringBuilder();
-    for(Map.Entry<String, Object> style :entrySet()) {
-      buf.append(style.getKey());
-      buf.append(":");
-      buf.append(style.getValue());
-      if (style.getValue() instanceof Integer) {
-        buf.append("px; ");
-      } else {
-        buf.append("; ");
-      }
+    if (width != null) {
+      buf.append("width:");
+      buf.append(width);
+      buf.append(';');
+    }
+    if (height != null) {
+      buf.append("height:");
+      buf.append(height);
+      buf.append(';');
+    }
+    if (top != null) {
+      buf.append("top:");
+      buf.append(top);
+      buf.append(';');
+    }
+    if (left != null) {
+      buf.append("left:");
+      buf.append(left);
+      buf.append(';');
+    }
+    if (display != null) {
+      buf.append("display:");
+      buf.append(display.getValue());
+      buf.append(';');
+    }
+    if (position != null) {
+      buf.append("position:");
+      buf.append(position);
+      buf.append(';');
+    }
+    if (overflow != null) {
+      buf.append("overflow:");
+      buf.append(overflow);
+      buf.append(';');
+    }
+    if (paddingTop != null) {
+      buf.append("padding-top:");
+      buf.append(paddingTop);
+      buf.append(';');
+    }
+    if (paddingBottom != null) {
+      buf.append("padding-bottom:");
+      buf.append(paddingBottom);
+      buf.append(';');
     }
+
     return buf.toString();
   }
+
+  public Measure getWidth() {
+    return width;
+  }
+
+  public void setWidth(Measure width) {
+    this.width = width;
+  }
+
+  public Measure getHeight() {
+    return height;
+  }
+
+  public void setHeight(Measure height) {
+    this.height = height;
+  }
+
+  public Measure getLeft() {
+    return left;
+  }
+
+  public void setLeft(Measure left) {
+    this.left = left;
+  }
+
+  public Measure getTop() {
+    return top;
+  }
+
+  public void setTop(Measure top) {
+    this.top = top;
+  }
+
+  public Display getDisplay() {
+    return display;
+  }
+
+  public void setDisplay(Display display) {
+    this.display = display;
+  }
+
+  public String getPosition() {
+    return position;
+  }
+
+  public void setPosition(String position) {
+    this.position = position;
+  }
+
+  public String getOverflow() {
+    return overflow;
+  }
+
+  public void setOverflow(String overflow) {
+    this.overflow = overflow;
+  }
+
+  public Measure getPaddingTop() {
+    return paddingTop;
+  }
+
+  public void setPaddingTop(Measure paddingTop) {
+    this.paddingTop = paddingTop;
+  }
+
+  public Measure getPaddingBottom() {
+    return paddingBottom;
+  }
+
+  public void setPaddingBottom(Measure paddingBottom) {
+    this.paddingBottom = paddingBottom;
+  }
 }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java Fri Oct 30 15:18:42 2009
@@ -138,7 +138,7 @@
    */
   public void writeStyleAttribute(HtmlStyleMap style) throws IOException {
     if (style != null) {
-      writeAttribute(HtmlAttributes.STYLE, style.toString(), false);
+      writeAttribute(HtmlAttributes.STYLE, style.encode(), false);
     }
   }
 

Modified: myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java (original)
+++ myfaces/tobago/trunk/sandbox/src/main/java/org/apache/myfaces/tobago/renderkit/html/sandbox/standard/tag/InputNumberSliderRenderer.java Fri Oct 30 15:18:42 2009
@@ -23,6 +23,7 @@
 import org.apache.myfaces.tobago.context.ResourceManager;
 import org.apache.myfaces.tobago.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -62,7 +63,7 @@
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
 
 
-    HtmlStyleMap style = (HtmlStyleMap) component.getAttributes().get(Attributes.STYLE);
+    HtmlStyleMap style = HtmlRendererUtil.ensureStyleAttributeMap(component);
     int width = -1;
     int sliderWidthPerc = 33;
     if (ThemeConfig.hasValue(facesContext, component, SLIDER_WIDTH_PERCENT)) {
@@ -76,10 +77,7 @@
     }
     int sliderWidth = 100; // fixme
     int inputWidth = 50; // fixme;
-    if (style != null && style.containsKey("width")) {
-      width = style.getInt("width");
-    }
-    if (width >= 0) {
+    if (style != null && style.getWidth() != null && style.getWidth().getPixel() >= 0) {
       sliderWidth = (width * sliderWidthPerc) / 100;
       inputWidth = (width * (100 - sliderWidthPerc)) / 100;
     }
@@ -98,7 +96,7 @@
     writer.writeClassAttribute(styleClasses);
 
     HtmlStyleMap widthStyle = new HtmlStyleMap();
-    widthStyle.put("width", sliderWidth / 2);
+    widthStyle.setWidth(new PixelMeasure(sliderWidth / 2));
     writer.writeStyleAttribute(widthStyle);
     writer.startElement(HtmlConstants.SPAN, null);
     writer.writeClassAttribute(styleClasses);
@@ -125,7 +123,7 @@
 
     writer.startElement(HtmlConstants.INPUT, null);
     writer.writeClassAttribute("tobago-in-default");
-    widthStyle.put("width", inputWidth);
+    widthStyle.setWidth(new PixelMeasure(inputWidth));
     writer.writeStyleAttribute(widthStyle);
     String inputIdAndName = getIdForInputField(facesContext, component);
     writer.writeNameAttribute(inputIdAndName);

Modified: myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml (original)
+++ myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml Fri Oct 30 15:18:42 2009
@@ -1187,7 +1187,7 @@
       demonstrates the usage of the style map.</para>
 
       <programlisting role="JAVA">HtmlStyleMap style = (HtmlStyleMap) component.getAttributes().get("style");
-int width = style.getInt("width");</programlisting>
+Measure width = style.getWidth();</programlisting>
     </sect2>
 
     <sect2>

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/opera/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/opera/tag/BoxRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/opera/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/opera/tag/BoxRenderer.java Fri Oct 30 15:18:42 2009
@@ -27,7 +27,6 @@
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.UserAgent;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
-import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
@@ -41,8 +40,6 @@
   public void encodeBegin(FacesContext facesContext,
       UIComponent component) throws IOException {
 
-    HtmlStyleMap innerStyle = HtmlRendererUtil.prepareInnerStyle(component);
-
     UIComponent label = component.getFacet(Facets.LABEL);
     String labelString
         = (String) component.getAttributes().get(Attributes.LABEL);
@@ -74,6 +71,5 @@
     }
     writer.startElement(HtmlConstants.DIV, component);
     writer.writeClassAttribute();
-    writer.writeStyleAttribute(innerStyle);
   }
 }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/BoxRenderer.java Fri Oct 30 15:18:42 2009
@@ -27,6 +27,7 @@
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.config.ThemeConfig;
 import org.apache.myfaces.tobago.context.ClientProperties;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.BoxRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
@@ -46,8 +47,6 @@
   public void encodeBegin(
       FacesContext facesContext, UIComponent component) throws IOException {
 
-    HtmlStyleMap innerStyle = HtmlRendererUtil.prepareInnerStyle(component);
-
     UIComponent label = component.getFacet(Facets.LABEL);
     String labelString
         = (String) component.getAttributes().get(Attributes.LABEL);
@@ -77,6 +76,7 @@
       writer.endElement(HtmlConstants.LEGEND);
     }
 
+    HtmlStyleMap innerStyle = new HtmlStyleMap();
     if (toolbar != null) {
       writer.startElement(HtmlConstants.DIV, null);
       writer.writeClassAttribute("tobago-box-toolbar-div");
@@ -87,7 +87,7 @@
       writer.endElement(HtmlConstants.DIV);
       writer.endElement(HtmlConstants.DIV);
       if (ClientProperties.getInstance(facesContext.getViewRoot()).getUserAgent().isMsie()) {
-        innerStyle.put("top", -10);
+        innerStyle.setTop(new PixelMeasure(-10));
       }
     }
     writer.startElement(HtmlConstants.DIV, component);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/RichTextEditorRenderer.java Fri Oct 30 15:18:42 2009
@@ -91,9 +91,6 @@
 
     UIInput component = (UIInput) uiComponent;
 
-    HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, component);
-
-
     boolean previewState
         = ComponentUtil.getBooleanAttribute(component, Attributes.STATE_PREVIEW);
     // FIXME: remove this when i18n is ok
@@ -147,7 +144,7 @@
       writer.writeClassAttribute(bodyClasses);
       writer.writeNameAttribute(clientId);
       writer.writeIdAttribute(clientId);
-      writer.writeAttribute(HtmlAttributes.STYLE, null, Attributes.STYLE_BODY);
+      writer.writeStyleAttribute();
       String onchange = HtmlUtils.generateOnchange(component, facesContext);
       if (null != onchange) {
         writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Fri Oct 30 15:18:42 2009
@@ -48,6 +48,8 @@
 import org.apache.myfaces.tobago.layout.AutoLayoutToken;
 import org.apache.myfaces.tobago.layout.LayoutToken;
 import org.apache.myfaces.tobago.layout.LayoutTokens;
+import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.layout.RelativeLayoutToken;
 import org.apache.myfaces.tobago.model.SheetState;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
@@ -103,8 +105,6 @@
 
     ensureColumnWidthList(facesContext, data);
 
-    HtmlRendererUtil.createHeaderAndBodyStyles(facesContext, data);
-
     final String sheetId = data.getClientId(facesContext);
 
     TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
@@ -113,6 +113,7 @@
     writer.startElement(HtmlConstants.DIV, data);
     writer.writeIdAttribute(sheetId + "_outer_div");
     writer.writeClassAttribute("tobago-sheet-outer-div");
+// todo    HtmlStyleMap style = HtmlRendererUtil.createStyle(data);
     writer.writeStyleAttribute();
     UICommand clickAction = null;
     UICommand dblClickAction = null;
@@ -182,19 +183,19 @@
     String selectorDisabled = contextPath + resourceManager.getImage(viewRoot, "image/sheetUncheckedDisabled.gif");
     String unchecked = contextPath + resourceManager.getImage(viewRoot, "image/sheetUnchecked.gif");
 
-    Map attributes = data.getAttributes();
-    HtmlStyleMap sheetStyle = (HtmlStyleMap) attributes.get(Attributes.STYLE);
+    HtmlStyleMap style = HtmlRendererUtil.ensureStyleAttributeMap(data);
     //HtmlStyleMap headerStyle = (HtmlStyleMap) attributes.get(STYLE_HEADER);
-//    String sheetWidthString = LayoutUtils.getStyleAttributeValue(sheetStyle,
+//    String sheetWidthString = LayoutUtils.getStyleAttributeValue(style,
 //        "width");
-    Integer sheetHeight = HtmlRendererUtil.getStyleAttributeIntValue(sheetStyle, "height");
-    if (sheetHeight == null) {
+    Integer sheetHeight;
+    if (style.getHeight() == null) {
       // FIXME: nullpointer if height not defined
       LOG.error("no height in parent container, setting to 100");
       sheetHeight = 100;
+    } else {
+      sheetHeight = style.getHeight().getPixel();
     }
-    //HtmlStyleMap bodyStyle = (HtmlStyleMap) attributes.get(STYLE_BODY);
-    int footerHeight = (Integer) attributes.get(Attributes.FOOTER_HEIGHT);
+    int footerHeight = (Integer) data.getAttributes().get(Attributes.FOOTER_HEIGHT);
 
     String selectable = data.getSelectable();
 
@@ -242,7 +243,7 @@
       writer.startElement(HtmlConstants.DIV, null);
       writer.writeIdAttribute(sheetId + "_header_div");
       writer.writeClassAttribute("tobago-sheet-header-div");
-      HtmlStyleMap headerStyle = (HtmlStyleMap) attributes.get(Attributes.STYLE_HEADER);
+      HtmlStyleMap headerStyle = new HtmlStyleMap();
       if (headerStyle != null) {
         writer.writeStyleAttribute(headerStyle);
       }
@@ -279,26 +280,28 @@
 
 // BEGIN RENDER BODY CONTENT
     HtmlStyleMap bodyStyle = new HtmlStyleMap();
-    bodyStyle.put("position", "relative");
-    bodyStyle.put("width", data.getWidth());
-    bodyStyle.put("height", sheetHeight - footerHeight);
+    bodyStyle.setPosition("relative");
+    bodyStyle.setWidth(data.getWidth());
+    bodyStyle.setHeight(new PixelMeasure(sheetHeight - footerHeight));
     
     writer.startElement(HtmlConstants.DIV, null);
     writer.writeIdAttribute(sheetId + "_data_div");
     writer.writeClassAttribute("tobago-sheet-body-div ");
-    writer.writeAttribute(HtmlAttributes.STYLE, bodyStyle.toString() + (showHeader?"":" padding-top: 0px;"), false);
-    Integer space = HtmlRendererUtil.getStyleAttributeIntValue(bodyStyle, "width");
-    HtmlStyleMap sheetBodyStyle = (HtmlStyleMap) bodyStyle.clone();
-    //String sheetBodyStyle;
-    if (space != null) {
+    HtmlStyleMap sheetBodyStyle = new HtmlStyleMap(bodyStyle);
+    if (!showHeader) {
+      bodyStyle.setPaddingTop(PixelMeasure.ZERO);
+    }
+    writer.writeStyleAttribute(bodyStyle);
+    if (bodyStyle.getWidth() != null) {
 //      intSpace -= columnWidths.get(columnWidths.size() - 1);
-      space -= getContentBorder(facesContext, data);
+      Measure space = bodyStyle.getWidth();
+      space.substractNotNegative(getContentBorder(facesContext, data));
       if (needVerticalScrollbar(facesContext, data)) {
-        space -= getScrollbarWidth(facesContext, data);
+        space.substractNotNegative(getScrollbarWidth(facesContext, data));
       }
-      sheetBodyStyle.put("width", space);
+      sheetBodyStyle.setWidth(space);
     }
-    sheetBodyStyle.remove("height");
+    sheetBodyStyle.setHeight(null);
 
 
 
@@ -441,7 +444,6 @@
 
 // END RENDER BODY CONTENT
 
-
     final String showRowRange
         = getPagingAttribute(data, Attributes.SHOW_ROW_RANGE);
     final String showPageRange
@@ -452,9 +454,9 @@
     if (isValidPagingValue(showRowRange)
         || isValidPagingValue(showPageRange)
         || isValidPagingValue(showDirectLinks)) {
-      final HtmlStyleMap footerStyle = (HtmlStyleMap) bodyStyle.clone();
-      footerStyle.put("height", footerHeight);
-      footerStyle.put("top", (sheetHeight - footerHeight));
+      HtmlStyleMap footerStyle = new HtmlStyleMap(bodyStyle);
+      footerStyle.setHeight(new PixelMeasure(footerHeight));
+      footerStyle.setTop(new PixelMeasure(sheetHeight - footerHeight));
 
         //  "height", MessageFormat.format("{0}px", footerHeight));
         //  + " top: " + (sheetHeight - footerHeight) + "px;";
@@ -640,9 +642,8 @@
       }
     }
 
-    HtmlStyleMap style = (HtmlStyleMap) data.getAttributes().get(Attributes.STYLE);
-    Integer height = HtmlRendererUtil.getStyleAttributeIntValue(style, "height");
-    if (height != null) {
+    HtmlStyleMap style = HtmlRendererUtil.ensureStyleAttributeMap(data);
+    if (style.getHeight() != null) {
       int first = data.getFirst();
       int rows = Math.min(data.getRowCount(), first + data.getRows()) - first;
       LOG.error("20; // FIXME: make dynamic (was removed by changing the layouting");
@@ -650,7 +651,7 @@
           + getFooterHeight(facesContext, data)
           + (rows * (20 /* FIXME */ + getRowPadding(facesContext, data)));
 
-      return heightNeeded > height;
+      return heightNeeded > style.getHeight().getPixel();
     } else {
       return false;
     }
@@ -660,9 +661,9 @@
     return ThemeConfig.getValue(facesContext, component, "rowPadding");
   }
 
-  public int getScrollbarWidth(FacesContext facesContext,
-      UIComponent component) {
-    return ThemeConfig.getValue(facesContext, component, "scrollbarWidth");
+  private Measure getScrollbarWidth(FacesContext facesContext, UIComponent component) {
+    // todo: get measure directly from theme config
+    return new PixelMeasure(ThemeConfig.getValue(facesContext, component, "scrollbarWidth"));
   }
 
   private void storeFooterHeight(FacesContext facesContext,
@@ -1081,8 +1082,9 @@
     writer.endElement(type);
   }
 
-  public int getContentBorder(FacesContext facesContext, UIData data) {
-    return ThemeConfig.getValue(facesContext, data, "contentBorder");
+  private Measure getContentBorder(FacesContext facesContext, UIData data) {
+    // todo: get measure directly from theme config
+    return new PixelMeasure(ThemeConfig.getValue(facesContext, data, "contentBorder"));
   }
 
   public void encodeAjax(FacesContext facesContext, UIComponent component) throws IOException {
@@ -1164,15 +1166,15 @@
         }
       }
 
-      int space = data.getWidth().getPixel();
-      space -= getContentBorder(facesContext, data);
+      Measure space = data.getWidth();
+      space.substractNotNegative(getContentBorder(facesContext, data));
       if (needVerticalScrollbar(facesContext, data)) {
-        space -= getScrollbarWidth(facesContext, data);
+        space.substractNotNegative(getScrollbarWidth(facesContext, data));
       }
       LayoutInfo layoutInfo =
-          new LayoutInfo(newTokens.getSize(), space, newTokens, data.getClientId(facesContext), false);
+          new LayoutInfo(newTokens.getSize(), space.getPixel(), newTokens, data.getClientId(facesContext), false);
       parseFixedWidth(facesContext, layoutInfo, rendererdColumns);
-      layoutInfo.parseColumnLayout(space);
+      layoutInfo.parseColumnLayout(space.getPixel());
       currentWidthList = layoutInfo.getSpaceList();
     }
 
@@ -1221,34 +1223,6 @@
     }
   }
 
-  private void prepareDimensions(FacesContext facesContext, UIData data) {
-     // prepare width's in column's children components
-
-     List<Integer> columnWidths = data.getWidthList();
-     int i = 0;
-     for (UIColumn column : data.getRenderedColumns()) {
-       if (i < columnWidths.size()) {
-         Integer width = columnWidths.get(i);
-         if (!(column instanceof UIColumnSelector)) {
-           if (column.getChildCount() == 1) {
-             UIComponent child = (UIComponent) column.getChildren().get(0);
-             int cellPaddingWidth = ThemeConfig.getValue(facesContext, data, "cellPaddingWidth");
-             child.getAttributes().put(
-                 Attributes.LAYOUT_WIDTH, width - cellPaddingWidth);
-             child.getAttributes().remove(Attributes.INNER_WIDTH);
-           } else {
-             LOG.warn("More or less than 1 child in column! "
-                 + "Can't set width for column " + i + " to " + width);
-           }
-         }
-       } else {
-         LOG.warn("More columns than columnSizes! "
-             + "Can't set width for column " + i);
-       }
-       i++;
-     }
-   }
-
   @Override
   public boolean getPrepareRendersChildren() {
     return true;

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Fri Oct 30 15:18:42 2009
@@ -42,6 +42,8 @@
 import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import org.apache.myfaces.tobago.event.TabChangeEvent;
 import org.apache.myfaces.tobago.layout.Display;
+import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
@@ -130,13 +132,13 @@
     // tabs and render it as they are selected, and it will
     // selected with stylesheet.
     int virtualTab = 0;
-    int currentWidth = 0;
+    Measure currentWidth = PixelMeasure.ZERO;
 
-    int navigationBarWidth = ThemeConfig.getValue(facesContext, tabGroup, "navigationBarWidth");
+    Measure navigationBarWidth = ThemeConfig.getMeasure(facesContext, tabGroup, "navigationBarWidth");
     for (UIComponent tab : (List<UIComponent>) tabGroup.getChildren()) {
       if (tab instanceof UIPanelBase) {
         if (tab.isRendered()) {
-          currentWidth += tabList.getWidthList().get(virtualTab);
+          currentWidth.add(tabList.getWidthList().get(virtualTab));
           if (SWITCH_TYPE_CLIENT.equals(switchType) || virtualTab == activeIndex) {
             if (virtualTab != activeIndex) {
               tabGroup.setDisplay(Display.NONE);
@@ -252,8 +254,8 @@
 
   private void renderTabGroupView(
       FacesContext facesContext, TobagoResponseWriter writer, UITabGroup tabGroup,
-      int virtualTab, String switchType, String image1x1, int toolbarWidth,
-      int currentWidth, TabList tabList) throws IOException {
+      int virtualTab, String switchType, String image1x1, Measure toolbarWidth,
+      Measure currentWidth, TabList tabList) throws IOException {
     writer.startElement(HtmlConstants.TABLE, tabGroup);
     writer.writeAttribute(HtmlAttributes.BORDER, 0);
     writer.writeAttribute(HtmlAttributes.CELLPADDING, 0);
@@ -267,27 +269,27 @@
     writer.writeAttribute(HtmlAttributes.VALIGN, "bottom", false);
 
     writer.startElement(HtmlConstants.TD, tabGroup);
-    int width = tabGroup.getWidth().getPixel();
-    int headerHeight = ThemeConfig.getMeasure(facesContext, tabGroup, "headerHeight").getPixel();
+    Measure width = tabGroup.getWidth();
+    Measure headerHeight = ThemeConfig.getMeasure(facesContext, tabGroup, "headerHeight");
     HtmlStyleMap header = new HtmlStyleMap();
-    header.put("position", "relative");
-    header.put("width", width);
-    header.put("height", headerHeight);
+    header.setPosition("relative");
+    header.setWidth(width);
+    header.setHeight(headerHeight);
     writer.writeStyleAttribute(header);
     writer.startElement(HtmlConstants.DIV, tabGroup);
     writer.writeStyleAttribute(header);
 
     writer.startElement(HtmlConstants.DIV, tabGroup);
     HtmlStyleMap map = new HtmlStyleMap();
-    if (currentWidth > width) {
-      map.put("width", currentWidth);
-      map.put("left", width - toolbarWidth - currentWidth);
+    if (currentWidth.greaterThan(width)) {
+      map.setWidth(new PixelMeasure(currentWidth));
+      map.setLeft(width.subtract(toolbarWidth).subtract(currentWidth));
     } else {
-      map.put("width", width - toolbarWidth);
+      map.setWidth(width.subtract(toolbarWidth));
     }
-    map.put("overflow", "hidden");
-    map.put("position", "absolute");
-    map.put("height", headerHeight);
+    map.setOverflow("hidden");
+    map.setPosition("absolute");
+    map.setHeight(headerHeight);
     writer.writeStyleAttribute(map);
     writer.startElement(HtmlConstants.TABLE, tabGroup);
     writer.writeAttribute(HtmlAttributes.BORDER, 0);
@@ -387,7 +389,7 @@
           innerClass.addMarkupClass(tab, "tab", "outer");
           writer.startElement(HtmlConstants.TD, tab);
           HtmlStyleMap labelStyle = new HtmlStyleMap();
-          labelStyle.put("width", tabList.getWidthList().get(index));
+          labelStyle.setWidth(new PixelMeasure(tabList.getWidthList().get(index)));
 
           writer.writeStyleAttribute(labelStyle);
           writer.writeIdAttribute(tab.getClientId(facesContext));
@@ -458,10 +460,10 @@
     //writer.writeAttribute(HtmlAttributes.WIDTH, "100%", false);
 
     writer.startElement(HtmlConstants.TD, tabGroup);
-    if (currentWidth > width) {
-      writer.writeAttribute(HtmlAttributes.WIDTH, toolbarWidth);
+    if (currentWidth.greaterThan(width)) {
+      writer.writeAttribute(HtmlAttributes.WIDTH, toolbarWidth.toString(), false);
     } else {
-      writer.writeAttribute(HtmlAttributes.WIDTH, Integer.toString((width - currentWidth)) + "px", false);
+      writer.writeAttribute(HtmlAttributes.WIDTH, width.subtract(currentWidth).toString(), false);
     }
     writer.startElement(HtmlConstants.DIV, tabGroup);
     writer.writeClassAttribute("tobago-tab-fulfill");
@@ -477,28 +479,28 @@
     writer.endElement(HtmlConstants.TABLE);
     writer.endElement(HtmlConstants.DIV);
     if (toolBar != null) { // todo: configurable later
-      renderToolbar(facesContext, writer, toolBar, width - toolbarWidth, toolbarWidth);
+      renderToolbar(facesContext, writer, toolBar, width.subtract(toolbarWidth), toolbarWidth);
     }
     writer.endElement(HtmlConstants.DIV);
     writer.endElement(HtmlConstants.TD);
     writer.endElement(HtmlConstants.TR);
 
     HtmlStyleMap body = new HtmlStyleMap();
-    body.put("position", "relative");
-    body.put("width", width);
-    body.put("height", tabGroup.getHeight().getPixel() - headerHeight);
+    body.setPosition("relative");
+    body.setWidth(width);
+    body.setHeight(tabGroup.getHeight().subtract(headerHeight));
     encodeContent(writer, facesContext, activeTab, body);
 
     writer.endElement(HtmlConstants.TABLE);
   }
 
   // todo: this is quite the same as in ButtonRenderer
-  private void renderToolbar(FacesContext facesContext, TobagoResponseWriter writer, UIPanel toolbar, int width,
-      int navigationBarWidth) throws IOException {
+  private void renderToolbar(FacesContext facesContext, TobagoResponseWriter writer, UIPanel toolbar, Measure width,
+      Measure navigationBarWidth) throws IOException {
     writer.startElement(HtmlConstants.DIV, null);
     HtmlStyleMap map = new HtmlStyleMap();
-    map.put("width", navigationBarWidth);
-    map.put("left", width);
+    map.setWidth(navigationBarWidth);
+    map.setLeft(width);
     writer.writeStyleAttribute(map);
     writer.writeClassAttribute("tobago-tabnavigationbar");
     toolbar.setRendererType("BoxToolBar");
@@ -528,11 +530,11 @@
     AjaxUtils.checkParamValidity(context, component, UITabGroup.class);
     TabList tabList = getTabList(context, (UITabGroup) component);
     int index = ensureRenderedActiveIndex(context, (UITabGroup) component);
-    int currentWidth = getCurrentWidth(tabList, index);
+    Measure currentWidth = new PixelMeasure(getCurrentWidth(tabList, index));
     renderTabGroupView(context, HtmlRendererUtil.getTobagoResponseWriter(context),
         (UITabGroup) component, index, SWITCH_TYPE_RELOAD_TAB,
         ResourceManagerUtil.getImageWithPath(context, "image/1x1.gif"),
-        ThemeConfig.getValue(context, component, "navigationBarWidth"), currentWidth, tabList);
+        ThemeConfig.getMeasure(context, component, "navigationBarWidth"), currentWidth, tabList);
   }
 
   private static class TabList {

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeNodeRenderer.java Fri Oct 30 15:18:42 2009
@@ -22,7 +22,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.component.AbstractUITree;
 import org.apache.myfaces.tobago.component.AbstractUITreeNode;
-import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UITree;
 import org.apache.myfaces.tobago.component.UITreeNode;
@@ -181,14 +180,10 @@
       writer.writeClassAttribute(styleClasses);
 
       // div style (width)
-      Integer width = null;
-      HtmlStyleMap style = (HtmlStyleMap) tree.getAttributes().get(Attributes.STYLE);
-      if (style != null) {
-        width = style.getInt("width");
-      }
+      HtmlStyleMap style = HtmlRendererUtil.ensureStyleAttributeMap(tree);
       String widthString;
-      if (width != null) {
-        widthString = "width: " + Integer.toString(width - 22); // fixme: 4 + 18 for scrollbar
+      if (style != null && style.getWidth() != null) {
+        widthString = "width: " + Integer.toString(style.getWidth().getPixel() - 22); // fixme: 4 + 18 for scrollbar
       } else {
         widthString = "100%";
       }

Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java Fri Oct 30 15:18:42 2009
@@ -31,7 +31,6 @@
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UIBox;
 import org.apache.myfaces.tobago.component.UIToolBar;
-import org.apache.myfaces.tobago.layout.PixelMeasure;
 import org.apache.myfaces.tobago.renderkit.BoxRendererBase;
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlStyleMap;
@@ -102,8 +101,8 @@
       writer.writeClassAttribute(classes);
 
       HtmlStyleMap shadow = new HtmlStyleMap();
-      shadow.put("width", box.getWidth().substractNotNegative(new PixelMeasure(1)));
-      shadow.put("height", box.getHeight().substractNotNegative(new PixelMeasure(1)));
+      shadow.setWidth(box.getWidth().subtract(1));
+      shadow.setHeight(box.getHeight().subtract(1));
       writer.writeStyleAttribute(shadow);
 //    }
 
@@ -118,8 +117,8 @@
 //      classes.addMarkupClass((SupportsMarkup) box, "box", "border");
 
       HtmlStyleMap border = new HtmlStyleMap();
-      border.put("width", box.getWidth().substractNotNegative(new PixelMeasure(3)));
-      border.put("height", box.getHeight().substractNotNegative(new PixelMeasure(3)));
+      border.setWidth(box.getWidth().subtract(3));
+      border.setHeight(box.getHeight().subtract(3));
       writer.writeStyleAttribute(border);
 //    }
 

Modified: myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/TabGroupRenderer.java Fri Oct 30 15:18:42 2009
@@ -57,9 +57,11 @@
     classes.addMarkupClass(activeTab, "tab", "content");
     writer.writeClassAttribute(classes);
 
-    body.put("height", body.getInt("height") - 1);
-    body.put("overflow", "auto");
-    writer.writeStyleAttribute(body);
+    if (body != null) {
+      body.setHeight(body.getHeight().subtract(1));
+      body.setOverflow("auto");
+      writer.writeStyleAttribute(body);
+    }
 
     writer.flush();
     RenderUtil.encodeChildren(facesContext, activeTab);

Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java?rev=831324&r1=831323&r2=831324&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtil.java Fri Oct 30 15:18:42 2009
@@ -36,6 +36,7 @@
 import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
 import org.apache.myfaces.tobago.util.ComponentUtil;
+import org.apache.myfaces.tobago.util.Deprecation;
 import org.apache.myfaces.tobago.webapp.TobagoResponseJsonWriterImpl;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriterWrapper;
@@ -107,22 +108,6 @@
     }
   }
 
-  public static HtmlStyleMap prepareInnerStyle(UIComponent component) {
-    HtmlStyleMap htmlStyleMap = new HtmlStyleMap();
-    Integer innerSpaceInteger = (Integer)
-        component.getAttributes().get(Attributes.INNER_WIDTH);
-    if (innerSpaceInteger != null && innerSpaceInteger != -1) {
-      htmlStyleMap.put("width", innerSpaceInteger);
-    }
-    innerSpaceInteger = (Integer)
-        component.getAttributes().get(Attributes.INNER_HEIGHT);
-    if (innerSpaceInteger != null && innerSpaceInteger != -1) {
-      htmlStyleMap.put("height", innerSpaceInteger);
-    }
-    return htmlStyleMap;
-  }
-
-
   public static void createCssClass(FacesContext facesContext, UIComponent component) {
     String rendererName = getRendererName(facesContext, component);
     if (rendererName != null) {
@@ -213,37 +198,42 @@
     return buffer.toString();
   }
 
-  public static Integer getStyleAttributeIntValue(HtmlStyleMap style, String name) {
-    if (style == null) {
-      return null;
-    }
-    return style.getInt(name);
-  }
-
+  /**
+   * @deprecated Please use setter;
+   */
+  @Deprecated
   public static void replaceStyleAttribute(UIComponent component, String styleAttribute, String value) {
-    HtmlStyleMap style = ensureStyleAttributeMap(component);
-    style.put(styleAttribute, value);
+    Deprecation.LOG.error("HtmlRendererUtil.replaceStyleAttribute() no longer supported. Use setter.");
   }
 
+  /**
+   * @deprecated Please use setter;
+   */
+  @Deprecated
   public static void replaceStyleAttribute(UIComponent component, String attribute,
       String styleAttribute, String value) {
-    HtmlStyleMap style = ensureStyleAttributeMap(component, attribute);
-    style.put(styleAttribute, value);
+    Deprecation.LOG.error("HtmlRendererUtil.replaceStyleAttribute() no longer supported. Use setter.");
   }
 
+  /**
+   * @deprecated Please use setter;
+   */
+  @Deprecated
   public static void replaceStyleAttribute(UIComponent component, String styleAttribute, int value) {
-    HtmlStyleMap style = ensureStyleAttributeMap(component);
-    style.put(styleAttribute, value);
+    Deprecation.LOG.error("HtmlRendererUtil.replaceStyleAttribute() no longer supported. Use setter.");
   }
 
+  /**
+   * @deprecated Please use setter;
+   */
+  @Deprecated
   public static void replaceStyleAttribute(UIComponent component, String attribute,
       String styleAttribute, int value) {
-    HtmlStyleMap style = ensureStyleAttributeMap(component, attribute);
-    style.put(styleAttribute, value);
+    Deprecation.LOG.error("HtmlRendererUtil.replaceStyleAttribute() no longer supported. Use setter.");
 
   }
 
-  private static HtmlStyleMap ensureStyleAttributeMap(UIComponent component) {
+  public static HtmlStyleMap ensureStyleAttributeMap(UIComponent component) {
     return ensureStyleAttributeMap(component, Attributes.STYLE);
   }
 
@@ -271,8 +261,12 @@
     return style.replaceAll(pattern, "").trim();
   }
 
+  /**
+   * @deprecated Please use setter;
+   */
+  @Deprecated
   public static void removeStyleAttribute(UIComponent component, String name) {
-    ensureStyleAttributeMap(component).remove(name);
+    Deprecation.LOG.error("HtmlRendererUtil.removeStyleAttribute() no longer supported. Use setter.");
   }
 
   /**
@@ -283,37 +277,14 @@
     StyleClasses.ensureStyleClasses(component).addFullQualifiedClass(clazz);
   }
 
+  @Deprecated
   public static void createHeaderAndBodyStyles(FacesContext facesContext, UIComponent component) {
-    createHeaderAndBodyStyles(facesContext, component, true);
-    createHeaderAndBodyStyles(facesContext, component, false);
+    Deprecation.LOG.error("HtmlRendererUtil.createHeaderAndBodyStyles() no longer supported");
   }
 
+  @Deprecated
   public static void createHeaderAndBodyStyles(FacesContext facesContext, UIComponent component, boolean width) {
-    HtmlStyleMap style = (HtmlStyleMap) component.getAttributes().get(Attributes.STYLE);
-    Integer styleSpace = null;
-    try {
-      styleSpace = style.getInt(width ? "width" : "height");
-    } catch (Exception e) {
-      /* ignore */
-    }
-    if (styleSpace != null) {
-      int bodySpace = 0;
-      int headerSpace = 0;
-      if (!width) {
-        headerSpace = 20; // FIXME: make dynamic (was removed by changing the layouting
-        LOG.error("20; // FIXME: make dynamic (was removed by changing the layouting");
-        bodySpace = styleSpace - headerSpace;
-      }
-      HtmlStyleMap headerStyle = ensureStyleAttributeMap(component, Attributes.STYLE_HEADER);
-      HtmlStyleMap bodyStyle = ensureStyleAttributeMap(component, Attributes.STYLE_BODY);
-      if (width) {
-        headerStyle.put("width", styleSpace);
-        bodyStyle.put("width", styleSpace);
-      } else {
-        headerStyle.put("height", headerSpace);
-        bodyStyle.put("height", bodySpace);
-      }
-    }
+    Deprecation.LOG.error("HtmlRendererUtil.createHeaderAndBodyStyles() no longer supported");
   }
 
   /**