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 2016/09/22 05:33:21 UTC

svn commit: r1761851 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/...

Author: lofwyr
Date: Thu Sep 22 05:33:21 2016
New Revision: 1761851

URL: http://svn.apache.org/viewvc?rev=1761851&view=rev
Log:
TOBAGO-1605: New component: tc:figure

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFigure.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FigureTagDeclaration.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FigureRenderer.java
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java?rev=1761851&r1=1761850&r2=1761851&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java Thu Sep 22 05:33:21 2016
@@ -35,6 +35,7 @@ public enum RendererTypes {
   Command,
   Commands,
   Date,
+  Figure,
   File,
   FlexLayout,
   FlowLayout,
@@ -102,6 +103,7 @@ public enum RendererTypes {
   public static final String COMMAND = "Command";
   public static final String COMMANDS = "Commands";
   public static final String DATE = "Date";
+  public static final String FIGURE = "Figure";
   public static final String FILE = "File";
   public static final String FLEX_LAYOUT = "FlexLayout";
   public static final String FLOW_LAYOUT = "FlowLayout";

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFigure.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFigure.java?rev=1761851&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFigure.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIFigure.java Thu Sep 22 05:33:21 2016
@@ -0,0 +1,25 @@
+/*
+ * 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.internal.component;
+
+public abstract class AbstractUIFigure extends AbstractUIPanelBase {
+
+  public abstract String getLabel();
+}

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FigureTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FigureTagDeclaration.java?rev=1761851&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FigureTagDeclaration.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/FigureTagDeclaration.java Thu Sep 22 05:33:21 2016
@@ -0,0 +1,51 @@
+/*
+ * 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.internal.taglib.component;
+
+import org.apache.myfaces.tobago.apt.annotation.Facet;
+import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
+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 javax.faces.component.UIPanel;
+
+/**
+ * Use figure to show e. g. images or videos inside.
+ */
+@Tag(name = "figure")
+@UIComponentTag(
+    uiComponent = "org.apache.myfaces.tobago.component.UIFigure",
+    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUIFigure",
+    uiComponentFacesClass = "javax.faces.component.UIPanel",
+    componentFamily = UIPanel.COMPONENT_FAMILY,
+    rendererType = RendererTypes.FIGURE,
+    interfaces = "org.apache.myfaces.tobago.component.Visual",
+    facets = {
+        @Facet(
+            name = Facets.LABEL,
+            description = "Contains some code to be placed in the header at the label position.")})
+public interface FigureTagDeclaration
+    extends HasIdBindingAndRendered, IsVisual, HasTip, HasLabel {
+}

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java?rev=1761851&r1=1761850&r2=1761851&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java Thu Sep 22 05:33:21 2016
@@ -111,6 +111,9 @@ public enum BootstrapClass implements Cs
   DROPDOWN_MENU("dropdown-menu"),
   DROPDOWN_TOGGLE("dropdown-toggle"),
   FADE("fade"),
+  FIGURE("figure"),
+  FIGURE_CAPTION("figure-caption"),
+  FIGURE_IMG("figure-img"),
   FORM_CHECK("form-check"),
   FORM_CHECK_INLINE("form-check-inline"),
   FORM_CHECK_LABEL("form-check-label"),

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java?rev=1761851&r1=1761850&r2=1761851&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java Thu Sep 22 05:33:21 2016
@@ -52,6 +52,7 @@ public enum TobagoClass implements CssIt
   BOX__HEADER("tobago-box-header"),
   COLLAPSED("tobago-collapsed"),
   FLEX_LAYOUT("tobago-flexLayout"),
+  FIGURE("tobago-figure"),
   FORM("tobago-form"),
   LABEL("tobago-label"),
   MENU_BAR("tobago-menuBar"),

Added: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FigureRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FigureRenderer.java?rev=1761851&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FigureRenderer.java (added)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/FigureRenderer.java Thu Sep 22 05:33:21 2016
@@ -0,0 +1,78 @@
+/*
+ * 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.renderkit.html.standard.standard.tag;
+
+import org.apache.myfaces.tobago.component.Facets;
+import org.apache.myfaces.tobago.internal.component.AbstractUIFigure;
+import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.Classes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
+import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+public class FigureRenderer extends RendererBase {
+
+  @Override
+  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+    final AbstractUIFigure figure = (AbstractUIFigure) component;
+    final TobagoResponseWriter writer = getResponseWriter(facesContext);
+    writer.startElement(HtmlElements.FIGURE);
+    writer.writeClassAttribute(Classes.create(figure), BootstrapClass.FIGURE, figure.getCustomClass());
+    writer.writeStyleAttribute(figure.getStyle());
+    final String tip = figure.getTip();
+    if (tip != null) {
+      writer.writeAttribute(HtmlAttributes.TITLE, tip, true);
+    }
+
+    writer.startElement(HtmlElements.DIV);
+    writer.writeClassAttribute(BootstrapClass.FIGURE_IMG);
+  }
+
+  @Override
+  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
+    final AbstractUIFigure figure = (AbstractUIFigure) component;
+    final UIComponent label = ComponentUtils.getFacet(figure, Facets.label);
+    final String labelString = figure.getLabel();
+
+    final TobagoResponseWriter writer = getResponseWriter(facesContext);
+
+    writer.endElement(HtmlElements.DIV);
+
+    if (labelString != null || label != null) {
+      writer.startElement(HtmlElements.FIGCAPTION);
+      writer.writeClassAttribute(BootstrapClass.FIGURE_CAPTION);
+      if (labelString != null) {
+        writer.writeText(labelString);
+      }
+      if (label != null) {
+        RenderUtils.encode(facesContext, label);
+      }
+      writer.endElement(HtmlElements.FIGCAPTION);
+    }
+    writer.endElement(HtmlElements.FIGURE);
+  }
+}