Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 24

Download

How can I add support for `Lookup`s on nodes representing my file type?

Any object you create can implement Lookup.Provider. The simplest way to create a mutable lookup is by using InstanceContent and AbstractLookup. Simplified typical usage:

public SomeObject implements Lookup.Provider {
   private InstanceContent content = new InstanceContent();
   private final AbstractLookup lkp = new AbstractLookup(content);

   public someMethod() {
      ic.set (someCollection...);
   }

   public Lookup getLookup() {
      return lkp;
   }
}

This is how you create a lookup with dynamic content of your choosing. See also Tom Wheeler’s TodoListManager for an example of some code that illustrates how to do this.

If you are using ProxyLookup to proxy another (or multiple) lookups, and you want to change the set of Lookups you are proxying on the fly, you will need to subclass ProxyLookup and call the protected method ProxyLookup.setLookups(Lookup…​ lookups).