Skip to content

DevFaqLookupForDataNode

Antonio Vieiro edited this page Jan 25, 2018 · 1 revision

DevFaqLookupForDataNode

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 [http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/ProxyLookup.html#setLookups(org.openide.util.Lookup…​) setLookups(Lookup…​ lookups)].

Apache Migration Information

The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.

This page was exported from http://wiki.netbeans.org/DevFaqLookupForDataNode , that was last modified by NetBeans user Jtulach on 2010-07-24T20:17:21Z.

NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.

Clone this wiki locally