| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html lang="en"> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2010. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> |
| <title> Searching the workbench </title> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| </head> |
| <body> |
| <h1> Searching the workbench </h1> |
| <p> In this section, you will search the workbench for Java elements. </p> |
| <p> In the Search dialog, you can perform file, text or Java searches. Java searches |
| operate on the structure of the code. File searches operate on the files |
| by name and/or text content. Java searches are faster, since there is an |
| underlying indexing structure for the code structure. Text searches allow |
| you to find matches inside comments and strings. |
| </p> |
| <h2> Performing a Java search from the workbench </h2> |
| <ol> |
| <li> In the Java perspective, click the <strong>Search</strong> |
| (<img src="images/search.png" alt="Search">) button |
| in the workbench toolbar or use <strong>Search > Java...</strong> from |
| the menu bar. </li> |
| <li> If it is not already selected, select the <strong>Java Search</strong> |
| tab. </li> |
| <li> In the <strong>Search string</strong> field, type <em>runTest</em>. |
| In the <em>Search For</em> area, select <strong>Method</strong>, and in the <em>Limit |
| To</em> area, select <strong>References</strong>.<br> |
| Verify that the Scope is set to <strong>Workspace</strong>. |
| <p> <img src="images/search_runTest_dialog.png" alt="Java Search dialog"> |
| </p> |
| Then click <strong>Search</strong>. While searching you may click <strong>Cancel</strong> |
| at any time to stop the search. Partial results will be shown. </li> |
| <li> In the Java perspective, the Search view shows the search results. |
| <p> <img src="images/view_search_runTest.png" alt="Search results view"> |
| </p> |
| Use the <strong>Show Next Match</strong> |
| (<img src="images/search_next.png" alt="Show Next Match">) and <strong>Show Previous |
| Match</strong> (<img src="images/search_prev.png" alt="Show Previous Match">) buttons to navigate to each match. If the file in which the |
| match was found is not currently open, it is opened in an editor. </li> |
| <li> When you navigate to a search match using the Search view buttons, |
| the file opens in the editor at the position of the match. Search matches |
| are tagged with a search marker in the rulers. |
| <p> <img src="images/view_search_editor_runTest.png" alt="Editor with Search marker"> |
| </p> |
| </li> |
| </ol> |
| <h2> Searching from a Java view </h2> |
| <p> Java searches can also be performed from specific views, including the Outline, |
| Type Hierarchy view and the Package Explorer view. </p> |
| <ol> |
| <li> In the Package Explorer view, double-click <em>junit.framework.Assert.java</em> |
| to open it in an editor. </li> |
| <li> In the Outline view, select the fail(String) method, and from its context |
| menu, select <strong>References > Workspace</strong>. |
| <p> <img src="images/view_outline_search_references.png" alt="Search context menu in Outline view"> |
| </p> |
| </li> |
| </ol> |
| <h2> Searching from an editor </h2> |
| <p> From the Package Explorer view, open <em>junit.framework.TestCase.java</em>. |
| In the editor, select the class name <em>TestCase</em> and from the context |
| menu, select <strong> References > Workspace</strong>. |
| </p> |
| <img src="images/editor_testcase_search_references.png" alt="Search context menu in editor"> |
| <h2> Continuing a search from the search view </h2> |
| <p> The Search Results view shows the results for the TestCase search. Select |
| a search result and open the context menu. You can continue searching the selected |
| element's references and declarations. </p> |
| <img src="images/view_search_research_menu.png" alt="Search context menu in Search results view"> |
| <p> If you want to follow multiple levels of method calls, you can also use |
| <strong>Navigate > Open Call Hierarchy</strong>. |
| </p> |
| |
| <h2> Performing a file search </h2> |
| <ol> |
| <li> In the Java perspective, click the <strong>Search</strong> button |
| in the workbench toolbar or select <strong>Search > File</strong> from the menu bar. </li> |
| <li> If it is not already selected, select the <strong>File Search</strong> |
| tab.</li> |
| <li> In the <strong>Containing text</strong> field, type <em>TestCase</em>. |
| Make sure that the <strong>File name patterns</strong> field is set |
| to <em>*.java</em>. The Scope should be set to <em>Workspace</em>. |
| Then click <strong>Search</strong>. |
| <p> <img src="images/search_file_dialog.png" alt="File search tab"> |
| </p> |
| </li> |
| <li> To find all files of a given file name pattern, leave the Containing |
| Text field empty. </li> |
| </ol> |
| <h2> Viewing previous search results </h2> |
| <p> In the Search Results view, click the arrow next to the<strong> Previous |
| Search Results</strong> toolbar button to see a menu containing the list of the most |
| recent searches. You can choose items from this menu to view previous |
| searches. The list can be cleared by choosing <strong>Clear History</strong>. |
| </p> |
| <img src="images/view_search_previous.png" alt="Previous search results menu"> |
| <p> |
| The <strong>Previous Search Results</strong> button will display a dialog |
| with the list of all previous searches from the current session. |
| </p> |
| <img src="images/previous_searches_dialog.png" alt="Previous search results dialog"> |
| <p> |
| Selecting a previous search from this dialog will let you view that search. |
| </p> |
| <P class="nav_footer" id="nav_footer">Next Section: <A href="qs-12.htm">Running your programs</A> |
| </P> |
| <img src="../images/ngrelc.png" alt="Related concepts" border="0"> |
| <p> |
| |
| <a href="../concepts/concept-java-search.htm">Java search</a> </p> |
| |
| <p> <img src="../images/ngrelr.png" alt="Related reference" border="0"> |
| </p> |
| <p> <a href="../reference/ref-menu-refactor.htm">Refactoring actions</a><br> |
| <a href="../reference/ref-wizard-refactorings.htm">Refactoring wizard</a><br> |
| <a href="../reference/preferences/ref-preferences-java.htm">Java preferences</a> </p> |
| |
| </body> |
| </html> |
| |