Data Modeler, along with SQL Developer and JDeveloper, has a powerful extension SDK; this allows bespoke extensions to be developed. These extension can modify workflows and access/update the internal data models of the application.
Several extension example exist for JDeveloper, but I wasn’t able to find any for Data Modeler.
Overview
A video overview is available here:
Source Code for Download is here: Source
Steps
-
Download JDeveloper.
JDeveloper can be downloaded here: http://www.oracle.com/technetwork/developer-tools/jdev/downloads/index.html -
Download the Extension SDK
To get the JDeveloper Extension SDK Documentation and Samples From inside JDeveloper use Help->Check-for-updates
You’ll need to restart JDeveloper to complete the installion.
-
Create a new Application and Project
Select File -> New -> From Gallery:
Choose Extension Application
Complete the Wizard:
Application Name : ExtensionExample
Directory: Where to save the Application
Application Package Prefix: com.theriom.ExampleExtensionProject Name: Extension
Directory: Choose the defaultClick Finish
-
Add a Extension Wizard to the Project
Select New -> From Gallery -> Gallery Item (Wizard)
Name: Example
Description : Example
Add item to Tools Menu : Enabled
Menu label : Example
Identifier : Example
Menu tool top : ExampleClick OK
-
Change the project to build for DataModeler instead of JDeveloper
Select the project properties (Right Click on the project name).
Under Project Properites Select Extension.
Select Manage and add you Data Modeler Installation directory.
For Mac OS X users, the Installation Directory is
OracleDataModeler.app/Contents/Resources/datamodeler
While still in the Project Properties Section Choose Deployment:
Select the Edit Pencil and change the jar file location to
DATAMODELER_PATH/datamodeler/datamodeler/extensions/com.theriom.ExampleExtension.jar
So every new build will automatically be saved to the extension folder of DataModeler .
-
Manually add the extension details to DataModeler
Doing this will ease your development cycle.
Edit:
DATAMODELER_PATH/datamodeler/configuration/bundles.info
and add
com.theriom.ExampleExtension,11.1.1,../datamodeler/extensions/com.theriom.ExampleExtension.jar,4,false,0
- Modify extension.xml
The wizard adds the new Menu Item to the Tools Menu (which is ok in SQL Developer and JDeveloper) however Data Modeler doesn’t allow the Tools menu to be used; so modify extension.xml and change
<menu-hook xmlns="http://jcp.org/jsr/198/extension-manifest">
<menus>
<menubar id="javax.ide.view.MAIN_WINDOW_MENUBAR_ID">
<menu id="Tools">
<section id="menu-addin-section-id" weight="2.0">
<item action-ref="Example" weight="2.0"/>
</section>
</menu>
</menubar>
</menus>
to
<menu-hook xmlns="http://jcp.org/jsr/198/extension-manifest">
<menus>
<menubar id="javax.ide.view.MAIN_WINDOW_MENUBAR_ID">
<menu id="javax.ide.VIEW_MENU_ID">
<section id="menu-addin-section-id" weight="2.0">
<item action-ref="Example" weight="2.0"/>
</section>
</menu>
</menubar>
</menus>
<menu id="Tools">
changes to <menu id="javax.ide.VIEW_MENU_ID">
-
Change ExampleController.java
package com.theriom.ExampleExtension; import oracle.ide.Context; import oracle.ide.controller.Controller; import oracle.ide.controller.IdeAction; import oracle.ide.wizard.WizardManager; /** * Controller for action Example. */ public final class ExampleController implements Controller { public boolean update(IdeAction action, Context context) { action.setEnabled(true); return true; } public boolean handleEvent(IdeAction action, Context context) { WizardManager.getInstance().getWizard(ExampleWizard.class).invoke(context); return true; } }
The update()
method is called before the handle event. Use this to enable the menu item.
The handleEvent()
invokes the Wizard.
-
Modify Example Wizard
package com.theriom.ExampleExtension; import javax.swing.JOptionPane; import oracle.ide.Context; import oracle.ide.wizard.Wizard; /** * Implementation of the "Example" gallery item. */ public final class ExampleWizard extends Wizard { public boolean invoke(Context context) { JOptionPane.showMessageDialog(null, "Menu Invoked"); return true; } @Override public boolean isAvailable(Context context) { return true; } @Override public String getShortLabel() { return "Example"; } }
Add a Message Dialog to the invoke()
method.
-
Build, Deploy and Debug the Application
-
Access details from you design
ApplicationView view = ApplicationView.getInstance();
- Get this current application instance.Design design = view.getCurrentDesign();
- Get the currently open design.LogicalDesign logical = design.getLogicalDesign();
- Get the Logical Modeldesign.getRelationalDesigns();
- Get the Relational Designs.
Understanding the API
The Data Modeler installation includes a set of documentation which is intended for Transformation Scripts
DATAMODELER_PATH/datamodeler/datamodeler/xmlmetadata/doc/index.html
Although not perfect, it can help to give you a good understanding of the available classes and how they interact.
Further Reading
Last modified on 2016-04-27