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 2015/06/03 14:21:45 UTC

svn commit: r1683309 - in /myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html: standard/standard/tag/SectionRenderer.java util/HtmlRendererUtils.java

Author: lofwyr
Date: Wed Jun  3 12:21:45 2015
New Revision: 1683309

URL: http://svn.apache.org/r1683309
Log:
TOBAGO-1368: Create a new theme which uses Bootstrap
 - glyphicon

Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java?rev=1683309&r1=1683308&r2=1683309&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java Wed Jun  3 12:21:45 2015
@@ -20,7 +20,6 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.UISection;
-import org.apache.myfaces.tobago.renderkit.HtmlUtils;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.CssItem;
@@ -74,21 +73,7 @@ public class SectionRenderer extends Lay
             writer.writeClassAttribute(clazz);
         }
         final String image = section.getImage();
-        if (image != null && image.startsWith("glyphicon-")) { // XXX hack: should be integrated in the resource manager
-          writer.startElement(HtmlElements.SPAN, null);
-          writer.writeClassAttribute(BootstrapClass.GLYPHICON, BootstrapClass.glyphicon(image));
-          writer.endElement(HtmlElements.SPAN);
-
-        }
-        if (image != null && label != null) {
-            writer.writeText(" ");
-        }
-        if (image == null && label == null) { // needed, otherwise the look is broken (bootstrap 3.3.1)
-            writer.writeText(HtmlUtils.CHAR_NON_BEAKING_SPACE);
-        }
-        if (label != null) {
-            writer.writeText(label);
-        }
+        HtmlRendererUtils.encodeIconWithLabel(writer, label, image);
         writer.endElement(tag);
     }
 

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1683309&r1=1683308&r2=1683309&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java Wed Jun  3 12:21:45 2015
@@ -33,6 +33,7 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
+import org.apache.myfaces.tobago.renderkit.html.BootstrapClass;
 import org.apache.myfaces.tobago.renderkit.html.Command;
 import org.apache.myfaces.tobago.renderkit.html.CommandMap;
 import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
@@ -104,6 +105,24 @@ public final class HtmlRendererUtils {
     }
   }
 
+  public static void encodeIconWithLabel(TobagoResponseWriter writer, String label, String image) throws IOException {
+    if (image != null && image.startsWith("glyphicon-")) { // XXX hack: should be integrated in the resource manager
+      writer.startElement(HtmlElements.SPAN, null);
+      writer.writeClassAttribute(BootstrapClass.GLYPHICON, BootstrapClass.glyphicon(image));
+      writer.endElement(HtmlElements.SPAN);
+
+    }
+    if (image != null && label != null) {
+      writer.writeText(" ");
+    }
+    if (image == null && label == null) { // needed, otherwise the look is broken (bootstrap 3.3.1)
+      writer.writeText(HtmlRendererUtils.CHAR_NON_BEAKING_SPACE);
+    }
+    if (label != null) {
+      writer.writeText(label);
+    }
+  }
+
   public static TobagoResponseWriter getTobagoResponseWriter(final FacesContext facesContext) {
 
     final ResponseWriter writer = facesContext.getResponseWriter();