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.
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:
- Select Windows - Preferences from the WebSphere Developer for zSeries menu bar.
- In the Preferences view on the left-hand side, expand Workbench and select Capabilities.
- 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.
- 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
- Launch the New Project Wizard by selecting File - New - Plug-in Project (Figure 1).
Figure 1. New Project Wizard
- On the Plug-in Project page, enter
com.mycompany.lpexExtensionsas the project name and click Next. - On the Plug-in Content page, click Finish to create the plug-in project and the necessary folders and files.
- You should see your new plug-in,
com.mycompany.lpexExtensions, in the Package Explorer view on the left side, and its plugin.xml file forcom.mycompany.lpexExtensionsopened in the editor area (Figure 2).
Figure 2. The OrderProcessing project
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:
- 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.
- On the Dependencies page, click the Add button.
- 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). Selectcom.ibm.lpexand click OK.
Figure 3. The completed Order business object type
- In the editor, click Extensions (use the tab at the bottom) to switch to the Extensions page.
- On the Extensions page, click the Add button.
- On the New Extension window, select
com.ibm.lpex.preloadand click Finish . - The
com.ibm.lpex.preloadextension 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. - Type Ctrl+S to save your changes to plugin.xml.
- 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.
Each LPEX Editor user action is a Java class that implements a specific LPEX editor interface. To create the class:
- In the Package Explorer view, expand the src folder and right click the
com.mycompany.lpexExtensionspackage. In the context menu select New - Class (figure 4).
Figure 4. The ProcessOrder component
- In the New Java Class window, enter
InsertSemicolonActionin 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. - Click the Add button next to the Interfaces text box.
- In the Implemented Interfaces Selection window, enter
lpin 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
- Click OK. This step adds
com.ibm.lpex.core.LpexActionto the Interfaces box. - Java classes that implement the
com.ibm.lpex.core.LpexActioninterface 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
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:
- In the editor for InsertSemicolonAction.java, change the argument name for the
doActionmethod and for theavailable()method fromarg0toview(for readability in the subsequent code since the input parameter is an LpexView object). - Add the statements shown in Listing 1 for both the
doActionmethod and for theavailable()method.
Listing 1. Define the Java class that implements your new LPEX actionpublic 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"); } - Save your changes by selecting File - Save, which automatically compiles the class.
- 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.
Eclipse provides a runtime environment for testing plug-ins that are being developed. To start the test environment:
- Go to the Overview page in the editor for plugin.xml (click the Overview tab).
- 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.
- Switch to workbench window titled Resource - Eclipse Platform when it appears.
- In the Resource - Eclipse Platform window, open the Preferences page by selecting Window - Preferences from the menu bar.
- In the Preferences window, expand LPEX Editor (on the left), and select User Actions.
- In the User Actions panel, enter
insertSemicolonin the Name field,com.mycompany.lpexExtensions.InsertSemicolonActionin the Class name field, and click the Set button at the top (figure 7).
Figure 7. Defining the user action in the Preferences window
Assign a key sequence to the user action
- In the Preferences window, under LPEX Editor (on the left), select User Key Actions.
- In the User Key Actions panel, enter
c-4in the Key field, enterinsertSemicolonin 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. - Click OK to save your changes and close the Preferences window.
Figure 8. Assigning a key sequence
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:
- From the menu bar, select File - New - Exampleâ¦
- In the New Example window, expand Examples, expand Workstation PL/I, select PLI Sample 1, and click Next.
- On the z/OS Local Project page, enter
PLITestin the Project name entry field and click Finish. - If the dialog box, Confirm Perspective Switch, appears, click Yes.
- In the z/OS Projects View, expand the project PLITest, expand the folder pli, and double-click on HelloApp.pli to edit it.
- 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.
- 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
insertSemicolonin the command line area and press Enter. Your new action is executed. - When you are finished testing your new action, close the editor for HelloApp.pli. You do not need to save the changes.
- 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
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:
- From the WebSphere Developer for zSeries menu bar, select File - Export...
- On the Select window, select Deployable plug-ins and fragments and click Next
- In the Deployable plug-ins and fragments window, check the box for
com.mycompany.lpexExtensionswhich is listed in the Available Plug-ins and Fragments textbox. - 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.
- 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
- 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.
- 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
Copy the plug-in to your WebSphere Developer for zSeries installation directory
- 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
- 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
- Stop WebSphere Developer for zSeries and restart it.
- 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).
- Open a file in the z/OS Text editor and test. If all went well, you should now have a working plug-in.
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.
Learn
- Read how to
Configure z/OS application development tools
- Learn more from
WebSphere Developer for zSeries Product Page
- Navigate resources with the
WebSphere Developer for zSeries Roadmap
- Get resources for System z in the developerWorks
System Z zone.
- Get resources for WebSphere Developer for zSeries in the developerWorks
Development tools zone.
-
Using WebSphere Developer for zSeries V6 to Connect to COBOL/CICS (developerWorks, May 2005) shows how to transform an existing CICS COBOL application so that it can be accessed as a Web service through the CICS Web services facilities of CICS Transaction Server for z/OS V3.1
- Stay current with
developerWorks events and Webcasts.
Get products and technologies
- Learn how to purchase
WebSphere Developer for zSeries.
- Build your next development project with
IBM software, available for download directly from developerWorks.
Discuss
- Participate in developerWorks Blogs and get involved in the developerWorks community.
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.



