classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Added method implementations for javax.swing.tree.Defa


From: Roman Kennke
Subject: [cp-patches] FYI: Added method implementations for javax.swing.tree.DefaultTreeSelectionModel
Date: Wed, 20 Apr 2005 11:55:41 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

I added the following method bodies in javax.swing.tree.DefaultTreeSelectionModel:

2005-04-20  Roman Kennke  <address@hidden>

       * javax/swing/tree/DefaultTreeSelectionModel.java
       (constructor): Added implementation.
       (getRowMapper): Added implementation.
       (setSelectionMode): Added implementation.
       (getSelectionMode): Added implementation.
       (getSelectionPath): Added implementation.
       (getSelectionPaths): Added implementation.
       (getSelectionCount): Added implementation.
       (isSelectionEmpty): Added implementation.
       (getSelectionRows): Added implementation.
       (getMinSelectionRow): Added implementation.
       (getMaxSelectionRow): Added implementation.
       (getLeadSelectionRow): Added implementation.
       (getLeadSelectionPath): Added implementation.


/Roman
Index: javax/swing/tree/DefaultTreeSelectionModel.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/tree/DefaultTreeSelectionModel.java,v
retrieving revision 1.8
diff -u -r1.8 DefaultTreeSelectionModel.java
--- javax/swing/tree/DefaultTreeSelectionModel.java     18 Apr 2005 14:02:50 
-0000      1.8
+++ javax/swing/tree/DefaultTreeSelectionModel.java     20 Apr 2005 09:47:40 
-0000
@@ -116,7 +116,7 @@
    */
   public DefaultTreeSelectionModel()
   {
-    // TODO
+    setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
   }
 
   /**
@@ -187,7 +187,7 @@
    */
   public RowMapper getRowMapper()
   {
-    return null; // TODO
+    return rowMapper;
   }
 
   /**
@@ -202,9 +202,9 @@
    * @see address@hidden #CONTIGUOUS_TREE_SELECTION}
    * @see address@hidden #DISCONTIGUOUS_TREE_SELECTION}
    */
-  public void setSelectionMode(int value0)
+  public void setSelectionMode(int mode)
   {
-    // TODO
+    selectionMode = mode;
   }
 
   /**
@@ -219,7 +219,7 @@
    */
   public int getSelectionMode()
   {
-    return 0; // TODO
+    return selectionMode;
   }
 
   /**
@@ -311,7 +311,10 @@
    */
   public TreePath getSelectionPath()
   {
-    return null; // TODO
+    if ((selection == null) || (selection.length == 0))
+      return null;
+    else
+      return selection[0];
   }
 
   /**
@@ -321,7 +324,7 @@
    */
   public TreePath[] getSelectionPaths()
   {
-    return null; // TODO
+    return selection;
   }
 
   /**
@@ -331,7 +334,10 @@
    */
   public int getSelectionCount()
   {
-    return 0; // TODO
+    if (selection == null)
+      return 0;
+    else
+      return selection.length;
   }
 
   /**
@@ -355,7 +361,7 @@
    */
   public boolean isSelectionEmpty()
   {
-    return false; // TODO
+    return ((selection == null) || (selection.length == 0));
   }
 
   /**
@@ -432,7 +438,10 @@
    */
   public int[] getSelectionRows()
   {
-    return null; // TODO
+    if (rowMapper == null)
+      return null;
+    else
+      return rowMapper.getRowsForPaths(selection);
   }
 
   /**
@@ -442,7 +451,15 @@
    */
   public int getMinSelectionRow()
   {
-    return 0; // TODO
+    if ((rowMapper == null) || (selection == null) || (selection.length == 0))
+      return -1;
+    else {
+      int[] rows = rowMapper.getRowsForPaths(selection);
+      int minRow = Integer.MAX_VALUE;
+      for (int index = 0; index < rows.length; index++)
+        minRow = Math.min(minRow, rows[index]);
+      return minRow;
+    }
   }
 
   /**
@@ -452,7 +469,15 @@
    */
   public int getMaxSelectionRow()
   {
-    return 0; // TODO
+    if ((rowMapper == null) || (selection == null) || (selection.length == 0))
+      return -1;
+    else {
+      int[] rows = rowMapper.getRowsForPaths(selection);
+      int maxRow = -1;
+      for (int index = 0; index < rows.length; index++)
+        maxRow = Math.max(maxRow, rows[index]);
+      return maxRow;
+    }
   }
 
   /**
@@ -482,7 +507,10 @@
    */
   public int getLeadSelectionRow()
   {
-    return 0; // TODO
+    if ((rowMapper == null) || (leadPath == null))
+      return -1;
+    else
+      return rowMapper.getRowsForPaths(new TreePath[]{ leadPath })[0];
   }
 
   /**
@@ -491,7 +519,7 @@
    */
   public TreePath getLeadSelectionPath()
   {
-    return null; // TODO
+    return leadPath;
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]