You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2007/01/21 13:03:39 UTC

svn commit: r498295 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org/apache/myfaces/tobago/config/ core/src/main/java/org/apache/myfaces/tobago/convert/ core/src/main/java/org/apache/myfaces/tob...

Author: bommel
Date: Sun Jan 21 04:03:38 2007
New Revision: 498295

URL: http://svn.apache.org/viewvc?view=rev&rev=498295
Log:
some code clean up

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILayout.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/convert/DurationConverter.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Sun Jan 21 04:03:38 2007
@@ -379,7 +379,7 @@
       return ((Character) charakter);
     } else if (charakter instanceof String) {
       String asString = ((String) charakter);
-      return asString.length() > 0 ? new Character(asString.charAt(0)) : null;
+      return asString.length() > 0 ? Character.valueOf(asString.charAt(0)) : null;
     } else {
       LOG.warn("Unknown type '" + charakter.getClass().getName()
           + "' for integer attribute: " + name + " comp: " + component);

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILayout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILayout.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILayout.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UILayout.java Sun Jan 21 04:03:38 2007
@@ -52,9 +52,8 @@
     Integer  layoutWidth = LayoutUtil.getLayoutWidth(component);
     if (layoutWidth != null) {
       int space = layoutWidth.intValue();
-      int innerSpace
-          = LayoutUtil.getInnerSpace(facesContext, component, space, true);
-      component.getAttributes().put(ATTR_INNER_WIDTH, new Integer(innerSpace));
+      int innerSpace = LayoutUtil.getInnerSpace(facesContext, component, space, true);
+      component.getAttributes().put(ATTR_INNER_WIDTH, Integer.valueOf(innerSpace));
     }
   }
 
@@ -62,9 +61,8 @@
     Integer  layoutHeight = LayoutUtil.getLayoutHeight(component);
     if (layoutHeight != null) {
       int space = layoutHeight.intValue();
-      int innerSpace
-          = LayoutUtil.getInnerSpace(facesContext, component, space, false);
-      component.getAttributes().put(ATTR_INNER_HEIGHT, new Integer(innerSpace));
+      int innerSpace = LayoutUtil.getInnerSpace(facesContext, component, space, false);
+      component.getAttributes().put(ATTR_INNER_HEIGHT, Integer.valueOf(innerSpace));
     }
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java Sun Jan 21 04:03:38 2007
@@ -107,7 +107,7 @@
   }
 
   private void registerDtd(Digester digester) {
-    URL url = getClass().getResource(TOBAGO_CONFIG_DTD);
+    URL url = TobagoConfigParser.class.getResource(TOBAGO_CONFIG_DTD);
     if (LOG.isDebugEnabled()) {
       LOG.debug("registering dtd: url=" + url);
     }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/convert/DurationConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/convert/DurationConverter.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/convert/DurationConverter.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/convert/DurationConverter.java Sun Jan 21 04:03:38 2007
@@ -62,7 +62,7 @@
     aDouble = aDouble * factor;
 
     NumberFormat format = new DecimalFormat("00");
-    long value = new Double(aDouble).longValue();
+    long value = Double.valueOf(aDouble).longValue();
     int seconds = (int) (value % 60);
     value = value / 60;
     int minutes = (int) (value % 60);
@@ -110,9 +110,9 @@
     double factor = getUnitFactor(component);
     long value = (long) (((hours * 60L + minutes) * 60L + seconds) / factor);
     if (negative) {
-      return new Long(-value);
+      return Long.valueOf(-value);
     } else {
-      return new Long(value);
+      return Long.valueOf(value);
     }
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Sun Jan 21 04:03:38 2007
@@ -349,7 +349,7 @@
       UIComponent parent = component.getParent();
       space = LayoutUtil.getInnerSpace(facesContext, parent, width);
       if (space > 0 && !ComponentUtil.isFacetOf(component, parent)) {
-        component.getAttributes().put(layoutAttribute, new Integer(space));
+        component.getAttributes().put(layoutAttribute, Integer.valueOf(space));
         if (width) {
           component.getAttributes().remove(ATTR_INNER_WIDTH);
         } else {
@@ -378,7 +378,7 @@
         int layoutSpace2 = LayoutUtil.getInnerSpace(facesContext, component,
             width);
         if (layoutSpace2 > 0) {
-          layout.getAttributes().put(layoutAttribute, new Integer(layoutSpace2));
+          layout.getAttributes().put(layoutAttribute, Integer.valueOf(layoutSpace2));
         }
       }
     }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/GridLayoutRenderer.java Sun Jan 21 04:03:38 2007
@@ -64,19 +64,6 @@
 
   private static final Log LOG = LogFactory.getLog(GridLayoutRenderer.class);
 
-  /*public Dimension getFixedSize(FacesContext facesContext, UIComponent component) {
-    Dimension dimension = null;
-
-    int height = getFixedHeight(facesContext, component);
-    int width =  getFixedWidth(facesContext, component);
-        //-1; // TODO. implement getFixedWidth
-
-    dimension = new Dimension(width, height);
-
-    return dimension;
-  } */
-
-
   public int getFixedHeight(FacesContext facesContext, UIComponent component) {
     int height = calculateLayoutHeight(facesContext, component, false);
 
@@ -96,7 +83,6 @@
      return width;
    }
 
-
   public int calculateLayoutHeight(
       FacesContext facesContext, UIComponent component, boolean minimum) {
     UIGridLayout layout = (UIGridLayout) UILayout.getLayout(component);
@@ -491,7 +477,7 @@
         needVerticalScroolbar = true;
       }
       value -= getHeightSpacingSum(layout, facesContext);
-      layoutHeight(new Integer(value), layout, facesContext);
+      layoutHeight(Integer.valueOf(value), layout, facesContext);
     }
 
 
