Index: src/org/openide/explorer/view/VisualizerChildren.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/view/VisualizerChildren.java,v retrieving revision 1.10 diff -u -r1.10 VisualizerChildren.java --- src/org/openide/explorer/view/VisualizerChildren.java 15 Feb 2002 15:04:39 -0000 1.10 +++ src/org/openide/explorer/view/VisualizerChildren.java 13 Mar 2003 17:23:16 -0000 @@ -81,23 +81,31 @@ * and fires info to all listeners. */ public void removed (VisualizerEvent.Removed ev) { - ListIterator it = list.listIterator (); - int[] indxs = ev.getArray (); + List remList = Arrays.asList (ev.getRemovedNodes ()); + + Iterator it = list.iterator (); + + VisualizerNode vis; + + int[] indx = new int[remList.size ()]; + int count = 0, remSize = 0; + while (it.hasNext ()) { + // take visualizer node + vis = (VisualizerNode)it.next (); + + // check if it will removed + if (remList.contains (vis.node)) { + indx[remSize++] = count; - int current = 0; - int inIndxs = 0; - while (inIndxs < indxs.length) { - Object last; - do { - last = it.next (); - } while (current++ < indxs[inIndxs]); - - ev.removed.add (last); - it.remove (); - - inIndxs++; + // remove this VisualizerNode from children + it.remove (); + } + count++; } - + + // notify event about changed indexes + ev.setRemovedIndicies (indx); + VisualizerNode parent = this.parent; while (parent != null) { Object[] listeners = parent.getListenerList (); @@ -112,7 +120,7 @@ this.parent.notifyVisualizerChildrenChange (0, this); } } - + /** Notification that children has been reordered. Modifies the list of nodes * and fires info to all listeners. */ Index: src/org/openide/explorer/view/VisualizerEvent.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/view/VisualizerEvent.java,v retrieving revision 1.6 diff -u -r1.6 VisualizerEvent.java --- src/org/openide/explorer/view/VisualizerEvent.java 10 Jan 2002 15:22:20 -0000 1.6 +++ src/org/openide/explorer/view/VisualizerEvent.java 13 Mar 2003 17:23:16 -0000 @@ -91,6 +91,8 @@ /** linked list of removed nodes, that is filled in getChildren ().removed () method */ public LinkedList removed = new LinkedList (); + + private Node[]removedNodes; static final long serialVersionUID =5102881916407672392L; /** Constructor for add of nodes notification. @@ -100,9 +102,18 @@ */ public Removed ( VisualizerChildren ch, - int[] indx + Node[] removedNodes ) { - super (ch, indx); + super (ch, null); + this.removedNodes = removedNodes; + } + + public Node[] getRemovedNodes () { + return removedNodes; + } + + public void setRemovedIndicies (int[] arr) { + super.array = arr; } /** Process the event @@ -132,31 +143,31 @@ super (ch, indx); } - /** Prepares list of changed indices for use in tree model. - */ - public int[] getChangedIndices () { - if (changedIndices == null) { - int[] permutation = super.getArray (); - int size = permutation.length; - int changes = 0; - for (int i = 0; i < size; i++) { - if (permutation[i] != i) - changes++; - } - - int[] indices = new int[changes]; - - int current = 0; - for (int i = 0; i < size; i++) { - if (permutation[i] != i) { - indices[current++] = i; - } - } - - changedIndices = indices; - } - return changedIndices; - } +// /** Prepares list of changed indices for use in tree model. +// */ +// public int[] getChangedIndices () { +// if (changedIndices == null) { +// int[] permutation = super.getArray (); +// int size = permutation.length; +// int changes = 0; +// for (int i = 0; i < size; i++) { +// if (permutation[i] != i) +// changes++; +// } +// +// int[] indices = new int[changes]; +// +// int current = 0; +// for (int i = 0; i < size; i++) { +// if (permutation[i] != i) { +// indices[current++] = i; +// } +// } +// +// changedIndices = indices; +// } +// return changedIndices; +// } /** Process the event */ Index: src/org/openide/explorer/view/VisualizerNode.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/view/VisualizerNode.java,v retrieving revision 1.33 diff -u -r1.33 VisualizerNode.java --- src/org/openide/explorer/view/VisualizerNode.java 11 Mar 2003 18:28:39 -0000 1.33 +++ src/org/openide/explorer/view/VisualizerNode.java 13 Mar 2003 17:23:16 -0000 @@ -254,29 +254,6 @@ )); } - // bugfix #30150, helper method tranforms an array the child's indices of removed nodes by actually sorting - private void tranformIndices (VisualizerChildren children, int[] indices, Node[] removedNodes) { - if (indices == null || indices.length == 0) { - return; - } - java.util.List list = children.list; - for (int i = 0; i < indices.length; i++) { - int idx = list.indexOf (getVisualizer ( children, removedNodes[i] )); - // debug check - if (idx == -1) { - ErrorManager.getDefault ().log (ErrorManager.INFORMATIONAL, "VisualizerNode: Node " + removedNodes[i] // NOI18N - + " wasn't found in children of " // NOI18N - + children.parent + "."); // NOI18N - idx = indices[i]; - } - // end of debug - indices[i] = idx; - } - // by sure the indices are in ascending order - Arrays.sort (indices); - return; - } - /** Fired when a set of children is removed. * @param ev event describing the action */ @@ -284,8 +261,7 @@ VisualizerChildren ch = (VisualizerChildren)children.get (); if (ch == null) return; - tranformIndices (ch, ev.getDeltaIndices (), ev.getDelta ()); - QUEUE.runSafe (new VisualizerEvent.Removed (ch, ev.getDeltaIndices ()) ); + QUEUE.runSafe (new VisualizerEvent.Removed (ch, ev.getDelta ()) ); } /** Fired when the order of children is changed.