|
The Port Parameters Panel displays the details of the Ports, The Port Parameters Panel is in the "PortParameter" tab of the "Details_TabbedPane" in the Main Screen. The designing Port Panel Details Panel is explained in this topic. Follow the steps given below to build the Port Parameters Panel.
Steps Involved
Initial Settings
Create a new screen under the "EMS_Configuration" project and rename it as "PortDetails".
Change the build type of the Screen to "Panel" using the menu command Build > Type > Panel.
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.
Dropping and Laying Out Components
Click and drop a JScrollPane bean from SwingBeans.list tab of Beans Palette in the "Center" position of the Draw Area. Change its instance name as "Details_ScrollPane".
Drop a SortTable bean from AdventNetUtils.jar of the Beans Palette in the "Details_ScrollPane" bean. Change the SortTable bean instance name as "Port_Details_Table".
Creating and Dropping the Virtual Table Model
Right-click the "Virtual Table Model" node in the XML Tree and select "Add" menu item to invoke the "Create New Virtual Table Model" Wizard.
Modify the "Virtual Table Model Name" as "PortParametersTable1".
Select the following
columnar nodes from XML tree to "Selected
Nodes" list using the
button. These nodes are
present under the "dot1dStpPortTable"
table node in the path BRIDGE-MIB
> mib-2 >
dot1dBridge > dot1dStp >
dot1dStpPortTable of the XML tree
dot1dStpPort
dot1dStpPortPriority
dot1dStpPortState
dot1dStpPortEnable
dot1dStpPortPathCost
dot1dStpPortForwardTransitions
Click the "Advanced Properties" button and change the 'PollInterval' to "0".
Click "Next" button to proceed to final screen of the Wizard.
Scroll down to end of the Class and add the following methods namely "getColumnClass", "getValueAt", and "setValueAt" before the closing brace ("}") of the class.
|
public Class getColumnClass(int c) { if(c == 3) { return Boolean.class; } else { return super.getColumnClass(c); } } public Object getValueAt(int row, int col) { if(col == 3) { String portEnabled = super.getValueAt(row,col).toString(); if(portEnabled.indexOf("1") != -1) { return Boolean.TRUE; } else { return Boolean.FALSE; } } else { return super.getValueAt(row,col); } } public void setValueAt(Object value , int row , int col) { if(col == 3) { Boolean enabled = (Boolean)value; if(enabled.booleanValue()) { super.setValueAt("1",row,col); } else { super.setValueAt("2",row,col); } } else { super.setValueAt(value,row,col); } } |
Click "Finish" button to close the Virtual Table Model Wizard.
Click and drop the "PortParametersTable1" node under the "Virtual Table Model" node of the XML tree outside the Draw Area. You can find the name of dropped bean is "PortParmetersTable11" .
Double-click the "Port_Details_Table" to invoke the Property Form. Select the "model" and choose the "PortParmetersTable11" from the combo box.
Dropping and Configuring ConfigCache Bean
Click and drop the ConfigCache bean from AdventNetMSBeans.jar of Beans Palette outside the Draw Area.
Switch to the Source View tab and scroll down of the screen's class.
Insert the following methods namely "saveTableValues", "getSavedTableValues" and "getStringConfigValueFor" before the closing braces of the class ("}"). This code is to save the values from the table.
|
public String getStringConfigValueFor(String gnameArg, String identifierNameArg, String identifierArg, String indexArg, Object[] userData) { if(gnameArg.equals("group1")) { if(identifierNameArg.equals("dot1dStpPortPriorityInstance")) { int index = Integer.parseInt((String)userData[0]); return (String)SortTable1.getValueAt(index, 1); } else if(identifierNameArg.equals("dot1dStpPortEnableInstance")) { int index = Integer.parseInt((String)userData[0]); String val=SortTable1.getValueAt(index,3).toString(); if(val.equals("true")) { return "1"; } else return "2"; } else if(identifierNameArg.equals("dot1dStpPortPathCostInstance")) { int index = Integer.parseInt((String)userData[0]); return (String)SortTable1.getValueAt(index, 4); } } return null; } public void saveTableValues() { ConfigCache1.resetAll(); for(int i=0;i<Port_Details_Table.getRowCount();i++) { try{ ConfigCache1.saveConfigInfo("this_group1"+i, "group1", PortDetails.this, new String[]{""+i}); }catch(Exception ex) { System.out.println("Error in Configuration "+ex); } } } public GroupInfoCache[] getSavedTableValues() { return ConfigCache1.getGroupInfoCaches(); } |
Add the following code under the package import declarations as given below :
|
import com.adventnet.beans.configuration.GroupInfoCache; |
Switch to the Config tab.
Select
the "dot1dStpPortPriorityInstance" node from the XML Tree, and click the
"Add Attribute"
button
to add the attributes from the Xml Tree to the Config Tree.
Edit the code in the "Code Area" and the following code
|
String valueStr = getStringConfigValueFor(gnameArg, identifierNameArg, identifierArg, indexArg, userData); if(valueStr == null) { return null; } |
Change the bolded code line as given below.
|
Properties valueProp = new Properties(); valueProp.setProperty(LABEL,"dot1dStpPortPriorityInstance"); valueProp.setProperty(TYPE,"2"); valueProp.setProperty(VALUE,valueStr); return valueProp; |
Similarly repeat the above steps for the nodes "dot1dStpPortEnableInstance","dot1dStpPortPathCostInstance". The corresponding code lines to be modified are given below :
|
valueProp.setProperty(VALUE,valueStr); |
Add the following the code against the index attribute in the code area
|
int index = Integer.parseInt((String)userData[0]); return (String)Port_Details_Table.getValueAt(index, 0); |
This design of "Port Details" panel screen is complete.
Save the "PortDetails" screen using the menu command File > Save > Screen.
Compile the "PortDetails" screen using the menu command Build > Compile.
|