myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r950069 - in /myfaces/tobago/trunk/tobago-theme: tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/...
Date Tue, 01 Jun 2010 13:23:17 GMT
Author: lofwyr
Date: Tue Jun  1 13:23:17 2010
New Revision: 950069

URL: http://svn.apache.org/viewvc?rev=950069&view=rev
Log:
TOBAGO-881: Make ToolBar work with new LayoutManager
 - fix label width for non ASCII characters

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java?rev=950069&r1=950068&r2=950069&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ToolBarRendererBase.java
Tue Jun  1 13:23:17 2010
@@ -44,7 +44,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 import java.io.IOException;
@@ -88,8 +87,8 @@ public abstract class ToolBarRendererBas
     }
   }
 
-  private Measure renderToolbarCommand(FacesContext facesContext, final UIToolBar toolBar,
-      final UICommandBase command, TobagoResponseWriter writer, Measure width)
+  private Measure renderToolbarCommand(
+      FacesContext facesContext, UIToolBar toolBar, UICommandBase command, TobagoResponseWriter
writer, Measure width)
       throws IOException {
     if (command instanceof UISelectBooleanCommand) {
       return renderSelectBoolean(facesContext, toolBar, command, writer, width);
@@ -452,34 +451,32 @@ public abstract class ToolBarRendererBas
     }
     String image = null;
     ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
-    UIViewRoot viewRoot = facesContext.getViewRoot();
     if (disabled && selected) {
-      image = resourceManager.getImage(viewRoot, key + "SelectedDisabled" + size + ext, true);
+      image = resourceManager.getImage(facesContext, key + "SelectedDisabled" + size + ext,
true);
       if (image == null) {
-        image = resourceManager.getImage(viewRoot, key + "SelectedDisabled" + ext, true);
+        image = resourceManager.getImage(facesContext, key + "SelectedDisabled" + ext, true);
       }
     }
     if (image == null && disabled) {
-      image = resourceManager.getImage(viewRoot, key + "Disabled" + size + ext, true);
+      image = resourceManager.getImage(facesContext, key + "Disabled" + size + ext, true);
       if (image == null) {
-        image = resourceManager.getImage(viewRoot, key + "Disabled" + ext, true);
+        image = resourceManager.getImage(facesContext, key + "Disabled" + ext, true);
       }
     }
     if (image == null && selected) {
-      image = resourceManager.getImage(viewRoot, key + "Selected" + size + ext, true);
+      image = resourceManager.getImage(facesContext, key + "Selected" + size + ext, true);
       if (image == null) {
-        image = resourceManager.getImage(viewRoot, key + "Selected" + ext, true);
+        image = resourceManager.getImage(facesContext, key + "Selected" + ext, true);
       }
     }
     if (image == null) {
-      image = resourceManager.getImage(viewRoot, key + size + ext, true);
+      image = resourceManager.getImage(facesContext, key + size + ext, true);
       if (image == null) {
-        image = resourceManager.getImage(viewRoot, key + ext, true);
+        image = resourceManager.getImage(facesContext, key + ext, true);
       }
     }
-    String contextPath = facesContext.getExternalContext().getRequestContextPath();
-//    LOG.info("getImage for " + name + ", " + iconSize + ", " + disabled + ", " + selected
+ " = " + image);
-    return contextPath + image;
+
+    return facesContext.getExternalContext().getRequestContextPath() + image;
   }
 
   private void renderPopup(FacesContext facesContext, TobagoResponseWriter writer, UIComponent
popupMenu)

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties?rev=950069&r1=950068&r2=950069&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/property/tobago-theme-config.properties
Tue Jun  1 13:23:17 2010
@@ -207,7 +207,7 @@ ToolBar.css.border-left-width=2
 ToolBar.css.border-top-width=2
 ToolBar.css.border-right-width=2
 ToolBar.css.border-bottom-width=2
-
+ToolBar.fontWidth=8
 ToolBar.custom.icon-big-width=32
 ToolBar.custom.icon-big-height=32
 ToolBar.custom.icon-small-width=16
@@ -226,8 +226,8 @@ BoxToolBar.css.border-left-width=2
 BoxToolBar.css.border-top-width=2
 BoxToolBar.css.border-right-width=2
 BoxToolBar.css.border-bottom-width=2
-
 BoxToolBar.height=21
+BoxToolBar.fontWidth=8
 BoxToolBar.custom.icon-small-width=16
 BoxToolBar.custom.icon-small-height=16
 BoxToolBar.custom.opener-width=11
@@ -243,8 +243,8 @@ TabGroupToolBar.css.border-left-width=0
 TabGroupToolBar.css.border-top-width=0
 TabGroupToolBar.css.border-right-width=0
 TabGroupToolBar.css.border-bottom-width=1
-
 TabGroupToolBar.height=19
+TabGroupToolBar.fontWidth=8
 TabGroupToolBar.custom.icon-small-width=16
 TabGroupToolBar.custom.icon-small-height=16
 TabGroupToolBar.custom.opener-width=11

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java?rev=950069&r1=950068&r2=950069&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/util/RenderUtils.java
Tue Jun  1 13:23:17 2010
@@ -186,27 +186,22 @@ public class RenderUtils {
       return Measure.ZERO;
     }
     int width = 0;
-    int defaultCharWidth = 0;
+    int defaultCharWidth = 10;
     try {
-      // todo: use Measure instead of int
       defaultCharWidth = ResourceManagerUtils.getThemeMeasure(facesContext, component, "fontWidth").getPixel();
     } catch (NullPointerException e) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("no value for \"fontWidth\" found in theme-config");
-      }
+      LOG.warn("no value for 'fontWidth' for type '" + component.getRendererType() + "' found
in theme-config");
     }
 
     String fontWidths = ResourceManagerUtils.getProperty(facesContext, "tobago", type);
 
     for (char c : text.toCharArray()) {
-      int charWidth;
-      if (c >= 32 && c < 128) {
+      if (c >= 32 && c < 128) { // "normal" char in precomputed range
         int begin = (c - 32) * 2;
-        charWidth = Integer.parseInt(fontWidths.substring(begin, begin + 2), 16);
+        width += Integer.parseInt(fontWidths.substring(begin, begin + 2), 16);
       } else {
-        charWidth = defaultCharWidth;
+        width += defaultCharWidth;
       }
-      width += charWidth;
     }
 
     return Measure.valueOf(width);



Mime
View raw message