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/05/28 16:26:28 UTC

svn commit: r1682255 - in /myfaces/tobago/branches/tobago-3.0.x: ./ tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/ tobago-example/tobago-example-demo/src/main/webapp/ tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/ tob...

Author: lofwyr
Date: Thu May 28 14:26:27 2015
New Revision: 1682255

URL: http://svn.apache.org/r1682255
Log:
TOBAGO-1368: Create a new theme which uses Bootstrap
- Fix Mojarra vs. MyFaces different severity ordinal
- Fix align for FlowLayout
- Layout optimizations (looks better)

Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-3.0.txt
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/BootstrapClass.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FlowLayoutRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FooterRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PanelRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-3.0.txt
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-3.0.txt?rev=1682255&r1=1682254&r2=1682255&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-3.0.txt (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-3.0.txt Thu May 28 14:26:27 2015
@@ -17,6 +17,23 @@ Todo:
 
   - consolidate LinkRenderer, ButtonRenderer with CommandRenderer
 
+  - check it its a good idea to use layouts with less typing:
+
+    <tc:flowLayout>
+      ... content ...
+    </tc:flowLayout>
+
+    instead of
+
+    <tc:panel>
+      <f:facet name="layout">
+        <tc:flowLayout/>
+      </f:facet>
+      ... content ...
+    </tc:panel>
+
+
+
 Done:
 
   - Removing tc:cell tag, please use tc:panel instead.

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java?rev=1682255&r1=1682254&r2=1682255&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java Thu May 28 14:26:27 2015
@@ -139,8 +139,24 @@ public abstract class TobagoResponseWrit
   public void writeClassAttribute(final CssItem first, final CssItem... others) throws IOException {
     StringBuilder builder = new StringBuilder(first.getName());
     for (CssItem other : others) {
-      builder.append(' ');
-      builder.append(other.getName());
+      if (other != null) {
+        builder.append(' ');
+        builder.append(other.getName());
+      }
+    }
+    writeAttribute(HtmlAttributes.CLASS, builder.toString(), false);
+  }
+
+  /**
+   * TBD: preliminary
+   */
+  public void writeClassAttribute(final Classes classes, final CssItem... others) throws IOException {
+    StringBuilder builder = new StringBuilder(classes.getStringValue());
+    for (CssItem other : others) {
+      if (other != null) {
+        builder.append(' ');
+        builder.append(other.getName());
+      }
     }
     writeAttribute(HtmlAttributes.CLASS, builder.toString(), false);
   }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml?rev=1682255&r1=1682254&r2=1682255&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/sheet.xhtml Thu May 28 14:26:27 2015
@@ -162,9 +162,10 @@
         <tc:out value="#{luminary.number}" id="t_number"/>
       </tc:column>
       <tc:column label="#{overviewBundle.solarArrayOrbit}" sortable="true" id="orbit">
+<!--
         <f:facet name="dropDownMenu">
           <tc:menu>
-            <!-- TODO: example or remove -->
+            &lt;!&ndash; TODO: example or remove &ndash;&gt;
             <tc:menuCommand omit="true" label="todo">
               <tc:dataAttribute name="alert-text" value="Not implemented yet"/>
             </tc:menuCommand>
@@ -179,8 +180,9 @@
           <f:facet name="layout">
             <tc:gridLayout rows="20px"/>
           </f:facet>
+-->
           <tc:out value="#{luminary.orbit}" id="t_orbit"/>
-        </tc:panel>
+        <!--</tc:panel>-->
       </tc:column>
       <tc:column label="#{overviewBundle.solarArrayPopulation}" sortable="true" id="population">
         <tc:in value="#{luminary.population}" id="t_population"/>

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml?rev=1682255&r1=1682254&r2=1682255&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml Thu May 28 14:26:27 2015
@@ -17,7 +17,9 @@
  * limitations under the License.
 -->
 
-<tc:header fixed="true" xmlns:tc="http://myfaces.apache.org/tobago/component">
+<tc:header fixed="true"
+           xmlns:tc="http://myfaces.apache.org/tobago/component"
+           xmlns:f="http://java.sun.com/jsf/core">
 
   <tc:nav image="image/feather-leaf.png" label="Tobago Demo">
 
@@ -79,12 +81,17 @@
     </tc:form>
 
     <tc:form>
-      <tc:in placeholder="Search"/>
-      <tc:button defaultCommand="true" omit="true" label="go">
-        <tc:dataAttribute name="alert-text"
-                          value="Sorry: Search not implemented"/>
+      <tc:panel>
+        <f:facet name="layout">
+          <tc:flowLayout textAlign="right"/>
+        </f:facet>
+        <tc:in placeholder="Search"/>
+        <tc:button defaultCommand="true" omit="true" label="go">
+          <tc:dataAttribute name="alert-text"
+                            value="Sorry: Search not implemented"/>
 
-      </tc:button>
+        </tc:button>
+      </tc:panel>
     </tc:form>
 
   </tc:nav>

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/BootstrapClass.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/BootstrapClass.java?rev=1682255&r1=1682254&r2=1682255&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/BootstrapClass.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/BootstrapClass.java Thu May 28 14:26:27 2015
@@ -19,6 +19,7 @@
 
 package org.apache.myfaces.tobago.renderkit.html;
 
+import org.apache.myfaces.tobago.layout.TextAlign;
 import org.apache.myfaces.tobago.renderkit.css.CssItem;
 
 import javax.faces.application.FacesMessage;
@@ -76,7 +77,11 @@ public enum BootstrapClass implements Cs
   TABLE("table"),
   TABLE_BORDERED("table-bordered"),
   TABLE_HOVER("table-hover"),
-  TABLE_STRIPED("table-striped");
+  TABLE_STRIPED("table-striped"),
+  TEXT_CENTER("text-center"),
+  TEXT_JUSTIFY("text-justify"),
+  TEXT_LEFT("text-left"),
+  TEXT_RIGHT("text-right");
 
   private final String name;
 
@@ -102,16 +107,31 @@ public enum BootstrapClass implements Cs
 
   public static CssItem alert(final FacesMessage.Severity severity) {
 
-    switch (severity.getOrdinal()) {
-      case 1:
-        return ALERT_INFO;
-      case 2:
-        return ALERT_WARNING;
-      case 3:
-      case 4:
-      default:
-        return ALERT_DANGER;
+    // switch over severity.getOrdinal() doesn't work, because different implementations use different ordinals,
+    // see MYFACES-3768
+    // may be optimized with a cache...
+
+    if (severity.equals(FacesMessage.SEVERITY_INFO)) {
+      return ALERT_INFO;
+    } else if (severity.equals(FacesMessage.SEVERITY_WARN)) {
+      return ALERT_WARNING;
+    } else {
+      return ALERT_DANGER;
     }
   }
 
+  public static CssItem textAlign(final TextAlign textAlign) {
+    switch (textAlign) {
+      case LEFT:
+        return TEXT_LEFT;
+      case RIGHT:
+        return TEXT_RIGHT;
+      case CENTER:
+        return TEXT_CENTER;
+      case JUSTIFY:
+        return TEXT_JUSTIFY;
+      default:
+        return null;
+    }
+  }
 }

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/FlowLayoutRenderer.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/FlowLayoutRenderer.java?rev=1682255&r1=1682254&r2=1682255&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/FlowLayoutRenderer.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/FlowLayoutRenderer.java Thu May 28 14:26:27 2015
@@ -29,6 +29,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.SpacingValues;
 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.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
@@ -45,13 +46,12 @@ public class FlowLayoutRenderer extends
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
     final UIFlowLayout layout = (UIFlowLayout) component;
     writer.startElement(HtmlElements.DIV, layout);
-    writer.writeClassAttribute(Classes.create(layout));
+    writer.writeClassAttribute(Classes.create(layout), BootstrapClass.textAlign(layout.getTextAlign()));
     final Style style = new Style();
     style.setMarginLeft(getMarginLeft(facesContext, layout));
     style.setMarginRight(getMarginRight(facesContext, layout));
     style.setMarginTop(getMarginTop(facesContext, layout));
     style.setMarginBottom(getMarginBottom(facesContext, layout));
-    style.setTextAlign(layout.getTextAlign());
     writer.writeStyleAttribute(style);
   }
 

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/FooterRenderer.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/FooterRenderer.java?rev=1682255&r1=1682254&r2=1682255&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/FooterRenderer.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/FooterRenderer.java Thu May 28 14:26:27 2015
@@ -40,8 +40,7 @@ public class FooterRenderer extends Rend
     writer.startElement(HtmlElements.FOOTER, component);
     writer.writeIdAttribute(component.getClientId(facesContext));
     if (footer.isFixed()) {
-      writer.writeClassAttribute(
-          Classes.create(footer).getStringValue() + " " + BootstrapClass.NAVBAR_FIXED_BOTTOM.getName());
+      writer.writeClassAttribute(Classes.create(footer), BootstrapClass.NAVBAR_FIXED_BOTTOM);
     } else {
       writer.writeClassAttribute(Classes.create(footer));
     }

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/PanelRenderer.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/PanelRenderer.java?rev=1682255&r1=1682254&r2=1682255&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/PanelRenderer.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/PanelRenderer.java Thu May 28 14:26:27 2015
@@ -22,6 +22,7 @@ package org.apache.myfaces.tobago.render
 import org.apache.myfaces.tobago.component.Facets;
 import org.apache.myfaces.tobago.component.UIPanel;
 import org.apache.myfaces.tobago.component.UIReload;
