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 190115
Collapse All | Expand All

(-)a/openide.nodes/apichanges.xml (+17 lines)
Lines 49-54 Link Here
49
<apidef name="nodes">Nodes API</apidef>
49
<apidef name="nodes">Nodes API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="Node.updateChildren">
53
        <api name="nodes"/>
54
        <summary>A mechanism to lazily update node's children.</summary>
55
        <version major="7" minor="18"/>
56
        <date day="9" month="9" year="2010"/>
57
        <author login="mentlicher"/>
58
        <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible"/>
59
        <description>
60
            <p>
61
            <a href="@TOP@/org/openide/nodes/Node.html">Node</a> has a new updateChildren()
62
            protected method, that can be overriden to provide Children implementation
63
            when node's children are needed.
64
            </p>
65
        </description>
66
        <class package="org.openide.nodes" name="Node"/>
67
        <issue number="190115"/>
68
    </change>
52
    <change id="IndexedNode.LookupConstr">
69
    <change id="IndexedNode.LookupConstr">
53
        <api name="nodes"/>
70
        <api name="nodes"/>
54
        <summary>New constructor of IndexedNode</summary>
71
        <summary>New constructor of IndexedNode</summary>
(-)a/openide.nodes/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.nodes
2
OpenIDE-Module: org.openide.nodes
3
OpenIDE-Module-Localizing-Bundle: org/openide/nodes/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/nodes/Bundle.properties
4
AutoUpdate-Essential-Module: true
4
AutoUpdate-Essential-Module: true
5
OpenIDE-Module-Specification-Version: 7.17
5
OpenIDE-Module-Specification-Version: 7.18
6
6
(-)a/openide.nodes/src/org/openide/nodes/FilterNode.java (-9 / +3 lines)
Lines 1049-1055 Link Here
1049
     * setChildren will fire the appropriate events
1049
     * setChildren will fire the appropriate events
1050
     */
1050
     */
1051
    @Override
1051
    @Override
1052
    final void updateChildren() {
1052
    protected final org.openide.nodes.Children updateChildren(org.openide.nodes.Children origChildren) {
1053
        if (isDefault()) {
1053
        if (isDefault()) {
1054
            org.openide.nodes.Children newChildren = null;
1054
            org.openide.nodes.Children newChildren = null;
1055
1055
Lines 1066-1081 Link Here
1066
            }
1066
            }
1067
1067
1068
            if (newChildren != null) {
1068
            if (newChildren != null) {
1069
                final org.openide.nodes.Children set = newChildren;
1069
                return newChildren;
1070
                Children.MUTEX.postWriteRequest(
1071
                    new Runnable() {
1072
                        public void run() {
1073
                            setChildren(set);
1074
                        }
1075
                    }
1076
                );
1077
            }
1070
            }
1078
        }
1071
        }
1072
        return origChildren;
1079
    }
1073
    }
1080
1074
1081
    /** An exception to be thrown from hashCode() to debug issue 46993.
1075
    /** An exception to be thrown from hashCode() to debug issue 46993.
(-)a/openide.nodes/src/org/openide/nodes/Node.java (-2 / +24 lines)
Lines 461-470 Link Here
461
        return hierarchy;
461
        return hierarchy;
462
    }
462
    }
463
463
464
    /** Can be overridden in subclasses (probably in FilterNode) to check
464
    /** Can be called in subclasses (probably in FilterNode) to check
465
     * whether children are of the right subclass
465
     * whether children are of the right subclass
466
     */
466
     */
467
    void updateChildren() {
467
    final void updateChildren() {
468
        Children origChildren = hierarchy;
469
        final Children newChildren = updateChildren(origChildren);
470
        if (newChildren != origChildren && newChildren != null) {
471
            Children.MUTEX.postWriteRequest(
472
                new Runnable() {
473
                    public void run() {
474
                        setChildren(newChildren);
475
                    }
476
                }
477
            );
478
        }
479
    }
480
481
    /**
482
     * Can be overridden in subclasses to update the children of this node
483
     * when someone asks for them.
484
     * @param origChildren Original Children passed to the constructor.
485
     * @return Children instance to be used instead of the original.
486
     * @since 7.18
487
     */
488
    protected Children updateChildren(Children origChildren) {
489
        return origChildren;
468
    }
490
    }
469
491
470
    /** Allows to change Children of the node. Call to this method aquires
492
    /** Allows to change Children of the node. Call to this method aquires
(-)a/openide.nodes/test/unit/src/org/openide/nodes/SetChildrenTest.java (+29 lines)
Lines 261-266 Link Here
261
        
261
        
262
        GoldenEvent.assertEvents ( nl.getEvents(), goldenEvents, PropertyChangeEvent.class );        
262
        GoldenEvent.assertEvents ( nl.getEvents(), goldenEvents, PropertyChangeEvent.class );        
263
    }
263
    }
264
265
    /** Test whether updateChildren() is called and children are updated
266
     */
267
    public void testUpdateChildren() {
268
        TestNodeUCh n = new TestNodeUCh(Children.LEAF);
269
        assertSame("Children not updated", n.newChildren, n.getChildren());
270
        n = new TestNodeUCh(Children.LEAF);
271
        assertFalse("Children not updated, the node should not be leaf", n.isLeaf());
272
    }
264
    
273
    
265
    
274
    
266
    /** Tests property changes on old and new nodes
275
    /** Tests property changes on old and new nodes
Lines 290-295 Link Here
290
        }        
299
        }        
291
    }
300
    }
292
    
301
    
302
    private static class TestNodeUCh extends AbstractNode {
303
304
        private Children origChildren;
305
        Children newChildren = new Children.Array();
306
307
        public TestNodeUCh( Children ch ) {
308
            super( ch );
309
            origChildren = ch;
310
        }
311
312
        @Override
313
        protected Children updateChildren(Children origChildren) {
314
            if (origChildren == this.origChildren) {
315
                return newChildren;
316
            }
317
            return origChildren;
318
        }
319
320
    }
321
293
    /** Useful class for testing events.
322
    /** Useful class for testing events.
294
     */
323
     */
295
    
324
    

Return to bug 190115