Listings from the Book

Inside the JBuilder OpenTools API

The tools provided in the book work in JBuilder versions from 7 through 10, unless otherwise noted.

A compiled and ready-to-run version of each project is available with the code.

Part 1 - Introduction to the OpenTools API (Chapters 1 - 3)

Part 2 - The PrimeTime Core (Chapters 4 - 6)

Part 3 - The User Experience (Chapters 7 - 9)

Part 4 - The Browser (Chapters 10 - 14)

Part 5 - The Editors and Viewers (Chapters 15 - 22)

Part 6 - The Wizard Framework (Chapters 23 - 24)

Part 7 - The Processors (Chapters 25 - 26)

Part 8 - External Systems (Chapters 27 - 28)

Appendices

Part 1 - Introduction to the OpenTools API

Chapter 1 - Introduction

JBuilder itself is a collection of OpenTools. Just about whatever you see that JBuilder can do, you can also do through an OpenTool.

Chapter 2 - OpenTool Basics

How OpenTools are found and loaded into JBuilder. This chapter includes a very basic OpenTool to demonstrate the basic loading techniques.

Chapter 3 - Debugging OpenTools

A discussion on various approaches to debugging your OpenTool: from simple debug output, to using JBuilder's own debugging abilities to run and examine itself. A configuration file for debugging JBuilder is included here.

Back to the top

Part 2 - The PrimeTime Core

Chapter 4 - PrimeTime and Command-Line Tools

The starting point for most OpenTools is the PrimeTime class which provides version information for the OpenTools API. Command-line tools let you respond to additional options on the JBuilder startup command. The JavadocCommand example lets you generate Javadoc for your project from the command line.

Chapter 5 - The Virtual File System

Interfacing with various implementations of persistent storage, the Virtual File System provides access to the files that make up a project. The HTTPVFS example demonstrates how you could save and retrieve your files across the Internet.

Chapter 6 - Node Types

Added functionality for different file types comes from the node type hierarchy within JBuilder. From the generic Node, through organizational and information nodes, to those that represent real files. From Java source code, to images, to JAR files, and deployment descriptors, each node type identifies a particular format and defines what you can do with that file. The OTFileNode example singles out OpenTools manifest files, distinguishing them from generic text files.

Back to the top

Part 3 - The User Experience

Chapter 7 - Persistent Properties

Saving property settings between sessions is a critical part of the user experience. Customizations are remembered and used again next time enabling the user to focus on their development tasks. Properties appear in several different contexts: global settings for the IDE, settings for a project or an individual node, and in memory collections. Values may be easily updated through property pages associated with a set of properties. The XMLTools example uses global properties to remember which XML validator and XSLT engine to use.

Chapter 8 - The Help System

Adding online help to your tool can make it more friendly, and more likely to be accepted and used. You can also provide Javadoc for your tool so that users can enhance or extend it. This documentation can be integrated into JBuilder's IDE so that it appears on request for your classes.

Chapter 9 - Utility Classes

A large number of utility classes are included in JBuilder and are available for your use. From UI components such as enhanced trees and tables, to information about the JBuilder environment, to dealing with Zip files and file differences, there is something of interest for everyone. The UISample example demonstrates most of the UI components and several of the non-visual ones as well.

Back to the top

Part 4 - The Browser

Chapter 10 - The Browser

The browser is the main window for JBuilder, although you many have several open at one time. It coordinates the interactions of the other sections of the window: the menu and toolbar, the Project, Content, Structure, Message, and Status Panes. The BrowserNumber example keeps track of your open browsers by adding a sequential number to the caption of each one.

Chapter 11 - Actions

Actions form the basis for most interactions with the UI. They underlie the menus and toolbars. They are linked to keystrokes in the editor. They invoke wizards to generate new files or work with existing files. JBuilder defines a hierarchy of action classes for the different situations, including the ActionGroup, which manages a set of other actions. The ActionSampler example places a new entry on the Help menu and demonstrates several of the action types.

Chapter 12 - Menus and Toolbars

The menus and toolbars in JBuilder are the starting point for many activities within the IDE. They host collections of actions which then provide the appropriate functionality. The ToolBarManager example lets you redesign your main toolbar completely. It uses global properties to retain the user's settings between sessions.

Chapter 13 - Status Pane and Message Pane

Communicating with the user in a non-intrusive manner is the purpose of the Status and Message Panes. The Status Pane appears along the base of the browser and displays a single line of text, such as fly-over hints for buttons and menu items, or the summarized results of a compilation. The IconTips example uses the Status Pane to explain those strange icons in the Structure Pane for Java code as you hover over them. For more detailed information, or where the user may want to interact with the data, you use the Message Pane. This panel above the Status Pane appears as necessary and provides a series of tabs for different topics. The ConsoleDisplay example is a command-line tool that redirects standard output and/or error to a tab on the Message Pane.

Chapter 14 - Project Pane and Content Pane

Files and other nodes that make up a project are shown in the Project Pane. They can be organized into hierarchical groupings, and operated on by bringing up a context menu. Selecting Properties from that menu displays a set of property pages applicable to the selected nodes. Opening a file or node usually loads its contents into a viewer within the Content Pane. This pane has a set of tabs across the top or right sides - one for each open node. Along its base appear tabs corresponding to viewers for the current node. The XMLTools example adds several menu items to the context menu for XML nodes, while the TabProps example adds menu items to the Content Pane popup menu to alter the location and appearance of its tabs.

Back to the top

Part 5 - The Editors and Viewers

Chapter 15 - The Editor

