Perspectives and views

A perspective defines the initial layout of views in an Eclipse workbench window. Each perspective provides a set of functions for accomplishing a specific type of task, or works with specific types of resources. For example, the Java™ perspective combines views commonly used while editing Java source files, and the Debug perspective contains the views for debugging Java programs.

Perspectives control what appears in certain menus and toolbars. Perspectives also define visible action sets, which you can change to customize a perspective. You can save a perspective that you build this way, making a custom perspective that you can open again later.

The Host Access perspective

A default perspective class, hostaccess.perspectives.MainPerspective, has been provided for you in the com.ibm.hats.rcp.runtime.extension plug-in project. This class extends from the HATS com.ibm.hats.rcp.ui.Perspective class and implements the Eclipse perspective interface, org.eclipse.ui.IPerspectiveFactory. The default title for this perspective is Host Access, although you can change the title by modifying the plugin_en.properties file in the com.ibm.hats.rcp.runtime.extension plug-in project.

Note:
You will need to modify each of the plugin_xx.properties files for each language you will be supporting.

Table 5 lists the methods that can be overridden in your perspective class.

Table 5. Methods to override perspective class
Method Description
addApplicationsView(IPageLayout) Adds the HATS applications view to the perspective.
createTransformationViewsPlaceholder(IPageLayout) Creates a placeholder for the HATS transformation views.
createPrintJobViewsPlaceholder(IPageLayout)</code> Creates the placeholder area for the 3270 and 5250 print jobs view.
addPrintActionsSet(IPageLayout)</code> Adds the print action set (defined in the plugin.xml of the com.ibm.hats.rcp.rntime.extension plug-in) to the perspective.

To change the default perspective first opened by the Host Access runtime application, edit the HostAccessWorkbenchAdvisor source file in com.ibm.hats.rcp.runtime.extension plug-in project, and change the PERSPECTIVE_ID to your custom perspective ID. See HostAccessWorkbenchAdvisor for more information about the Host Access perspective.

The following is an example showing how the Host Access perspective is registered in the plug-in descriptor for com.ibm.hats.rcp.runtime.extension:

<extension 
     point="org.eclipse.ui.perspectives">
     <perspective
            name="%PERSPECTIVE_TITLE"
            icon="images/applications_view.gif"
            class="hostaccess.perspectives.MainPerspective"
            id="hostaccess.perspectives.main">
      </perspective>
</extension>     

You are not required to use the Host Access perspective, although it provides your end users with easy access to the HATS applications you have provided them. You can use the Host Access perspective as a starting point, or start from scratch and develop a perspective that better fits the needs of your users.

By default, the Host Access perspective includes the Applications view. See Applications view for more information on this view.

See the Javadoc API for more information on the com.ibm.hats.rcp.ui.Perspective class

Note:
Lotus® Expeditor Client and Lotus Notes® developers: Perspectives are not displayed in the Open menu of the Lotus Expeditor Client or Lotus Notes windows. This menu displays the applications that are registered using the com.ibm.eswe.workbench.WctApplication extension point. See HATS runtime extension plug-in for more information on this extension point.

Applications view

The Applications view (com.ibm.hats.rcp.ui.views.ApplicationsView) is registered in the com.ibm.hats.rcp.runtime.extension plug-in. This view provides users access to the HATS rich client applications installed in the client environment. Users can also configure properties for an application by launching the Properties dialog from this view.

See Applications view in the User's and Administrator's Guide for more information on how to use this view.

Programmatically starting an instance of an application

The Applications view is provided by default on the Host Access perspective so that your end users can start new instances of their HATS rich client applications. An API is provided to enable you to programmatically launch a new instance of a HATS rich client application. This is useful if you have elected to not show the Applications view in your perspective; however, you want to provide a way to launch an application from the perspective or to programmatically launch an application instance from another view. For example, you might have a HATS application to collect data from one host system, launch a new instance of another HATS application, and pass the data to the new instance.

To facilitate passing parameters to the new application instance, the API enables you to override connection parameters and initialize global variable values. To launch a HATS rich client application instance by clicking a button:

  1. If the Visual Editor is installed, add an SWT Button from the Palette to the parent composite or transformation. If the Visual Editor is not installed, use standard SWT programming to add a button and the widgetSelected() code. For more information, see Editing transformations.
  2. Right-click the button and select Events > widgetSelected.
  3. Replace the sample placeholder code in the widgetSelected(SelectionEvent) method with the following code:
String applicationId = "myApplication";

Properties initParams = new Properties();
initParams.setProperty(com.ibm.eNetwork.beans.HOD.Session.HOST, "129.12.11.2");
initParams.setProperty(com.ibm.eNetwork.beans.HOD.Session.PORT, "623");
initParams.setProperty("hatsgv_userName", "some user");
initParams.setProperty("hatsgv_password", "xxxxx");
initParams.setProperty("hatssharedgv_someVariable", "zzzzz");

