Appendix E. Eclipse Tips

E.1. Introduction

This section will give you some useful hints for using Eclipse.

E.2. Package Explorer View

Eclipse's Package Explorer view offers two ways of displaying packages. Flat view, used by default, lists each package at the same level, even if it is a subpackage of another. Hierarchical view, however, will display subpackages nested within one another, making it easy to hide an entire package hierarchy. You can switch between hierarchical and flat views by selecting the menu inside the package view (represented as a triangle), selecting either Flat or Hierarchical from the Package Presentation submenu.

Package explorer panel (package view)

Switch between hierarchical and flat views by selecting the menu inside the package view (represented as a triangle), selecting either Flat or Hierarchical from the Package Presentation submenu

Figure E.1. Package explorer panel (package view)



Package explorer panel (hierarchical view)

The hierarchical view shows nested packages in a tree view

Figure E.2. Package explorer panel (hierarchical view)



E.3. Add Unimplemented Methods

If the cursor is on a line with an error, CTRL+1 (use COMAND+1 on a Mac) may popup a list of quick fixes

"Add unimplemented methods" quick fix

Figure E.3. "Add unimplemented methods" quick fix



E.4. Field Auto-Completion

Note that auto-completion in Eclipse and STS is CTRL+Space, even on a Mac.

Field name auto-completion

Figure E.4. Field name auto-completion



E.5. Generating Constructors From Fields

Right-click in a class and select "Source" on the popup menu. Alternatively use ALT-SHIFT-S (ALT-COMMAND-S on a Mac). Many options to generate source, including constructors.

Generate Constructor using Fields

Figure E.5. Generate Constructor using Fields



E.6. Field Naming Conventions

A field's name should describe the role it provides callers, and often corresponds to the field's type. It should not describe implementation details. For this reason, a bean's name often corresponds to its service interface. For example, the class JdbcAccountRepository implements the AccountRepository interface. This interface is what callers work with. By convention, then, the bean name should be accountRepository.

E.7. Tasks View

The tasks view in the bottom right page area

Figure E.6. The tasks view in the bottom right page area



To display the Tasks view, select the Window menu, then Show View. If Tasks is not in the list, select Other ... and then open the General folder. Select Tasks from the folder contents. You do not want the view called "Task List" (which is from the MyLyn plugin).

You can configure the Tasks View to only show the tasks relevant to the current project. In order to do this, open the dropdown menu in the upper-right corner of the tasks view (indicated by the little triangle) and select 'Configure Content...'. Now select the TODO configuration and from the Scopes, select 'On any element in same project'. Now if you have multiple project opened, with different TODOs, you will only see those relevant to the current project.

E.8. Rename a File

It is not immediately obvious how to do this - it is actually a refactoring exercise.

Renaming a Spring configuration file using the Refactor command

Figure E.7. Renaming a Spring configuration file using the Refactor command