[Skip to content]

Chapter 12. NetBeans Module

Describes the installation and usage of the Jalopy NetBeans Plug-in module. NetBeans [Link] is the original full-featured, free and open source IDE for Java software developers to create cross-platform desktop, mobile and web applications based on industry standards utilizing the latest technologies.

12.1. Installation

Explains the steps involved to install the NetBeans Plug-in module.

12.1.1. System requirements

The Plug-in works with NetBeans releases 4.0 - 6.5 or the corresponding Sun ONE Studio or Java Studio Creator versions. See Section 1.1, “System requirements” for the basic requirements to run Jalopy.

12.1.2. Setup

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 mandatory and explained in detail in Section 1.3, “Wizard Installation”.

12.2. Integration

Describes how the Plug-in integrates into NetBeans.

12.2.1. Editor pop-up menu

The Plug-in adds a new menu item into the context pop-up menu of Java code editors:

Format with Jalopy

Formats the contents of the editor. When currently some text is selected in the editor, only the selected text will be formatted (selective formatting). This can be especially helpful when editing portions of very large files, as selective formatting can speed up processing considerably. But comes especially when you want to limit formatting to a specific file portion in order to avoid unnecessary differences when editing a file that has not (yet) been formatted according to the active code convention.

Figure 12.1. Jalopy editor pop-up menu item

Jalopy editor pop-up menu item

12.2.2. Explorer pop-up menu

Formatting can also be triggered via the pop-up menu of several views, like the Projects or Files window. Note that the item only appears for folder nodes or Java source files.

Figure 12.2. Jalopy Format pop-up menu item

Jalopy Format pop-up menu item

If it happens that a file has an open editor, this editor will be updated, not the actual file. You have to save the editor first, to see the physical file updated.

12.2.3. Workspace main menu

The module adds a new menu item into the main menu of the current workspace to seamlessly integrate with NetBeans:

SourceFormat with Jalopy

Formats the currently selected node(s) or the currently active editor. Only available if there are indeed nodes selected which represents or contains Java source files or an editor is focused.

Figure 12.3. Jalopy Format menu bar item

Jalopy Format menu bar item

12.2.4. Message window

Jalopy displays all runtime messages in its own dockable window. 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 12.4. Jalopy dockable window

Jalopy 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 12.5. Jalopy dockable window

Jalopy dockable window

The window 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

12.2.5. Keyboard shortcuts

You can define keyboard shortcuts for the different Jalopy actions via the NetBeans Keymap dialog. Open the options dialog via ToolsOptions (NetBeansPreferences... on Mac OS X) and select the Keymap item.

Jalopy provides two actions. The “Format with Jalopy” action in the “Source” section and the “Jalopy Options” action to invoke the configuration dialog in the “Tools” section.

Figure 12.6. Keyboard shortcuts

Keyboard shortcuts

To configure a keyboard shortcut, select an action and either press the Add... button to add a keyboard shortcut. Or use the Remove button to remove an existing shortcut. For compatibility reasons, the default keyboard shortcut for the “Format with Jalopy” action is Strg+Shift+F10, but it is recommended to adjust the shortcut to something more accessible, like Alt+Shift+F.

12.2.6. Options dialog

The Jalopy options are available through the NetBeans options dialog. In order to display the options dialog, on Mac OS X you use NetBeansPreferences... and select the “Jalopy” item in the top pane. On other platforms the dialog is available through ToolsOptions. Please note that the options dialog is only available since NetBeans 5.0. With earlier versions, Jalopy adds a new menu item to the menu bar to display the Jalopy options.

Figure 12.7. Jalopy options dialog

Jalopy options dialog

The main options page lets you manage your Jalopy profiles. A profile stores the actual code convention to define formatting output, as well as user-specific data like file and dialog histories. You can add, remove, activate, map and configure any number of profiles. For a detailed explanation of the available options, please refer to Section 2.1.1.1, “Main window”.

12.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 12.2, “Integration” for information on how to display the configuration dialog from within NetBeans.