|
org.openidex.util/3 3.34 | |||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||
See:
Description
| Search API | |
|---|---|
| org.openidex.search | |
The module is useless by itself. It contains an SPI which can be used by modules defining nodes to make the nodes searchable, or to specify how the nodes should be searched, and an API which makes implementation of the SPI easier.
SearchGroup.onStopSearch
Class SearchGroup now contains method
onStopSearch, that can be overriden in subclasses
to perform some custom operations that are needed to stop the
search, e.g. terminate internal tasks.
Utils
Class Utils made public with one public static method
getFileObjectsIterator(SearchInfo si). This utility
method returns Iterator of FileObjects
for the provided SearchInfo. This change simplifies
the work with SearchInfo implementations.
SearchInfo.Files
Added SearchInfo.Files interface which extends
SearchInfo interface. It adds method
filesToSearch() to provide FileObjects
which should be searched. This change allows to operate FileObjects
in the search mechanism instead of DataObjects and
as a result improves search performance.
createCompoundSearchInfo(...)
to class SearchInfoFactory
Compound SearchInfo is a useful functionality that
has been present in the package since the
SearchInfo interface had been introduced. It just
was not available from outside the
org.openidex.search package. This change makes it
available through a public factory method.
SearchInfo
objects contained in Projects'
lookups are now taken into account by action Find in Projects...
The change is not in the API itself but in the range of its usage.
Before the change, action Find in Projects... did not look
for
SearchInfo
objects – it always searched
projects' SourceGroups.
Now the action first checks the
project's Lookup
for presence of a SearchInfo object. If some
SearchInfo is present, it is used for the search,
and only if there is no SearchInfo,
the project's SourceGroups are searched.
The SearchInfo API+SPI allows other modules to specify whether and how should nodes they define be searched.
The definition is represented by objects implementing interface
SearchInfo. To enable searching on a custom node,
a SearchInfo object must be added to the node's lookup.
In most cases, there is no need to define own class implementing the
interface - one can use factory methods of class
SearchInfoFactory.
Example:
import org.openide.util.lookup.Lookups;
public class MyNode extends AbstractNode {
public MyNode(FileObject folder) {
super( new MyNodeChildren(folder),
Lookups.singleton(SearchInfoFactory.createSearchInfo(
folder,
true,
new FileObjectFilter[] {
SearchInfoFactory.VISIBILITY_FILTER
}) );
}
...
}
One of the factory methods - createSearchInfoBySubnodes(...)
- requires that a reference to the node itself. In this case, it is not
possible to fully define the lookup in the super(...)
statement of the constructor because a reference to the node is not
available until the call of super(...) returns.
In this case, a special technique must be used:
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
public class MyNode extends AbstractNode {
public MyNode() {
this(new InstanceContent());
}
public MyNode(InstanceContent ic) {
super(new AbstractLookup(ic));
ic.add(SearchInfoFactory.createSearchInfoBySubnodes(this));
}
...
}
deprecated-SearchAPI
defines interfaces SearchInfo, FileObjectFilter
and a factory class SearchInfoFactory
|
|
The sources for the module are in the NetBeans Mercurial repositories.
Nothing.
Read more about the implementation in the answers to architecture questions.
|
org.openidex.util/3 3.34 | |||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||