Lines 23-28
Link Here
|
23 |
import java.lang.ref.WeakReference; |
23 |
import java.lang.ref.WeakReference; |
24 |
import java.util.Set; |
24 |
import java.util.Set; |
25 |
import junit.textui.TestRunner; |
25 |
import junit.textui.TestRunner; |
|
|
26 |
import org.openide.cookies.OpenCookie; |
26 |
import org.openide.filesystems.FileObject; |
27 |
import org.openide.filesystems.FileObject; |
27 |
import org.openide.filesystems.FileStatusEvent; |
28 |
import org.openide.filesystems.FileStatusEvent; |
28 |
import org.openide.filesystems.FileSystem; |
29 |
import org.openide.filesystems.FileSystem; |
Lines 103-108
Link Here
|
103 |
assertEquals ("Size is two", 2, fs.lastFiles.size ()); |
104 |
assertEquals ("Size is two", 2, fs.lastFiles.size ()); |
104 |
assertEquals ("Now the secondary entry had to be created", 1, TwoPartLoader.get ().secondary); |
105 |
assertEquals ("Now the secondary entry had to be created", 1, TwoPartLoader.get ().secondary); |
105 |
} |
106 |
} |
|
|
107 |
|
108 |
|
109 |
public void testWhatIsAddedToNodeLookupIsByDefaultVisibleInDataObjectLookup() throws Exception { |
110 |
org.openide.filesystems.FileSystem lfs = TestUtilHid.createLocalFileSystem(getWorkDir (), new String[] { |
111 |
"F.java", "F.form" |
112 |
}); |
113 |
|
114 |
FSWithStatus fs = new FSWithStatus (); |
115 |
fs.setRootDirectory(org.openide.filesystems.FileUtil.toFile(lfs.getRoot())); |
116 |
|
117 |
DataObject obj = DataObject.find (fs.findResource("F.java")); |
118 |
|
119 |
OpenCookie fromNode = obj.getNodeDelegate().getLookup().lookup(OpenCookie.class); |
120 |
assertNotNull("There is some cookie in node", fromNode); |
121 |
|
122 |
OpenCookie fromObject = obj.getLookup().lookup(OpenCookie.class); |
123 |
assertNotNull("There is a cookie in data object too", fromObject); |
124 |
|
125 |
} |
106 |
|
126 |
|
107 |
public void testDataNodeGetDataFromLookup() throws Exception { |
127 |
public void testDataNodeGetDataFromLookup() throws Exception { |
108 |
|
128 |
|
Lines 245-250
Link Here
|
245 |
public static final class TwoPartObject extends MultiDataObject { |
265 |
public static final class TwoPartObject extends MultiDataObject { |
246 |
public TwoPartObject(TwoPartLoader l, FileObject folder) throws DataObjectExistsException { |
266 |
public TwoPartObject(TwoPartLoader l, FileObject folder) throws DataObjectExistsException { |
247 |
super(folder, l); |
267 |
super(folder, l); |
|
|
268 |
} |
269 |
|
270 |
protected Node createNodeDelegate() { |
271 |
return new DN(this); |
272 |
} |
273 |
} |
274 |
|
275 |
private static final class DN extends DataNode { |
276 |
public DN(TwoPartObject obj) { |
277 |
super(obj, Children.LEAF); |
278 |
} |
279 |
|
280 |
public <T extends Node.Cookie> T getCookie(Class<T> clazz) { |
281 |
if (clazz.isAssignableFrom(OpenCookie.class)) { |
282 |
return clazz.cast(new OpenCookie () { |
283 |
public void open() { |
284 |
} |
285 |
}); |
286 |
} |
287 |
return super.getCookie(clazz); |
248 |
} |
288 |
} |
249 |
} |
289 |
} |
250 |
|
290 |
|