See: Description
Package | Description |
---|---|
org.netbeans.api.search |
This package contains classes that can be used by modules that need
to work with Search in Projects dialog, or want to share
information about what data was recently searched.
|
org.netbeans.api.search.provider |
Classes that you may need to work with if you are implementing
a custom search provider.
|
org.netbeans.api.search.ui |
Helpers for creating UI controls for your search provider that are
similar to controls in the default provider.
|
org.netbeans.spi.search |
This package contains classes that you can subclass and register to
lookups of nodes if you want to specify how the nodes should be
searched.
|
org.netbeans.spi.search.provider |
This package contains classes that are needed to add a custom panel
to Find in Projects dialog, that can have customized search
criteria, search algorithm and results panel.
|
There are three goals:
The module also contains UI for Find (Replace) in Projects dialog and search results window, and implementation of default search provider.
Controls for specifying search scope options can now be split into two panels - one for scope options, and one for file name options.
Class ComponentUtils has new method adjustPanelsForOptions(JPanel, JPanel, boolean, FileNameController), that takes the two panels. It can be used instead of adjustPanelForOptions(JPanel, boolean, FileNameController), that puts all controls into a single panel.
Class ScopeOptionsController has new method getFileNameComponent() to get the panel with controls related to file name. (The panel related to search scope can be get using getComponent()).
Before, the search pattern distinguished two match types: Regular Expression and Standard. The standard meant that the text was searched literally in editor search, and that the searched text could contain basic wildcards (* and ?) in Find in Projects.
Now, the Search pattern can specify exact match type: Regular Expression, Basic Wildcards and Literal. Basic wildcards are not supported by Editor search, but the fallback to Literal Search is transparent for the editor.
To support extra match types, a few parts have to be added to the API:
Search scope can define an icon that will be shown in the UI, usually in the combo box for search scope selection.
To use a custom scope icon, override method SearchScopeDefinition.getIcon().
Search History is extended for replace history.
New ReplacePattern is a wrap class for replace expression.
The new SearchResultsDisplayer.closed()
is
called when the results panel is closed by the user. It can
be overriden to release all resouces held by the panel.
Before this change, HierarchyListener
s were
used to detect detaching of search results panels. But it
is quite complicated as the panels can be often detached and
attached again when they are moved from a simple pane to a
tabbed pane or vice versa.
SearchHistory
is synchronising history content through netbeans modules and it saves history to preferences.
There are two separate histories. One for search and another for replace.
When you add your propertyListener to
SearchHistory
- you can listen for changes in histories.
SearchHistory
has methods for adding new entries and getting whole history list.
This use-case was formerly covered by module org.openidex.search.
The SearchInfo API+SPI allows other modules to specify whether and how should nodes they define be searched.
The definition is represented by objects extending class
SearchInfoDefinition
. To customize searching on a custom node, a
SearchInfoDefinition
object must be added to the node's lookup.
In most cases, there is no need to define own class extending the
class - one can use factory methods of class
SearchInfoDefinitionFactory
.
In some cases implementators may need to apply the same set
of SearchFilterDefinitions in the whole subtree of a node.
If so, it is not needed to put SearchInfoDefinition
to all
nodes' lookups, but only one instance of
SubTreeSearchOptions
have to be put into the lookup of the root node.
SearchInfoDefinition
,
SearchFilterDefinition
,
SubTreeSearchOptions
and a factory class
SearchInfoDefinitionFactory
People that want to enhance IDE searching features (with custom search criteria or specialized algorithms) can add a new tab to the "Search in Projects" dialog.
They need to implement several classes:
SearchProvider
to register the new search feature to the IDE or platform application.
SearchProvider.Presenter
that creates visual component for adding to the search dialog and that can interact with dialog buttons.
SearchResultsDisplayer
to show search results to the user.
SearchComposition
that encapsulates setting and state of searches, provide access to result displayer, and is able to start
and terminate the search.
SearchProvider
,
SearchProvider.Presenter
,
SearchResultsDisplayer
,
SearchComposition
and relative classes.
SearchInfo
,
that defines which files should be searched (it can be retrieved from methods in
SearchInfoUtils
,
or UI component controller ScopeController
),
SearchListener
that you should inform about events that happen during searching, and helper classes
SearchInfoUtils
(getting SearchInfo objects for nodes) and
FileNameMatcher
(filtering files by file name).
This API enables other modules to open Find in Projects dialog with some pre-defined criteria and to start searching programatically.
|
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
No extra declaration is required.
Read more about the implementation in the answers to architecture questions.