• No results found

Integrating Panels and Adding Actions for Button

5. IMPLEMENTATION

5.7 Client-side Implementation

5.7.2 Building Configuration Screen

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

2. Designing the Details_TabbedPane Bean

• Drop a JPanel1 in "Details_TabbedPane" bean and change its instance name as

"Results_Panel" using the Property Form.

• Change the layout of the "Results_Panel" bean to "Border" layout.

• Click and drop a "ConfigResultTableModel" bean from AdventNetMSBeans.jar tab of the Beans Palette outside the Draw Area. You can find the instance name of the dropped "ConfigResultTableModel" bean is "ConfigResultTableModel1".

• Switch to Component tab and edit the ConfigurationResultEventAction under the connections node. Remove the code in the configPerformed method and add the following code :

try {

ConfigResultTableModel1.addConfigResult( arg0);

}

catch(java.lang.NullPointerException ex) {

ex.printStackTrace();

}

• Drop a JTable bean from "SwingBeans.list" tab of Beans Palette in the

"Results_Panel" bean and change its instance name as "Results_Table".

• Invoke the Property Form for the "Results_Table" bean and set the model property with "ConfigResultTableModel1" and close the Property Form.

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

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

5. 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();

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

}

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

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

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

String userName = NmsClientUtil.getUserName();

userOperations = authEngine.getOperationsForUser(userName);

}

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

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

userOperations.contains("Ems Configure None")))

Setting Action for Buttons For "configure" button

1. Right-click the "configure" button, select Interaction Wizard > action >

actionPerformed to get a rubber band line. Bring the rubber band line into

"configure" button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Select the "Task based Configuration with Roll Back and Multiple Device Support " option as you need this option in this case.

4. Click "Next" 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.

5. Select the Configurator Bean to be used for applying the Configuration. This is applicable when there are some Configurator Beans already available in the Screen.

Since you do not have a Configurator Bean till now, this Select Instance combo box is disabled. This means you need to instantiate a new one.

6. Specify the Instance Name in the New Instance Name text field (default is Configurator1).

Processing the Configuration Result

7. Ensure that the "Create Result Event Connection" is checked, since you need the result of the Configuration in a dialog. The Result Event connection can be created with a name of your choice. This name can be specified in the text field

corresponding to Connection Class Name. If you are not in need of the Result Processing Part, the Check Box can be unchecked. Click "Next" button.

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.

8. Click "Next" button.

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.

9. Ensure the name is "EditedValueChecker_task". If you require details on Roll Back you follow the topic Rolling Back to previous Configuration. Click "Next" button.

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.

10. Click "Next" button.

12. Click "Finish" to close the Interaction Wizard. If you now go to the Component Tree and click "Connections" you find two new connections created. This completes the construction of the application.

For "refresh" Button

1. Right-click the "refresh" button, select Interaction Wizard > action >

actionPerformed to get a rubber band line. Bring the rubber band line into "refresh"

button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

4. Insert the following code in the actionPerformed method PortDetails1.PortParametersTable11.refresh();

SystemConfig1.refresh();

STP1.refresh();

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

For "close" Button

1. Right-click the "close" button, select Interaction Wizard > action >

actionPerformed to get a rubber band line. Bring the rubber band line into "close"

button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

4. Insert the following code in the actionPerformed method setVisible(false);

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

For "help" Button

1. Right-click the "help" button, select Interaction

Wizard-->action-->actionPerformed to get a rubber band line. Bring the rubber band line into "help"

button itself to invoke the Interaction Wizard.

2. Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.

3. Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.

4. Insert the following code in the actionPerformed method helpAction();

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

This completes the building of Main Screen.

5.7.2.4 Compiling and Packaging the Application

The Packaging of applications built using Client Builder to NAR (NMS ARchive) is done using the Package Wizard. After NAR is created, NAR is installed in the Web NMS Client (using Deployment Wizard in Web NMS). Before the packaging the chassis application to NAR, you must compile the project Follow the steps given below to compile the project.

Compiling the Project

1. Regenerate the Project using the menu command Project > Regenerate Project.

2. Compile the Project using the menu command Project > Compile Project. You will get the message "Compilation succeeded for EMS_Configuration" in status bar.

Packaging the Classes using Package Wizard

1. Invoke the Package Wizard for creating the Device Specific NAR using the menu command Tools > Package for Web NMS > Device Specific. For detailed explanation on using the Package Wizard follow the topic Integration with Web NMS.

2. Select the value "com.adventnet.nms.tutorials.ems.SwitchConfiguration" from the Classes list and click "Next" button to proceed to next screen.

3. Choose the required destination directory where the NAR has to be created using the browse button. Click "Next" button to proceed to next screen.

4. Provide the corresponding device type that of the device host such as "Windows NT",

"Linux", or "Solaris" in the "Device Type" field. Click "Next" button to proceed to next screen.

5. Ensure the required device information are listed in the "DESTINATION DIRECTORY" and click "Next" button to proceed to final screen of the Package Wizard.

Note: For security features, include four classes from the package

com.adventnet.security.authorization located in <Web NMS Home>/classes directory into in <Client Builder Home>/projects/EMS_Configuration/classes directory. The required classes are AuthorizationException.class,

AuthorizationEngine.class, AuthorizationEngineImpl.class, and AuthorizationEngineImpl_Stub.class.

6. Click Finish button to close the Package Wizard to get the confirmation dialog with the message SwitchConfiguration.nar created successfully at <specified location>.

7. Import the NAR into the EMS Project, using the Client Application Import Wizard.

8. Deploy the NAR in Web NMS Client using the Deployment Wizard in Web NMS with the required menu name and menu item

Note: The above project is also available in <Web NMS Home>/StudioTools/ClientBuilder/projects

directory as EMS_Configuration that can be loaded for your reference.

Related documents