ViewInitInfo viewInitInfo = new ViewInitInfo(true, initParams);
RcpUiUtils.launchView(PlatformUI.getWorkbench().getActiveWorkbenchWindow().
                                  getActivePage(), applicationId, viewInitInfo);
Note:
You must enable connection parameter overriding in the Project Settings of your project to allow any overriding of connection parameters. (You must also enable global variable overriding to allow overriding global variables.) Enabling this function causes the Connection Parameters page to be visible in the properties dialog of the application. See the description of the org.eclipse.ui.propertyPages extension point in Table 3 for information on hiding Connection Parameters page using the properties dialog.

Transformation view

A view is a visual component of an Eclipse perspective that displays information to a user. For more information on perspectives, see The Host Access perspective. Each HATS rich client application contributes a view, which extends from the base com.ibm.hats.rcp.ui.views.TransformationView class, to the Eclipse environment it is running in. The transformation view is used by a user to interact with a HATS rich client application.

Table 6 lists the methods of your application's transformation view class can be overridden.

Table 6. Transformation view methods
Method Description
createViewActions() Creates actions for the view's menu.
Note:
After actions are created, they must then be registered. See Extending the transformation view's menu for more information.
createKeyboardActions() Creates keyboard action classes for all known HATS keyboard functions registered in the plugin.xml of the com.ibm.hats.rcp.runtime.extension plug-in project. Once keyboard actions are created, each is registered with the IKeyBindingService of the workbench window by the registerKeyboardActions() method.
Note:
See the User's and Administrator's Guide for information about the createKeyboardActions() method and how to add keyboard support for other keys.
getApplicationKeypadDisplayInfo() Controls which buttons to display in the application keypad area of the view's toolbar. By default, the application's settings are read to determine what keys to display. You can override this method in your transformation view class if you need to calculate what is displayed. This method has no affect if the view's toolbar is hidden.
getHostKeypadDisplayInfo() Controls which keys to display in the host keypad area of the view, and indicates how the keys are displayed. By default, the application's settings are read to determine which keys to display. You can override this method in your transformation view class if you need to calculate what is displayed.
getOiaDisplayInfo() Indicates what information to display in the OIA of the transformation view. By default, the application's settings are read to determine what to display. You can override this method in your transformation view class if you need to calculate what is displayed.
getToolbarDisplayInfo() Indicates whether the view's toolbar is displayed. If displayed, this method also indicates how buttons are rendered on the toolbar. By default, the application's settings are read to determine how the toolbar is presented. You can override this method in your transformation view class.
shouldAutoStart() Indicates whether the application should connect automatically when this view is opened.
Note:
If you need to override how the application keypad, host keypad, OIA, or toolbar is displayed for a specific transformation, override the appropriate method in the transformation class, not in the transformation view class. Only override these methods in the transformation view class if you need to programmatically alter how these areas are displayed. See Customizing the host keypad for an example of overriding how the host keypad is displayed for a specific transformation.

See the HATS Rich Client API Reference for more information on these methods.

Extending the transformation view's menu

The following code sample shows how to extend your transformation view's menu. In the sample, a disconnect menu item is added which, when clicked, causes the host connection to be disconnected and the disconnect and stop events of the application to be run. You should only add actions to the view's menu that are applicable during the entire lifecycle of the view.

Follow these steps to extend the menu of your transformation view class (the Java source file for this class is located in the <project name>.views package of your project):

  1. Since your action needs to be accessed in at least two methods of your transformation view class, declare it as a private member of your transformation view class.
    private com.ibm.hats.rcp.ui.actions.DisconnectAction disconnectAction;
  2. Override the createViewActions() method of the transformation view class, ensuring that you call super.createViewActions() if you want the default actions provided by HATS to be available on the view's menu).
    protected void createViewActions() {		 		 
    		 		 super.createViewActions();
           	 		 
    		 		 //create an action and append the action to the view's menu.
    		 		 disconnectAction = new DisconnectAction("Disconnect",getSessionService());		 		 
    		 		 getViewSite().getActionBars().getMenuManager().add(new Separator());
    		 		 getViewSite().getActionBars().getMenuManager().add(disconnectAction);
    		 }
  3. Override the updateViewActions() method to cause your new action to be enabled or disabled when the menu is updated.
    protected void updateViewActions() {		 		 
    		 		 super.updateViewActions();
           	 		 
    		 		 //enable the action based on the session state.
    		 		 disconnectAction.setEnabled(getSessionService().getSessionServiceState().
                                                         isOperational());
    		 }

After adding the Disconnect action, when you click the menu button in the transformation view, you can see Disconnect on the menu:

Figure 2. Disconnect on the transformation view menu
Disconnect on the transformation view menu