myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject svn commit: r1792194 - in /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago: component/ internal/renderkit/renderer/ internal/taglib/component/ renderkit/css/
Date Fri, 21 Apr 2017 12:18:52 GMT
Author: hnoeth
Date: Fri Apr 21 12:18:52 2017
New Revision: 1792194

URL: http://svn.apache.org/viewvc?rev=1792194&view=rev
Log:
TOBAGO-1734 Align of dropdown menu is always 'left'
* implement ButtonInsideInAfterRenderer for buttons inside an after-facet of an input field

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideInAfterRenderer.java
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.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=1792194&r1=1792193&r2=1792194&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
Fri Apr 21 12:18:52 2017
@@ -28,6 +28,7 @@ public enum RendererTypes {
   Box,
   Button,
   ButtonInsideIn,
+  ButtonInsideInAfter,
   Buttons,
   Calendar,
   Column,
@@ -99,6 +100,7 @@ public enum RendererTypes {
   public static final String BOX = "Box";
   public static final String BUTTON = "Button";
   public static final String BUTTON_INSIDE_IN = "ButtonInsideIn";
+  public static final String BUTTON_INSIDE_IN_AFTER = "ButtonInsideInAfter";
   public static final String BUTTONS = "Buttons";
   public static final String CALENDAR = "Calendar";
   public static final String COLUMN = "Column";

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideInAfterRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideInAfterRenderer.java?rev=1792194&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideInAfterRenderer.java
(added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideInAfterRenderer.java
Fri Apr 21 12:18:52 2017
@@ -0,0 +1,36 @@
+/*
+ * 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.renderkit.renderer;
+
+import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.CssItem;
+
+import javax.faces.context.FacesContext;
+import java.util.List;
+
+public class ButtonInsideInAfterRenderer extends ButtonInsideInRenderer {
+
+  @Override
+  protected void addDropdownCssItems(final FacesContext facesContext, final AbstractUICommand
command,
+                                  final List<CssItem> collected) {
+    collected.add(BootstrapClass.DROPDOWN_MENU_RIGHT);
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java?rev=1792194&r1=1792193&r2=1792194&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
Fri Apr 21 12:18:52 2017
@@ -157,7 +157,13 @@ public abstract class CommandRendererBas
 
     if (parentOfCommands) {
       writer.startElement(HtmlElements.DIV);
-      writer.writeClassAttribute(BootstrapClass.DROPDOWN_MENU);
+      final List<CssItem> dropdownCssItems = new ArrayList<CssItem>();
+      addDropdownCssItems(facesContext, command, dropdownCssItems);
+      writer.writeClassAttribute(
+          BootstrapClass.DROPDOWN_MENU,
+          null,
+          dropdownCssItems.toArray(new CssItem[dropdownCssItems.size()])
+      );
       writer.writeAttribute(Arias.LABELLEDBY, "dropdownMenuButton", false);
 
       for (final UIComponent child : component.getChildren()) {
@@ -230,4 +236,8 @@ public abstract class CommandRendererBas
   protected void addCssItems(final FacesContext facesContext, final AbstractUICommand command,
                              final List<CssItem> collected) {
   }
+
+  protected void addDropdownCssItems(final FacesContext facesContext, final AbstractUICommand
command,
+                                     final List<CssItem> collected) {
+  }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java?rev=1792194&r1=1792193&r2=1792194&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java
Fri Apr 21 12:18:52 2017
@@ -82,7 +82,7 @@ public class InRenderer extends MessageL
       writer.startElement(HtmlElements.DIV);
       writer.writeClassAttribute(BootstrapClass.INPUT_GROUP);
     }
-    encodeGroupAddon(facesContext, writer, before);
+    encodeGroupAddon(facesContext, writer, before, false);
 
     writer.startElement(HtmlElements.INPUT);
 
@@ -141,7 +141,7 @@ public class InRenderer extends MessageL
 
     writer.endElement(HtmlElements.INPUT);
 
-    encodeGroupAddon(facesContext, writer, after);
+    encodeGroupAddon(facesContext, writer, after, true);
 
     if (after != null || before != null) {
       writer.endElement(HtmlElements.DIV);
@@ -149,8 +149,8 @@ public class InRenderer extends MessageL
     }
   }
 
-  private void encodeGroupAddon(FacesContext facesContext, TobagoResponseWriter writer, UIComponent
addon)
-      throws IOException {
+  private void encodeGroupAddon(FacesContext facesContext, TobagoResponseWriter writer, UIComponent
addon,
+                                boolean isAfterFacet) throws IOException {
     if (addon != null) {
       final List<UIComponent> children;
       if (addon instanceof UIPanel) {
@@ -160,7 +160,11 @@ public class InRenderer extends MessageL
       }
       for (UIComponent child : children) {
         if (child instanceof AbstractUIButton && ((AbstractUIButton) child).isParentOfCommands())
{
-          child.setRendererType(RendererTypes.ButtonInsideIn.name());
+          if (isAfterFacet) {
+            child.setRendererType(RendererTypes.ButtonInsideInAfter.name());
+          } else {
+            child.setRendererType(RendererTypes.ButtonInsideIn.name());
+          }
           RenderUtils.encode(facesContext, child);
         } else {
           writer.startElement(HtmlElements.SPAN);

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java?rev=1792194&r1=1792193&r2=1792194&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
Fri Apr 21 12:18:52 2017
@@ -60,7 +60,7 @@ import javax.faces.component.UICommand;
         "org.apache.myfaces.tobago.component.SupportsAccessKey"
     },
     componentFamily = UICommand.COMPONENT_FAMILY,
-    rendererType = {RendererTypes.BUTTON, RendererTypes.BUTTON_INSIDE_IN},
+    rendererType = {RendererTypes.BUTTON, RendererTypes.BUTTON_INSIDE_IN, RendererTypes.BUTTON_INSIDE_IN_AFTER},
     allowedChildComponenents = "NONE",
     facets = {
         @Facet(

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=1792194&r1=1792193&r2=1792194&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
Fri Apr 21 12:18:52 2017
@@ -151,6 +151,7 @@ public enum BootstrapClass implements Cs
   DROPDOWN("dropdown"),
   DROPDOWN_ITEM("dropdown-item"),
   DROPDOWN_MENU("dropdown-menu"),
+  DROPDOWN_MENU_RIGHT("dropdown-menu-right"),
   DROPDOWN_TOGGLE("dropdown-toggle"),
   FADE("fade"),
   FIGURE("figure"),



Mime
View raw message