You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/24 23:30:00 UTC

svn commit: r788188 - in /incubator/pivot/trunk: core/src/org/apache/pivot/collections/ tools/src/org/apache/pivot/tools/json/ wtk/src/org/apache/pivot/wtk/skin/terra/

Author: gbrown
Date: Wed Jun 24 21:29:59 2009
New Revision: 788188

URL: http://svn.apache.org/viewvc?rev=788188&view=rev
Log:
Add varargs constructor to Sequence.Tree.Path.

Modified:
    incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
    incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/JSONViewer.java
    incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/json_viewer.wtkx
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java

Modified: incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java?rev=788188&r1=788187&r2=788188&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/collections/Sequence.java Wed Jun 24 21:29:59 2009
@@ -39,40 +39,45 @@
          * data.
          *
          * @author tvolkert
+         * @author gbrown
          */
         public static class Path implements Sequence<Integer>, Iterable<Integer> {
-            private ArrayList<Integer> path;
+            private ArrayList<Integer> elements;
 
             public Path() {
-                path = new ArrayList<Integer>();
+                elements = new ArrayList<Integer>();
             }
 
-            public Path(Sequence<Integer> sequence) {
-                this(sequence, 0, sequence.getLength());
+            public Path(Integer... elements) {
+                this.elements = new ArrayList<Integer>(elements);
             }
 
-            public Path(Sequence<Integer> sequence, int index, int count) {
-                path = new ArrayList<Integer>(count);
+            public Path(Sequence<Integer> elements) {
+                this(elements, 0, elements.getLength());
+            }
+
+            public Path(Sequence<Integer> elements, int index, int count) {
+                this.elements = new ArrayList<Integer>(count);
 
                 for (int i = index, n = index + count; i < n; i++) {
-                    path.add(sequence.get(i));
+                    this.elements.add(elements.get(i));
                 }
             }
 
-            public Path(int initialCapacity) {
-                path = new ArrayList<Integer>(initialCapacity);
+            private Path(ArrayList<Integer> elements) {
+                this.elements = elements;
             }
 
             public int add(Integer item) {
-                return path.add(item);
+                return elements.add(item);
             }
 
             public void insert(Integer item, int index) {
-                path.insert(item, index);
+                elements.insert(item, index);
             }
 
             public Integer update(int index, Integer item) {
-                return path.update(index, item);
+                return elements.update(index, item);
             }
 
             public int remove(Integer item) {
@@ -80,23 +85,27 @@
             }
 
             public Sequence<Integer> remove(int index, int count) {
-                return path.remove(index, count);
+                return elements.remove(index, count);
             }
 
             public Integer get(int index) {
-                return path.get(index);
+                return elements.get(index);
             }
 
             public int indexOf(Integer item) {
-                return path.indexOf(item);
+                return elements.indexOf(item);
             }
 
             public int getLength() {
-                return path.getLength();
+                return elements.getLength();
             }
 
             public Iterator<Integer> iterator() {
-                return new ImmutableIterator<Integer>(path.iterator());
+                return new ImmutableIterator<Integer>(elements.iterator());
+            }
+
+            public static Path forDepth(int depth) {
+                return new Path(new ArrayList<Integer>(depth));
             }
         }
 

Modified: incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/JSONViewer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/JSONViewer.java?rev=788188&r1=788187&r2=788188&view=diff
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/JSONViewer.java (original)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/JSONViewer.java Wed Jun 24 21:29:59 2009
@@ -20,6 +20,7 @@
 
 import org.apache.pivot.collections.List;
 import org.apache.pivot.collections.Map;
+import org.apache.pivot.collections.Sequence.Tree.Path;
 import org.apache.pivot.serialization.JSONSerializer;
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.wtk.Application;
@@ -94,6 +95,7 @@
                 TreeBranch treeData = new TreeBranch();
                 treeData.add(build(value));
                 treeView.setTreeData(treeData);
+                treeView.expandBranch(new Path(0));
             } else {
                 Prompt.prompt("Clipboard does not contain a JSON object or array.", window);
             }

Modified: incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/json_viewer.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/json_viewer.wtkx?rev=788188&r1=788187&r2=788188&view=diff
==============================================================================
--- incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/json_viewer.wtkx (original)
+++ incubator/pivot/trunk/tools/src/org/apache/pivot/tools/json/json_viewer.wtkx Wed Jun 24 21:29:59 2009
@@ -18,7 +18,6 @@
 
 <Window title="JSON Viewer" maximized="true"
     xmlns:wtkx="http://pivot.apache.org/wtkx"
-    xmlns:content="org.apache.pivot.wtk.content"
     xmlns="org.apache.pivot.wtk">
     <content>
         <ScrollPane horizontalScrollBarPolicy="fillToCapacity"

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java?rev=788188&r1=788187&r2=788188&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTreeViewSkin.java Wed Jun 24 21:29:59 2009
@@ -112,7 +112,7 @@
 
         @SuppressWarnings("unchecked")
         public Path getPath() {
-            Path path = new Path(depth);
+            Path path = Path.forDepth(depth);
 
             NodeInfo nodeInfo = this;