myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1750640 [2/2] - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/event/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tob...
Date Wed, 29 Jun 2016 13:58:19 GMT
Added: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PanelRendererBase.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/PanelRendererBase.java?rev=1750640&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PanelRendererBase.java
(added)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PanelRendererBase.java
Wed Jun 29 13:58:18 2016
@@ -0,0 +1,76 @@
+/*
+ * 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.internal.component.AbstractUICollapsiblePanel;
+import org.apache.myfaces.tobago.internal.util.StringUtils;
+import org.apache.myfaces.tobago.model.CollapseState;
+import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
+import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
+import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
+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;
+import java.util.Map;
+
+public class PanelRendererBase extends RendererBase {
+
+  @Override
+  public void decode(final FacesContext facesContext, final UIComponent component) {
+    super.decode(facesContext, component);
+
+    final AbstractUICollapsiblePanel collapsible = (AbstractUICollapsiblePanel) component;
+    final String clientId = collapsible.getClientId(facesContext);
+    final String hiddenId = clientId + ComponentUtils.SUB_SEPARATOR + "collapse";
+
+    final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
+    if (requestParameterMap.containsKey(hiddenId)) {
+      final String newValue = requestParameterMap.get(hiddenId);
+      if (StringUtils.isNotBlank(newValue)) {
+        collapsible.setNextState(CollapseState.valueOf(newValue));
+      }
+    }
+  }
+
+  protected void encodeHidden(final TobagoResponseWriter writer, final String clientId) throws
IOException {
+    writer.startElement(HtmlElements.INPUT);
+    writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN);
+    writer.writeNameAttribute(clientId + ComponentUtils.SUB_SEPARATOR + "collapse");
+    writer.writeIdAttribute(clientId + ComponentUtils.SUB_SEPARATOR + "collapse");
+    writer.endElement(HtmlElements.INPUT);
+  }
+
+  @Override
+  public boolean getRendersChildren() {
+    return true;
+  }
+
+  @Override
+  public void encodeChildren(final FacesContext facesContext, final UIComponent component)
throws IOException {
+    if (((AbstractUICollapsiblePanel) component).getCollapsed().isSkipLifecycle()) {
+      return;
+    }
+    super.encodeChildren(facesContext, component);
+  }
+}

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.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/SectionRenderer.java?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java
Wed Jun 29 13:58:18 2016
@@ -20,8 +20,8 @@
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
 import org.apache.myfaces.tobago.component.Facets;
-import org.apache.myfaces.tobago.component.UISection;
-import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.internal.component.AbstractUISection;
+import org.apache.myfaces.tobago.model.CollapseState;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
@@ -34,60 +34,71 @@ import javax.faces.component.UIComponent
 import javax.faces.context.FacesContext;
 import java.io.IOException;
 
-public class SectionRenderer extends RendererBase {
+public class SectionRenderer extends PanelRendererBase {
 
-    @Override
-    public void encodeBegin(final FacesContext facesContext, final UIComponent component)
throws IOException {
+  @Override
+  public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws
IOException {
 
-        final UISection section = (UISection) component;
-        final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    final AbstractUISection section = (AbstractUISection) component;
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    final String clientId = section.getClientId(facesContext);
+    final CollapseState collapsed = section.getCollapsed();
+
+    writer.startElement(HtmlElements.DIV);
+    writer.writeIdAttribute(clientId);
+    writer.writeClassAttribute(
+        Classes.create(section),
+        collapsed == CollapseState.visible ? null : TobagoClass.COLLAPSED,
+        section.getCustomClass());
+    HtmlRendererUtils.writeDataAttributes(facesContext, writer, section);
+
+    String label = section.getLabelToRender();
+    final HtmlElements tag;
+    switch (section.getLevel()) {
+      case 1:
+        tag = HtmlElements.H1;
+        break;
+      case 2:
+        tag = HtmlElements.H2;
+        break;
+      case 3:
+        tag = HtmlElements.H3;
+        break;
+      case 4:
+        tag = HtmlElements.H4;
+        break;
+      case 5:
+        tag = HtmlElements.H5;
+        break;
+      default:
+        tag = HtmlElements.H6;
+    }
 
-        writer.startElement(HtmlElements.DIV);
-        writer.writeIdAttribute(section.getClientId(facesContext));
-        writer.writeClassAttribute(Classes.create(section), section.getCustomClass());
-        HtmlRendererUtils.writeDataAttributes(facesContext, writer, section);
-
-        String label = section.getLabelToRender();
-        final HtmlElements tag;
-        switch (section.getLevel()) {
-            case 1:
-                tag = HtmlElements.H1;
-                break;
-            case 2:
-                tag = HtmlElements.H2;
-                break;
-            case 3:
-                tag = HtmlElements.H3;
-                break;
-            case 4:
-                tag = HtmlElements.H4;
-                break;
-            case 5:
-                tag = HtmlElements.H5;
-                break;
-            default:
-                tag = HtmlElements.H6;
-        }
-
-        writer.startElement(HtmlElements.DIV);
-        writer.writeClassAttribute(TobagoClass.SECTION__HEADER);
-        writer.startElement(tag);
-        final String image = section.getImage();
-        HtmlRendererUtils.encodeIconWithLabel(writer, image, label);
-        writer.endElement(tag);
-
-        final UIComponent bar = ComponentUtils.getFacet(section, Facets.bar);
-        if (bar != null) {
-            RenderUtils.encode(facesContext, bar);
-        }
+    encodeHidden(writer, clientId);
 
-        writer.endElement(HtmlElements.DIV);
+    writer.startElement(HtmlElements.DIV);
+    writer.writeClassAttribute(TobagoClass.SECTION__HEADER);
+    writer.startElement(tag);
+    final String image = section.getImage();
+    HtmlRendererUtils.encodeIconWithLabel(writer, image, label);
+    writer.endElement(tag);
+
+    final UIComponent bar = ComponentUtils.getFacet(section, Facets.bar);
+    if (bar != null) {
+      RenderUtils.encode(facesContext, bar);
     }
 
-    @Override
-    public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws
IOException {
+    writer.endElement(HtmlElements.DIV);
 
-        final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-        writer.endElement(HtmlElements.DIV);
-    }
+    writer.startElement(HtmlElements.DIV);
+    writer.writeClassAttribute(TobagoClass.SECTION__CONTENT);
+  }
+
+  @Override
+  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws
IOException {
+
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    writer.endElement(HtmlElements.DIV);
+    writer.endElement(HtmlElements.DIV);
+  }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.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/SheetRenderer.java?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SheetRenderer.java
Wed Jun 29 13:58:18 2016
@@ -766,7 +766,8 @@ public class SheetRenderer extends Rende
               }
               final CommandMap map = new CommandMap();
               final Command click = new Command(
-                  sortCommand.getClientId(facesContext), null, null, null, clientIds, null,
null, null, null, null);
+                  sortCommand.getClientId(facesContext), null, null, null, clientIds, null,
null, null, null, null,
+                  null);
               map.setClick(click);
               writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.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/TabGroupRenderer.java?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/TabGroupRenderer.java
Wed Jun 29 13:58:18 2016
@@ -31,7 +31,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.event.TabChangeEvent;
-import org.apache.myfaces.tobago.internal.component.AbstractUIPanel;
+import org.apache.myfaces.tobago.internal.component.AbstractUIPanelBase;
 import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
 import org.apache.myfaces.tobago.internal.util.Deprecation;
 import org.apache.myfaces.tobago.model.SwitchType;
@@ -133,7 +133,7 @@ public class TabGroupRenderer extends Re
     int closestRenderedTabIndex = -1;
     for (final UIComponent tab : tabGroup.getChildren()) {
       index++;
-      if (tab instanceof AbstractUIPanel) {
+      if (tab instanceof AbstractUIPanelBase) {
         if (index == activeIndex) {
           if (tab.isRendered()) {
             return index;

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
Wed Jun 29 13:58:18 2016
@@ -35,3 +35,41 @@ Tobago.Popup.close = function(button) {
 
 Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.DOCUMENT_READY);
 Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.AFTER_UPDATE);
+
+Tobago.Collapse = {};
+
+Tobago.Collapse.findHidden = function ($element) {
+  return jQuery(Tobago.Utils.escapeClientId($element.attr("id") + "::collapse"));
+};
+
+Tobago.Collapse.execute = function (collapse) {
+  var transition = collapse.transition;
+  var $for = jQuery(Tobago.Utils.escapeClientId(collapse.forId));
+  var $hidden = Tobago.Collapse.findHidden($for);
+  var state = $hidden.val();
+  var newState;
+  switch (transition) {
+    case "hide":
+      newState = "hidden";
+      break;
+    case "show":
+      newState = "visible";
+      break;
+    case "drop":
+      newState = "absent";
+      break;
+    default:
+      console.error("unknown transition: '" + transition + "'");
+  }
+  if (newState == "visible") {
+    $for.removeClass("tobago-collapsed");
+  } else {
+    $for.addClass("tobago-collapsed");
+  }
+  var serverRequestRequired = state == "absent" || newState == "absent";
+  if (serverRequestRequired) {
+    console.info("serverRequestRequired!"); // todo: remove var serverRequestRequired: is
not needed.
+    // tbd. this this must be done be the deveopoer manually
+  }
+  $hidden.val(newState);
+};

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Wed Jun 29 13:58:18 2016
@@ -638,8 +638,14 @@ var Tobago = {
 
     if (commands.click) {
       command.click(function(event) {
-        if (commands.click.omit != true) {
-          if (commands.click.confirmation == null || confirm(commands.click.confirmation))
{
+        if (commands.click.confirmation == null || confirm(commands.click.confirmation))
{
+
+          var collapse = commands.click.collapse;
+          if (collapse) {
+            Tobago.Collapse.execute(collapse);
+          }
+
+          if (commands.click.omit != true) {
             var popup = commands.click.popup;
             if (popup && popup.command == "close" && popup.immediate) {
               Tobago.Popup.close(this);

Modified: myfaces/tobago/trunk/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/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
Wed Jun 29 13:58:18 2016
@@ -41,11 +41,11 @@
 
 /* collapsible -------------------------------------------------------------- */
 
