Chapter 6. Eclipse Plug-in

Describes the installation and usage of the Jalopy Eclipse Plug-in.

Eclipse is an open platform for tool integration built by an open community of tool providers. Operating under an open source paradigm, with a common public license that provides royalty free source code and world wide redistribution rights, the eclipse platform provides tool developers with ultimate flexibility and control over their software technology.

The homepage can be reached under http://www.eclipse.org/

6.1. Installation

Explains the steps involved to install the Eclipse Plug-in.

6.1.1. System requirements

The Plug-in requires Eclipse 2.1 or later. See Section 1.1, "System requirements" for the basic requirements to run Jalopy.

6.1.2. Installation

The Plug-in comes as an executable Jar Archive (Jar) that contains a graphical setup wizard to let you easily install the software. Wizard installation is recommended and explained in detail in Section 1.3, "Wizard Installation".

If you would rather install the Plug-in manually, you have to decompress and copy the appropriate files into the different application folders. To decompress the contents of the installer Jar, you can either use the Jar tool that ships with your Java distribution or any other software that can handle the ZIP compression format (e.g. 7Zip or WinZip).

If you're upgrading from a prior version and want to keep your settings, first copy or rename the current Jalopy settings directory to match the version number of the new release. For instance, if your current settings directory is "C:\Documents and Settings\John Doo\.jalopy\1.0.4" and you're about to install Jalopy 1.8, either copy the directory contents or rename it to "C:\Documents and Settings\.jalopy\John Doo\1.8". Wizard installation can perform this step automatically.

Make sure Eclipse is not running and remove any present "com.triemax.jalopy_1.8" directory in your Eclipse plugin folder. This folder is usually located in the root directory of your Eclipse installation, e.g. "C:\Program Files\Eclipse\plugins\".

Copy the Jalopy Plug-in folder "com_triemax.jalopy_1.8" from the temporary directory into the Eclipse plugin folder. Then place the two Jar files "jalopy-1.8.jar" and "jalopy-eclipse-1.8.jar" from the temporary directory into the Jalopy Plug-in folder.

If you are running Eclipse 2.1, as a final step delete the file "plugin.xml" from the Jalopy Plug-in folder and rename the file "plugin.xml-2.x.xml" to "plugin.xml".

6.2. Integration

Describes how the Plug-in is integrated into the Eclipse IDE.

6.2.1. Main menu bar

Currently, the software adds a new item into the main menu bar of Eclipse to launch the Jalopy settings dialog. Note that the configuration dialog is actually a Java Swing dialog launched in-process so the appearance and behavior may slightly differ compared to native applications. A future version will bring tight integration with the Eclipse workbench preferences dialog.

  • Window->Jalopy Preferences

    Displays the Jalopy preferences dialog. Use this item if you want to change the settings that control the layout of formatted code.

Figure 6.1. Jalopy Preferences menu item

Jalopy Preferences menu item

The menu item appears only for certain views/editors. If you want to enable it permanently, mark Window->Customize Perspective...->Action Sets->Jalopy

For an explanation of the available options to configure formatting output, please refer to Chapter 2, Configuration.

Please note that the menu item currently does not work under Mac OS X. With this operating system, a dialog is displayed to inform you about this restriction.

Figure 6.2. Preferences Action not available on Mac OS X

Preferences Action not available on Mac OS X

In order to be able to manually switch between profiles and import/export your settings on the Mac, the Jalopy profiles settings are available from within the Eclipse preferences dialog as well. Open the preferences dialog via Window->Preferences and select the Jalopy/Profiles item.

Figure 6.3. Jalopy SWT Preferences

Jalopy SWT Preferences
6.2.2. Java Editor popup menu

The software adds a new menu item to the popup menu of Java editors.

  • Format with Jalopy

    Formats the contents of the editor.

Figure 6.4. Editor popup menu

Editor popup menu

The default keyboard shortcut for this action is Ctrl-Shift-F10. To configure the shortcut, open the Eclipse Keys preference page via Window->Preferences->Workbench->Keys. Open the Source category and select the Format with Jalopy item.

Figure 6.5. Keyboard shortcut

Keyboard shortcut
6.2.3. Project, Folder, File popup menus

The software adds a new menu item to the popup menu of projects, folders, packages and Java source files in the Navigator and Package Explorer view of the Java perspective.

Figure 6.6. Project popup menu

Project popup menu
  • Format

    Formats the selected files. Depending on the object type (project, folder, file) formats either all Java source files of the project, the contents of the selected folder(s) (including subfolders) or the currently selected Java source file(s).

6.3. Configuration

Although Jalopy ships with sensible default settings (mimicking the Sun Java coding convention), you most likely want to configure the formatter to match your needs (adding copyright headers, tune Javadoc handling and the like). For such, Jalopy comes with a graphical configuration tool that lets you interactively customize the settings. See Chapter 2, Configuration for an in-depth discussion of the available options.

Please refer to Section 6.2.1, "Main menu bar" for information on how to display the configuration tool from within Eclipse.