Apache NetBeans Wiki Index

Note: These pages are being reviewed.

How do I implement my own lookup or proxy another one?

It is not uncommon to be subclassing a class, such as TopComponent or Node which has a method getLookup(), and to need to add to or filter the original Lookup’s contents. There are a number of convenience factories and classes which make it easy to do this:

  • ProxyLookup - a Lookup which takes an array of Lookups and merges them together. Typical use is taking an existing lookup and providing it plus a lookup created with one of the convenience methods below

  • Lookups.fixed(Object…​ arr) - a static method that creates a Lookup with an array of persistent objects as its contents

  • Lookups.singleton (Object single) - a static method that creates a Lookup with one object as its content

  • AbstractLookup - a Lookup which can have dynamic content - use it in conjunction with InstanceContent, which you can add/remove things from

If you need to customize a Node’s lookup, read the FAQ item on how to do that.

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/DevFaqLookupImplement , that was last modified by NetBeans user Geertjan on 2010-03-26T08:00:37Z.

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