-/*.tobago-collapsed.tobago-box .card-block,*/
-/*.tobago-collapsed.tobago-section .tobago-section-content,*/
-/*.tobago-collapsed.tobago-panel {*/
-  /*display: none;*/
-/*}*/
+.tobago-collapsed.tobago-box .card-block,
+.tobago-collapsed.tobago-section .tobago-section-content,
+.tobago-collapsed.tobago-panel {
+  display: none;
+}
 
 /* date -------------------------------------------------------------- */
 

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
(original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/html/JsonUtilsUnitTest.java
Wed Jun 29 13:58:18 2016
@@ -47,7 +47,7 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void click() {
     final CommandMap map = new CommandMap();
-    map.setClick(new Command(null, null, null, null, "", null, null, null, null, null));
+    map.setClick(new Command(null, null, null, null, "", null, null, null, null, null, null));
     final String expected = "{'click':{}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(map));
   }
@@ -55,7 +55,7 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void change() {
     final CommandMap map = new CommandMap();
-    map.addCommand("change", new Command(null, null, null, null, null, null, null, null,
null, null));
+    map.addCommand("change", new Command(null, null, null, null, null, null, null, null,
null, null, null));
     final String expected = "{'change':{}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(map));
   }
@@ -63,8 +63,8 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void two() {
     final CommandMap map = new CommandMap();
-    map.addCommand("click", new Command(null, null, "target", null, null, null, null, null,
null, null));
-    map.addCommand("change", new Command(null, null, null, null, null, null, null, null,
null, null));
+    map.addCommand("click", new Command(null, null, "target", null, null, null, null, null,
null, null, null));
+    map.addCommand("change", new Command(null, null, null, null, null, null, null, null,
null, null, null));
     final String expected = "{'click':{'target':'target'},'change':{}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(map));
   }
@@ -72,7 +72,7 @@ public class JsonUtilsUnitTest extends A
   @Test
   public void transition() {
     final CommandMap commandMap = new CommandMap();
-    commandMap.setClick(new Command(null, false, null, null, null, null, null, null, null,
null));
+    commandMap.setClick(new Command(null, false, null, null, null, null, null, null, null,
null, null));
     final String expected = "{'click':{'transition':false}}".replaceAll("'", "\"");
     Assert.assertEquals(expected, JsonUtils.encode(commandMap));
   }
@@ -91,7 +91,7 @@ public class JsonUtilsUnitTest extends A
         "_blank", "http://www.apache.org/",
         StringUtils.join(Arrays.asList("id1", "id2"), ' '),
         "id_focus",
-        "Really?", 1000, Popup.createPopup(command), true));
+        "Really?", 1000, Popup.createPopup(command), null, true));
     final String expected = (
         "{"
             + "'click':{"

Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg?rev=1750640&r1=1750639&r2=1750640&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
(original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
Wed Jun 29 13:58:18 2016
@@ -330,6 +330,10 @@ SanitizeModeProperty(property) ::= <<
 <NormalProperty(property)>
 >>
 
+CollapseStateProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
 ShowPositionProperty(property) ::= <<
 <NormalProperty(property)>
 >>



Mime
View raw message