+import org.apache.myfaces.tobago.internal.component.AbstractUIColumnLayout;
 import org.apache.myfaces.tobago.internal.component.AbstractUIPanel;
 import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
 import org.apache.myfaces.tobago.layout.Measure;
@@ -68,7 +69,14 @@ public class PanelRenderer extends Layou
     final String clientId = panel.getClientId(facesContext);
     writer.startElement(HtmlElements.DIV, panel);
     writer.writeIdAttribute(clientId);
-    writer.writeClassAttribute(Classes.create(panel).getStringValue() + " " + BootstrapClass.ROW.getName());
+
+    if (panel.getLayoutManager() instanceof AbstractUIColumnLayout) {
+      // TBD: this might be nicer, wen using the layout not as a facet
+      writer.writeClassAttribute(Classes.create(panel), BootstrapClass.ROW);
+    } else {
+      writer.writeClassAttribute(Classes.create(panel));
+    }
+
     HtmlRendererUtils.writeDataAttributes(facesContext, writer, panel);
     if (panel instanceof UIPanel && ((UIPanel) panel).getTip() != null) {
       writer.writeAttribute(HtmlAttributes.TITLE, ((UIPanel) panel).getTip(), true);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css?rev=1682255&r1=1682254&r2=1682255&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css Thu May 28 14:26:27 2015
@@ -52,6 +52,7 @@
 
 .tobago-footer {
   background-color: #ffffff;
+  padding: 5px 10px;
 }
 
 /* gridLayout -------------------------------------------------------------- */
@@ -95,7 +96,8 @@ table.tobago-gridLayout > tbody > tr:fir
 /* page ----------------------------------------------------------- */
 
 body > form > .navbar-fixed-top + * {
-  margin-top: 70px;
+  margin-top: 40px; /* height of the .navbar-fixed-top, todo: use "less" variable */
+  margin-top: 50px; /* XXX */
 }
 
 /* selectManyCheckbox ----------------------------------------------------------- */