You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2017/09/22 07:45:15 UTC

[myfaces-tobago] branch master updated: TOBAGO-1759 Update Bootstrap to 4.0.0 beta 1 (from alpha 6) * new size for segment layout 'extraLarge'

This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 294b260  TOBAGO-1759 Update Bootstrap to 4.0.0 beta 1 (from alpha 6) * new size for segment layout 'extraLarge'
294b260 is described below

commit 294b260bde1bbf92095be32a1ba8a436edbefa6b
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Fri Sep 22 09:45:13 2017 +0200

    TOBAGO-1759 Update Bootstrap to 4.0.0 beta 1 (from alpha 6)
    * new size for segment layout 'extraLarge'
---
 .../myfaces/tobago/component/Attributes.java       |  5 +++++
 .../facelets/SegmentLayoutConstraintHandler.java   | 11 +++++++++++
 .../myfaces/tobago/facelets/SegmentLayoutRule.java | 16 ++++++++++++++++
 .../renderkit/renderer/SegmentLayoutRenderer.java  |  3 ++-
 .../SegmentLayoutConstraintTagDeclaration.java     |  6 ++++++
 .../component/SegmentLayoutTagDeclaration.java     | 14 ++++++++++----
 .../tobago/renderkit/css/BootstrapClass.java       | 22 +++++++++++++++++++++-
 .../16-layout/30-segment/segment-layout.xhtml      | 21 +++++++++++----------
 8 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
