Example: creating and distributing custom perspectives
This example shows how you can create a custom perspective and share it with multiple end
users in your enterprise by using the extensibility features of Eclipse.
Many CICS Explorer® users create special perspectives tailored to their company, or workflow, pulling together the critical set of views for their situation. For a limited number of users, it's easy to customize a perspective as described in Customizing and saving perspectives. However, it's difficult to share the custom perspective between users. Follow this example to create a custom perspective (CICS Web Hosting perspective) by creating a plug-in project and share it by using the update site. The custom CICS Web Hosting perspective shows the information needed to manage files hosted as web files using CICS.
Creating a custom perspective
Procedure
Switch to the Java perspective by entering "Java™" in the Quick
Access box () in the toolbar.
Create a new plug-in project by selecting
File > New > Project
from the menu. In the New Project window, select Plug-in
Project and click Next.Figure 1. Creating
a new plug-in project
In the New Plug-in Project window, give your project a name, for example,
"WebPerspective" and click Next.
Supply other information if needed and click Finish. You'll be prompted
whether to switch to the associated perspective. You can press No to stay in
the Java perspective. The WebPerspective project's manifest is then shown in an
editor.
Make sure your Target Platform is set to Running Platform in the
Preferences window.
Switch to the Dependencies tab, and add the
org.eclipse.ui plug-in to the Required Plug-ins list.
Switch to the Extensions tab to add extensions to extend the behavior of
Eclipse.
Click Add.
Type "perspective" in the Extension Point filter field:Figure 2. Searching for available extension points
You can see
two extension points that you can extend. These are pieces of API provided by Eclipse that allows
users to define their own perspectives.
Allows us to extend an existing perspective, for example, the SM Perspective, by adding
additional views, wizards, and more. This extension is XML-based.
You need to create your own perspective, so select
org.eclipse.ui.perspectives.
Select Release Engineering Perspective as a base to work from and click
Next.
Enter the class name "WebPerspective" and the perspective name "CICS Web Hosting". Clear all of the boxes that give extras because the perspective needs only some views in it.
Tip: You can try starting up CICS Explorer with the new plug-in to test it. That way if you break things while you're editing, you know you started with something that worked.
In the Package Explorer view, right-click the WebPerspective project and
select Run As > Eclipse
Application:Figure 3. Running the WebPerspective
project
A second copy of CICS Explorer opens, which contains the plug-in you just created. This allows you to see how users will experience the plug-in.
In the new copy of CICS Explorer, select Window > Perspective > Open
Perspective > Other from the menu (or click the
Open Perspective icon [] on the toolbar) to switch to the CICS Web
Hosting perspective you just created. Normally you will have the
Navigator and JUnit views on the left side, with the
Problems and History views in the bottom.
Result
You have created a custom perspective. You can now customize the perspective to meet your
needs.
Customizing the new perspective to your requirements
In this example, you need the perspective to have the CICSplex Explorer view
on the left, the URIMAP, TCPIPSERVICES, and
FILES views so you can see the status of the artifacts involved in hosting a
file in the middle, and the Properties, Error log, and
Host Connections views at the bottom. Follow this procedure to customize your
perspective.
Procedure
Close the new copy of CICS Explorer so you can now see the WebPerspective plug-in code.
Navigate to the WebPerspective Java class:
Select Navigate > Open
Type from menu.
Type "WebPerspective" and click OK. The Java code editor opens.Figure 4. Opening WebPerspective plug-in Java code editor
Scroll down until you find the addViews method,
starting:
This
declared a folder layout that will be docked at the bottom of the screen. The
Problems and History views are added to this folder, and a
placeholder for the Console view is provided so that if the
Console view is opened it will automatically add itself to this bottom
folder.
Go back to the manifest file for the WebPerspective project. In the
Dependencies tab, click Add and type
com.ibm.cics.core. Double-click com.ibm.cics.core.ui
to add it as a dependency for your project, then save the editor.
Open the WebPerspective code editor and replace the addViews method with this
text and save
it:
You
will see a red cross on the main.addView() line because a parameter needs to be
passed in to addView:
Click between the brackets after main.addView and type "PluginConstants".
Press Ctrl + space (command + space on macOS) to show available options (known as code
complete). Type "F" and select FILES_VIEW_ID.
Save the file to resolve the red crosses. If you still see red crosses, try selecting
Source > Organize Imports and
saving again.
At this point you have only the Files view in your perspective. Right-click
the project and run it as Eclipse application again to test it. You might not see any change because
the old perspective layout is remembered in your workspace. Select
Window > Reset Perspective
from the menu to see the refreshed perspective:Figure 5. New perspective with
Files view
Close the test Explorer and add similar main.addView lines for the
URIMAPS_VIEW_ID and the TCPIPSERVICES_VIEW_ID.
Create the folder on the left side:
copy the main IFolderLayout declaration that you started
with:
IFolderLayout main =
factory.createFolder(
"main", //NON-NLS-1
IPageLayout.LEFT,
0.75f,
factory.getEditorArea());
Paste it in before the main folder's first line. You might get an error because the
main variable has already been used. You can call this new folder
navigate instead of main.
Add in a navigate.addView line for the CICSPLEX_VIEW_ID. You
can change the 0.75f specification for the navigate folder to
0.25f to reduce the size of CICSplex Explorer view.
Start the test Explorer and reset the perspective.
Add a folder between navigate and main for the bottom panel
with the Properties view. At this point, your addViews method
will look like
this:
You have finished customizing the perspective. You can now deploy the custom perspective to other
end users.Figure 6. Finalized custom perspective
Deploying the custom perspective to end users
Now you need to distribute the new custom perspective to end users. The simplest and most robust way to do this is using an update site, in a similar way to how the CICS Tools plug-ins are distributed.
Procedure
To create an update site, the plug-in must be contained within a feature. Select
File > New > Other
from the menu to create a Feature Project. You might use this feature project
to contain other custom plug-ins, so you can name it the OurCompanyCustomizations feature.
Click Next and select your WebPerspective plug-in from the plug-in list.
Click Finish. This creates a feature that contains only your new
plug-in.
In the Package Explorer view, right-click the feature you just created and
select Export
In the Export window, select Deployable features.
Select Archive file and type a filename where the new update site will be
stored.
Result
Now your end users can select Help > Install New
Software from the menu to add your update site and install your feature.
Note: When installing new software in the Install window, end users need to
clear the Group items by category box. To avoid that, you can categorize your
features by supplying a categorization file when you export the feature. For instructions, see Categorize your p2 repository.