Searching the Workbench

In this section, you will search the workbench for Java elements.

In the Search dialog, you can perform text searches and Java searches.

Performing a JDT Search

1.

In the Java perspective, click the Search button in the workbench toolbar.

2.

Select the Java Search tab (if it is not already selected).

3.

In the Search Expression field, type runTest . In the Search For area, select Method, and in the Limit To area, select References.

Then click Search. Notice that in the search progress dialog, you can click Cancel at any point while the search is being conducted to stop the search.

4.

In the Java perspective, the Search view displays.

Use the Show Next Match and Show Previous Match buttons to view each match. If the file in which the match was found is not currently open, it is opened in an editor.

5.

Note that when you navigate to a search match using the Search view buttons, the file opens in the editor at the position of the search match, which is tagged with a search marker in the marker bar.

Notice that the search results list displays the method containing the match.

From a Java View

You can conduct a Java search from many views, such as the Outline, Hierarchy, or Packages view.

1.

In the Packages view, double-click junit.framework.Assert.java to open it in an editor.

2.

In the Outline view, select the fail(String) method, and from its context menu, select Search > References.

3.

Notice that in the search progress dialog, you can click Cancel at any point while the search is being conducted to stop the search.

4.

In the Java perspective, the Search Results view displays.

Use the Show Next Match and Show Previous Match buttons to view each match. If the file in which the match was found is not currently open, it is opened automatically in an editor.

From an Editor

In the Packages view, double-click junit.framework.TestCase.java to open it in an editor. In the editor, select the word TestCase (in its initial declaration line, at the top of the file), and from its context menu, select Search > References.

Searching from an Editor

From the Search View

In the Search Results view showing the results for the TestCase search, select any search result. From the context menu of this result, select either References, Declarations in Workspace, or Declarations in Hierarchy.

Searching from the Search View

Performing a Text Search

1.

In the Java perspective, click the Search button in the workbench toolbar.

2.

Select the Text Search tab (if it is not already selected).

3.

In the Search Expression field, type TestCase. In the Extensions field, make sure that java is the only extension.

Then click Search.

4.

Notice that the search results list displays the resource that contains each match.

Viewing Previous Search Results

In the Search Results view, click the Previous Search Results button's drop-down menu (on the view toolbar) to see a list of most recently-conducted searches.

Repeating a Previous Search

You can also click the Previous Search Results button to bring up a dialog displaying the list of all previous searches.

Previous Searches Dialog

Select any one of these previous searches either in the menu or in the dialog to review the results of the selected search.

Clearing Previous Search Results

In the Search Results view, click the Remove All Searches button on the view toolbar to clear the list of previously-conducted searches. After this, all search results are no longer available for you to review.

Remove All Searches Button