@@ -504,7 +490,7 @@
         value -= getConfiguredValue(facesContext, component, "scrollbarWidth");
         HtmlRendererUtil.replaceStyleAttribute(layout, "width", value);
       }
-      layoutWidth(new Integer(value), layout, facesContext);
+      layoutWidth(Integer.valueOf(value), layout, facesContext);
     }
 
   }
@@ -577,8 +563,8 @@
       boolean hidden = true;
       UIGridLayout.Row row = rows.get(i);
       List cells = row.getElements();
-      for (int j = 0; j < cells.size(); j++) {
-        hidden &= isHidden(cells.get(j));
+      for (Object cell : cells) {
+        hidden &= isHidden(cell);
       }
       row.setHidden(hidden);
       if (hidden) {
@@ -646,10 +632,8 @@
     int maxHeight = 0;
     List cells = row.getElements();
     for (Object cell : cells) {
-      Object object = cell;
-
-      if (object instanceof UIComponent) {
-        UIComponent component = (UIComponent) object;
+      if (cell instanceof UIComponent) {
+        UIComponent component = (UIComponent) cell;
         int height = -1;
         if (minimum) {
           height = (int) LayoutUtil.getMinimumSize(facesContext, component).getHeight();
@@ -660,11 +644,11 @@
           }
         }
         maxHeight = Math.max(maxHeight, height);
-      } else if (object instanceof UIGridLayout.Marker) {
+      } else if (cell instanceof UIGridLayout.Marker) {
         // ignore 
       } else {
         // TODO is this needed?
-        LOG.error("Object is not instanceof UIComponent " + object.getClass().getName());
+        LOG.error("Object is not instanceof UIComponent " + cell.getClass().getName());
       }
     }
     return maxHeight;
@@ -726,7 +710,7 @@
           }
           cellWidth += (spanX - 1) * getCellSpacing(facesContext, layout);
           LayoutUtil.maybeSetLayoutAttribute(cell,
-              ATTR_LAYOUT_WIDTH, new Integer(cellWidth));
+              ATTR_LAYOUT_WIDTH, Integer.valueOf(cellWidth));
         }
       }
     }
@@ -756,19 +740,17 @@
             LOG.debug("set height of " + cellHeight + "px to "
                 + cell.getRendererType());
           }
-          cell.getAttributes().put(ATTR_LAYOUT_HEIGHT,
-              new Integer(cellHeight));
+          cell.getAttributes().put(ATTR_LAYOUT_HEIGHT, Integer.valueOf(cellHeight));
           cell.getAttributes().remove(ATTR_INNER_HEIGHT);
           if (cell instanceof UICell || cell instanceof UIForm) {
-            List children = LayoutUtil.addChildren(new ArrayList(), cell);
+            List children = LayoutUtil.addChildren(new ArrayList<UIComponent>(), cell);
             for (Iterator childs = children.iterator(); childs.hasNext();) {
               UIComponent component = (UIComponent) childs.next();
               if (LOG.isDebugEnabled()) {
                 LOG.debug("set height of " + cellHeight + "px to "
                     + component.getRendererType());
               }
-              component.getAttributes().put(ATTR_LAYOUT_HEIGHT,
-                  new Integer(cellHeight));
+              component.getAttributes().put(ATTR_LAYOUT_HEIGHT, Integer.valueOf(cellHeight));
               component.getAttributes().remove(ATTR_INNER_HEIGHT);
 
             }

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java Sun Jan 21 04:03:38 2007
@@ -84,8 +84,7 @@
     if (width == null
         && !(ComponentUtil.getBooleanAttribute(findParent(component), ATTR_INLINE)
              || ComponentUtil.getBooleanAttribute(component, ATTR_INLINE))) {
-      width = new
-          Integer(getConfiguredValue(facesContext, component, "labelWidth"));      
+      width = Integer.valueOf(getConfiguredValue(facesContext, component, "labelWidth"));      
     }
 
     LabelWithAccessKey label = new LabelWithAccessKey(component);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java?view=diff&rev=498295&r1=498294&r2=498295
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TimeRenderer.java Sun Jan 21 04:03:38 2007
@@ -27,7 +27,6 @@
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CALENDAR_DATE_INPUT_ID;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DISABLED;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_POPUP_CALENDAR_FORCE_TIME;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_TIP;
 import static org.apache.myfaces.tobago.TobagoConstants.SUBCOMPONENT_SEP;
 import org.apache.myfaces.tobago.component.ComponentUtil;
 import org.apache.myfaces.tobago.component.UIPage;
@@ -39,7 +38,6 @@
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.apache.myfaces.tobago.util.DateFormatUtils;
 
-import javax.faces.application.FacesMessage;
 import javax.faces.component.UIInput;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -49,7 +47,6 @@
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
-import java.util.Iterator;
 
 public class TimeRenderer extends InputRendererBase {
 
@@ -68,6 +65,9 @@
       page.getScriptFiles().add(script);
     }
     UIInput input = (UIInput) component;
+
+    // TODO title??
+    /*
     Iterator messages = facesContext.getMessages(
         input.getClientId(facesContext));
     StringBuilder stringBuffer = new StringBuilder();
@@ -81,9 +81,8 @@
       title = stringBuffer.toString();
     }
 
-    // TODO title??
     title =
-        HtmlRendererUtil.addTip(title, (String) input.getAttributes().get(ATTR_TIP));
+        HtmlRendererUtil.addTip(title, (String) input.getAttributes().get(ATTR_TIP));*/
 
     String currentValue = getCurrentValue(facesContext, input);
     if (LOG.isDebugEnabled()) {