classpath-patches
[Top][All Lists]
Advanced

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

Re: [cp-patches] RFC: TreeSelectionEvent


From: Ka-Hing Cheung
Subject: Re: [cp-patches] RFC: TreeSelectionEvent
Date: Sun, 5 Jun 2005 00:02:04 -0700
User-agent: Mutt/1.5.6+20040907i

2nd patch with real code changes.

20050605  Ka-Hing Cheung <address@hidden>

    * javax/swing/event/TreeSelectionEvent:
      (getPaths): Return a cloned copy.
      (isAddedPath): Implemented.
      (cloneWithSource): Likewise.

--- javax/swing/event/TreeSelectionEvent.java-  2005-06-04 23:48:28.961020000 
-0700
+++ javax/swing/event/TreeSelectionEvent.java   2005-06-04 23:58:56.548612368 
-0700
@@ -110,8 +110,8 @@
                            TreePath newLeadSelectionPath)
   {
     super(source);
-    //TODO             this.paths                                      = new 
TreePath[1]{path};
-    //TODO             this.areNew                                     = new 
boolean[1]{isNew};
+    this.paths = new TreePath[]{path};
+    this.areNew = new boolean[]{isNew};
     this.oldLeadSelectionPath  = oldLeadSelectionPath;
     this.newLeadSelectionPath  = newLeadSelectionPath;
   } // TreeSelectionEvent()
@@ -122,8 +122,7 @@
   //-------------------------------------------------------------
 
   /**
-   * getPath
-   * @returns TreePath
+   * @returns the first path element
    */
   public TreePath getPath()
   {
@@ -131,46 +130,46 @@
   } // getPath()
 
   /**
-   * getPaths
-   * @returns TreePath[]
+   * 
+   * @returns the paths with selection changed
    */
   public TreePath[] getPaths()
   {
-    return paths;
+    return (TreePath[]) paths.clone();
   } // getPaths()
 
   /**
-   * isAddedPath
-   * @returns boolean
+   * @return true if the first path is added to the selection, false otherwise
    */
   public boolean isAddedPath()
   {
-    return false; // TODO
+    return areNew[0];
   } // isAddedPath()
 
   /**
-   * isAddedPath
-   * @param path TODO
-   * @returns boolean
+   * @param path the path to check
+   * @return true if the path is added to the selection, false otherwise
    */
   public boolean isAddedPath(TreePath path)
   {
-    return false; // TODO
+    for (int i = paths.length - 1; i >= 0; i--)
+      if (paths[i].equals(path))
+       return areNew[i];
+
+    return false;
   } // isAddedPath()
 
   /**
-   * isAddedPath
-   * @param index TODO
-   * @returns boolean
+   * @param index the index'th path
+   * @return true if the path is added to the selection, false otherwise
    */
   public boolean isAddedPath(int index)
   {
-    return false; // TODO
+    return areNew[index];
   } // isAddedPath()
 
   /**
-   * getOldLeadSelectionPath
-   * @returns TreePath
+   * @return the previous lead selection path
    */
   public TreePath getOldLeadSelectionPath()
   {
@@ -178,8 +177,7 @@
   } // getOldLeadSelectionPath()
 
   /**
-   * getNewLeadSelectionPath
-   * @returns TreePath
+   * @returns the current lead selection path
    */
   public TreePath getNewLeadSelectionPath()
   {
@@ -187,13 +185,14 @@
   } // getNewLeadSelectionPath()
 
   /**
-   * cloneWithSource
-   * @param source TODO
-   * @returns Object
+   * @param source the new event source
+   * @return a cloned event with another event source
    */
   public Object cloneWithSource(Object source)
   {
-    return null; // TODO
+    return new TreeSelectionEvent (source, paths, areNew,
+                                  oldLeadSelectionPath,
+                                  newLeadSelectionPath);
   } // cloneWithSource()
 
 




reply via email to

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