Eclipse Tutorial

< Part 3: Useful Programming Functions

Part 4: Useful Eclipse Views

Part 5: Running and Debugging >

Part 4: Useful Eclipse Views

"Knowledge is of two kinds. We know a subject ourselves, or we know where we can find information on it." Samuel Johnson.

Eclipse user interface consists of two types of elements: views and editors. While editors allow to perform a complete task, views provide support functions. At this point of the tutorial you should be quite familiar with the Java code editor whose main functions where detailed in Part 3. Now, the most interesting views of Eclipse will be explained in detail as well as some editor navigation tips.

 Perspectives

An Eclipse Perspective is a grouping of views and editors in order to support completely a software development activity. Nevertheless, you can customise your own perspectives by adding new views and by changing the screen layout. Perspectives may be selected by clicking on the perspective icons at the left border or choosing "Window > Open Perspective" from the menu. These are the perspectives defined inside Eclipse by default:

Resource: this perspective is closely related with the file system, as it represents the physical location of the resources stored inside projects.

Java: this perspective is focused in Java programming tasks. Their related views show packages, classes, methods and attributes.

Plug-in development: the plug-in development perspective allows programmers to extend Eclipse creating new modules.

Install/Update: allows Eclipse configuration management. It shows Eclipse components as well as versions and installation conflicts.

Debug: related to the debugging task. It focuses on running processes, breakpoints, variable status, console output, etc.

Java Browsing: the Java browsing perspective allows quick traversing of code, projects, packages and type hierarchies.

Eclipse 3.0 Update

In Eclipse 3.0 the perspective icons have been moved to the upper right corner. There is also an "Open Perspective" button which acts as a shortcut to select another perspective. The Install/Update perspective has been removed and its related actions can now be accessed through "Help > Software Updates".

 Tasks

The tasks view allows quickly pending task management. Selecting "Window> Show View> Tasks" shows this view. New tasks can be added just by clicking the "Add task" button. Notice that the task priority and completion status can also be modified by clicking in those fields. Also, errors and warnings from saved code files are shown in this view. Clicking on an error description will get you to the exact point of the code file where the error is found.

Adding "// TODO [description]" to a Java file will add a new "to do" task to your tasks view. Once again, clicking its description will get you to the exact point where the TODO tag was added. Inside the Java code editor, TODO tags can be quickly found as blue marks on the right margin. Clicking these marks will get you to the tagged line. Notice that many automated processes insert TODO tags to make sure that you review and comment the auto generated code.

Right clicking on any point of the tasks view will show a useful contextual menu which will allow you to quickly perform task management activities.

 Navigator

The resource Navigator view allows taking a look at the file structure of the defined projects. Notice that the resource Navigator view is the only one that shows the output folder ("bin") as well as the compiled Java files (".class").

 Package Explorer

The Package Explorer View shows the logical structure of Java classes and packages stored inside the different projects. Source folders (intended to store the ".java" source code files) are here decorated with a "contained package" icon. Also, Java files can be expanded in order to reveal their inner methods and attributes just by clicking the "+" button.

 

A working set is a group of elements shown in the different Eclipse views. Working sets are used to clearly separating projects. This can become a very useful feature when you are working simultaneously in many non-directly related projects. Organising your different project groups in working sets will speed up the process of finding the desired elements and will decrease the view visual clutter.

To define a working set just click the Package Explorer menu icon (the inverted triangle) and select "Select Working Set". Here you will be able to name a new working set and to select its related resources, as well as to edit or remove existing working sets. Every available working set will be shown the next time you click on the view triangular icon.

It is important to take into account that creating a new project when a working set is being used will cause the new project not to be shown inside the Eclipse views. In order to see the recently created project, it will be necessary to edit the current working set ("View menu > Select Working Set > Edit" or directly "Edit Current Working Set" and select the new project).

 Outline View

The Outline View is a quick way of seeing which methods and attributes are defined inside a Java class. The related icons provide additional information according to the attribute or method visibility. And just by clicking any of these icons you will be get to the exact line of code where such attribute or method is defined. The outline view is an essential tool in order to understand and navigate big Java files.

 

Hierarchy View

The Hierarchy View shows the hierarchical relationships present between different Java elements. Right clicking on a Java class name at the code editor and selecting "Open Type Hierarchy" will open this hierarchy view. Its keyboard shortcut is "F4".

Eclipse 3.0 Update

In Eclipse 3.0 there is a new option accessible from the contextual menu called "Open Call Hierarchy". Selecting a method and then clicking on this option will show where such method is used. The related keyboard shortcut is "CTRL + ALT + H".    

Fast Views

