2.5 Some Essential Skills

     

There are some additional skills that are good to know about. For example, if you highlight an item in the JDT editor, right-click it, and select Open Declaration, the declaration of that item will open . This is great for tracking down where and how methods and fields were created. Several of those are detailed in this section and all are worth adding to your Eclipse toolbox.

2.5.1 Viewing Type Hierarchies

Another menu item in the JDT editor's context menu is the Open Type Hierarchy; when you select an item in the editor and select this menu item, that item's type hierarchy appears in the Java perspective's hierarchy view, as you see at left in Figure 2-24.

Figure 2-24. The hierarchy view
figs/ecps_0224.gif

This view acts like an object browser. It lets you explore a type's Java complete hierarchy, and double-clicking an item in this view opens its definition in the editor. That's useful if, for example, you want to see all the members of the System.out classjust highlight System.out in your code and open its hierarchy. You can also open this view by selecting an item in the editor and selecting the Navigate Open Type Hierarchy item.

The hierarchy view is not dissimilar from the outline view, which you see at right in Figure 2-24. However, the outline view is designed to show an automatic hierarchy of your code rather than the hierarchy of items you specifically select. As you work in the JDT editor, the outline view is updated automatically to show the hierarchy of the current type you're working with.

2.5.2 Browsing Java Code

There's even another entire perspective dedicated to letting you browse through projects in a Java-oriented way: the Java Browsing perspective. To open this perspective, select Window Open Perspective Java Browsing; you can see the results in Figure 2-25.

Figure 2-25. The Java browsing perspective
figs/ecps_0225.gif

This perspective presents the information you see in the standard Java perspective in a new way, and it breaks type and member information into two new views (the Members view here is much like the Outline view in the standard Java perspective). As you'd expect, the views in this perspective are all coordinatedselecting an element in the Projects views makes its packages appear in the Packages view, for example. And selecting an item in the Members view makes that item appear in the editor, and so on.

2.5.3 Searching Code

Eclipse also has great facilities for searching through code in the Search menu. In fact, the main menu items in the Search menu, Search Search, Search File, Search Help, and Search Java, all open the Search dialog, although each item corresponds to a different tab in that dialog. Searching is particularly powerful in Eclipsefor example, not only can you search across multiple files, you can also search using wildcards.

The File Search tab in the Search dialog lets you search across multiple files. For example, in Figure 2-26, we're searching for the word main through all .java files in the workspace. The scope of the search is set with the radio buttons in the Scope box, and the default is to search all matching files throughout the workspace (that is, all your projects that appear in the Package Explorer). You can also restrict the search to a working set (covered in a few pages) of projects. If you want to search only the current project or just a restricted number of projects, you can select that project or those projects in the Package Explorer, then open the Search dialog and select the Selected Resources radio button in the Scope box.

Figure 2-26. Performing a file search
figs/ecps_0226.gif

Clicking Search makes Eclipse search for matches to the text you've entered, and you can see the results in the Search Results view, which appears at the bottom in Figure 2-27. Double-clicking a match in the Search Results view opens the match in the JDT editor, as you can see in the figure, and both underlines the match and points to it with an arrow.

Figure 2-27. Viewing search results
figs/ecps_0227.gif

You can also perform Java searches with the Java tab in the Search dialog. This lets you search for Java elements by kindtypes, methods, packages, constructors, and fieldsas you can see in Figure 2-28. You can also limit the search so that it only matches declarations or references.

Figure 2-28. Performing a Java search
figs/ecps_0228.gif

Being able to search across files and classes is one of the big advantages of using an IDEif you've been doing Java development using a text editor and javac , you'll find there's no comparison when you start using the project management capabilities like these in Eclipse.



Eclipse
Eclipse
ISBN: 0596006411
EAN: 2147483647
Year: 2006
Pages: 114
Authors: Steve Holzner

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net