Adding Server preferences pages

This topic describes programming concepts and requirements needed to extend IBM Director to include one or more new panels in the server preferences dialog.

Subtopics

Related information

Related sample code

Understanding Server preferences

IBM Director provides the server preferences dialog to allow users to configure specific properties that a server task might require for execution. If your organization is extending IBM Director with a new server task, you might need to extend this dialog to include tabbed pages allowing configuration of that new server task. To provide GUI interaction with a server preference class, you must understand how IBM Director implements this interface to allow your organization to display a configuration panel that is integrated into the IBM Director server preferences dialog.

Creating IBM Director tasks describes how to build your own management tasks and provides steps for adding your own server task extensions. One of the steps in that process is Identifying your task to IBM Director at startup. As described in this section, the extension class is a subclass of the TWGExtension abstract base class. Also described is the fact that new tasks are added in the InitClassInstances() method of the extension class. What is not described is that any server preference classes that are needed to support your server task must also be added in the InitClassInstances() method of the extension class. This is done through the TWGConfigPanelBeans class. This class handles the registration of all server preference classes with the server. At startup, IBM Director will be notified by the server of all server preferences classes that have been registered. The IBM Director Management Console will display a separate tabbed page in the server preferences dialog for each page registered. Note that one server preference class can register multiple pages.

Task preferences

Tasks can participate in IBM Director preference notebooks if there is a need. The participating task must provide a panel that implements required interfaces and must register it with the server. The console will recognize these panels and add them to the appropriate notebook. Server and Discovery Preferences panels should refrain from including JTabbedPane and should follow the GUI panel layout guidelines described in Director programming: best practices.

The Server preferences notebook is shown in Figure 1.


Figure 1. The Server Preferences notebook.

The Discovery Preferences notebook is shown in Figure 2.


Figure 2. The Discovery Preferences notebook.

Understanding TWGConfigPanelBeans

The TWGConfigPanelBeans is the class to use to create your own server preference pages to allow your users to customize your server task. Using TWGConfigPanelBeans enables you to integrate your customized server preference pages for your server task in with the IBM Director server preferences dialog. Because a configuration panel bean instance is a persistent object, you should always check that an instance does not already exist before creating one.

TWGConfigPanelBeans()
There are two constructors provided for this class. One constructor is a default constructor that is used when the class is being restored. The other constructor is the one you should use to create your server preferences instance. There are several parameters that you will specify when constructing an instance of TWGConfigPanelBeans:

inst_id
This is the unique instance ID that is used to distinguish this instance from all others. It should be a string that is unique from all other server preference ids.
sort_wt
This is the ordering weight for this bean versus all others. Panels are ordered from lowest to highest sort weight.
nls_bndl
This is the base classname for the NLS bundle to use to resolve the tab labels specified. If null, then the tab labels specified will be used as is.
tab_lbls
This is a list of one or more tab labels to use for each page specified. If nls_bndl is non-null, then these are the resource IDs for the tab labels.
panel_beans
This is a list of one of more classes to use as the content for each page in the server preferences dialog. These bean classes must extend the JPanel class to provide the dialog page logic for gathering input from user. In addition, they must implement the UFDialogListener interface so that they are notified when the dialog is dismissed. They should also implement the TWGDynamicHelp interface if they want to provide an associated help reference to be brought up whenever the user requests help and their server preference page is the topmost page in the dialog.

The syntax of the constructor you should use is:

public TWGConfigPanelBeans( String inst_id, int sort_wt, String nls_bndl,
String[] tab_lbls, String[] panel_beans) throws TWGPersistentObjectSaveException

Example:

private static final String CONFIG_PANEL_BEAN = "BobCo.MyServerTask.config";
.
.
try
{
  // Register our configuration panel page but only if it is not already registered.
  if ( TWGConfigPanelBeans.getConfigPanelBeans( CONFIG_PANEL_BEAN ) == null )
  {
    // Register one class bean for one page in the server preferences.
    // The page should have the tab label that is specified by the key found
    // in the resource bundle specified.  The class to display on the page
    // is the one specified in the bean_cls array.
    String[] tab_ids = { "MyServerTask.MyPreferenceTab1" };
    String[] bean_cls = { "com.BobCo.MyServerTask.BCServerPrefGui" };

    TWGConfigPanelBeans cfg = new TWGConfigPanelBeans( CONFIG_PANEL_BEAN, 500,
                                   "com.BobCo.MyServerTask.BCServerResources",
                                   tab_ids, bean_cls );
  }
}
catch ( TWGPersistentObjectSaveException posx )
{
  throw new TWGExtensionInitException("Error registering ConfigPanelBean");
}

Note:  The configuration panel bean class must be constructed in the InitClassInstances() method of the extension class. The preceding code should appear in that method, typically after the server task has been created successfully.