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 2012/11/27 09:54:46 UTC

svn commit: r1414024 - in /myfaces/tobago/trunk/tobago-example: tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/ tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ tobago-example-demo/src/main/webapp/cont...

Author: lofwyr
Date: Tue Nov 27 08:54:44 2012
New Revision: 1414024

URL: http://svn.apache.org/viewvc?rev=1414024&view=rev
Log:
TOBAGO-1049: Tree inside of the Sheet (aka TreeTable) 
 - demo

Added:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/02/
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/02/sheet-tree.xhtml
      - copied, changed from r1413687, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/01/sheet-multi-header.xhtml
Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TobagoDemoController.java

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java?rev=1414024&r1=1414023&r2=1414024&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java Tue Nov 27 08:54:44 2012
@@ -19,8 +19,11 @@
 
 package org.apache.myfaces.tobago.example.data;
 
+import javax.swing.tree.DefaultMutableTreeNode;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 public class SolarObject {
 
@@ -159,7 +162,6 @@ public class SolarObject {
     return DATA;
   }
 
-
   public static List<SolarObject> getList() {
     SolarObject[] array = getArray();
     List<SolarObject> list = new ArrayList<SolarObject>(array.length);
@@ -169,6 +171,22 @@ public class SolarObject {
     return list;
   }
 
+  public static DefaultMutableTreeNode getTree() {
+    final SolarObject[] array = getArray();
+    final Map<String, DefaultMutableTreeNode> cache = new HashMap<String, DefaultMutableTreeNode>();
+    for (SolarObject solar : array) {
+      final DefaultMutableTreeNode node = new DefaultMutableTreeNode(solar);
+      cache.put(solar.getName(), node);
+      final String orbitName = solar.getOrbit();
+      if (orbitName.equals("-")) {
+        continue;
+      }
+      // adds a solar object as node to its orbit as tree child.
+      cache.get(orbitName).add(node);
+    }
+    return cache.get("Sun");
+  }
+
   public static List<SolarObject> getSatellites(String center) {
     List<SolarObject> collect = new ArrayList<SolarObject>();
     SolarObject[] all = getArray();

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TobagoDemoController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TobagoDemoController.java?rev=1414024&r1=1414023&r2=1414024&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TobagoDemoController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TobagoDemoController.java Tue Nov 27 08:54:44 2012
@@ -28,6 +28,7 @@ import org.apache.myfaces.tobago.event.T
 import org.apache.myfaces.tobago.example.data.CategoryTree;
 import org.apache.myfaces.tobago.example.data.Solar;
 import org.apache.myfaces.tobago.example.data.SolarObject;
+import org.apache.myfaces.tobago.model.ExpandedState;
 import org.apache.myfaces.tobago.model.SheetState;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.util.CreateComponentUtils;
@@ -77,6 +78,8 @@ public class TobagoDemoController {
 
   private SolarObject currentSolarObject;
 
+  private DefaultMutableTreeNode solarTree;
+
   private DefaultMutableTreeNode tree;
 
   private boolean showJunctions;
@@ -111,6 +114,8 @@ public class TobagoDemoController {
 
   private SheetState sheetState;
 
+  private SheetState sheetTreeState;
+
   private String toolbarIconSize;
 
   private SelectItem[] toolbarIconItems;
@@ -152,6 +157,9 @@ public class TobagoDemoController {
         + "ist emphasis__\n\n**und nochmal strong**\n\n**__ strong und emphasis__**";
     solarArray = SolarObject.getArray();
     solarList = SolarObject.getList();
+    solarTree = SolarObject.getTree();
+    sheetTreeState = new SheetState();
+    sheetTreeState.setExpandedState(new ExpandedState(1));
     solarArrayColumns = createSolarArrayColumns();
     solarArrayColumnLayout = "3*; 3*; 3*";
 
@@ -333,6 +341,9 @@ public class TobagoDemoController {
     return solarList;
   }
 
+  public DefaultMutableTreeNode getSolarTree() {
+    return solarTree;
+  }
 
   public void selectOrbit(ActionEvent event) {
     SolarObject clicked = (SolarObject) ComponentUtils.findParameter(event.getComponent(), "luminary");
@@ -528,6 +539,10 @@ public class TobagoDemoController {
     this.sheetState = sheetState;
   }
 
+  public SheetState getSheetTreeState() {
+    return sheetTreeState;
+  }
+
   public void stateChangeListener(ActionEvent e) {
     LOG.error("SheetState has Changed: " + e);
 

Copied: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/02/sheet-tree.xhtml (from r1413687, myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/01/sheet-multi-header.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/02/sheet-tree.xhtml?p2=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/02/sheet-tree.xhtml&p1=myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/01/sheet-multi-header.xhtml&r1=1413687&r2=1414024&rev=1414024&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/01/sheet-multi-header.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/02-sheet/02/sheet-tree.xhtml Tue Nov 27 08:54:44 2012
@@ -21,7 +21,6 @@
                 xmlns:tc="http://myfaces.apache.org/tobago/component"
                 xmlns:tx="http://myfaces.apache.org/tobago/extension"
                 xmlns:ui="http://java.sun.com/jsf/facelets"
-                xmlns:h="http://java.sun.com/jsf/html"
                 xmlns:f="http://java.sun.com/jsf/core">
   <ui:param name="title" value="#{overviewBundle.sheet}"/>
 
@@ -30,81 +29,45 @@
       <tc:gridLayout rows="1*;5*"/>
     </f:facet>
 
-    <tc:out value="For simple column headers, use the lable attribute of the tc:column.
-    For more complex headers, which can span over columns and/or rows use a &lt;f:facet name='header'&gt; in the sheet." />
+    <tc:out value="Tree Table"/>
 
-    <tc:sheet value="#{demo.solarList}" id="sheet"
+    <tc:sheet value="#{demo.solarTree}" id="sheet"
               columns="3*;2*;30px;2*;2*;2*;2*;2*;2*" var="luminary"
-              state="#{demo.sheetState}"
+              state="#{demo.sheetTreeState}"
+              showRoot="true"
+              showRootJunction="true"
               showRowRange="left"
               showPageRange="right"
               showDirectLinks="center">
 
-      <f:facet name="header">
-        <tc:panel>
-          <tc:out value="#{overviewBundle.solarArrayName}">
-            <tc:gridLayoutConstraint rowSpan="3"/>
-          </tc:out>
-          <tc:out value="Information">
-            <tc:gridLayoutConstraint columnSpan="2"/>
-          </tc:out>
-          <tc:out value="Data">
-            <tc:gridLayoutConstraint columnSpan="4"/>
-          </tc:out>
-          <tc:out value="Discovery">
-            <tc:gridLayoutConstraint columnSpan="2"/>
-          </tc:out>
-
-          <tc:out value="Orbit">
-            <tc:gridLayoutConstraint columnSpan="3"/>
-          </tc:out>
-          <tc:out value="Orb">
-            <tc:gridLayoutConstraint columnSpan="3"/>
-          </tc:out>
-          <tc:out value="Name">
-            <tc:gridLayoutConstraint rowSpan="2"/>
-          </tc:out>
-          <tc:out value="Year">
-            <tc:gridLayoutConstraint rowSpan="2"/>
-          </tc:out>
-
-          <tc:out value="of"/>
-          <tc:out value="#{overviewBundle.solarArrayNumber}"/>
-          <tc:out value="#{overviewBundle.solarArrayDistance} [1000 km]"/>
-          <tc:out value="Period [days]"/>
-          <tc:out value="Inclination [°]"/>
-          <tc:out value="Eccentricity"/>
-
-        </tc:panel>
-      </f:facet>
-
-      <tc:column id="name">
-        <tc:out value="#{luminary.name}" id="t_name"/>
-      </tc:column>
-      <tc:column  id="orbit" label="#{overviewBundle.solarArrayOrbit}" sortable="true">
-          <tc:out value="#{luminary.orbit}" id="t_orbit"/>
+      <tc:columnNode id="name">
+        <tc:treeIndent/>
+        <tc:out value="#{luminary.userObject.name}" id="t_name"/>
+      </tc:columnNode>
+      <tc:column id="orbit" label="#{overviewBundle.solarArrayOrbit}">
+        <tc:out value="#{luminary.userObject.orbit}" id="t_orbit"/>
       </tc:column>
-      <tc:column id="number" sortable="false" resizable="false"
+      <tc:column id="number" resizable="false"
                  tip="#{overviewBundle.solarArrayNumberTip}" align="center">
-        <tc:out value="#{luminary.number}" id="t_number"/>
+        <tc:out value="#{luminary.userObject.number}" id="t_number"/>
       </tc:column>
-      <tc:column sortable="true" align="right" id="distance">
-        <tc:out value="#{luminary.distance}" id="t_distance"/>
+      <tc:column align="right" id="distance">
+        <tc:out value="#{luminary.userObject.distance}" id="t_distance"/>
       </tc:column>
-      <tc:column label="#{overviewBundle.solarArrayPeriod}" sortable="true" align="right" id="period">
-        <tc:out value="#{luminary.period}" id="t_period"/>
+      <tc:column label="#{overviewBundle.solarArrayPeriod}" align="right" id="period">
+        <tc:out value="#{luminary.userObject.period}" id="t_period"/>
       </tc:column>
-      <tc:column sortable="true" align="right" id="incl">
-        <tc:out value="#{luminary.incl}" id="t_incl"/>
+      <tc:column align="right" id="incl">
+        <tc:out value="#{luminary.userObject.incl}" id="t_incl"/>
       </tc:column>
-      <tc:column sortable="true" align="right" id="eccen">
-        <tc:out value="#{luminary.eccen}" id="t_eccen"/>
+      <tc:column align="right" id="eccen">
+        <tc:out value="#{luminary.userObject.eccen}" id="t_eccen"/>
       </tc:column>
-      <tc:column sortable="true" id="discoverer">
-        <tc:out value="#{luminary.discoverer}" id="t_discoverer"/>
+      <tc:column id="discoverer">
+        <tc:out value="#{luminary.userObject.discoverer}" id="t_discoverer"/>
       </tc:column>
-      <tc:column sortable="true" align="center" id="discoverYear">
-        <tc:out value="#{luminary.discoverYear}" id="t_discoverYear"/>
+      <tc:column align="center" id="discoverYear">
+        <tc:out value="#{luminary.userObject.discoverYear}" id="t_discoverYear"/>
       </tc:column>
     </tc:sheet>
   </tc:panel>