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.

Bug 26790 - Remove Node.Cookie from the API
Summary: Remove Node.Cookie from the API
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: Jaroslav Tulach
Keywords: API
Depends on: 26876 27425
Blocks: 26913 27441
  Show dependency tree
Reported: 2002-08-26 21:41 UTC by Vitezslav Stejskal
Modified: 2008-12-22 15:54 UTC (History)
2 users (show)

See Also:
Issue Type: TASK
Exception Reporter:

Diff with implementation (38.35 KB, patch)
2002-10-03 09:16 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vitezslav Stejskal 2002-08-26 21:41:40 UTC
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.
Comment 1 Jaroslav Tulach 2002-08-29 13:26:32 UTC
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.

Comment 2 Jesse Glick 2002-08-30 02:45:52 UTC
Generally getCookie should be replaced with getLookup anyway.
Comment 3 Jaroslav Tulach 2002-08-30 07:53:18 UTC
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...

Comment 4 Jesse Glick 2002-08-31 16:08:31 UTC
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) {
    // ...
  private static class FilterLookup extends ProxyLookup {
    public void change(Lookup l) {
      setDelegates(new Lookup[] {l});

or similar.
Comment 5 Jaroslav Tulach 2002-09-13 14:02:10 UTC
Create branching point nocookies_26970_base and branch nocookies_26970
(sorry for messing numbers). Initial implementation checked in.
Comment 6 Jaroslav Tulach 2002-09-19 12:51:22 UTC
Implementation seems to be done. Could you please review the code in
branch? If ok, I can integrate it on Monday.
Comment 7 Petr Hrebejk 2002-09-19 16:02:07 UTC
OK, I looked briefly Jarda's changes. It's worth of trying. Let's see
how it will work.
Comment 8 Vitezslav Stejskal 2002-09-30 13:23:19 UTC
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.
Comment 9 Jaroslav Tulach 2002-10-02 11:00:43 UTC
Ok, let's go.
Comment 10 Jaroslav Tulach 2002-10-03 09:16:01 UTC
Created attachment 7576 [details]
Diff with implementation
Comment 11 Jaroslav Tulach 2002-10-03 09:18:43 UTC
api/doc/changes/apichanges.xml; revision: 1.97; 
src/org/openide/nodes/; new revision: 1.53; 
src/org/openide/nodes/; new revision: 1.60
src/org/openide/nodes/; new revision: 1.51
src/org/openide/nodes/;new revision: 1.2
test/unit/src/org/openide/nodes/;new revision: 1.4