Re: Help with lookup
Vitezslav Stejskal <[email protected]> Thu, 21 Aug 2003 11:46:00 +0200
| Newsgroups | gmane.comp.java.netbeans.modules.projects.devel |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: >I have a look (org/netbeans/modules/j2ee/deployment/impl/projects/J2eeModuleProjectLook) that adds a lookup.item to the project's lookup. > >I'd like Lookup.Item.getInstance() to be called lazily - ie only >somebody actually interested in the particular lookup should cause the >object that's very expensive to create to be created. > > You have to provide your own implementation of Lookup.Item which will create the instance lazily. >Unfortunately, project open seems to call all the getInstances() >multiple times (4-5 times). For example, LookNode.getIcon() seems to >ask for my lookup to be created. > > Yes, the lookup is created immediately when the LookNode is created (when the represented object is visualized), this is by design. As said before, you have to provide your own impl of Lookup.Item which you will return in J2eeMPL.getLookupItems and which will create the instance only when somebody will really need it (e.g. somebody will LookNode.getLookup().lookup(yourInst.class)). Do not use Lookups.lookupItem() in this case. -vita