3 Developing with the Extension SDK

This chapter describes the Extension SDK, which is available to download to JDeveloper, and how to use it to develop your own extensions.

This chapter includes the following sections:

3.1 About Developing with the Extension SDK

The JDeveloper Extension Software Developer Kit (SDK) includes a collection of projects containing sample code and the javadoc-generated documentation for the Extension API.

Each sample project contains a deployment profile for one-click deployment of the sample to the appropriate directory. You can also deploy all the projects at once.

You can use the code that provides each extension as a template to help you develop similar features.

3.2 Downloading and Installing the Extension SDK

You can download and install the Extension SDK using the Check for Updates wizard, or by downloading it from the Oracle website.

To install the Extension SDK using Check for Updates:

  1. Follow the information in "How to Install Extensions with Check for Updates" in Developing Applications with Oracle JDeveloper, and on the Source page select the Official Oracle Extensions and Updates update center.

  2. On the Updates page, choose Extension SDK from the list of available extensions, and click Next. Owing to the size of the extension, it may take a few minutes to download depending on your internet connection.

  3. When you finish the wizard, JDeveloper will restart and install the Extension SDK. When it restarts, you are asked whether JDeveloper should install the sample application containing the sample projects described in this chapter. If you answer yes, the application extensionsdk is open in the Applications window, and the sample projects are listed.

If you are working behind a firewall, JDeveloper will not be able to connect to the update center until you enter details of your proxy server. You can either do this in the Web Browser and Proxy page of the Preferences dialog (available from the Tools menu), or the Check for Updates wizard will time out and display the Web Browser and Proxy page.

To install the Extension SDK using a file:

  1. Follow the information in "How to Install Extensions Directly from OTN" in Developing Applications with Oracle JDeveloper, and navigate to the page for Official Oracle JDeveloper Extensions.

  2. Download the Extension SDK to a local location, then open the Check for Updates wizard from the Help menu.

  3. On the Source page, choose Install from Local File and enter the location of the esdk_bundle.zip file and complete the wizard.

  4. JDeveloper will restart and install the Extension SDK. When it restarts, you are asked whether JDeveloper should install the sample application containing the sample projects described in this chapter. If you answer yes, the application extensionsdk is open in the Applications window, and the sample projects are listed.

3.2.1 What Happens When you Install the Extension SDK

When you successfully install the Extension SDK, the sample application is optionally open in the Applications window, giving you access to the sample projects that illustrate different aspects of JDeveloper functionality. You can use the code to help you develop your own extensions.

