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
  1. Switch to the Java perspective by entering "Java™" in the Quick Access box (Quick Access box) in the toolbar.
  2. 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
    New Project window
  3. In the New Plug-in Project window, give your project a name, for example, "WebPerspective" and click Next.
  4. 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.
  5. Make sure your Target Platform is set to Running Platform in the Preferences window.
  6. Switch to the Dependencies tab, and add the org.eclipse.ui plug-in to the Required Plug-ins list.
  7. Switch to the Extensions tab to add extensions to extend the behavior of Eclipse.
  8. Click Add.
  9. Type "perspective" in the Extension Point filter field:
    Figure 2. Searching for available extension points
    New Extension window
    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.
  10. You need to create your own perspective, so select org.eclipse.ui.perspectives.
  11. Select Release Engineering Perspective as a base to work from and click Next.
  12. 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.
  13. In the Package Explorer view, right-click the WebPerspective project and select Run As > Eclipse Application:
    Figure 3. Running the WebPerspective project
    Run As menu of 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.
  14. In the new copy of CICS Explorer, select Window > Perspective > Open Perspective > Other from the menu (or click the Open Perspective icon [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
  1. Close the new copy of CICS Explorer so you can now see the WebPerspective plug-in code.
  2. Navigate to the WebPerspective Java class:
    1. Select Navigate > Open Type from menu.
    2. Type "WebPerspective" and click OK. The Java code editor opens.
      Figure 4. Opening WebPerspective plug-in Java code editor
      WebPerspective Java code editor
  3. Scroll down until you find the addViews method, starting:
    private void addViews()
    Find a couple of paragraphs of code like this:
            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)
    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.
  4. 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.
  5. Open the WebPerspective code editor and replace the addViews method with this text and save it:
        private void addViews() {
            IFolderLayout main =
                factory.createFolder(
                    "main", //NON-NLS-1
                    IPageLayout.LEFT,
                    0.75f,
                    factory.getEditorArea());
            main.addView();
        }
    You will see a red cross on the main.addView() line because a parameter needs to be passed in to addView:
    1. Click between the brackets after main.addView and type "PluginConstants".
    2. Press Ctrl + space (command + space on macOS) to show available options (known as code complete). Type "F" and select FILES_VIEW_ID.
    3. Save the file to resolve the red crosses. If you still see red crosses, try selecting Source > Organize Imports and saving again.
  6. 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 viewNew perspective with Files view
  7. Close the test Explorer and add similar main.addView lines for the URIMAPS_VIEW_ID and the TCPIPSERVICES_VIEW_ID.
  8. Create the folder on the left side:
    1. copy the main IFolderLayout declaration that you started with:
              IFolderLayout main =
                  factory.createFolder(
                      "main", //NON-NLS-1
                      IPageLayout.LEFT,
                      0.75f,
                      factory.getEditorArea());
    2. 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.
    3. 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.
    4. Start the test Explorer and reset the perspective.
  9. 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:
        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
You have finished customizing the perspective. You can now deploy the custom perspective to other end users.
Figure 6. Finalized custom perspective
Final look of the 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
  1. 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.
  2. Click Next and select your WebPerspective plug-in from the plug-in list.
  3. Click Finish. This creates a feature that contains only your new plug-in.
  4. In the Package Explorer view, right-click the feature you just created and select Export
  5. In the Export window, select Deployable features.
  6. 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.