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.
This tagging interface isn't neccesary, the getCookie methods can simply return the Object. It makes problems in Project API when we would like to return the Project class from getCookie of DataObject. It would require the Project class to implement Node.Cookie, which is ugly and brings unneccessary dependency. Anyway this would be right step in terms of transition to new DataSystems API.
It is easy to say, but hard to do. The problem is not in having both methods there (Node.Cookie getCookie and Object getCookie) that is relatively easy. The problem is that there are subclasses of Node and they override these methods. The old override Node.Cookie one, the new override Object one and there is a need to properly delegate between them.
Generally getCookie should be replaced with getLookup anyway.
Very likely I will have to do the replacement with lookup. The impact of change from Node.Cookie getCookie to Object getCookie has been underestimated. I thought no source needs to be updated, but it is not true. Everyone subclassing Node and overriding getCookie would have to update the sources. That is much bigger impact that I want especially when we consider that the final state is really Lookup getLookup (). The solution that could work: class Node implements Lookup.Provider { public Node (Children ch, Lookup lookup); /** Either returns the lookup or delegates to getCookie if none * passed to constructor */ public final Lookup getLookup (); /** @deprecated + delegates to getLookup if there is one */ public Node.Cookie getCookie (Class c); } Btw. this means that the Lookup cannot change during the lifetime of the Node, that is probably the right thing (otherwise one cannot reliably listen for changes) but it is possible problem for FilterNode and LookNode...
Is it really a problem for FilterNode and LookNode? public class FilterNode { public FilterNode(Node n) { super(new FilterChildren(n), new FilterLookup(n.getLookup())); } public void setOriginal(Node n2) { // ... ((FilterLookup)getLookup()).change(n2.getLookup()); } private static class FilterLookup extends ProxyLookup { public void change(Lookup l) { setDelegates(new Lookup[] {l}); } } } or similar.
Create branching point nocookies_26970_base and branch nocookies_26970 (sorry for messing numbers). Initial implementation checked in.
Implementation seems to be done. Could you please review the code in branch? If ok, I can integrate it on Monday.
OK, I looked briefly Jarda's changes. It's worth of trying. Let's see how it will work.
Please, go ahead and merge it, I would like to get rid of Node.Cookie in projects API and this seems to be the right way.
Ok, let's go.
Created attachment 7576 [details] Diff with implementation
api/doc/changes/apichanges.xml; revision: 1.97; src/org/openide/nodes/AbstractNode.java; new revision: 1.53; src/org/openide/nodes/FilterNode.java; new revision: 1.60 src/org/openide/nodes/Node.java; new revision: 1.51 src/org/openide/nodes/NodeLookup.java;new revision: 1.2 test/unit/src/org/openide/nodes/NodeLookupTest.java;new revision: 1.4