Index: loaders/manifest.mf
===================================================================
RCS file: /cvs/openide/loaders/manifest.mf,v
retrieving revision 1.22
diff -u -r1.22 manifest.mf
--- loaders/manifest.mf 14 Jul 2005 07:41:05 -0000 1.22
+++ loaders/manifest.mf 5 Aug 2005 08:49:32 -0000
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
OpenIDE-Module: org.openide.loaders
-OpenIDE-Module-Specification-Version: 5.5
+OpenIDE-Module-Specification-Version: 5.6
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
Index: loaders/api/apichanges.xml
===================================================================
RCS file: /cvs/openide/loaders/api/apichanges.xml,v
retrieving revision 1.17
diff -u -r1.17 apichanges.xml
--- loaders/api/apichanges.xml 20 May 2005 17:07:28 -0000 1.17
+++ loaders/api/apichanges.xml 5 Aug 2005 08:49:32 -0000
@@ -350,6 +350,23 @@
+
+
+ New DataNode
constructor with with Lookup
+
+
+
+
+
+ Common Palette client infrastructure needs to have DataNode associated with a "palette item".
+ This can be now achieved only by implementing item as Node.Cookie and returning it
+ from the corresponding DataObject via getCookie() method.
+ Depending on Node.Cookie is problematic, thus introducing this new constructor with a Lookup.
+
+
+
+
+
Index: loaders/src/org/openide/loaders/DataNode.java
===================================================================
RCS file: /cvs/openide/loaders/src/org/openide/loaders/DataNode.java,v
retrieving revision 1.20
diff -u -r1.20 DataNode.java
--- loaders/src/org/openide/loaders/DataNode.java 20 May 2005 17:07:29 -0000 1.20
+++ loaders/src/org/openide/loaders/DataNode.java 5 Aug 2005 08:49:32 -0000
@@ -41,6 +41,7 @@
import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet;
import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
import org.openide.util.Mutex;
import org.openide.util.RequestProcessor;
import org.openide.util.NbBundle;
@@ -65,16 +66,30 @@
/** should file extensions be displayed? */
private static boolean showFileExtensions = true;
+ /** Create a data node with the given children set for the given data object.
+ * @param obj object to work with
+ * @param ch children container for the node
+ * @see #getShowFileExtensions
+ */
+ public DataNode (DataObject obj, Children ch) {
+ this(obj, ch, null);
+ }
+
/** Create a data node for a given data object.
* The provided children object will be used to hold all child nodes.
* The name is always set to the base name of the primary file;
* the display name may instead be set to the base name with extension.
* @param obj object to work with
* @param ch children container for the node
+ * @param lookup the lookup to provide content of {@link #getLookup}
+ * and also {@link #getCookie}
* @see #getShowFileExtensions
+ *
+ * @since 5.6
+ * @author Libor Kotouc
*/
- public DataNode (DataObject obj, Children ch) {
- super (ch);
+ public DataNode (DataObject obj, Children ch, Lookup lookup) {
+ super (ch, lookup);
this.obj = obj;
propL = new PropL ();
Index: loaders/test/unit/src/org/openide/loaders/DataNodeTest.java
===================================================================
RCS file: /cvs/openide/loaders/test/unit/src/org/openide/loaders/DataNodeTest.java,v
retrieving revision 1.1
diff -u -r1.1 DataNodeTest.java
--- loaders/test/unit/src/org/openide/loaders/DataNodeTest.java 22 Apr 2005 09:05:11 -0000 1.1
+++ loaders/test/unit/src/org/openide/loaders/DataNodeTest.java 5 Aug 2005 08:49:33 -0000
@@ -19,10 +19,13 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileSystem;
import java.util.Enumeration;
+import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.cookies.InstanceCookie;
import org.openide.filesystems.Repository;
import org.netbeans.junit.*;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
/** Test things about node delegates.
* @author Jesse Glick
@@ -103,6 +106,19 @@
assertEquals ("Now the secondary entry had to be created", 1, TwoPartLoader.get ().secondary);
}
+ public void testDataNodeGetDataFromLookup() throws Exception {
+
+ FileSystem sfs = Repository.getDefault().getDefaultFileSystem();
+ DataFolder rootFolder = DataFolder.findFolder(sfs.getRoot());
+
+ String objectToLookup = "I like my Lookup";
+ Lookup lookup = Lookups.fixed(new Object[] { objectToLookup });
+
+ DataNode node = new DataNode(rootFolder, Children.LEAF, lookup);
+ Object objectLookuped = node.getLookup().lookup(String.class);
+ assertEquals("Object found in the Lookup is not equal to the inserted one.", objectToLookup, objectLookuped);
+
+ }
private static final class FSWithStatus extends org.openide.filesystems.LocalFileSystem
implements FileSystem.HtmlStatus {