|
The main screen of the Configuration Management Application has a tree in the left side, tabbed pane in the right side and a panel with buttons at the bottom of the screen. The figure below shows the components in the main screen.
Design Time View

Steps Involved
Initial Settings
Create a new screen under the "EMS_Configuration" project and rename it as "SwitchConfiguration".
Change the build type of the Screen to "NMS Frame" using the menu command Build > Type > NMS Frame.
Change the layout of the Screen to "Border Layout" by right-clicking the Draw Area to invoke the screen pop-up menu, select Layouts > Border Layout.
Dropping and Laying out the Components
Drop the AdventNetTree bean and change its instance name by following the steps below
Switch to the "Project Classes" tab of Beans Palette.
Provide the value "com.adventnet.beans.utilbeans.AdventNetTree" in the "Enter the Class Name" text field.
Click
and drop the "bean"
button
in the "West"
position of the Draw Area .
Change the instance name of the AdventNetTree bean instance as "Switch_Tree" using the Property Form.
Drop the JTabbedPane bean and change its instance name by following the steps below
Switch to the "SwingBeans.list" tab of Beans Palette.
Click and drop the JTabbedPane bean in the "Center" position of the Draw Area.
Change the instance name of the JTabbed bean instance as "Details_TabbedPane" using the Property Form.
Drop the JPanel bean and change its instance name by following the steps below
Switch to the "SwingBeans.list" tab of Beans Palette.
Click and drop the "JPanel" bean in the "South" position of the Draw Area.
Change the instance name of the JPanel bean instance as "Button_Panel" using the Property Form.
Invoke the "Border Layout" dialog to arrange the components by right-clicking the Draw Area and select "Layout Properties" menu item.
Select each component in the "Component" combo box and ensure the parameters are as in the table given below, if not provide the values and click "OK" button to close the dialog.
|
Component |
Position |
HGap |
VGap |
|
Button_panel |
South |
5 |
5 |
|
Switch_Tree |
West |
||
|
Details_TappedPane |
Center |
Designing Switch_Tree Bean
Double-click the "Switch_Tree" bean to invoke the Property Form.
Select the TreeValues and Click "Click to edit Titles and class or File names" button against it to invoke the "Tree Values" dialog.
Add the "Configure Switches" node by following the steps below
Provide the value "Configure Switches" in the "Node Name" text field.
Select the "logo.png" from the <Client Builder Home>/images using the "Browse" button.
Click the "Add" button.
Similarly, add following nodes under the root node (Configure Switches) of the tree with the respective icons as given in the table below.
|
Node Name |
Icon Name |
|
Switch Name |
ems_tut_switch_tick.jpg |
|
View Result |
properties.png |
Click "Apply" button after adding the above nodes and Click "Close" to close the dialog.
Close the Property Form using the "Close" button.
Right-click the "Switch_Tree" bean, select Interaction Wizard > treeSelection > valueChanged to get a rubber band line. Bring the rubber band line into "Switch_Tree" bean itself to invoke the Interaction Wizard.
Ensure that the "Create New Connection class" option is selected in the first screen of the Interaction Wizard. click "Next" button.
Ensure the "General Component Interaction" is selected and Click "Next" button twice to go to the final screen of the Interaction Wizard.
Insert the following code in the valueChanged method
|
String name=null; TreePath tp=arg0.getNewLeadSelectionPath(); if(tp != null) { AdventNetTreeNode an=(AdventNetTreeNode)tp.getLastPathComponent(); name=an.getName(); if(name.equals("View Result")) { Details_TabbedPane.setEnabledAt(0,false); if (userOperations.toString().indexOf("Ems") != -1) { if ( userOperations.contains("Ems Configure All") && (! userOperations.contains("Ems Configure None"))) { Details_TabbedPane.setEnabledAt(1,false); Details_TabbedPane.setEnabledAt(2,false); } } if (userOperations.toString().indexOf("Ems") == -1) { Details_TabbedPane.setEnabledAt(1,false); Details_TabbedPane.setEnabledAt(2,false); } if(Details_TabbedPane.indexOfTab("Results") == -1) Details_TabbedPane.insertTab("Results",null,Results_Panel,null,Details_TabbedPane.getTabCount()); Details_TabbedPane.setSelectedIndex(Details_TabbedPane.getTabCount()-1); configure.setEnabled(false); refresh.setEnabled(false); } if(name.equals(getParameter("HOST"))) { if((Details_TabbedPane.indexOfTab("Results")) != -1) { Details_TabbedPane.removeTabAt(Details_TabbedPane.indexOfTab("Results")); } Details_TabbedPane.setEnabledAt(0,true); if (userOperations.toString().indexOf("Ems") != -1) { if ( userOperations.contains("Ems Configure All") && (! userOperations.contains("Ems Configure None"))) { Details_TabbedPane.setEnabledAt(1,true); Details_TabbedPane.setEnabledAt(2,true); } } Details_TabbedPane.setSelectedIndex(0); refresh.setEnabled(true); if (userOperations.toString().indexOf("Ems") != -1) { if ( (userOperations.contains("Ems Configure Scalar") || userOperations.contains("Ems Configure All")) && ! userOperations.contains("Ems Configure None")) { configure.setEnabled(true); } } if (userOperations.toString().indexOf("Ems") == -1) { Details_TabbedPane.setEnabledAt(1,true); Details_TabbedPane.setEnabledAt(2,true); configure.setEnabled(true); } } } |
Click "Finish" to close the Interaction Wizard.
Switch to Source View tab and scroll to the setVisible method. Write the following code under the //<End_setVisible_boolean> tag.
|
if(bl) { String icon2="../images/ems_tut_switch_small.png"; AdventNetTreeNode node=Switch_Tree.getNode(getParameter("HOST"),icon2); Switch_Tree.setSelectionInterval(1,1); Switch_Tree.addNode(node); Switch_Tree.selectNode(node); if (userOperations.toString().indexOf("Ems") != -1) { if(userOperations.contains("Ems Configure Scalar") && ( ! userOperations.contains("Ems Configure All") && ! (userOperations.contains("Ems Configure None")) )) { Details_TabbedPane.removeTabAt(Details_TabbedPane.indexOfTab("STP")); Details_TabbedPane.removeTabAt(Details_TabbedPane.indexOfTab("PortParameters")); } if (userOperations.contains("Ems Configure None")) { configure.setEnabled(false); } } } |
Add the following code under the package import declarations as given below :
|
import java.net.*; import javax.swing.tree.TreePath; import java.util.Vector; import java.rmi.Naming; import com.adventnet.beans.utilbeans.AdventNetTreeNode; import com.adventnet.nms.util.NmsClientUtil; import com.adventnet.nms.util.BrowserControl; import com.adventnet.security.authorization.AuthorizationEngine; |
Add the following code under the package variable declarations as given below :
|
private Vector userOperations=new Vector(); |
Add the following code in the init method before the closing braces ("}") of this method as given below :
|
checkUserOperations(); setResizable(false); |
Add the following code in stop method before the closing braces ("}") of this method as given below :
|
PortDetails1.stop(); |
Add the following code in start method after the opening braces ("{") of this method as given below :
|
PortDetails1.start(); |
Custom code that need to be added in the Configuration management screen to cater for Security administration
In the Configuration wizard, we have created the screens for configuring the Switches. In the SwitchConfiguration.java file of the EMS configuration project, the following code was accommodated in order to cater for Security administration.
When the switch configuration screen is invoked from the client, the checkUserOperations() method makes a RMI lookup to the AuthorizationEngineAPI for retrieving the operations for the logged-in user.
|
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) { System.out.println("Could not get rmi handle to AuthAPI"); } else { String userName = NmsClientUtil.getUserName(); userOperations = authEngine.getOperationsForUser(userName); } } } catch(AuthorizationException ex) { System.out.println("Exception while getting RMI handle to Authorization Engine " + ex.getMessage()); } catch(Exception exp) { System.out.println("Exception while getting RMI handle to Authorization Engine " + exp.getMessage()); } } |
Whenever a component in the UI is added, disabled or enabled, a check is made if the user logged in has the required permission to perform the operation. Based on the user operation, the component is enabled or disabled.
|
if(userOperations.toString().indexOf("Ems") != -1) { if (userOperations.contains("Ems Configure None")) { configure.setEnabled(false); } } |
Switch back to Screen View tab.
Designing the Button_Panel Bean
Ensure that the layout of Button_Panel is flow layout.
Drop a JButton from the SwingBeans.list tab of BeansPalette and change its instance name as "configure" and provide "text" property value "Configure" in the Property Form. Similarly drop three more JButtons and change their properties in Property Form as given in the table below:
|
Instance Name |
Text Property |
|
refresh |
Refresh |
|
help |
Help |
|
close |
Close |
Resize the bean components to the required size (refer the Design Time View screen shot).
|
|
Note: The actions for each of the above buttons are provided after the panel screens are designed and integrated. |
|