harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r495646 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/tree/ test/api/java/common/javax/swing/ test/api/java/common/javax/swing/tree/
Date Fri, 12 Jan 2007 17:13:40 GMT
Author: odeakin
Date: Fri Jan 12 09:13:37 2007
New Revision: 495646

URL: http://svn.apache.org/viewvc?view=rev&rev=495646
Log:
Apply patch HARMONY-2770 ([classlib][swing] DefaultTreeSelectionModel.getSelectionRows() returns
empty array while RI returns null)

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeSelectionModel.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JTreeTest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/tree/DefaultTreeSelectionModelTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeSelectionModel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeSelectionModel.java?view=diff&rev=495646&r1=495645&r2=495646
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeSelectionModel.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeSelectionModel.java
Fri Jan 12 09:13:37 2007
@@ -146,7 +146,7 @@
     }
 
     public TreePath[] getSelectionPaths() {
-        return selection;
+        return (((selection != null) && (selection.length > 0)) ? selection :
null) ;
     }
 
     public void removeSelectionPaths(final TreePath[] paths) {
@@ -202,10 +202,10 @@
 
     public int[] getSelectionRows() {
         if (rowMapper == null || isSelectionEmpty()) {
-            return new int[0];
+            return null;
         }
-
-        return getCleanedSortedRowsArray(rowMapper.getRowsForPaths(getSelectionPaths()));
+        int[] ret = getCleanedSortedRowsArray(rowMapper.getRowsForPaths(getSelectionPaths()));
+        return (ret.length == 0 ? null : ret);
     }
 
     public boolean isRowSelected(final int i) {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JTreeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JTreeTest.java?view=diff&rev=495646&r1=495645&r2=495646
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JTreeTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/JTreeTest.java
Fri Jan 12 09:13:37 2007
@@ -442,11 +442,7 @@
         tree.removeSelectionInterval(0, 2);
         assertEqualsIgnoreOrder(new TreePath[] { path2 }, tree.getSelectionPaths());
         tree.removeSelectionInterval(-1, 10);
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionPaths().length);
-        } else {
-            assertNull(tree.getSelectionPaths());
-        }
+        assertNull(tree.getSelectionPaths());
         tree.setSelectionInterval(3, 1);
         assertEqualsIgnoreOrder(new TreePath[] { path1, path11, path2 }, tree
                 .getSelectionPaths());
@@ -1679,11 +1675,7 @@
         tree.removeDescendantSelectedPaths(rootPath, false);
         assertEqualsIgnoreOrder(new TreePath[] { rootPath }, tree.getSelectionPaths());
         tree.removeDescendantSelectedPaths(rootPath, true);
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionPaths().length);
-        } else {
-            assertNull(tree.getSelectionPaths());
-        }
+        assertNull(tree.getSelectionPaths());
     }
 
     public void testRemoveDescendantToggledPaths() {
@@ -1712,9 +1704,8 @@
         assertTrue(tree.isExpanded(path1));
         assertFalse(tree.isExpanded(path11));
         assertTrue(tree.isExpanded(path2));
-        tree
-                .removeDescendantToggledPaths(createTestEnumeration(new TreePath[] { path2,
-                        path1 }));
+        tree.removeDescendantToggledPaths(createTestEnumeration(
+                new TreePath[] { path2, path1 }));
         assertTrue(tree.isExpanded(rootPath));
         assertFalse(tree.isExpanded(path1));
         assertFalse(tree.isExpanded(path11));
@@ -1959,11 +1950,7 @@
         assertSame(path, tree.getSelectionPath());
         assertSame(path, tree.getSelectionModel().getSelectionPath());
         assertEquals(1, tree.getSelectionCount());
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionRows().length);
-        } else {
-            assertNull(tree.getSelectionRows());
-        }
+        assertNull(tree.getSelectionRows());
         Object root = tree.getModel().getRoot();
         Object child = tree.getModel().getChild(root, 0);
         path = new TreePath(root).pathByAddingChild(child);
