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 New Project window, select Plug-in Project and click Next. from the menu. In the
- 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:
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.
- org.eclipse.ui.perspectives
- Allows users to define custom perspectives from scratch, by writing a small amount of Java code.
- org.eclipse.ui.perspectiveExtensions
- 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 : 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 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. from the menu (or click the
- 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 from menu.
- Type "WebPerspective" and click OK. The Java code editor opens.
- Scroll down until you find the
addViews
method, starting:private void addViews()
Find a couple of paragraphs of code like this:
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.IFolderLayout bottom = factory.createFolder( "bottomRight", //NON-NLS-1 IPageLayout.BOTTOM, 0.75f, factory.getEditorArea()); bottom.addView(IPageLayout.ID_PROBLEM_VIEW); bottom.addView("org.eclipse.team.ui.GenericHistoryView"); //NON-NLS-1 bottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW)
- 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 theprivate void addViews() { IFolderLayout main = factory.createFolder( "main", //NON-NLS-1 IPageLayout.LEFT, 0.75f, factory.getEditorArea()); main.addView(); }
main.addView()
line because a parameter needs to be passed in toaddView
:- 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 and saving again.
- Click between the brackets after
- 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 from the menu to see the refreshed perspective:
- Close the test Explorer and add similar
main.addView
lines for theURIMAPS_VIEW_ID
and theTCPIPSERVICES_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 foldernavigate
instead ofmain
. - Add in a
navigate.addView
line for theCICSPLEX_VIEW_ID
. You can change the0.75f
specification for the navigate folder to0.25f
to reduce the size of CICSplex Explorer view. - Start the test Explorer and reset the perspective.
- copy the main
- Add a folder between
navigate
andmain
for the bottom panel with the Properties view. At this point, youraddViews
method will look like this:private void addViews() { IFolderLayout navigate = factory.createFolder( "navigate", //NON-NLS-1 IPageLayout.LEFT, 0.25f, factory.getEditorArea()); navigate.addView(PluginConstants.CICSPLEX_VIEW_ID); IFolderLayout bottom = factory.createFolder( "bottom", //NON-NLS-1 IPageLayout.BOTTOM, 0.75f, factory.getEditorArea()); bottom.addView(IPageLayout.ID_PROP_SHEET); bottom.addView("com.ibm.cics.explorer.connections_view"); bottom.addView(IPageLayout.ID_PROBLEM_VIEW); IFolderLayout main = factory.createFolder( "main", //NON-NLS-1 IPageLayout.LEFT, 0.75f, factory.getEditorArea()); main.addView(PluginConstants.FILES_VIEW_ID); main.addView(PluginConstants.URIMAPS_VIEW_ID); main.addView(PluginConstants.TCPIPSERVICES_VIEW_ID); }
- Result
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 Feature Project. You might use this feature project to contain other custom plug-ins, so you can name it the OurCompanyCustomizations feature. from the menu to create a
- 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