Materialize Maven Modules in Eclipse

This note relates to:

  • Eclipse SDK 3.6.2
  • m2eclipse plugin 0.12.1
  • subclipse 1.6.17

In Eclipse, modules in a Maven project are materialized separately when the project is first checked out of a Subversion repository. However, when new modules are loaded as a result of a repository update, the new modules are not automatically materialized.

To prompt Eclipse to create new projects for the acquired modules:

  1. Right-click on the project containing the new modules
  2. Select Import… from menu
  3. Select Maven > Existing Maven Projects and press Next button
  4. Set the check boxes next to the projects to materialize and press Finish button

Automatically organize Java imports in Eclipse

This note relates to Eclipse SDK 3.6.2.

When editing a Java source file, in Eclipse, warnings are reported when an import statement is specified but not used. Unused import statements can be removed automatically by using the Java editor menu entry Source > Organize Imports.

This can be automatized when the file is saved using the following approach:

  1. Open “Preferences” page via menu Window > Preferences
  2. Navigate to Save Actions for Java Editor (Java > Editor > Save Actions)
  3. Select Perform the selected actions on save
  4. Select Organize imports
  5. Press button Apply

From this point on, when a Java file is saved, import statements will automatically be cleaned.

Export and Import custom key bindings in Eclipse

This note relates to Eclipse 3.6.0

Eclipse saves a user’s preferences in a special area of the workspace directory. In fact, it saves all the information in the sub-directory called “.metadata”. If you use multiple workspaces or need to create a fresh new workspace, when you first start the workspace, you will find out that all the key bindings and other preferences are lost. Copying the “.metadata” directory between two workspaces is not an option since it also contains the information about the projects.

The process needed to copy the user’s preferences between two workspaces is to export them from the workspace containing the favoured ones, and importing them in the desired workspace. In the process, Eclipse produces a text file with an “.epf” extension which can be used to port the preferences between workspaces.

To produce the exported preferences file, use the Eclipse menu:

  • File > Export… > General > Preferences > Next
  • At this page, select what should be exported. For exporting only key bindings, unselect “Export All” and check “Keys Preferences”
  • Specify a file to save the preferences to
  • Press “Finish”

To import the preferences file, using the Eclipse menu:

  • File > Import… > General > Preferences > Next
  • Browse for the desired preferences file
  • Click “Finish”

Although there exists, in the preferences page where key bindings are assigned, a button offering to export key bindings in a CSV file, I do not know how to use the produced CSV file restore key bindings in the different workspace. The .epf method, described above, is the only one I know, so far.

Use CTL-Tab for switching editor windows in Eclipse

This note relates to Eclipse SDK 3.6.0

Many development platforms and editors use the key combination CTL+Tab to switch between edited windows. In Eclipse, the default key combination is CTL+F6. However, the Eclipse platform is customisable and the key combination can easily be changed.

In using the Eclipse menu:

  • Window > Preferences > General > Keys
  • Select the command titled “Next Editor”
  • Click mouse in text box titled “Binding” and select all text
  • Press the key combination CTL+Tab. The text in the box should reflect the action
  • Press the button “Apply”

While you are at it, you should assign the binding “Shift+CTL+Tab” to the command titled “Previous Editor”

To back up your key bindings or port them into a different workspace, use the note in exporting and importing key bindings.