blob: cb1c467c8946810fcc7fbf3ab363ccec21702729 [file] [log] [blame]
//
// 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.
//
= DevFaqLookupForDataNode
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqLookupForDataNode
:description: Apache NetBeans wiki DevFaqLookupForDataNode
:toc: left
:toc-title:
:syntax: true
=== 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:
[source,java]
----
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 link:http://www.tomwheeler.com/netbeans/[TodoListManager] for an example of some code that illustrates how to do this.
If you are using `link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/ProxyLookup.html[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 [link:http://bits.netbeans.org/dev/javadoc/org-openide-util-lookup/org/openide/util/lookup/ProxyLookup.html#setLookups(org.openide.util.Lookup[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 link:http://wiki.netbeans.org/DevFaqLookupForDataNode[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-02-07, and needs to be reviewed.