This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 30150
Collapse All | Expand All

(-)src/org/openide/explorer/view/TreeTableView.java (-1 / +40 lines)
Lines 934-940 Link Here
934
                rowComparator = new Comparator() {
934
                rowComparator = new Comparator() {
935
                    public int compare(Object o1, Object o2) {
935
                    public int compare(Object o1, Object o2) {
936
                        if (o1 == o2)
936
                        if (o1 == o2)
937
                            return -1;
937
                            return 0;
938
938
939
                        Node n1 = ((VisualizerNode) o1).node;
939
                        Node n1 = ((VisualizerNode) o1).node;
940
                        Node n2 = ((VisualizerNode) o2).node;
940
                        Node n2 = ((VisualizerNode) o2).node;
Lines 1025-1030 Link Here
1025
            }
1025
            }
1026
            return "";    // NOI18N
1026
            return "";    // NOI18N
1027
        }
1027
        }
1028
        
1029
        // override mothod from DefaultTreeModel
1030
        public void nodesWereInserted (TreeNode node, int[] childIndices) {
1031
            super.nodesWereInserted (node, tranformIndices (node, childIndices)); 
1032
        }
1033
        
1034
//        public void nodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren) {
1035
//            System.out.println("### nodesWereRemoved");
1036
//            super.nodesWereRemoved (node, tranformIndices (node, childIndices), removedChildren);
1037
//        }
1038
        
1039
        public void nodesChanged(TreeNode node, int[] childIndices) {
1040
            if (childIndices == null || childIndices.length == 0) return ;
1041
            int[] newIndices = tranformIndices (node, childIndices);
1042
            java.util.Arrays.sort (newIndices);
1043
            int min = Math.min (childIndices[0], newIndices[0]);
1044
            int max = Math.max (childIndices[childIndices.length - 1], newIndices[newIndices.length - 1]);
1045
            for (int i = min; i <= max; i++) super.nodesChanged (node, new int[] {i});
1046
        }
1047
        
1048
        // bugfix #30150, helper method tranforms the original child indices by actually sorting
1049
        private int[] tranformIndices (TreeNode parent, int[] original) {
1050
            if (parent == null || !(parent instanceof VisualizerNode)) {
1051
                // XXX
1052
                return original;
1053
            }
1054
            if (original == null || original.length == 0) {
1055
                return original;
1056
            }
1057
            int[] tranformed = (int[])original.clone ();
1058
            if (sortingActive ()) {
1059
                java.util.List list = ((VisualizerNode)parent).getChildren ();
1060
                for (int i = 0; i < original.length; i++) {
1061
                    tranformed[i] = getIndexOfChild (parent, list.get (original[i]));
1062
                }
1063
            }
1064
            return tranformed;
1065
        }
1066
        
1028
    }
1067
    }
1029
    
1068
    
1030
    /* Cell renderer for sorting column header.
1069
    /* Cell renderer for sorting column header.
(-)src/org/openide/explorer/view/VisualizerNode.java (-1 / +14 lines)
Lines 254-259 Link Here
254
        ));
254
        ));
255
    }
255
    }
256
256
257
    // bugfix #30150, helper method tranforms the child indices of removed nodes by actually sorting
258
    private int[] tranformIndices (VisualizerChildren children, int[] original, Node[] removedNodes) {
259
        if (original == null || original.length == 0) {
260
            return original;
261
        }
262
        int[] tranformed = (int[])original.clone ();
263
        java.util.List list = children.list;
264
        for (int i = 0; i < original.length; i++) {
265
            tranformed[i] = list.indexOf (getVisualizer ( children, removedNodes[i] ));
266
        }
267
        return tranformed;
268
    }
269
257
    /** Fired when a set of children is removed.
270
    /** Fired when a set of children is removed.
258
    * @param ev event describing the action
271
    * @param ev event describing the action
259
    */
272
    */
Lines 261-267 Link Here
261
        VisualizerChildren ch = (VisualizerChildren)children.get ();
274
        VisualizerChildren ch = (VisualizerChildren)children.get ();
262
        if (ch == null) return;
275
        if (ch == null) return;
263
276
264
        QUEUE.runSafe (new VisualizerEvent.Removed (ch, ev.getDeltaIndices ()));
277
        QUEUE.runSafe (new VisualizerEvent.Removed (ch, tranformIndices (ch, ev.getDeltaIndices (), ev.getDelta ()) ) );
265
    }
278
    }
266
279
267
    /** Fired when the order of children is changed.
280
    /** Fired when the order of children is changed.

Return to bug 30150