Index: javax/swing/event/TreeSelectionEvent.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/event/TreeSelectionEvent.java,v retrieving revision 1.3 diff -u -r1.3 TreeSelectionEvent.java --- javax/swing/event/TreeSelectionEvent.java 22 Oct 2004 12:44:00 -0000 1.3 +++ javax/swing/event/TreeSelectionEvent.java 4 Jun 2005 23:23:42 -0000 @@ -49,142 +49,141 @@ */ public class TreeSelectionEvent extends EventObject { - //------------------------------------------------------------- - // Variables -------------------------------------------------- - //------------------------------------------------------------- - - /** - * paths - */ - protected TreePath[] paths; - - /** - * areNew - */ - protected boolean[] areNew; - - /** - * oldLeadSelectionPath - */ - protected TreePath oldLeadSelectionPath; - - /** - * newLeadSelectionPath - */ - protected TreePath newLeadSelectionPath; - - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor TreeSelectionEvent - * @param source TODO - * @param paths TODO - * @param areNew TODO - * @param oldLeadSelectionPath TODO - * @param newLeadSelectionPath TODO - */ - public TreeSelectionEvent(Object source, TreePath[] paths, - boolean[] areNew, TreePath oldLeadSelectionPath, - TreePath newLeadSelectionPath) { - super(source); - this.paths = paths; - this.areNew = areNew; - this.oldLeadSelectionPath = oldLeadSelectionPath; - this.newLeadSelectionPath = newLeadSelectionPath; - } // TreeSelectionEvent() - - /** - * Constructor TreeSelectionEvent - * @param source TODO - * @param paths TODO - * @param areNew TODO - * @param oldLeadSelectionPath TODO - * @param newLeadSelectionPath TODO - */ - public TreeSelectionEvent(Object source, TreePath path, - boolean isNew, TreePath oldLeadSelectionPath, - TreePath newLeadSelectionPath) { - super(source); -//TODO this.paths = new TreePath[1]{path}; -//TODO this.areNew = new boolean[1]{isNew}; - this.oldLeadSelectionPath = oldLeadSelectionPath; - this.newLeadSelectionPath = newLeadSelectionPath; - } // TreeSelectionEvent() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getPath - * @returns TreePath - */ - public TreePath getPath() { - return paths[0]; - } // getPath() - - /** - * getPaths - * @returns TreePath[] - */ - public TreePath[] getPaths() { - return paths; - } // getPaths() - - /** - * isAddedPath - * @returns boolean - */ - public boolean isAddedPath() { - return false; // TODO - } // isAddedPath() - - /** - * isAddedPath - * @param path TODO - * @returns boolean - */ - public boolean isAddedPath(TreePath path) { - return false; // TODO - } // isAddedPath() - - /** - * isAddedPath - * @param index TODO - * @returns boolean - */ - public boolean isAddedPath(int index) { - return false; // TODO - } // isAddedPath() - - /** - * getOldLeadSelectionPath - * @returns TreePath - */ - public TreePath getOldLeadSelectionPath() { - return oldLeadSelectionPath; - } // getOldLeadSelectionPath() - - /** - * getNewLeadSelectionPath - * @returns TreePath - */ - public TreePath getNewLeadSelectionPath() { - return newLeadSelectionPath; - } // getNewLeadSelectionPath() - - /** - * cloneWithSource - * @param source TODO - * @returns Object - */ - public Object cloneWithSource(Object source) { - return null; // TODO - } // cloneWithSource() + //------------------------------------------------------------- + // Variables -------------------------------------------------- + //------------------------------------------------------------- + + /** + * paths + */ + protected TreePath[] paths; + + /** + * areNew + */ + protected boolean[] areNew; + + /** + * oldLeadSelectionPath + */ + protected TreePath oldLeadSelectionPath; + + /** + * newLeadSelectionPath + */ + protected TreePath newLeadSelectionPath; + + + //------------------------------------------------------------- + // Initialization --------------------------------------------- + //------------------------------------------------------------- + + /** + * Constructor TreeSelectionEvent + * @param source TODO + * @param paths TODO + * @param areNew TODO + * @param oldLeadSelectionPath TODO + * @param newLeadSelectionPath TODO + */ + public TreeSelectionEvent(Object source, TreePath[] paths, + boolean[] areNew, TreePath oldLeadSelectionPath, + TreePath newLeadSelectionPath) { + super(source); + this.paths = paths; + this.areNew = areNew; + this.oldLeadSelectionPath = oldLeadSelectionPath; + this.newLeadSelectionPath = newLeadSelectionPath; + } // TreeSelectionEvent() + + /** + * Constructor TreeSelectionEvent + * @param source TODO + * @param paths TODO + * @param areNew TODO + * @param oldLeadSelectionPath TODO + * @param newLeadSelectionPath TODO + */ + public TreeSelectionEvent(Object source, TreePath path, + boolean isNew, TreePath oldLeadSelectionPath, + TreePath newLeadSelectionPath) { + super(source); + this.paths = new TreePath[]{path}; + this.areNew = new boolean[]{isNew}; + this.oldLeadSelectionPath = oldLeadSelectionPath; + this.newLeadSelectionPath = newLeadSelectionPath; + } // TreeSelectionEvent() + + + //------------------------------------------------------------- + // Methods ---------------------------------------------------- + //------------------------------------------------------------- + + /** + * @returns the first path element + */ + public TreePath getPath() { + return paths[0]; + } // getPath() + + /** + * + * @returns the paths with selection changed + */ + public TreePath[] getPaths() { + return (TreePath[])paths.clone(); + } // getPaths() + + /** + * @return true if the first path is added to the selection, false otherwise + */ + public boolean isAddedPath() { + return areNew[0]; + } // isAddedPath() + + /** + * @param path the path to check + * @return true if the path is added to the selection, false otherwise + */ + public boolean isAddedPath(TreePath path) { + for (int i = paths.length - 1; i >= 0; i--) + if (paths[i].equals(path)) + return areNew[i]; + + return false; + } // isAddedPath() + + /** + * @param index the index'th path + * @return true if the path is added to the selection, false otherwise + */ + public boolean isAddedPath(int index) { + return areNew[index]; + } // isAddedPath() + + /** + * @return the previous lead selection path + */ + public TreePath getOldLeadSelectionPath() { + return oldLeadSelectionPath; + } // getOldLeadSelectionPath() + + /** + * @returns the current lead selection path + */ + public TreePath getNewLeadSelectionPath() { + return newLeadSelectionPath; + } // getNewLeadSelectionPath() + + /** + * @param source the new event source + * @return a cloned event with another event source + */ + public Object cloneWithSource(Object source) { + return new TreeSelectionEvent (source, paths, areNew, + oldLeadSelectionPath, + newLeadSelectionPath); + } // cloneWithSource() } // TreeSelectionEvent