@@ -1975,21 +1962,13 @@
     }
 
     public void testGetSetSelectionRow() {
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionRows().length);
-        } else {
-            assertNull(tree.getSelectionRows());
-        }
+        assertNull(tree.getSelectionRows());
         tree.setSelectionRow(2);
         assertEquals(1, tree.getSelectionRows().length);
         assertEquals(2, tree.getSelectionRows()[0]);
         assertEquals(2, tree.getSelectionModel().getSelectionRows()[0]);
         tree.setSelectionRow(10000);
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionRows().length);
-        } else {
-            assertNull(tree.getSelectionRows());
-        }
+        assertNull(tree.getSelectionRows());
         TreePath path = new TreePath(tree.getModel().getRoot());
         tree.getSelectionModel().setSelectionPath(path);
         assertEquals(path, tree.getSelectionPath());
@@ -1999,28 +1978,15 @@
     }
 
     public void testGetSetSelectionRows() {
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionRows().length);
-        } else {
-            assertNull(tree.getSelectionRows());
-        }
+        assertNull(tree.getSelectionRows());
         tree.setSelectionRows(null);
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionRows().length);
-        } else {
-            assertNull(tree.getSelectionRows());
-        }
+        assertNull(tree.getSelectionRows());
         tree.setSelectionRows(new int[] { 0, 1 });
         assertEquals(2, tree.getSelectionRows().length);
         assertEquals(2, tree.getSelectionModel().getSelectionRows().length);
         tree.setSelectionRows(new int[] { 100 });
-        if (isHarmony()) {
-            assertEquals(0, tree.getSelectionRows().length);
-            assertEquals(0, tree.getSelectionPaths().length);
-        } else {
-            assertNull(tree.getSelectionRows());
-            assertNull(tree.getSelectionPaths());
-        }
+        assertNull(tree.getSelectionRows());
+        assertNull(tree.getSelectionPaths());
     }
 
     public void testSetUITreeUI() {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/tree/DefaultTreeSelectionModelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/tree/DefaultTreeSelectionModelTest.java?view=diff&rev=495646&r1=495645&r2=495646
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/tree/DefaultTreeSelectionModelTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/tree/DefaultTreeSelectionModelTest.java
Fri Jan 12 09:13:37 2007
@@ -668,17 +668,9 @@
         TreePath[] paths4 = new TreePath[] { path2, path1, path3, path5 };
         TreePath[] paths5 = new TreePath[] { path6, path4, path2 };
         TreePath[] paths6 = new TreePath[] { path6 };
-        if (!isHarmony()) {
-            assertNull(model.getSelectionRows());
-        } else {
-            assertEquals(0, model.getSelectionRows().length);
-        }
+        assertNull(model.getSelectionRows());
         model.setSelectionPaths(paths1);
-        if (!isHarmony()) {
-            assertNull(model.getSelectionRows());
-        } else {
-            assertEquals(0, model.getSelectionRows().length);
-        }
+        assertNull(model.getSelectionRows());
         model.setRowMapper(new MyRowMapper());
         assertEquals(5, model.getSelectionRows().length);
         model.setSelectionPaths(paths3);
@@ -688,17 +680,9 @@
         model.setSelectionPaths(paths5);
         assertEquals(2, model.getSelectionRows().length);
         model.setSelectionPaths(paths6);
-        if (!isHarmony()) {
-            assertNull(model.getSelectionRows());
-        } else {
-            assertEquals(0, model.getSelectionRows().length);
-        }
+        assertNull(model.getSelectionRows());
         model.setSelectionPaths(new TreePath[0]);
-        if (!isHarmony()) {
-            assertNull(model.getSelectionRows());
-        } else {
-            assertEquals(0, model.getSelectionRows().length);
-        }
+        assertNull(model.getSelectionRows());
     }
 
     /*



Mime
View raw message