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/10/03 13:54:06 UTC

svn commit: r1706556 - in /myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag: TreeCommandRenderer.java TreeMenuCommandRenderer.java

Author: lofwyr
Date: Sat Oct  3 11:54:05 2015
New Revision: 1706556

URL: http://svn.apache.org/viewvc?rev=1706556&view=rev
Log:
TOBAGO-1495: Adapt the tc:tree to Bootstrap

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/TreeCommandRenderer.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/TreeMenuCommandRenderer.java

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/TreeCommandRenderer.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/TreeCommandRenderer.java?rev=1706556&r1=1706555&r2=1706556&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/TreeCommandRenderer.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/TreeCommandRenderer.java Sat Oct  3 11:54:05 2015
@@ -21,10 +21,14 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.myfaces.tobago.component.UITreeCommand;
 import org.apache.myfaces.tobago.component.UITreeNode;
+import org.apache.myfaces.tobago.internal.component.AbstractUIData;
+import org.apache.myfaces.tobago.internal.component.AbstractUITreeNode;
 import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
+import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.renderkit.CommandRendererBase;
 import org.apache.myfaces.tobago.renderkit.LabelWithAccessKey;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
+import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.Command;
 import org.apache.myfaces.tobago.renderkit.html.CommandMap;
 import org.apache.myfaces.tobago.renderkit.html.DataAttributes;
@@ -64,6 +68,16 @@ public class TreeCommandRenderer extends
     final LabelWithAccessKey label = new LabelWithAccessKey(command);
     final boolean disabled = command.isDisabled();
 
+    final AbstractUITreeNode node = ComponentUtils.findAncestor(command, AbstractUITreeNode.class);
+    final AbstractUIData data = ComponentUtils.findAncestor(command, AbstractUIData.class);
+    Style style = command.getStyle();
+    if (style == null) {
+      style = new Style();
+    }
+    if (style.getLeft() == null) { // do not override it
+      style.setMarginLeft(leftOffset(node.getLevel(), data.isShowRoot()));
+    }
+
     if (disabled) {
       writer.startElement(HtmlElements.SPAN, command);
     } else {
@@ -72,7 +86,7 @@ public class TreeCommandRenderer extends
       writer.writeAttribute(DataAttributes.COMMANDS, JsonUtils.encode(map), true);
       writer.writeNameAttribute(clientId);
     }
-    writer.writeStyleAttribute(command.getStyle());
+    writer.writeStyleAttribute(style);
     writer.writeClassAttribute(Classes.create(command));
     writer.writeIdAttribute(clientId);
     HtmlRendererUtils.writeDataAttributes(facesContext, writer, command);
@@ -99,4 +113,8 @@ public class TreeCommandRenderer extends
       writer.endElement(HtmlElements.A);
     }
   }
+
+  protected Measure leftOffset(int level, boolean showRoot) {
+    return Measure.ZERO;
+  }
 }

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/TreeMenuCommandRenderer.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/TreeMenuCommandRenderer.java?rev=1706556&r1=1706555&r2=1706556&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/TreeMenuCommandRenderer.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/TreeMenuCommandRenderer.java Sat Oct  3 11:54:05 2015
@@ -19,5 +19,13 @@
 
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
+import org.apache.myfaces.tobago.layout.Measure;
+
 public class TreeMenuCommandRenderer extends TreeCommandRenderer {
+
+  protected Measure leftOffset(final int level, final boolean showRoot) {
+    final int factor = showRoot ? level : level - 1;
+    return Measure.valueOf(factor * 25); // XXX should be defined in CSS
+  }
+
 }