Index: openide/loaders/api/apichanges.xml
===================================================================
RCS file: /shared/data/ccvs/repository/openide/loaders/api/apichanges.xml,v
retrieving revision 1.23
diff -u -r1.23 apichanges.xml
--- openide/loaders/api/apichanges.xml 6 Nov 2006 08:23:46 -0000 1.23
+++ openide/loaders/api/apichanges.xml 7 Nov 2006 07:39:26 -0000
@@ -85,7 +85,7 @@
FileObject
(s) associated with its
DataObject
available in its own lookup.
+ Also a
+ DataObject
+ has been retrofitted to implement a
+ Lookup.Provider
+ interface and thus have its
+ getLookup
+ method that can be used instead of the old getCookie
one.
getNodeDelegate().getLookup()
.
+ *
+ * @return lookup representing this data object and its content
+ * @since 6.0
+ */
+ public Lookup getLookup() {
+ return getNodeDelegate().getLookup();
}
/** When a request for a cookie is done on a DataShadow of this DataObject
Index: openide/loaders/test/unit/src/org/openide/loaders/BasicDataObjectTest.java
===================================================================
RCS file: /shared/data/ccvs/repository/openide/loaders/test/unit/src/org/openide/loaders/BasicDataObjectTest.java,v
retrieving revision 1.5
diff -u -r1.5 BasicDataObjectTest.java
--- openide/loaders/test/unit/src/org/openide/loaders/BasicDataObjectTest.java 10 Jul 2006 10:25:46 -0000 1.5
+++ openide/loaders/test/unit/src/org/openide/loaders/BasicDataObjectTest.java 7 Nov 2006 07:39:33 -0000
@@ -278,6 +278,15 @@
));
}
+ public void testDataObjectIsInItLookup() throws Exception {
+ DataObject obj = DataObject.find (
+ FileUtil.createData (subDir, "somedata.txt")
+ );
+
+ DataObject query = obj.getLookup().lookup(DataObject.class);
+ assertSame("Object is in its own lookup", obj, query);
+ }
+
private void doSerTest (DataObject obj) throws Exception {
org.openide.util.io.NbMarshalledObject mar = new org.openide.util.io.NbMarshalledObject (obj);
Index: openide/loaders/test/unit/src/org/openide/loaders/DataNodeTest.java
===================================================================
RCS file: /shared/data/ccvs/repository/openide/loaders/test/unit/src/org/openide/loaders/DataNodeTest.java,v
retrieving revision 1.7
diff -u -r1.7 DataNodeTest.java
--- openide/loaders/test/unit/src/org/openide/loaders/DataNodeTest.java 2 Aug 2006 06:53:32 -0000 1.7
+++ openide/loaders/test/unit/src/org/openide/loaders/DataNodeTest.java 7 Nov 2006 07:39:33 -0000
@@ -23,6 +23,7 @@
import java.lang.ref.WeakReference;
import java.util.Set;
import junit.textui.TestRunner;
+import org.openide.cookies.OpenCookie;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStatusEvent;
import org.openide.filesystems.FileSystem;
@@ -103,6 +104,25 @@
assertEquals ("Size is two", 2, fs.lastFiles.size ());
assertEquals ("Now the secondary entry had to be created", 1, TwoPartLoader.get ().secondary);
}
+
+
+ public void testWhatIsAddedToNodeLookupIsByDefaultVisibleInDataObjectLookup() throws Exception {
+ org.openide.filesystems.FileSystem lfs = TestUtilHid.createLocalFileSystem(getWorkDir (), new String[] {
+ "F.java", "F.form"
+ });
+
+ FSWithStatus fs = new FSWithStatus ();
+ fs.setRootDirectory(org.openide.filesystems.FileUtil.toFile(lfs.getRoot()));
+
+ DataObject obj = DataObject.find (fs.findResource("F.java"));
+
+ OpenCookie fromNode = obj.getNodeDelegate().getLookup().lookup(OpenCookie.class);
+ assertNotNull("There is some cookie in node", fromNode);
+
+ OpenCookie fromObject = obj.getLookup().lookup(OpenCookie.class);
+ assertNotNull("There is a cookie in data object too", fromObject);
+
+ }
public void testDataNodeGetDataFromLookup() throws Exception {
@@ -245,6 +265,26 @@
public static final class TwoPartObject extends MultiDataObject {
public TwoPartObject(TwoPartLoader l, FileObject folder) throws DataObjectExistsException {
super(folder, l);
+ }
+
+ protected Node createNodeDelegate() {
+ return new DN(this);
+ }
+ }
+
+ private static final class DN extends DataNode {
+ public DN(TwoPartObject obj) {
+ super(obj, Children.LEAF);
+ }
+
+ public