Extending the LPEX Editor in WebSphere Developer for zSeries v6.0

This article leads you through the process of creating a user action as an extension to the LPEX Editor, which is provided with WebSphere® Developer for zSeries v6.0. It describes how to create a plug-in that defines a custom user action, how to test the user action, and how to package your plug-in.

John Casey (jocasey@us.ibm.com), Worldwide Technical Sales Support for WebSphere Developer for z/Series, IBM

John Casey is an IBM Certified Application Development Specialist. During his 27 years at IBM, he has been involved in many application projects on both distributed and zSeries platforms. He has authored and conducted technical workshops both inside and outside of IBM. In his current role, he assists IBM customers throughout the world in understanding and using IBM development tools, such as WebSphere Developer for zSeries and WebSphere Studio Asset Analyzer, to address their Application Transformation needs. You can reach John at jcasey@us.ibm.com.



08 June 2006

Introduction

The LPEX Editor, which is integrated into the Eclipse Workbench, can be used to create and edit many types of files, including program source files, documentation, and data files. In addition to basic editing functions, the core LPEX Editor offers the following features:

  • Language parsing, which uses automatic indenting, color, and text effects to emphasize different parts of your source program, such as programming language keywords, logic structures, and comment lines.
  • View filtering of specific document elements so you can zoom in and work on particular sections of the document.
  • Embedded informational and error messages.
  • Base profiles which emulate the keyboard and command personalities of several popular editors.
  • Elaborate search facilities so you can specify the precise scope of the search.
  • Location marking facilities to define bookmarks so you can move quickly from one location to another within the document.
  • Keystroke recording facilities so you can record a set of keystrokes to replay later.
  • Facilities to customize and extend the base editor to suit individual preference and project needs.

The z/OS LPEX editor, which is provided in WebSphere Developer for zSeries v6.0, extends the LPEX editor to support editing of remote MVS files that contain source written in COBOL, PL/I, HLASM, and JCL languages. The z/OS LPEX editor provides these extensions to the basic LPEX editor:

  • Editing of remote z/OS source files, while maintaining z/OS attributes such as record length and sequence numbers
  • Locking of remote files being edited by way of ISPF ENQ/DEQ, so that other users (ISPF or z/OS LPEX) cannot edit them at the same time.
  • A content-assist tool to complete variable names, COBOL or PL/I statements, and EXEC CICS statements with fewer keystrokes.
  • A command to open a file referenced in a COPY or INCLUDE statement by right-clicking on the file name, and selecting Open Copy Member or Open Include File from the context menu.
  • Language-sensitive help for PL/I and COBOL. Pressing the F1 key will display information from the Language Reference Manual for the current statement.
  • An Outline View for PL/I, COBOL, HLASM and JCL.

You can add your own extensions to the LPEX editor, such as user profiles, commands, actions, and document parsers. These extensions are implemented using the Eclipse plug-in architecture. In fact, WebSphere Developer for zSeries and the LPEX Editor are plug-ins to Eclipse. Using the Eclipse Plug-in Development Environment that comes with WebSphere Developer for zSeries, you can easily create and package new function for existing plug-ins such as the LPEX Editor.

This article leads you through the process of creating a user action as an extension to the LPEX Editor. We describe how to create a plug-in that defines a custom user action, how to test the user action, and how to package your plug-in. The action we create in this article executes 3 actions at once: move the cursor to the end of the line, insert a semi-colon, and insert a new line below the current line. You do not need to know Java or Eclipse to follow the steps. The article does assume that you have some experience with either Eclipse or one of the Eclipse-based products, such as WebSphere Developer for zSeries.


Create the Plug-in

Start WebSphere Developer for zSeries

When starting WebSphere Developer for zSeries, I suggest that you create a new workspace in which to develop your plug-in. When the Workbench comes up, close the Welcome page.

Enable the Plug-in Development environment

Eclipse Plug-in Development Environment provides tools to simplify the development of plug-ins. To enable access to these tools:

  1. Select Windows - Preferences from the WebSphere Developer for zSeries menu bar.
  2. In the Preferences view on the left-hand side, expand Workbench and select Capabilities.
  3. In the Capabilities pane, which is displayed on the right-hand side of the Preferences view, expand Eclipse Developer and check the boxes for Eclipse Plug-in Development and Eclipse Plug-in Development Examples.
  4. Click OK at the bottom of the Preferences view to save your changes and close the window.

Open the Plug-in Development perspective

From the WebSphere Developer for zSeries menu bar select Window-Open Perspective-Other .. In the Select Perspective window, select Plug-in Development and click OK to open a perspective that’s designed for developing plug-ins.

Create a Plug-in development project

  1. Launch the New Project Wizard by selecting File - New - Plug-in Project (Figure 1).
    Figure 1. New Project Wizard
    New Project Wizard
  2. On the Plug-in Project page, enter com.mycompany.lpexExtensions as the project name and click Next.
  3. On the Plug-in Content page, click Finish to create the plug-in project and the necessary folders and files.
  4. You should see your new plug-in, com.mycompany.lpexExtensions, in the Package Explorer view on the left side, and its plugin.xml file for com.mycompany.lpexExtensions opened in the editor area (Figure 2).
    Figure 2. The OrderProcessing project
    The OrderProcessing project

