5.7.2.3 Integrating Panels and Adding Actions for Button

 

The Main Screen has "Details_TabbedPane" (tabbed pane bean) containing four tabs, but the Main Screen currently has only tab named "Results_Panel" (The "Results" in figure below). This topic explains the integration of the three panel screens into to the Main Screen as tabs of the "Details_TabbedPane" bean and setting action for each button in the "Button_Panel". Follow the steps given below to achieve the same

 

Design Time View

 

 

Steps Involved

 

  1. Switch to "Project Classes" tab of the Beans Palette and select "com.adventnet.nms.tutorials.ems.SystemConfig" from the "Enter Class Name" combo box.  Click and drop the  button in the "Details_TabbedPane" bean. Thus you have dropped the "SystemConfig" class as bean. You can find tab with the name "SystemConfig1" in the "Details_TabbedPane" bean. Similarly drop the "com.adventnet.nms.tutorials.ems.STP" and "com.adventnet.nms.tutorials.ems.PortDetails" in the "Details_TabbedPane" bean. You can find the "STP1" and "PortDetails1" in the "Details_TabbedPane" bean.

  2. Designing the Details_TabbedPane Bean

 

try

{

ConfigResultTableModel1.addConfigResult( arg0);

}

catch(java.lang.NullPointerException ex)

{

ex.printStackTrace();

}

 

  1. Ensure that the order of screen instance and panel beans in the "Details_TabbedPane" is as in the above Design Time View screen shot.

  2. Invoke the "Layout Properties" dialog for the "Details_TabbedPane" bean by right-clicking it and selecting "Layout Properties" menu item.

  

 

  1. Provide the "Title" text field value for "SystemConfig1" bean as "System Configuration" (refer the above figure).

Similarly, provide the "Title" text field value for the other beans in the "Details_TabbedPane" as given in the table below

 

Bean

Title

STP1

STP

PortDetails1

PortParameters

Results_Panel

Results

 

Inserting Methods for Button Actions

 

  1. Switch to Source View tab and scroll down to end of the screen's class.

  2. Insert the following methods "checkUserOperations", "helpAction" and, "screenConfiguration" before the closing braces ("}") for the screen's class. These methods are required for configuring button actions.

 

private void checkUserOperations()

{

try{

URL BE_Url = NmsClientUtil.applet.getCodeBase();

String BEHostName = "localhost";

BEHostName = BE_Url.getHost();

if(BEHostName.trim().equalsIgnoreCase("localhost"))

try

{

BEHostName = InetAddress.getLocalHost().getHostName();

}

catch(UnknownHostException unknownhostexception1)

{

System.err.println("unknown host : " + unknownhostexception1);

}

if(BE_Url != null && BEHostName != null)

{

String name = "//" + BEHostName + "/NmsAuthEngineAPI";

AuthorizationEngine authEngine = (AuthorizationEngine) Naming.lookup(name);

if(authEngine == null)

{

}

else

{

String userName = NmsClientUtil.getUserName();

userOperations = authEngine.getOperationsForUser(userName);

}

}

}catch(Exception exp)

{

System.out.println("Exception while getting RMI handle to Authorization Engine " + exp.getMessage());

}

}

public void helpAction()

{

BrowserControl bc = new BrowserControl();

bc.displayURL(System.getProperty("user.dir")+File.separator+"tutorials"+File.separator+"ems_tutorial"+File.separator+"help"+File.separator+"ems_tutorial"+File.separator+"implementation"+File.separator+"configtutdoc.html");

}

public void screenConfiguration()

{

try{

ConfigResultTableModel1.clearAllRows();

Configurator1.resetAll();

Configurator1.setTaskName("SwitchConfiguration_task");

Configurator1.addGroup("group1", SystemConfig1, null);

if (userOperations.toString().indexOf("Ems") != -1)

{

if ( userOperations.contains("Ems Configure All") && (! userOperations.contains("Ems Configure None")))

{

Configurator1.addGroup("group1", STP1, null);

PortDetails1.saveTableValues();

Configurator1.addGroupInfoCaches( PortDetails1.getSavedTableValues());

}

}

else

{

Configurator1.addGroup("group1", STP1, null);

PortDetails1.saveTableValues();

Configurator1.addGroupInfoCaches( PortDetails1.getSavedTableValues());

}

Configurator1.doConfiguration();

Switch_Tree.setSelectionInterval((Switch_Tree.getRowCount())-1,(Switch_Tree.getRowCount())-1);

}

catch(java.lang.Exception ex)

{

ex.printStackTrace();

}

}   

 

Setting Action for Buttons

 

For "configure" button

 

 

Steps to be followed in Interaction Wizard

 

Specifying How to Apply the Configuration

  

The Configuration is performed by the Configurator Bean. The Configurator Bean does this task by task, each task containing one or more groups.

 

 

Processing the Configuration Result

  

 

Specifying the Device(s) to be Configured

  

This screen displays a list where you specify the Devices on which the Configuration need to be applied.

 

 

Configuration Task Details

 

This screen asks for information on the configuration task like the Name, whether an option is needed to revert to the previous configuration on failure and if so based on which document that contains the configuration profile.

 

 

Specifying the Group of Interest

  

This screen displays a group tree on the left, This Tree contains all the available groups in the Screen. Since you have defined only one group, this will be listed. The list on the right contains the different groups that are to be configured with the current operation. You  can see that the group has already been added to the Selected Groups list.

 

 

Generate the Code for Configuration with the Details Provided

  

This brings up the screen that has a list (on the left) that displays the components being used in the Screen and components for which references are needed can be added to the list on the right.

 

 

In this screen, you can find the code is generated automatically within the actionPerformed method based on the information furnished through all the steps so far in Interaction Wizard. Remove the existing code and Insert the following code in this method

 

screenConfiguration();

 

 

For "refresh" Button

 

 

PortDetails1.PortParametersTable11.refresh();

SystemConfig1.refresh();

STP1.refresh();

 

 

For "close" Button

 

 

setVisible(false);

 

 

For "help" Button

 

 

helpAction();

 

  1. Click "Finish" to close the Interaction Wizard.

 

This completes the building of Main Screen.

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.