myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] 01/02: TOBAGO-1933 Attribute 'vertical-align' for tc:column
Date Thu, 20 Sep 2018 14:38:06 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 040f31eceb93dd91c17de67068847a59309dc407
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Thu Sep 20 16:08:22 2018 +0200

    TOBAGO-1933 Attribute 'vertical-align' for tc:column
    
    * add VerticalAlign enum
    * add markups 'middle', 'bottom'
    * implement style for middle/bottom markup in column
    * better description for attribute 'align' in column
    
    (cherry picked from commit 4125e805b381036f3a9512767922ac4bde32d9ba)
---
 .../myfaces/tobago/component/Attributes.java       |  1 +
 .../org/apache/myfaces/tobago/context/Markup.java  |  4 ++
 .../internal/renderkit/renderer/SheetRenderer.java | 18 ++++++++-
 .../taglib/component/ColumnTagDeclaration.java     | 15 +++++++-
 .../myfaces/tobago/layout/VerticalAlign.java       | 44 ++++++++++++++++++++++
 tobago-core/src/main/resources/scss/_tobago.scss   | 10 +++++
 .../org/apache/myfaces/tobago/apt/component.stg    |  4 ++
 7 files changed, 94 insertions(+), 2 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 ae2213e..c48c9e9 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
@@ -405,6 +405,7 @@ public enum Attributes {
   value,
   valueChangeListener,
   var,
+  verticalAlign,
   unit,
   unselectedLabel,
   update,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
index bc6924c..6889e77 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
@@ -64,6 +64,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final Markup BADGE = valueOf("badge");
   public static final Markup BIG = valueOf("big");
   public static final Markup BORDERED = valueOf("bordered");
+  public static final Markup BOTTOM = valueOf("bottom");
   public static final Markup CENTER = valueOf("center");
   public static final Markup CLICKABLE = valueOf("clickable");
   public static final Markup DANGER = valueOf("danger");
@@ -99,6 +100,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final Markup LOCAL_MENU = valueOf("localMenu");
   public static final Markup MARKED = valueOf("marked");
   public static final Markup MEDIUM = valueOf("medium");
+  public static final Markup MIDDLE = valueOf("middle");
   public static final Markup MODAL = valueOf("modal");
   public static final Markup NONE = valueOf("none");
   public static final Markup NUMBER = valueOf("number");
@@ -144,6 +146,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final String STRING_BADGE = "badge";
   public static final String STRING_BIG = "big";
   public static final String STRING_BORDERED = "bordered";
+  public static final String STRING_BOTTOM = "bottom";
   public static final String STRING_CENTER = "center";
   public static final String STRING_CLICKABLE = "clickable";
   public static final String STRING_DANGER = "danger";
@@ -179,6 +182,7 @@ public final class Markup implements Serializable, Iterable<String>
{
   public static final String STRING_LOCAL_MENU = "localMenu";
   public static final String STRING_MARKED = "marked";
   public static final String STRING_MEDIUM = "medium";
+  public static final String STRING_MIDDLE = "middle";
   public static final String STRING_MODAL = "modal";
   public static final String STRING_NONE = "none";
   public static final String STRING_NUMBER = "number";
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
index d76b794..dd20103 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
@@ -51,6 +51,7 @@ import org.apache.myfaces.tobago.internal.util.RenderUtils;
 import org.apache.myfaces.tobago.internal.util.StringUtils;
 import org.apache.myfaces.tobago.layout.ShowPosition;
 import org.apache.myfaces.tobago.layout.TextAlign;
+import org.apache.myfaces.tobago.layout.VerticalAlign;
 import org.apache.myfaces.tobago.model.ExpandedState;
 import org.apache.myfaces.tobago.model.Selectable;
 import org.apache.myfaces.tobago.model.SheetState;
@@ -82,7 +83,6 @@ import javax.faces.component.behavior.ClientBehavior;
 import javax.faces.component.behavior.ClientBehaviorHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.event.ActionEvent;
-
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -713,6 +713,7 @@ public class SheetRenderer extends RendererBase {
               markup = Markup.NULL;
             }
             markup = markup.add(getMarkupForAlign(normalColumn));
+            markup = markup.add(getMarkupForVerticalAlign(normalColumn));
             writer.writeClassAttribute(
                 TobagoClass.SHEET__CELL,
                 TobagoClass.SHEET__CELL.createMarkup(markup),
@@ -844,6 +845,21 @@ public class SheetRenderer extends RendererBase {
     return null;
   }
 
+  private Markup getMarkupForVerticalAlign(final UIColumn column) {
+    final String verticalAlign = ComponentUtils.getStringAttribute(column, Attributes.verticalAlign);
+    if (verticalAlign != null) {
+      switch (VerticalAlign.valueOf(verticalAlign)) {
+        case bottom:
+          return Markup.BOTTOM;
+        case middle:
+          return Markup.MIDDLE;
+        default:
+          // nothing to do
+      }
+    }
+    return null;
+  }
+
   private void encodeHeaderRows(
       final FacesContext facesContext, final UISheet sheet, final TobagoResponseWriter writer,
       final List<AbstractUIColumnBase> columns)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ColumnTagDeclaration.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ColumnTagDeclaration.java
index 9b4e825..2c68abc 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ColumnTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ColumnTagDeclaration.java
@@ -28,6 +28,7 @@ import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRend
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasLabel;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasTip;
 import org.apache.myfaces.tobago.internal.taglib.declaration.IsVisual;
+import org.apache.myfaces.tobago.layout.VerticalAlign;
 
 import javax.faces.component.UIColumn;
 
@@ -49,13 +50,25 @@ import javax.faces.component.UIColumn;
 public interface ColumnTagDeclaration
     extends HasIdBindingAndRendered, HasLabel, HasTip, IsVisual {
   /**
-   * Alignment of this column.
+   * Horizontal alignment of this column.
+   * Possible values: left (default), right, center, justify
    */
   @TagAttribute
   @UIComponentTagAttribute()
   void setAlign(String align);
 
   /**
+   * Vertical alignment of this column.
+   * Possible values:
+   * {@link VerticalAlign#top} (default),
+   * {@link VerticalAlign#bottom},
+   * {@link VerticalAlign#middle}
+   */
+  @TagAttribute
+  @UIComponentTagAttribute()
+  void setVerticalAlign(String verticalAlign); //TODO: use VerticalAlign enum instead of
string
+
+  /**
    * Flag indicating whether or not this column is sortable.
    * To make a column sortable the data of the sheet must be one of
    * <code>java.util.List</code> or <code>Object[]</code>.
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/VerticalAlign.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/VerticalAlign.java
new file mode 100644
index 0000000..2248cfe
--- /dev/null
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/VerticalAlign.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.layout;
+
+/**
+ * Values for vertical alignments used with CSS.
+ * <p>
+ * Note: the enums are not capitalized, because of problems with {@link java.beans.PropertyEditor}.
+ */
+public enum VerticalAlign {
+  top, bottom, middle;
+
+  /**
+   * Internal constant to use in annotations. Please use {@link VerticalAlign#top}
+   */
+  public static final String TOP = "top";
+
+  /**
+   * Internal constant to use in annotations. Please use {@link VerticalAlign#bottom}
+   */
+  public static final String BOTTOM = "bottom";
+
+  /**
+   * Internal constant to use in annotations. Please use {@link VerticalAlign#middle}
+   */
+  public static final String MIDDLE = "middle";
+}
diff --git a/tobago-core/src/main/resources/scss/_tobago.scss b/tobago-core/src/main/resources/scss/_tobago.scss
index 2732a4a..8cf6194 100644
--- a/tobago-core/src/main/resources/scss/_tobago.scss
+++ b/tobago-core/src/main/resources/scss/_tobago.scss
@@ -1176,6 +1176,16 @@ th.tobago-sheet-headerCell-markup-filler > .tobago-sheet-header
{
   padding: 0 !important; /* fix for IE 11 */
 }
 
+.tobago-sheet-cell.tobago-sheet-cell-markup-middle {
+  vertical-align: middle;
+  line-height: initial;
+}
+
+.tobago-sheet-cell.tobago-sheet-cell-markup-bottom {
+  vertical-align: bottom;
+  line-height: initial;
+}
+
 .tobago-sheet-footer {
   text-align: center;
 }
diff --git a/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
b/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
index 5c3a393..ab6c417 100644
--- a/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
+++ b/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
@@ -334,6 +334,10 @@ TextAlignProperty(property) ::= <<
 <NormalProperty(property)>
 >>
 
+VerticalAlignProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
 SuggestFilterProperty(property) ::= <<
 <NormalProperty(property)>
 >>


Mime
View raw message