index 6cbc3c7..5715e2d 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
@@ -85,6 +85,7 @@ public enum Attributes {
   expanded,
   execute,
   event,
+  extraLarge,
   extraSmall,
   fieldId,
   file,
@@ -187,6 +188,10 @@ public enum Attributes {
   /**
    * Used by a layout manager
    */
+  overwriteExtraLarge,
+  /**
+   * Used by a layout manager
+   */
   overwriteExtraSmall,
   /**
    * Used by a layout manager
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java
index 498a216..5154e01 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutConstraintHandler.java
@@ -39,6 +39,7 @@ public class SegmentLayoutConstraintHandler extends TagHandler {
   private final TagAttribute overwriteSmall;
   private final TagAttribute overwriteMedium;
   private final TagAttribute overwriteLarge;
+  private final TagAttribute overwriteExtraLarge;
 
   public SegmentLayoutConstraintHandler(TagConfig config) {
     super(config);
@@ -50,6 +51,7 @@ public class SegmentLayoutConstraintHandler extends TagHandler {
     overwriteSmall = getAttribute(Attributes.overwriteSmall.getName());
     overwriteMedium = getAttribute(Attributes.overwriteMedium.getName());
     overwriteLarge = getAttribute(Attributes.overwriteLarge.getName());
+    overwriteExtraLarge = getAttribute(Attributes.overwriteExtraLarge.getName());
   }
 
   @Override
@@ -127,5 +129,14 @@ public class SegmentLayoutConstraintHandler extends TagHandler {
             overwriteLarge.getValueExpression(faceletContext, Integer.TYPE));
       }
     }
+
+    if (overwriteExtraLarge != null) {
+      if (overwriteExtraLarge.isLiteral()) {
+        attributes.put(Attributes.overwriteExtraLarge.getName(), overwriteExtraLarge.getValue());
+      } else {
+        parent.setValueExpression(Attributes.overwriteExtraLarge.getName(),
+            overwriteExtraLarge.getValueExpression(faceletContext, Integer.TYPE));
+      }
+    }
   }
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutRule.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutRule.java
index 276c963..9c039de 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutRule.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/SegmentLayoutRule.java
@@ -50,6 +50,9 @@ public class SegmentLayoutRule extends MetaRule {
         if (Attributes.large == a) {
           return new LargeMapper(attribute);
         }
+        if (Attributes.extraLarge == a) {
+          return new ExtraLargeMapper(attribute);
+        }
       }
     }
     return null;
@@ -111,4 +114,17 @@ public class SegmentLayoutRule extends MetaRule {
     }
   }
 
+  static final class ExtraLargeMapper extends Metadata {
+    private final TagAttribute attribute;
+
+    ExtraLargeMapper(final TagAttribute attribute) {
+      this.attribute = attribute;
+    }
+
+    @Override
+    public void applyMetadata(final FaceletContext ctx, final Object instance) {
+      final UISegmentLayout gridLayout = (UISegmentLayout) instance;
+      gridLayout.setExtraLarge(ColumnPartition.valueOf(attribute.getValue()));
+    }
+  }
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SegmentLayoutRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SegmentLayoutRenderer.java
index b613fd5..0e61de8 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SegmentLayoutRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SegmentLayoutRenderer.java
@@ -78,7 +78,8 @@ public class SegmentLayoutRenderer extends RendererBase {
         segmentLayout.getExtraSmall(),
         segmentLayout.getSmall(),
         segmentLayout.getMedium(),
-        segmentLayout.getLarge());
+        segmentLayout.getLarge(),
+        segmentLayout.getExtraLarge());
     for (UIComponent child : children) {
       if (child.isRendered()) {
         encodeChild(facesContext, writer, generator, child);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java
index aa5f4af..80ccb85 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutConstraintTagDeclaration.java
@@ -87,4 +87,10 @@ public interface SegmentLayoutConstraintTagDeclaration {
    */
   @TagAttribute(type = "java.lang.Integer")
   void setOverwriteLarge(final ValueExpression overwriteLarge);
+
+  /**
+   * Overwrite the default layout for extra large devices.
+   */
+  @TagAttribute(type = "java.lang.Integer")
+  void setOverwriteExtraLarge(final ValueExpression overwriteExtraLarge);
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutTagDeclaration.java
index 9e0a612..eb94abd 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SegmentLayoutTagDeclaration.java
@@ -49,31 +49,37 @@ import org.apache.myfaces.tobago.internal.taglib.declaration.IsVisual;
 public interface SegmentLayoutTagDeclaration extends HasIdBindingAndRendered, IsVisual {
 
   /**
-   * The semicolon-separated definition of the columns for extra small devices. The sum must be 12.
+   * The semicolon-separated definition of the columns for extra small devices.
    */
   @TagAttribute
   @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.ColumnPartition")
   void setExtraSmall(String extraSmall);
 
   /**
-   * The semicolon-separated definition of the columns for small devices. The sum must be 12.
+   * The semicolon-separated definition of the columns for small devices.
    */
   @TagAttribute
   @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.ColumnPartition")
   void setSmall(String small);
 
   /**
-   * The semicolon-separated definition of the columns for medium devices. The sum must be 12.
+   * The semicolon-separated definition of the columns for medium devices.
    */
   @TagAttribute
   @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.ColumnPartition")
   void setMedium(String medium);
 
   /**
-   * The semicolon-separated definition of the columns for large devices. The sum must be 12.
+   * The semicolon-separated definition of the columns for large devices.
    */
   @TagAttribute
   @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.ColumnPartition")
   void setLarge(String large);
 
+  /**
+   * The semicolon-separated definition of the columns for extra large devices.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "org.apache.myfaces.tobago.layout.ColumnPartition")
+  void setExtraLarge(String extraLarge);
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
index a0fc43b..3bcd3c6 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
@@ -114,6 +114,18 @@ public enum BootstrapClass implements CssItem {
   COL_SM_10("col-sm-10"),
   COL_SM_11("col-sm-11"),
   COL_SM_12("col-sm-12"),
+  COL_XL_1("col-xl-1"),
+  COL_XL_2("col-xl-2"),
+  COL_XL_3("col-xl-3"),
+  COL_XL_4("col-xl-4"),
+  COL_XL_5("col-xl-5"),
+  COL_XL_6("col-xl-6"),
+  COL_XL_7("col-xl-7"),
+  COL_XL_8("col-xl-8"),
+  COL_XL_9("col-xl-9"),
+  COL_XL_10("col-xl-10"),
+  COL_XL_11("col-xl-11"),
+  COL_XL_12("col-xl-12"),
   COL_1("col-1"),
   COL_2("col-2"),
   COL_3("col-3"),
@@ -513,6 +525,11 @@ public enum BootstrapClass implements CssItem {
         COL_LG_5, COL_LG_6, COL_LG_7, COL_LG_8,
         COL_LG_9, COL_LG_10, COL_LG_11, COL_LG_12,
     };
+    private static final BootstrapClass[] EXTRA_LARGE = new BootstrapClass[]{
+        COL_XL_1, COL_XL_2, COL_XL_3, COL_XL_4,
+        COL_XL_5, COL_XL_6, COL_XL_7, COL_XL_8,
+        COL_XL_9, COL_XL_10, COL_XL_11, COL_XL_12,
+    };
     private static final BootstrapClass[] OFFSET_EXTRA_SMALL = new BootstrapClass[]{
         null, OFFSET_1, OFFSET_2, OFFSET_3, OFFSET_4, OFFSET_5,
         OFFSET_6, OFFSET_7, OFFSET_8, OFFSET_9, OFFSET_10, OFFSET_11
@@ -534,12 +551,13 @@ public enum BootstrapClass implements CssItem {
     private final ColumnPartition small;
     private final ColumnPartition medium;
     private final ColumnPartition large;
+    private final ColumnPartition extraLarge;
 
     private int index = 0;
 
     public Generator(
         final ColumnPartition extraSmall, final ColumnPartition small, final ColumnPartition medium,
-        final ColumnPartition large) {
+        final ColumnPartition large, final ColumnPartition extraLarge) {
       if (extraSmall == null && small == null && medium == null && large == null) {
         this.extraSmall = ColumnPartition.PARTITION_12;
       } else {
@@ -548,6 +566,7 @@ public enum BootstrapClass implements CssItem {
       this.small = small;
       this.medium = medium;
       this.large = large;
+      this.extraLarge = extraLarge;
     }
 
     public void reset() {
@@ -565,6 +584,7 @@ public enum BootstrapClass implements CssItem {
       generate(result, small, SMALL, attributes.get(Attributes.overwriteSmall.name()));
       generate(result, medium, MEDIUM, attributes.get(Attributes.overwriteMedium.name()));
       generate(result, large, LARGE, attributes.get(Attributes.overwriteLarge.name()));
+      generate(result, extraLarge, EXTRA_LARGE, attributes.get(Attributes.overwriteExtraLarge.name()));
       generateOffset(result, attributes.get(Attributes.offsetExtraSmall.name()), OFFSET_EXTRA_SMALL);
       generateOffset(result, attributes.get(Attributes.offsetSmall.name()), OFFSET_SMALL);
       generateOffset(result, attributes.get(Attributes.offsetMedium.name()), OFFSET_MEDIUM);
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml
index ec47960..9bded06 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/30-segment/segment-layout.xhtml
@@ -22,11 +22,11 @@
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets">
   <ui:param name="title" value="#{demoBundle.segment_layout}  &lt;tc:segmentLayout>"/>
-  <p>The segment layout is basicly a grid with 12 columns.
-    The number and the proportion of the columns can be set with
-    <code>large</code>, <code>medium</code>, <code>small</code> or <code>extraSmall</code>.
+  <p>The segment layout is a grid with 12 columns.
+    The number and the proportion of the columns can be set with the attributes
+    <code>extraSmall</code>, <code>small</code>, <code>medium</code>, <code>large</code> and <code>extraLarge</code>.
     Every attribute has a different css class, but the usage is the same.
-    The value is a semicolon separated list of integers, which sum has to be '12'.
+    The value is a semicolon separated list of integers, which sum must be '12' or less.
     A value of n will use n columns from the grid.</p>
   <tc:link label="Tag Library Documentation" image="#{request.contextPath}/image/feather-leaf.png"
            link="#{demoBundle.tagDocUrl}/#{info.stableVersion}/tld/tc/segmentLayout.html"/>
@@ -60,18 +60,19 @@
   </tc:section>
 
   <tc:section label="Screen Size">
-    <p>For the different kinds of screen sizes, the segment layout has four attributes:
-      <code>large</code>, <code>medium</code>, <code>small</code> and <code>extraSmall</code>.
-      The first two ones should be used for desktops. The last two should be used for tablets and phones.
-      Notice, that only the screen size matters. So a small browser window on a big screen also reacts with
+    <p>For the different kinds of screen sizes, the segment layout has five attributes:
+      <code>extraLarge</code>, <code>large</code>, <code>medium</code>, <code>small</code> and <code>extraSmall</code>.
+      The first three should be used for desktops. The last two should be used for tablets and phones.
+      Notice, that only the browser size matters. So a small browser window on a big screen also reacts with
       <code>small</code> and <code>extraSmall</code>.</p>
     <p>In the following example, all attributes are used. If you are on a desktop you can see the different
       behavior by changing the size of the browser window.</p>
-    <pre><code class="language-markup">&lt;tc:segmentLayout large="2;2;2;2;2;2"
+    <pre><code class="language-markup">&lt;tc:segmentLayout extraLarge="1;1;1;1;1;1;1;1;1;1;1;1" large="2;2;2;2;2;2"
   medium="3;3;3;3" small="4;4;4" extraSmall="6;6">
     ...</code></pre>
 
-    <tc:segmentLayout large="2;2;2;2;2;2" medium="3;3;3;3" small="4;4;4" extraSmall="6;6">
+    <tc:segmentLayout extraLarge="1;1;1;1;1;1;1;1;1;1;1;1" large="2;2;2;2;2;2" medium="3;3;3;3" small="4;4;4"
+                      extraSmall="6;6">
       <tc:in value="1"/>
       <tc:in value="2"/>
       <tc:in value="3"/>

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].