Dragging a view to the left margin (till a stacked folders icon appears) turns this view into a "fast view". Pressing the fast view icon will cause this view to show up, while clicking it again (or clicking anywhere in the screen) will hide the view. Right clicking the fast view icon and clicking again on "fast view" will restore the view to its original position.

Eclipse 3.0 Update

The default area in which fast views may be stacked has been changed in Eclipse 3.0. Now it is a small rectangle located at the lower left corner of the screen. So, fast views are now created by dragging a view inside this rectangle till an icon representing an arrow inside a square appears. Nevertheless, placing the cursor over the fast view area till a four arrowed redimensioning cursor appears and dragging this fast view area will allow you to relocate it wherever you want.

Search View

To perform a search inside Eclipse, the "Search" menu from the top menu bar should be selected. A search can also be invoked clicking the torch icon.

 

There are various kinds of search inside Eclipse.

File search is just a textual search which can be performed on archives of every type. It is equivalent to a traditional search.

Help search is a search performed inside Eclipse help.

Java search is similar to file search, but it provides additional features for performing search in Java files. So, you can look explicitly for types, methods, packages, constructors and fields using additional search constraints (i.e., only declarations).

It is important to check that the search is being performed on the appropriate files. This can be defined inside the "scope" field. "Workspace" refers to the complete working environment. "Selected Resources" are only the currently selected files (select more than a file just by left clicking on them while holding the CTRL key). "Working Set" is a previously defined resource group.

Search results appear in the Search View. They are also underlined in grey inside the code editor, with a yellow arrow on the left margin and with a grey mark in the right margin. Clicking on those found elements on the search view will directly get you to them.

Eclipse 3.0 Update

Search results are shown as a hierarchical tree in Eclipse 3.0.

 Navigating Views and Editors

Till now, we have introduced how to use Eclipse views and how these views help to manage information. Now, it is time to explain some additional navigation functions that will be useful to quickly find information and to properly display it in the different views and editors.  

Maximizing a view or editor

Just double clicking on the title area will maximize the window. Double clicking on it again will restore the original dimension and location of such window. In Eclipse 3.0 there is also a default keyboard shortcut for maximizing or restoring the current editor: "CTRL + M".  

Going to Last Edit Location

The menu "arrow with an asterisk" icon moves your cursor to the last edit location inside the active editor. Sometimes, after implementing a change in the code (i.e. writing some code instructions), you move the cursor to another line in order to check some other piece of code. Then, if you want to return to you last change, or to the line where you were last coding, this "going to last edit location" option will solve your problems. The associated keyboard shortcut is "CTRL + Q".  

Navigating a Editor

But what should you do if you want to continue writing at a code location where you did not change anything? (i.e. you moved the cursor over there but did not type any character). Or what if you want to go to the location before your last edit location? The menu navigation arrows will solve these problems. Click the "back" arrow to return to previously visited code locations.

And click the "forward" arrow to traverse the history of visited locations towards the most recent location.

In fact, these useful features work like a web browser. The "back" option will only be enabled if there are previously accesed locations. And the "forward" option will be activated after pressing the "back" button. Also, clicking on the small black menu triangle next to the navigation arrows will expand a list showing files where other visited locations are available. By the way, to show other editor tabs you can use the following keyboard shortcut: "ALT + F6" ("next editor" command). 

The useful keyboard shortcuts related to these navigation actions are "ALT + LEFT" for "back" and "ALT + RIGHT" for "forward".

Checking Problems

The "Go to the next/previous problem" buttons will allow you to check any pending problems in your active Java editor window.  

Remember that it is also possible going to problems, warnings, found strings or "TODO" tasks by clicking the marks on the editor right margin.

Eclipse 3.0 Update

In Eclipse 3.0 these "go to problem" buttons have been substituted by "Go to next/previous annotation". Clicking on the small black triangle next to these annotation navigation arrows will show up a customisable list of the kind of annotations that will be traversed when clicking such buttons. So, the use of these buttons is not limited to "problem checking". Now you can also choose, for example, going through your "pending tasks" while navigating the annotations.

 

< Part 3: Useful Programming Functions

Part 4: Useful Eclipse Views

Part 5: Running and Debugging >

Google
 
Web eclipsetutorial.forge.os4os.org

Return to index

A la versión española


This site is optimised for a 1024x768 screen resolution.

Created by Enrique Serrano Valle

This site contents are under the Creative Commons Attribution 2.0 license.

Eclipse trademark and logos appear according to Eclipse legal conditions. For more information check http://www.eclipse.org/legal/main.html

Java is a registered trademark of Sun Microsystems Inc.