The Oracle Fusion Middleware Java API Reference for Oracle Extension SDK is available from the Reference node in the Contents list of the online help (available from the Help menu.

3.2.2 Troubleshooting Installing the Extension SDK

If you have trouble downloading the Extension SDK and you are working behind a firewall, ensure that you have set the proxy server settings on the Web Browser and Proxy page of the Preferences dialog (available from the Tools menu).

If the Check for Updates wizard has located the update center you are using, it may take up to a couple of minutes before the list of available extensions is displayed, depending on the speed of your connection.

When you select the Extension SDK in the wizard, it downloads while the wizard is still open, and this can take a couple of minutes, depending on the speed of your connection. Once the extension has finished downloading, JDeveloper needs to restart in order to install it, and a message to this effect is displayed.

3.3 Using with the Sample Extensions

When you install the Extension SDK you install an application extensionsdk which contains a number of projects which give examples of how to create and use different types of JDeveloper element.

For information about running the samples, see Section 3.4, "How to Run the Sample Projects."

This list briefly summarizes the main features of the sample extension projects:

  • ApplicationOverview.jpr: Demonstrates how to plug in to the Application Overview window. Adds a Show Overview menu item to both the Application and Project context menus. It illustrates how to:

    • Add your own custom editor.

    • Get files from an application and project.

    • Get the status of individual files in a project.

  • AuditRefactor.jpr: Demonstrates using the Audit framework to detect problems in Java code, and how to write a transform using the refactoring API to fix the problems automatically.

    • Adds an option to the IDE Audit properties page.

    • Manages the public final static methods names.

    • shows how to use the refactoring features of the IDE.

  • Balloon.jpr: Demonstrates how to install a balloon notification into the JDeveloper status bar.

    Shows how to:

    • Add an Action Listener to a dialog or Balloon element.

    • Interact with the IDE Status bar, both adding and removing items.

    • Get an icon from OracleIcons.

  • ClassBrowser.jpr: Shows how to use the JDeveloper ClassBrowser.

    • Shows how to setup a single page wizard.

    • Adds a context menu to Applications window and Observer UI sections.

  • ClassGenerator.jpr: Shows the basic of JOT (Java Object Tool) to generate a java file in your project. Also demonstrates how to use the Finite State Machine (FSM) Wizard utility to create a multi step wizard.

    • Adds an item to the View menu.

    • Shows how to enable and disable a menu option based on what is currently selected in the Applications window.

    • Shows how to setup a multi-page wizard.

  • ClassSpy.jpr: Shows the simplest way to identify the class of a given node in the Applications window, and how to write its name in the Log window. Shows how to:

    • Add a context menu to the source editor, explorer, and Applications window using extension.xml.

    • Work with a Context object.

    • Display information in a Log window.

  • ClickableURL.jpr: Shows how to generate a clickable URL in the Log window.

    • Adds a context menu to the Applications window using the extension.xml file.

    • Shows interaction with a new Log window.

    • Shows how to work with a file URL.

    • Works with MessageWindow to place data in a log.

    • Shows how to launch a browser from the IDE.

  • CodeInteraction.jpr: Shows how to get text from the code editor, and launches a Google search on the currently selected text.

    • Adds context menu to the source editor.

    • Shows how to enable the context menu item based on a condition in the source editor.

    • Shows how to call a browser with data from the source editor.

  • ConfigPanel.jpr: Demonstrates how to store and retrieve preferences, and install a panel into the Preferences dialog.

    • Adds a menu item to the Tools menu using an Addin class.

    • Shows interaction with the Log window.

    • Shows how to use a listener to listen for changes to the IDE Preferences model.

  • CPPageProvider.jpr: Demonstrates how to plug into the component palette using the palette2 API.

  • CreateDialog.jpr: An example of a simple create dialog invoked from the gallery.

    • Shows how to add a New Gallery item using extension.xml.

    • Shows how to use a background task with monitor.

    • Uses JEWTDialog and Panel to display data.

    • Shows how to listen for Enter key press in text fields and do something with the event.

  • CreateStructure.jpr: Demonstrates creating a new empty application (jws file) and adding a new empty project (jpr file) to it.

    • Works with the file system IO, creating files, and directories

    • Uses oracle.ide APIs to build structure rather than JDeveloper APIs

    • Shows the use of a logs() method for sending info to the logs window

  • CustomEditor.jpr: Shows how to implement your own editor for a given kind of file. To see the tool in action, open any XML file and switch to the Query page.

  • CustomExtensionHook.jpr: Demonstrates a custom extension hook, which allows other extensions to plug into your extension.

    Shows how to add a menu item declaratively in extension.xml, specifically to the View menu.

  • CustomNavigator.jpr: Demonstrates how to install a custom Applications window. Installs a "Favorites" window which can be used to store frequently accessed files.

    • Shows how to create your own window.

    • Shows file IO methods for saving a file to the system directory.

    • Shows how to add a custom icon to the window.

    • Shows how to work with selected items in a menu.

    • Adds a separate controller for just one menu area.

  • DebugObjectPreferences.jpr: Demonstrates how to install a custom object preferences renderer for the Data window of the debugger.

    • Adds its parameter to the debugger output window in the Data tab.

    • Shows how to work with the <debugger_hook> in extension.xml.

  • DockableWindow.jpr: Shows how to implement a custom dockable window.

    • Shows how to work with DockableFactory.

    • Uses Addin initialize to add extension to View menu.

    • Shows how to work with DockableWindow.

  • ExternalToolCreation.jpr: Shows how to write an addin that installs an external tools shortcut for an external program. This feature is actually part of the JDeveloper IDE, and uses a wizard to set up external applications. For more information about External Tools, see the section "Adding External Tools to JDeveloper" in Developing Applications with Oracle JDeveloper.

    Shows how to setup an external tool and integrate it into the JDeveloper IDE, for example, passing the current editor content to an external tool for review or processing.

  • ExternalToolImportExport.jpr: Imports and exports the properties associated with a list of External Tools.

    Works with reading and writing ExternalTool properties.

  • ExternalToolMacros.jpr: Shows how to write an addin that installs a custom macro for use by external tools.

    Shows the use of <externaltools> and <macros> tags in extension.xml.

  • ExternalToolScanner.jpr: Shows how to write a scanner for external tools that can automatically install external program shortcuts when the user clicks on the Find Tools button in the External Tools dialog, (available from the Tools menu).

  • FirstSample.jpr: A sample that illustrates the main concepts involved in writing extensions for JDeveloper.

  • FlatEditor.jpr: Demonstrates how to implement a form-based overview editor similar to the one used for extension.xml.

    • Shows <editor> in extension.xml.

    • Adds a custom tab to the editor window.

    • Shows how to work with VerticalFlowLayout.

  • HelloX.jpr: This is a sample that demonstrates a number of core concepts, including installing New Gallery items, actions, and menu items.

  • LayoutMenuFilter.jpr: Shows how to filter the top level menus in the IDE when the layout changes.

    • Allows you to set only those menu items that you want shown.

    • Uses ExtensionRegistry.

    • Uses addIdeListener to get IDE events and act on them.

  • MethodCallCounter.jpr: Uses JOT (Java Object Tool) to count the number of occurrences of a named method in some code.

    • Shows how to determine node type in the Applications window and source editor menus.

    • Adds context menu options to the Applications window and source editor.

    • Uses showInputDialog to allow parameter entry at runtime.

    • Uses MessageDialog.information to display results.

    • Shows how to use two method declarations in one class. The method used depends on parameters passed to it.

  • OpenNodes.jpr:Implements a dockable window which shows nodes that are open in the NodeFactory, and tracks when nodes are opened and closed.

    • Shows how to create and implement a dockable window in the IDE.

    • Overrides toString() to set specific string formatting.

    • Uses Jtable inside a Jpanel, and shows setup and configuration.

    • Uses a timer to flash a color change on a table change then return to normal state.

    When you run this sample, you can choose View > ESDKSample: Open Nodes to open an Open Node Tracker window, which shows the nodes that are open in NodeFactory, and tracks when nodes are opened and closed.

  • Overlay.jpr: Shows how to use overlays in the Applications window, like those used by the version control extensions.

    • Shows how to set up multiple Actions in extension.xml.

    • Works with OverlayCache.

    • Works with IdeActions.

  • ProgressBar.jpr: Shows how to implement a progress bar during the execution of some lengthy task.

    • Uses oracle.ide.progressbar.

    • Illustrates a background running process.

    • Shows an indeterminate progress bar.

    • Writes to the Log window in a background process.

  • ProjectSettings.jpr: Demonstrates storing and retrieving project properties and adding custom project settings UI.

    • Illustrates use of <settings-ui> tag in extension.xml.

    • Uses ProjectSettingsTraversablePanel to layout project settings page.

    • Uses HashStructure and PropertyStorage to store and retrieve project settings data.

  • StructurePane.jpr: Shows how to display your own content in the Structure Window.

  • UpdateCenter.jpr: Demonstrates how to install a custom update center as part of an extension.

    • Shows how to use <update-hook> and <update-center> tags in extension.xml.

    • Shows how your extension can add its own Update Center item to the Updates Center page of the Check for Updates wizard.

3.4 How to Run the Sample Projects

You can run the sample projects in JDeveloper to see how they work.

To run a sample project:

  1. The first time you run one of the sample project extensions, you have to right-click on it and choose Deploy to Target Platform.

  2. To run the extension, right-click and choose Run Extension.

    This runs a second copy of JDeveloper with the sample project installed.