Register the Plug-in

Plug-ins, such as the LPEX editor, have defined extension points (programming interfaces), which your plug-in uses to add new function. You use the Dependencies page to name these plug-ins so that the code that they contribute (and that you will use in coding your new action) will be added to your plug-in project's classpath. When you modify the list of dependencies and save the file, PDE automatically updates your classpath.

To register the plug-in:

  1. In the editor, click Dependencies (use either the tab at the bottom or the link in the text on the Overview page) to switch to the Dependencies page.
  2. On the Dependencies page, click the Add button.
  3. On the Plug-in Selection window, in the Select a Plug-in field enter com.ibm.lpex, which will reduce the list that is displayed below this field to three entries (Figure 3). Select com.ibm.lpex and click OK.
    Figure 3. The completed Order business object type
    The completed Order business object type
  4. In the editor, click Extensions (use the tab at the bottom) to switch to the Extensions page.
  5. On the Extensions page, click the Add button.
  6. On the New Extension window, select com.ibm.lpex.preload and click Finish .
  7. The com.ibm.lpex.preload extension point allows the LPEX Editor plug-in to record, upon initialization, the class loaders of all declaring client plug-ins. The effect is that your new action is ready to use when you open the LPEX editor.
  8. Type Ctrl+S to save your changes to plugin.xml.
  9. You have completed all of the updates needed to create and configure the plug-in. The next step is to create your LPEX Editor user action.

Create the User Action class

Each LPEX Editor user action is a Java class that implements a specific LPEX editor interface. To create the class:

  1. In the Package Explorer view, expand the src folder and right click the com.mycompany.lpexExtensions package. In the context menu select New - Class (figure 4).
    Figure 4. The ProcessOrder component
    The ProcessOrder component
  2. In the New Java Class window, enter InsertSemicolonAction in the Name entry field. The Source folder and Package fields have been prefilled because you had selected the package folder when you started the New Java Class wizard.
  3. Click the Add button next to the Interfaces text box.
  4. In the Implemented Interfaces Selection window, enter lp in the Choose interfaces entry field, which will shorten the list as you type and make LpexAction the first item, and therefore selected (figure 5).
    Figure 5. Creating the ProcessOrder interface
    Creating the ProcessOrder interface
  5. Click OK. This step adds com.ibm.lpex.core.LpexAction to the Interfaces box.
  6. Java classes that implement the com.ibm.lpex.core.LpexAction interface are LPEX Editor user actions. The New Java Class wizard should resemble Figure 6. Click Finish to create the class and open it for editing.
    Figure 6. The completed CustomerCheck interface
    The completed CustomerCheck interface

Code the User Action

In an LPEX Editor user action class, you code your action in the doAction() method and define the conditions for when the action is available for use with the available() method.