The editor is one of the key node viewers, allowing you to view and alter any text-based file. It provides syntax-highlighting, line and gutter marking, and numerous options for configuring its behavior. The SyntaxChecker example from Steven Lee, monitors the Structure Tree for Java code, and highlights the positions of errors in the code within the editor.

Chapter 16 - EditorKits and Scanners

Support for different languages and text file formats is provided by the EditorKits associated with the various node types. These use a Scanner to identify the tokens that make up that language, thus connecting to the syntax-highlighting feature. The OTEditorKit and OTScanner examples illustrate these abilities for OpenTools manifest files.

Chapter 17 - Key Bindings

Linking keystrokes in the editor to actions within the IDE is the purpose of key bindings. You can define an entire set of key bindings to emulate a particular environment, or you can customize existing bindings to add your particular actions. The Clippy example from Matt Mower takes over the standard keystrokes for cut, copy, and paste, and redirects them to its own set of multiple clipboard buffers.

Chapter 18 - Node Viewers

Additional functionality may be provided for specific file types, such as rendering HTML, viewing images, or comparing text files. Viewers must interact with the Virtual File System to synchronize themselves and the underlying file. The GIFEditorViewer example operates on GIF image nodes and provides a basic image editor.

Chapter 19 - Structure Pane

The Structure Pane generally provides some sort of navigational view of the node in the Content Pane. However, you can place whatever UI components you want here. The GIFEditorStructure example displays a preview of the image for the GIFEditor tool from the previous chapter. The OTStructure example lists the OpenTools categories found in the manifest file, and adds a context menu that makes it easy to add new categories to it.

Chapter 20 - Component Modeling Tool

The Component Modeling Tool (CMT) is a collection of classes and interfaces that makes it easier to read and alter properties on components within a Java class. It is used in the UI designer and layout assistants described below. The CMTDump example displays basic CMT information about the current file.

Chapter 21 - UI Designers

For Java source files, a Design viewer tab is added to the Content Pane. Here you can visually design your class, from UI development to database interactions. The IBXDesigner example manages components from the InternetBeans Express suite, displaying their relationships and HTML content.

Chapter 22 - Layout Assistants

Layouts let you design your UI in a device-independent manner. However, the basic layout implementations do not provide enough feedback information for a visual design tool. Enter layout assistants that fill the void, acting as the go-between for various layouts in the UI designer. The BorderCornerLayoutAssistant example creates a new layout and its assistant for an enhanced BorderLayout.

Back to the top

Part 6 - The Wizard Framework

Chapter 23 - Wizards

Wizards are implemented as dialogs with one or more pages that lead you through a repetitive or complex task. They come in two main types: those that generate new files and typically reside in the Object Gallery, and those that operate on existing files and reside on the Wizards menu. JBuilder provides a hosting environment for the pages, making the job of writing a wizard that much easier. The TaglibDescriptorWizard example creates a wizard that scans a project for classes that implement JSP custom tag functionality, and constructs a taglib descriptor file from them.

Chapter 24 - Java Object Toolkit

Many wizards either generate or parse Java code to provide their abilities. To assist in this process, the Java Object Toolkit (JOT) is available. Starting from a package, you can step down into files, classes within a file, methods and fields in a class, and statements within a method. You can generate entire new classes or make very precise modifications to existing code. The JSPTagWizard example is a wizard that builds a new class implementing JSP custom tag functionality.

Back to the top

Part 7 - The Processors

Chapter 25 - The Build System

Transforming your source code and supporting files into a runnable application is the purpose of the build processor within JBuilder. It lets you define tasks that are executed as part of the build of a project, and provides many standard ones. This subsystem underwent a major overhaul in JBuilder 7 to base it on the open source Ant tool. The BuildNumber example from Joi Ellis demonstrates how to add a task to the build process - updating a build number file each time. It has been updated to work with JBuilder 7 and up.

Chapter 26 - The Runtime System

Once the application is built and packaged up you need to be able to run and debug it. The runtime processor supports this requirement. Multiple configurations for running your project may be established, each with its own runtime environment. JBuilder automatically provides support for standalone applications, for applets, for servlets and JSPs, and for EJBs. The OTRunner example adds an appropriate environment for running OpenTools - namely a second JBuilder instance.

Back to the top

Part 8 - External Systems

Chapter 27 - Version Control Systems

Version Control Systems (VCS) assist in the management of access to multiple versions of a file, for maintaining historical versions of files, and for grouping files versions that work together as an application. These are external, standalone systems that can be used in a variety of programming environments. JBuilder provides an API whereby these tools can be integrated into the IDE, allowing you to check files in and out, to retrieve old versions and compare them, and to review the status of all the files in a project. The SourceSafeVCS example from David Brouse demonstrates how this is used to interact with Visual SourceSafe.

Chapter 28 - Application Servers

Another type of external system that JBuilder regularly interacts with is an application server. Again an API exists so that JBuilder can communicate with external servers and deploy applications to them, start and stop them, and even debug them. The JBossOpenTool example from Marcus Redeker provides a connection to JBoss, an open source application server.

Back to the top

Appendices

Appendix A - OpenTools Repositories

Many OpenTools are available online from the repositories listed in this chapter. Also described in the process of submitting an OpenTool to CodeCentral, Borland's code repository.

Appendix B - JBuilder Documentation Differences

More and more classes within the OpenTools API are being documented as new JBuilder versions are released. This chapter tracks the differences between the versions with respect to documentation.

Appendix C - Help Topics

Several help topics are already defined as constants if you wich to reuse them. This chapter lists those that are available.

Appendix D - XMLTools OpenTool

The XMLTools OpenTool is partially described through the book where its functionality demonstrates various aspects of the OpenTools API. This chapter provides a wrap up of the tool.

Back to the top

Inside the JBuilder OpenTools API