[Skip to content]

Chapter 9. jEdit Plug-in

Describes the installation and usage of the Jalopy jEdit plug-in. jEdit is a mature programmer’s text editor written in Java that provides auto indent and syntax highlighting for more than 130 languages and is easily extensible with its plug-in architecture.

9.1. Installation

Explains the steps involved to install the jEdit plug-in.

9.1.1. System requirements

The Jalopy jEdit plug-in requires jEdit 4.3 or later. See Section 1.1, “System requirements” for the basic requirements to run Jalopy.

9.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 highly 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 and/or settings folders. To decompress the contents of the installer JAR, you can often use the build-in support of your file manager (e.g. Nautilus) or any other software that can handle the ZIP compression format (e.g. 7Zip, WinZip or Stuffit Expander). If you don’t have access to one of the convenience tools, you might resort to the jar command-line application that ships with your Java distribution.

When 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:\Users\John Doo\.jalopy\1.9 and you’re about to install Jalopy 1.9.4, either copy the directory contents or rename it to C:\Users\John Doo\.jalopy\1.9.4.

Make sure jEdit is not running and remove any prior Jalopy JAR files in your jEdit Plugin folder. The jEdit Plugin folder is located under the root directory of your jEdit installation, e.g. C:\Program Files\jEdit\jars. Remove all JAR files whose names start with jalopy-. Now decompress the contents of the installer JAR file into a temporary directory and copy the two JAR files jalopy-1.9.4.jar and jalopy-jedit-1.9.4.jar from the temporary directory into the jEdit Plugin folder.

9.2. Integration

Describes how the plug-in integrates into jEdit.

9.2.1. Menu bar

The software adds a new menu item group into the Plugins menu of the main view. Available are two new menu items:

Figure 9.1. jEdit menu bar items

jEdit menu bar items

  • PluginsJalopyFormat active Buffer

    Formats the contents of the active text area. Note that this menu item reflects the state of the text area: it will only be enabled if the current edit mode is supported by Jalopy.

  • PluginsJalopyJalopy Options....

    Displays the Jalopy options dialog. Use this item if you want to change your settings to control the layout of any formatted code.

    Please note that all options are available under jEdit’s PluginsPlugin Options... dialog as well, but the Jalopy dialog provides the advantage of a live-preview that makes editing the options somewhat easier. You find the Jalopy settings system and options dialog described in detail in Chapter 2, Configuration.

9.2.2. Dockable window

Jalopy displays all runtime messages in its own dockable window that works similar like to the ErrorList plug-in, but is not limited to just display errors and warnings. Messages are shown in a tree control, with each branch containing the messages for a specific file, and individual messages displayed as leafs. File messages display the number of leaves and the warning and error count.

The message types are differentiated with icons and by color: Errors are red with an error icon, warnings are shown in blue and display a warning sign, informational messages are black and carry a file icon and debugging messages are black and prepended by a bug icon.

Figure 9.2. jEdit dockable window

jEdit dockable window

Clicking on a file name will open that file, clicking on a message that contains location information will open the file containing the message and move the caret to the nominated location.

Figure 9.3. jEdit dockable window

jEdit dockable window

The view provides a context menu with some useful actions.

Copy Copies the textual contents of the selected messages into the System clipboard. If a message contains children, the contents of all children are copied as well
Clear Removes all selected messages
Clear All Removes all messages currently being displayed in the window
Select All Selects all messages currently being displayed in the window

9.2.3. Keyboard shortcuts

You can define keyboard shortcuts for the different menu and dockable window actions via the jEdit Shortcut options: UtilitiesGlobal Options...jEditShortcuts. In the Edit Shortcuts combo box, select Plugin: Jalopy Source Code Formatter to display the available actions.

Figure 9.4. Define keyboard shortcuts

Define keyboard shortcuts

9.2.4. Context menu

You can add the different menu and dockable window actions to the context menu of the text area via the jEdit Context Menu options: UtilitiesGlobal Options...jEditContext Menu. Press the + button and, select the Command or macro option and choose Plugin: Jalopy Source Code Formatter to display the available actions.

Figure 9.5. Add actions to context menu

Add actions to context menu

9.2.5. File System Browser Plugins menu

Jalopy registers an action in the File System Browser Plugins menu to let you bulk format files and/or directories selected in the browser. Please note that if nothing is selected in the browser table component, the contents of the currently selected parent directory are formatted.

Figure 9.6. File System Browser Plugins menu

File System Browser Plugins menu

9.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 to configure formatting output. Please refer to Section 9.2, “Integration” for information on how to display the configuration tool from within jEdit.