To code the user action:

  1. In the editor for InsertSemicolonAction.java, change the argument name for the doAction method and for the available() method from arg0 to view (for readability in the subsequent code since the input parameter is an LpexView object).
  2. Add the statements shown in Listing 1 for both the doAction method and for the available() method.
    Listing 1. Define the Java class that implements your new LPEX action
    public class InsertSemicolonAction implements LpexAction {
       /* (non-Javadoc)
       * @see com.ibm.lpex.core.LpexAction#doAction(com.ibm.lpex.core.LpexView)
       */
       public void doAction(LpexView view) {
          // TODO Auto-generated method stub
          // go to the end of the line
         view.doAction(view.actionId("contextEnd"));
         // insert semicolon
         view.doDefaultCommand("insertText ;");
         // insert a new line and position the cursor at the beginning
         view.doAction(view.actionId("openLine"));
       }
       /* (non-Javadoc)
       * @see com.ibm.lpex.core.LpexAction#available(com.ibm.lpex.core.LpexView)
       */
       public boolean available(LpexView view) {
          // TODO Auto-generated method stub
          // allow the action to run in any visible, writable document
         return view.currentElement() != 0 && !view.queryOn("readonly");
       }
  3. Save your changes by selecting File - Save, which automatically compiles the class.
  4. Errors are flagged by a red circle with an "X" that appears beside the line with the error. If this happens, hover the mouse pointer over the red circle to display the error message, make the needed correction, and save the file again. When there are no errors, close the editor for InsertSemicolonAction.java.

Testing the User Action

Start the test environment

Eclipse provides a runtime environment for testing plug-ins that are being developed. To start the test environment:

  1. Go to the Overview page in the editor for plugin.xml (click the Overview tab).
  2. On the Overview page, click Launch a runtime workbench or Launch a runtime workbench in debug mode, which starts another instance of WebSphere Developer for zSeries that has your plug-in code deployed.
  3. Switch to workbench window titled Resource - Eclipse Platform when it appears.

Define the user action

  1. In the Resource - Eclipse Platform window, open the Preferences page by selecting Window - Preferences from the menu bar.
  2. In the Preferences window, expand LPEX Editor (on the left), and select User Actions.
  3. In the User Actions panel, enter insertSemicolon in the Name field, com.mycompany.lpexExtensions.InsertSemicolonAction in the Class name field, and click the Set button at the top (figure 7).
    Figure 7. Defining the user action in the Preferences window
    Defining the user action in the Preferences window

Assign a key sequence to the user action

  1. In the Preferences window, under LPEX Editor (on the left), select User Key Actions.
  2. In the User Key Actions panel, enter c-4 in the Key field, enter insertSemicolon in the Action field, and click the Set button at the top (figure 8). Note: Assigning a key sequence, such as Ctrl+4, provides a shortcut for executing your new action. You may choose any key sequence you like.
  3. Click OK to save your changes and close the Preferences window.
    Figure 8. Assigning a key sequence
    Assigning a key sequence

Test the new user action

To test your new action, you need to open a file in the z/OS LPEX editor. An easy way to do this is to create a new project using sample code shipped with WebSphere Developer for zSeries. Since our user action supports the PL/I syntax of ending a command with a semicolon, we will use a PL/I example.

To test your action:

  1. From the menu bar, select File - New - Example…
  2. In the New Example window, expand Examples, expand Workstation PL/I, select PLI Sample 1, and click Next.
  3. On the z/OS Local Project page, enter PLITest in the Project name entry field and click Finish.
  4. If the dialog box, Confirm Perspective Switch, appears, click Yes.
  5. In the z/OS Projects View, expand the project PLITest, expand the folder pli, and double-click on HelloApp.pli to edit it.
  6. Position your cursor at the beginning of a line with text, and then press Ctrl+4. Your new action is executed, placing a semicolon at the end of the line and inserting a new line below.
  7. Your action can also be run from the command line using the action command. Position your cursor at the beginning of a line with text, and then press Esc, which will place the cursor in the command line. Enter action insertSemicolon in the command line area and press Enter. Your new action is executed.
  8. When you are finished testing your new action, close the editor for HelloApp.pli. You do not need to save the changes.
  9. In the test workbench window, select File - Exit from the menu bar to close the workbench window.

Installing the new plug-in in WebSphere Developer for zSeries

Export the plug-in from PDE

During development, plug-ins in your workspace are used as-is so that you can quickly test and debug them. When you are satisfied with the operation of your new plug-in, you will want to publish this plug-in so that others may use it. The easiest way to publish your plug-in is using the Export Plug-ins and Fragments Wizard:

  1. From the WebSphere Developer for zSeries menu bar, select File - Export...
  2. On the Select window, select Deployable plug-ins and fragments and click Next
  3. In the Deployable plug-ins and fragments window, check the box for com.mycompany.lpexExtensions which is listed in the Available Plug-ins and Fragments textbox.
  4. In the Export Options field, select a directory structure from the drop-down list You can deploy the plug-ins in one of three formats:
    • A single ZIP file whose content can be unzipped into any Eclipse-based product.
    • A directory structure, so the destination of the export operation can be the root of an Eclipse installation.
    • Individual JAR archives for an update site.  This option creates one JAR per plug-in, and places the JARs in a plugins/ subdirectory of the chosen destination.
  5. In the Destination field, which contains the path name for where you would like the directory structure to be written, enter C:\WDzPlugins, (figure 9).
    Figure 9. Selecting a target directory
    Selecting a target directory
  6. You also have the option to save the settings of this export operation by checking the box for Save Export Operation, which lets you redo this export operation without having to go through the wizard again.
  7. Click Finish to start the build process, which displays a message dialog (figure 10). The build is in progress. You do not need to press any of the buttons. When the build is finished the dialog box will close.
    Figure 10. Build message
    Build message

Copy the plug-in to your WebSphere Developer for zSeries installation directory

  1. Using Windows Explorer, navigate to the directory WDzPlugins to see the results. It should contain a subdirectory, plugins, which contains the folder for each of the plug-ins that you selected for export. This folder contains a jar file containing your new action class, and plugin.xml, which contains information about your plug-in (Figure 11).
    Figure 11. Export directory
    Export directory
  2. Move the c:\WDzPlugins\plugins\com.mycompany.lpexExtensions_1.0.0 folder to \WDz60\wdz\eclipse\plugins, where WDz60 is the WebSphere Developer for zSeries installation directory (Figure 12)
    Figure 12. Installation directory
    Installation directory

Verify that the plug-in works

  1. Stop WebSphere Developer for zSeries and restart it.
  2. Using the Preferences view, associate your action class to a name and assign that name to a key in Preferences (see Define the user action and Assign a key sequence to the user action for a refresher).
  3. Open a file in the z/OS Text editor and test. If all went well, you should now have a working plug-in.

Conclusion

Eclipse provides an architecture that makes it easy to add and deploy new user functions. In this article we took advantage of this architecture to extend the z/OS LPEX editor in WebSphere Developer for z/Series with our own user action. By following the steps in this article you have a model by which you can create additional extensions to the LPEX editor.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=126915
ArticleTitle=Extending the LPEX Editor in WebSphere Developer for zSeries v6.0
publish-date=06082006