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

(-)loaders/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.loaders
2
OpenIDE-Module: org.openide.loaders
3
OpenIDE-Module-Specification-Version: 5.5
3
OpenIDE-Module-Specification-Version: 5.6
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
5
5
(-)loaders/api/apichanges.xml (+17 lines)
Lines 350-355 Link Here
350
        <issue number="53295"/>
350
        <issue number="53295"/>
351
    </change>
351
    </change>
352
352
353
    <change>
354
        <api name="loaders"/>
355
        <summary>New <code>DataNode</code> constructor with  with Lookup</summary>
356
        <version major="5" minor="6"/>
357
        <date day="5" month="8" year="2005"/>
358
        <author login="lkotouc"/>
359
        <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
360
        <description>
361
        Common Palette client infrastructure needs to have DataNode associated with a "palette item".
362
        This can be now achieved only by implementing item as Node.Cookie and returning it 
363
        from the corresponding DataObject via getCookie() method.
364
        Depending on Node.Cookie is problematic, thus introducing this new constructor with a Lookup.
365
        </description>
366
        <class package="org.openide.loaders" name="DataNode"/>
367
        <issue number="61824"/>
368
    </change>
369
353
  </changes>
370
  </changes>
354
371
355
  <!-- Now the surrounding HTML text and document structure: -->
372
  <!-- Now the surrounding HTML text and document structure: -->
(-)loaders/src/org/openide/loaders/DataNode.java (-2 / +17 lines)
Lines 41-46 Link Here
41
import org.openide.nodes.PropertySupport;
41
import org.openide.nodes.PropertySupport;
42
import org.openide.nodes.Sheet;
42
import org.openide.nodes.Sheet;
43
import org.openide.util.HelpCtx;
43
import org.openide.util.HelpCtx;
44
import org.openide.util.Lookup;
44
import org.openide.util.Mutex;
45
import org.openide.util.Mutex;
45
import org.openide.util.RequestProcessor;
46
import org.openide.util.RequestProcessor;
46
import org.openide.util.NbBundle;
47
import org.openide.util.NbBundle;
Lines 65-80 Link Here
65
    /** should file extensions be displayed? */
66
    /** should file extensions be displayed? */
66
    private static boolean showFileExtensions = true;
67
    private static boolean showFileExtensions = true;
67
68
69
    /** Create a data node with the given children set for the given data object.
70
    * @param obj object to work with
71
    * @param ch children container for the node
72
    * @see #getShowFileExtensions
73
    */
74
    public DataNode (DataObject obj, Children ch) {
75
        this(obj, ch, null);
76
    }
77
68
    /** Create a data node for a given data object.
78
    /** Create a data node for a given data object.
69
    * The provided children object will be used to hold all child nodes.
79
    * The provided children object will be used to hold all child nodes.
70
    * The name is always set to the base name of the primary file;
80
    * The name is always set to the base name of the primary file;
71
    * the display name may instead be set to the base name with extension.
81
    * the display name may instead be set to the base name with extension.
72
    * @param obj object to work with
82
    * @param obj object to work with
73
    * @param ch children container for the node
83
    * @param ch children container for the node
84
    * @param lookup the lookup to provide content of {@link #getLookup}
85
    *   and also {@link #getCookie}
74
    * @see #getShowFileExtensions
86
    * @see #getShowFileExtensions
87
    *
88
    * @since 5.6
89
    * @author Libor Kotouc
75
    */
90
    */
76
    public DataNode (DataObject obj, Children ch) {
91
    public DataNode (DataObject obj, Children ch, Lookup lookup) {
77
        super (ch);
92
        super (ch, lookup);
78
        this.obj = obj;
93
        this.obj = obj;
79
94
80
        propL = new PropL ();
95
        propL = new PropL ();
(-)loaders/test/unit/src/org/openide/loaders/DataNodeTest.java (+16 lines)
Lines 19-28 Link Here
19
import org.openide.filesystems.FileObject;
19
import org.openide.filesystems.FileObject;
20
import org.openide.filesystems.FileSystem;
20
import org.openide.filesystems.FileSystem;
21
import java.util.Enumeration;
21
import java.util.Enumeration;
22
import org.openide.nodes.Children;
22
import org.openide.nodes.Node;
23
import org.openide.nodes.Node;
23
import org.openide.cookies.InstanceCookie;
24
import org.openide.cookies.InstanceCookie;
24
import org.openide.filesystems.Repository;
25
import org.openide.filesystems.Repository;
25
import org.netbeans.junit.*;
26
import org.netbeans.junit.*;
27
import org.openide.util.Lookup;
28
import org.openide.util.lookup.Lookups;
26
29
27
/** Test things about node delegates.
30
/** Test things about node delegates.
28
 * @author Jesse Glick
31
 * @author Jesse Glick
Lines 103-108 Link Here
103
        assertEquals ("Now the secondary entry had to be created", 1, TwoPartLoader.get ().secondary);
106
        assertEquals ("Now the secondary entry had to be created", 1, TwoPartLoader.get ().secondary);
104
    }
107
    }
105
    
108
    
109
    public void testDataNodeGetDataFromLookup() throws Exception {
110
111
        FileSystem sfs = Repository.getDefault().getDefaultFileSystem();
112
        DataFolder rootFolder = DataFolder.findFolder(sfs.getRoot());
113
        
114
        String objectToLookup = "I like my Lookup";
115
        Lookup lookup = Lookups.fixed(new Object[] { objectToLookup });
116
        
117
        DataNode node = new DataNode(rootFolder, Children.LEAF, lookup);
118
        Object objectLookuped = node.getLookup().lookup(String.class);
119
        assertEquals("Object found in the Lookup is not equal to the inserted one.", objectToLookup, objectLookuped);
120
        
121
    }
106
    
122
    
107
    private static final class FSWithStatus extends org.openide.filesystems.LocalFileSystem 
123
    private static final class FSWithStatus extends org.openide.filesystems.LocalFileSystem 
108
    implements FileSystem.HtmlStatus {
124
    implements FileSystem.HtmlStatus {

Return to bug 61824