2006-04-10  Audrius Meskauskas  <[EMAIL PROTECTED]>

   * javax/swing/tree/DefaultTreeSelectionModel.java
   (addSelectionPaths, setSelectionPaths): Call
   insureUniqueness. (clone, setRowMapper): Implemented.
   * TreePath (path): Marked final.

Index: javax/swing/tree/DefaultTreeSelectionModel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/tree/DefaultTreeSelectionModel.java,v
retrieving revision 1.23
diff -u -r1.23 DefaultTreeSelectionModel.java
--- javax/swing/tree/DefaultTreeSelectionModel.java	10 Apr 2006 08:19:16 -0000	1.23
+++ javax/swing/tree/DefaultTreeSelectionModel.java	10 Apr 2006 09:02:19 -0000
@@ -133,15 +133,21 @@
   /**
    * Creates a clone of this DefaultTreeSelectionModel with the same selection.
    * The cloned instance will have the same registered listeners, the listeners
-   * themselves will not be cloned.
+   * themselves will not be cloned. The selection will be cloned.
    * 
    * @exception CloneNotSupportedException should not be thrown here
-   * @return a clone of this DefaultTreeSelectionModel
+   * @return a copy of this DefaultTreeSelectionModel
    */
-  public Object clone() throws CloneNotSupportedException,
-      NotImplementedException
+  public Object clone() throws CloneNotSupportedException
   {
-    return null; // TODO
+    DefaultTreeSelectionModel cloned = 
+      (DefaultTreeSelectionModel) super.clone();
+    
+    // Clone the selection and the list selection model.
+    cloned.selection = (TreePath[]) selection.clone();
+    cloned.listSelectionModel = 
+      (DefaultListSelectionModel) listSelectionModel.clone();
+    return cloned;
   }
 
   /**
@@ -181,12 +187,12 @@
   /**
    * Sets the RowMapper that should be used to map between paths and their rows.
    * 
-   * @param rowMapper the RowMapper to set
+   * @param mapper the RowMapper to set
    * @see RowMapper
    */
-  public void setRowMapper(RowMapper rowMapper) throws NotImplementedException
+  public void setRowMapper(RowMapper mapper)
   {
-    // TODO
+    rowMapper = mapper;
   }
 
   /**
@@ -252,6 +258,8 @@
   public void setSelectionPaths(TreePath[] paths)
       throws NotImplementedException
   {
+    // Must be called, as defined in JDK API 1.4.
+    insureUniqueness();
     // TODO
   }
 
@@ -291,6 +299,9 @@
    */
   public void addSelectionPaths(TreePath[] paths)
   {
+    // Must be called, as defined in JDK API 1.4.
+    insureUniqueness();
+    
     if (paths != null)
       {
         TreePath v0 = null;
Index: javax/swing/tree/TreePath.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/tree/TreePath.java,v
retrieving revision 1.9
diff -u -r1.9 TreePath.java
--- javax/swing/tree/TreePath.java	14 Mar 2006 10:41:22 -0000	1.9
+++ javax/swing/tree/TreePath.java	10 Apr 2006 09:02:19 -0000
@@ -53,9 +53,10 @@
   static final long serialVersionUID = 4380036194768077479L;
 
   /**
-   * path
+   * The actual patch. The [EMAIL PROTECTED] DefaultTreeSelectionModel#clone()}
+   * assumes that the TreePath is immutable, so it is marked final here.
    */
-  private Object[] path = null;
+  private final Object[] path;
 
 
   /**

Reply via email to