myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1793787 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/ tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ tobago-example/tobago-example-demo/src/main/res...
Date Thu, 04 May 2017 11:58:14 GMT
Author: lofwyr
Date: Thu May  4 11:58:14 2017
New Revision: 1793787

URL: http://svn.apache.org/viewvc?rev=1793787&view=rev
Log:
TOBAGO-1719: Update Bootstrap to 4.0.0 alpha 6 (from alpha 5)
* demo: use "badge" instead of "tag"
* ensure to use the correct Bootstrap classes
* Enhance UnitTest to ensure Bootstrap classes

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/BootstrapUtils.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/resources/META-INF/
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/resources/META-INF/tobago-example-demo.taglib.xml
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/25-facelets-as-resources/facelets-as-resources.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/collapsible.xhtml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java?rev=1793787&r1=1793786&r2=1793787&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
Thu May  4 11:58:14 2017
@@ -44,6 +44,13 @@ public enum BootstrapClass implements Cs
   ALERT_DISMISSIBLE("alert-dismissible"),
   ALIGN_ITEMS_CENTER("align-items-center"),
   BG_INVERSE("bg-inverse"),
+  BADGE("badge"),
+  BADGE_DANGER("badge-danger"),
+  BADGE_DEFAULT("badge-default"),
+  BADGE_INFO("badge-info"),
+  BADGE_PRIMARY("badge-primary"),
+  BADGE_SUCCESS("badge-success"),
+  BADGE_WARNING("badge-warning"),
   BTN("btn"),
   BTN_DANGER("btn-danger"),
   BTN_GROUP("btn-group"),

Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/BootstrapUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/BootstrapUtils.java?rev=1793787&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/BootstrapUtils.java
(added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/BootstrapUtils.java
Thu May  4 11:58:14 2017
@@ -0,0 +1,13 @@
+package org.apache.myfaces.tobago.example.demo;
+
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+
+public class BootstrapUtils {
+
+  /**
+   * This method ensures, the used Bootstrap class is really existing.
+   */
+  public static String valueOf(String name) {
+    return BootstrapClass.valueOf(name).getName();
+  }
+}

Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/resources/META-INF/tobago-example-demo.taglib.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/resources/META-INF/tobago-example-demo.taglib.xml?rev=1793787&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/resources/META-INF/tobago-example-demo.taglib.xml
(added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/resources/META-INF/tobago-example-demo.taglib.xml
Thu May  4 11:58:14 2017
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<facelet-taglib
+    version="2.0"
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd">
+
+  <namespace>http://myfaces.apache.org/tobago/example/demo</namespace>
+
+  <function>
+    <function-name>bootstrapClass</function-name>
+    <function-class>org.apache.myfaces.tobago.example.demo.BootstrapUtils</function-class>
+    <function-signature>java.lang.String valueOf(java.lang.String)</function-signature>
+  </function>
+
+</facelet-taglib>
\ No newline at end of file

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml?rev=1793787&r1=1793786&r2=1793787&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
Thu May  4 11:58:14 2017
@@ -21,7 +21,8 @@
                 xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
-                xmlns:f="http://java.sun.com/jsf/core">
+                xmlns:f="http://java.sun.com/jsf/core"
+                xmlns:demo="http://myfaces.apache.org/tobago/example/demo">
   <ui:param name="title" value="#{demoBundle.progress} &lt;tc:progress>"/>
   <p>The <code class="language-markup">&lt;tc:progress/></code>
tag create a progressbar.
     The most important attribute is <code>value</code>.
@@ -66,7 +67,7 @@
       </f:facet>
 
       <p>
-        <span class="tag tag-danger">Warning!</span>
+        <span class="#{demo:bootstrapClass('BADGE')} #{demo:bootstrapClass('BADGE_DANGER')}">Warning!</span>
         <b>The reload feature is preliminary and may be subject of change in later
versions!</b>
       </p>
 

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/25-facelets-as-resources/facelets-as-resources.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/25-facelets-as-resources/facelets-as-resources.xhtml?rev=1793787&r1=1793786&r2=1793787&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/25-facelets-as-resources/facelets-as-resources.xhtml
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/25-facelets-as-resources/facelets-as-resources.xhtml
Thu May  4 11:58:14 2017
@@ -20,9 +20,15 @@
 <ui:composition template="/main.xhtml"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
-                xmlns:f="http://java.sun.com/jsf/core">
+                xmlns:demo="http://myfaces.apache.org/tobago/example/demo">
   <ui:param name="title" value="Loading Facelets from JARs"/>
   <tc:panel>
+
+    <p>
+      <span class="#{demo:bootstrapClass('BADGE')} #{demo:bootstrapClass('BADGE_DANGER')}">Warning!</span>
+      <b>This page is out of date. This is no longer needed with Servlet 3.0.</b>
+    </p>
+
     <tc:out value="#{demoBundle.faceletsAsResources_text}"/>
 
     <tc:box label="This content is included from a JAR.">

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/collapsible.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/collapsible.xhtml?rev=1793787&r1=1793786&r2=1793787&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/collapsible.xhtml
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/53-collapsible/collapsible.xhtml
Thu May  4 11:58:14 2017
@@ -18,11 +18,12 @@
 <ui:composition template="/main.xhtml"
                 xmlns="http://www.w3.org/1999/xhtml"
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
-                xmlns:ui="http://java.sun.com/jsf/facelets">
+                xmlns:ui="http://java.sun.com/jsf/facelets"
+                xmlns:demo="http://myfaces.apache.org/tobago/example/demo">
   <ui:param name="title" value="#{demoBundle.collapsible}"/>
 
   <p>
-    <span class="tag tag-danger">Warning!</span>
+    <span class="#{demo:bootstrapClass('BADGE')} #{demo:bootstrapClass('BADGE_DANGER')}">Warning!</span>
     <b>This feature is preliminary and may be subject of change in later versions!</b>
   </p>
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java?rev=1793787&r1=1793786&r2=1793787&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
Thu May  4 11:58:14 2017
@@ -19,52 +19,68 @@
 
 package org.apache.myfaces.tobago.renderkit.css;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.FileNotFoundException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
+
 /**
  * Test if every in Java declared CSS class has really an entry in a CSS file.
  */
 public class BootstrapClassUnitTest {
 
-  private List<BootstrapClass> not = Arrays.asList(
-      BootstrapClass.COL_XS_1,
-      BootstrapClass.COL_XS_2,
-      BootstrapClass.COL_XS_3,
-      BootstrapClass.COL_XS_4,
-      BootstrapClass.COL_XS_5,
-      BootstrapClass.COL_XS_6,
-      BootstrapClass.COL_XS_7,
-      BootstrapClass.COL_XS_8,
-      BootstrapClass.COL_XS_9,
-      BootstrapClass.COL_XS_10,
-      BootstrapClass.COL_XS_11,
-      BootstrapClass.COL_XS_12,
-      BootstrapClass.NAVBAR_DARK,
-      BootstrapClass.NAVBAR_TOGGLEABLE_XS
-  );
+  @Test
+  public void testNames() throws NoSuchFieldException {
+
+    final String fieldRegex = "[A-Z][A-Z0-9_]*[A-Z0-9]";
+    final String nameRegex = "[a-z][a-z0-9\\-]*[a-z0-9]";
+
+    for (BootstrapClass value : BootstrapClass.values()) {
+      boolean ignoreByTest = BootstrapClass.class.getField(value.name()).isAnnotationPresent(Deprecated.class);
+      if (!ignoreByTest) {
+        final String field = value.toString();
+        final String name = value.getName();
+
+        Assert.assertTrue("testing: '" + field + "' matches regexp for consts like FOO_BAR",
field.matches(fieldRegex));
+        Assert.assertTrue("testing: '" + name + "' matches regexp for CSS like foo-bar",
name.matches(nameRegex));
+
+        StringBuilder calculatedName = new StringBuilder();
+        for (int i = 0; i < field.length(); i++) {
+          char c = field.charAt(i);
+          if (c == '_') {
+            calculatedName.append("-");
+          } else {
+            calculatedName.append(Character.toLowerCase(c));
+          }
+        }
+
+        Assert.assertEquals(field, calculatedName.toString(), name);
+      }
+    }
+  }
 
   /**
    * This test checks, if every item of the {@link BootstrapClass} occurs in the bootstrap.css.
    */
   @Test
-  public void testCompareBootstrapCss() throws FileNotFoundException {
+  public void testCompareBootstrapCss() throws FileNotFoundException, NoSuchFieldException
{
 
     final BootstrapClass[] allValues = BootstrapClass.values();
     final List<BootstrapClass> toCheck = new ArrayList<BootstrapClass>();
     for (BootstrapClass value : allValues) {
-      if (!not.contains(value)) {
+      boolean ignoreByTest = BootstrapClass.class.getField(value.name()).isAnnotationPresent(Deprecated.class);
+      if (!ignoreByTest) {
         toCheck.add(value);
       }
     }
 
-    CssClassUtils.compareCss(
+    final List<CssItem> missing = CssClassUtils.compareCss(
         "src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/css/bootstrap.css",
         toCheck.toArray(new BootstrapClass[toCheck.size()]));
-  }
 
+    Assert.assertTrue("These classes are missing in bootstrap.css: " + missing, missing.isEmpty());
+  }
 }



Mime
View raw message