Overview | ||
Prerequisites | ||
Creating the Hello X Wizard Project | ||
Creating the Hello X Wizard | ||
Creating the Archive Description File | ||
Deploying the Hello X Wizard | ||
Testing Hello X | ||
Summary |
About an hour.
1. |
Install Oracle JDeveloper 10g.
|
This step explains how to create a workspace and project
to contain the extension you wish to add to JDeveloper, and add the libraries
you need.
1. | In the Application Navigator, right-click Applications
and select New Application Workspace.
|
2. | Fill in the Create New Application Workspace
dialog using the values listed:
For Application Name, enter HelloX.
|
3. | Click OK to add the workspace. JDeveloper
creates a project named Project
in the HelloX workspace.
|
4. | In the HelloX workspace, right click the
Project node and select Project Properties to open the Project
Properties dialog.
|
5. | In the Project Properties dialog, select Profiles
| Development | Libraries to display the list of libraries which can
be made available to the project in the Available column, and those
which a Java file in the project can successfully access in the Selected
column. Move these libraries to the Selected column: JDeveloper
Runtime, JDeveloper Extension SDK . The Java file that you create
in the next step imports classes from these libraries.
Click OK to close the Project Properties dialog.
|
6. | Select File | Save All to save your work. |
1. | Right-click the Project node in the
HelloX
workspace and select New to display the New dialog.
|
2. | In the New dialog, select General | File to
display the Create File dialog. Enter HelloX.java
for the filename. Enter <your_hard_drive>:\hello_x\Project\src\oracle\jdev\hellox
as the directory name. Notice the path after \src matches the Application Package Prefix you entered when you created the workspace. Click OK to create the file.
|
3. | Copy all of the following code and paste it
into the HelloX.java file:
package oracle.jdev.hellox; // Copyright (c) 2001, 2003, Oracle. All rights reserved. import javax.swing.ImageIcon; /** private Icon image; /** public HelloX() /** public boolean invoke(oracle.ide.addin.Context context, java.lang.String[]
params) boolean go = WizardLauncher.runDialog(dlg); if ( greetee == null ) /** /** /** public MenuSpec getMenuSpecification() /** public boolean isAvailable(oracle.ide.addin.Context context) /** /** public Icon getIcon() public void initialize() public void shutdown() public float version() public float ideVersion() public boolean canShutdown() /** /** protected boolean createContent(JavaSourceNode node, JProject project,
String className, String greetee) Notes: When the wizard's New Gallery page or menu is opened, before the wizard is actually selected, the Wizard Manager calls the wizard's getIcon() method to obtain its graphic and call isAvailable() to determine if the icon and name should be displayed as selectable or not. In this case, the generated class file must be added to an existing project, so the current context — the currently selected object — must be a JProject. When the user selects the wizard's item the Wizard Manager calls its invoke() method. As a typical wizard, Hello X opens a modal dialog to obtain user input — the string greetee — and passes it to the method that will create the class and its node. To construct the node, the createNode() method creates a URL from the class name (a concatenation of "Hello" and the greetee parameter supplied by the user), and the project's URL. The class file will be created in the project's directory. The content of the class file is Java code, created in the createContent() method using JOT (Java Object Tool). JOT classes represent Java's syntactic elements, such as classes, methods, parameters, and expressions.
|
4. | Optionally, you can add an icon to the project,
for use in the wizard menu item. Copy HelloX.gif
and paste it in your HelloX
directory, in this example <your_hard_drive>:\hello_x\Project\src\oracle\jdev\hellox\.
|
5. | In the Application Navigator, right-click HelloX.java
and select Make.
Check the Messages window for a message that the compilation has run without error. If any errors occur, check for cut-and-paste errors. Correct and recompile until the compilation is error-free.
|
6. | Select File | Save All to save all changes in the project. |
1. | Right-click the Project
node and select New from the context menu to display the New Gallery
dialog.
|
2. | From the New Gallery,
select General | File to display the Create File dialog.
Click OK.
|
3. | In the Create File dialog,
enter these values:
File Name: jdev-ext.xml. The archive description file uses this exact name, and it must be in the meta-inf directory in the project. In the directory name, enter <your_hard_drive>:\hello_x\Project\src\meta-inf. Click OK to create the file.
|
4. | Copy and paste the
following XML into jdev-ext.xml
to register Hello X with JDeveloper:
<?xml version = '1.0'
encoding = 'windows-1252'?>
Notes:
The <addin> entry names the class that implements the Addin interface. When JDeveloper is launched, jdev-ext.xml is read, and all the named addins are loaded, instantiated, and initialized. Any extension that is invoked from the menu or toolbar must be installed as an addin, otherwise the addin menu item or icon will not appear.
|
5. | Right click
jdev-ext.xml and select Check XML Syntax. You should see
a message in the message log that reports no errors. If errors are reported,
look for copy-and-paste errors, correct them, and retest until no errors
are reported.
|
6. | Select File | Save All to save all changes. |
1. | In the Application Navigator,
right-click the Project node and select New.
|
2. | From the New Gallery dialog,
select General | Deployment Profiles | JAR File.
Click OK.
|
3. | From the Create Deployment
Profile dialog, enter hellox.deploy
in the Deployment Profile Name field. Use the default value for Directory.
Click OK to create the file and display the JAR Deployment Profile Properties dialog. If the dialog does not automatically display, you can right-click hellox.deploy from the Application Navigator and choose Properties.
|
4. | In JAR options, set the
JAR File to <jdev_install>\jdev\lib\ext\hellox.jar
where <jdev_install> is the root directory where you installed JDeveloper.
Uncheck Compress Archive and Include Manifest File. The manifest
file is not necessary unless you are deploying to a version of OC4J (JDeveloper,
standalone, or remote) earlier than 9.0.3.
|
5. | Select File | Save All
to save all changes in the project.
|
6. | In the Application
Navigator Resources node, right-click hellox.deploy
and choose Deploy to JAR File.
The log window should show that deployment has finished without error, and that the hellox.jar archive has been created. Because you deployed the JAR file to the target directory for all extensions, <jdev_install>\jdev\lib\ext, you do not need to copy the JAR file to that directory.
|
1. | In the Application Navigator,
right-click the Project node and choose Debug.
|
2. | In the Choose Default
Run Target dialog, select Hellox.java
and click OK.
The debuggee process opens with Hello X loaded in a new JDeveloper instance.
|
3. | To use the Hello X
Wizard, right-click any project node to display the context menu and choose
New.
(Hello X must be called from a project).
From Categories, select General | Samples | Hello X Wizard Click OK.
|
4. | In the Greetee
dialog, enter a name, for example Kim.
|
5. | JDeveloper closes the
Greetee dialog and creates a HelloKim
class. You should see it in your Hello X project.
Notice that the Hello X wizard is also available by selecting Tools | HelloX Wizard.
|
Now that you have created and deployed this extension, you can use it with any instance of JDeveloper.
Move your mouse over this icon to hide all screenshots