Search in sources :

Example 1 with DelegatingSearchInfo

use of org.netbeans.api.search.provider.impl.DelegatingSearchInfo in project netbeans-rcp-lite by outersky.

the class SearchInfoUtils method findDefinedSearchInfo.

/**
 * Get a search info for a node, if it was explicitly defined in node's
 * lookup, or in lookup of a ancestor node. Default search info is not
 * created.
 *
 * @see #getSearchInfoForNode(org.openide.nodes.Node)
 *
 * @return Defined SearchInfo, or null if not available.
 */
@CheckForNull
public static SearchInfo findDefinedSearchInfo(@NonNull Node node) {
    // NOI18N
    Parameters.notNull("node", node);
    SearchInfoDefinition sid = SearchInfoDefinitionUtils.findSearchInfoDefinition(node);
    if (sid != null) {
        return new DelegatingSearchInfo(sid);
    } else {
        return null;
    }
}
Also used : SearchInfoDefinition(org.netbeans.spi.search.SearchInfoDefinition) DelegatingSearchInfo(org.netbeans.api.search.provider.impl.DelegatingSearchInfo) CheckForNull(org.netbeans.api.annotations.common.CheckForNull)

Example 2 with DelegatingSearchInfo

use of org.netbeans.api.search.provider.impl.DelegatingSearchInfo in project netbeans-rcp-lite by outersky.

the class SearchInfoUtils method getSearchInfoForNode.

/**
 * Gets a search info for node.
 *
 * <div class="nonnormative">
 * <p>
 *   Algorithm for getting search info:
 * </p>
 * <ol>
 *    <li>Look for SearchInfoDefinition in lookup of the node. If found,
 *    create and return search info for this definition.</li>
 *    <li>Look for SubTreeSearchOptions in lookups of this node and its
 *    ancestors. If found, check if the node has a {@link FileObject}
 *    (possibly as primary file of a {@link DataObject}) in its lookup,
 *    and, if so, create search info for recursive searching in the file
 *    object, using filters defined in found {@link SubTreeSearchOptions}.
 *    </li>
 *    <li>Check whether the node has a {@link FileObject}
 *    (possibly as primary file of a {@link DataObject}) in is lookup. If
 *    so, create default search info for that file object. Default means
 *    that the file object will be searched recursively, using default
 *    filters.
 *    </li>
 *    <li>
 *    Return null.
 *    </li>
 * </ol>
 * </div>
 *
 * @see FileObject
 * @see DataObject
 * @see SearchInfoDefinition
 * @see SubTreeSearchOptions
 * @see #findDefinedSearchInfo(org.openide.nodes.Node)
 *
 * @return Search info for a node. If no search info was defined and it
 * cannot be created for this node, null is returned.
 */
@CheckForNull
public static SearchInfo getSearchInfoForNode(@NonNull Node node) {
    // NOI18N
    Parameters.notNull("node", node);
    SearchInfoDefinition sid = SearchInfoDefinitionUtils.getSearchInfoDefinition(node);
    if (sid == null) {
        return null;
    } else {
        return new DelegatingSearchInfo(sid);
    }
}
Also used : SearchInfoDefinition(org.netbeans.spi.search.SearchInfoDefinition) DelegatingSearchInfo(org.netbeans.api.search.provider.impl.DelegatingSearchInfo) CheckForNull(org.netbeans.api.annotations.common.CheckForNull)

Aggregations

CheckForNull (org.netbeans.api.annotations.common.CheckForNull)2 DelegatingSearchInfo (org.netbeans.api.search.provider.impl.DelegatingSearchInfo)2 SearchInfoDefinition (org.netbeans.spi.search.SearchInfoDefinition)2