|
org.openidex.util/3 3.11 | |||||||||
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.
SearchInfo
objects contained in Project
s'
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' SourceGroup
s.
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 SourceGroup
s are searched.
ADD_TO_HISTORY
field
It is necessary to fire further PropertyChangeEvent to fix it. (Details in the issue #54028)It is event ADD_TO_HISTORY, that will be fired after adding new SearchPattern to history. Old value of event would be null, new value would be added pattern. Also pattern checking before adding to history is a subject of the API change.
SearchHistory
and SearchPattern
classes
Editor find and replace dialog and search over files in explorer should have one and shareable history. Editor module should be notified about last selected search expression to highlight(in yellow) the matched patterns.
SearchInfo
interface
together with a factory class SearchInfoFactory
and interface FileObjectFilter
In NetBeans 3.6, only nodes representing file folders were
searchable. In NetBeans 4.0, there are several special views
and nodes not representing folders. But many of these nodes
still need to be searchable. Interface SearchInfo
allows to specify how a particular node should be searched
- simply by putting a SearchInfo
object to the
node's lookup.
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:
SearchAPI defines interfacesimport 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)); } ... }
SearchInfo
, FileObjectFilter
and a factory class SearchInfoFactory
|
|
The sources for the module are in NetBeans CVS in openidex directory.
Nothing.
Read more about the implementation in the answers to architecture questions.
|
org.openidex.util/3 3.11 | |||||||||
PREV NEXT | FRAMES NO FRAMES |