| // |
| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| // |
| |
| = DevFaqLookupImplement |
| :jbake-type: wiki |
| :jbake-tags: wiki, devfaq, needsreview |
| :jbake-status: published |
| |
| === How do I implement my own lookup or proxy another one? |
| |
| It is not uncommon to be subclassing a class, such as link:DevFaqWindowsTopComponent.html[TopComponent] or link:DevFaqWhatIsANode.html[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: |
| |
| * link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/ProxyLookup.html[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 |
| * link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/Lookups.html#fixed(java.lang.Object...)[Lookups.fixed(Object... arr)] - a static method that creates a Lookup with an array of persistent objects as its contents |
| * link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/Lookups.html#singleton(java.lang.Object)[Lookups.singleton (Object single)] - a static method that creates a Lookup with one object as its content |
| * link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/AbstractLookup.html[AbstractLookup] - a Lookup which can have dynamic content - use it in conjunction with link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/InstanceContent.html[InstanceContent], which you can add/remove things from |
| |
| If you need to customize a Node's lookup, read link:DevFaqNodesCustomLookup.html[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 link:http://wiki.netbeans.org/DevFaqLookupImplement[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-01-10, and needs to be reviewed. |