5.7.1.2.3 Building Property Screen

 

Property screen is to display the properties for the Cards or Port at run time.  This screen is of the built type dialog that is invoked from card  or port (present in the card). At run time, right-click the card or port to invoke the pop-up menu and select "Property" menu item. This topic explains the steps involved in building this dialog screen. The JTextField bean components dropped in this screen are not provided with client property since the values are set for these JTextFields at run time depending on the how this dialog is invoked viz. card's pop-up menu or port's pop-up menu (port components are present in the cards).

 

Initial Settings

  1. Create a new screen under "Screens" node using the menu command File > New > Screen and rename the screen name as "Property_Screen".

  2. Change the layout of the screen by right-clicking the Draw Area and select Layouts > Border Layout.

  3. Click and drop a two JPanels from SwingBeans.list tab of the Beans Pallete.

  4. Change the instance name of these JPanels as Details_Panel and Button_Panel.

 

Designing Details_Panel Panel

  1. Set the position of "Details_Panel" JPanel to "Center" and "Button_Panel" to south using the "Layout Properties" dialog (invoked by right-clicking the Draw Area and select Layouts Properties ).

  2. Drop a JLabel from SwingBeans.list tab of the Beans Palette in the "Details_Panel" JPanel. Invoke the Property Form, provide the following properties as given in the table below

 

Property

Value

InstanceName

NameL

horizontalTextPosition

RIGHT

horizontalAlignment

RIGHT

text

Name

foreground

bottle green

 

  1. Drop 11 JLabels from SwingBeans.list tab of the Beans Palette. Select "RIGHT" option for "horizontalTextPosition" and "horizontalAlignment"  properties. Change the instance name and text properties for these JLabels as listed in the Instance Name in the table given below. Set the properties for each component as given in the table below (Similar to the above step-6)

 

Instance Name Property Value

Text Property Value

DisplayNameL

Display Name

TypeL

Type

ManagedL

Managed

StatusL

Status

ParentKeyL

Parent Key

SwitchL

Switch

PortTypeL

Port Type

SpeedL

Speed

PortNoL

Port Number

TrunkL

Trunk

RemotePortL

Remote Port

 

  1. Drop a JTextField from SwingBeans.list tab of the Beans Palette in the "Details_Panel" JPanel. Invoke the Property Form, provide the "Instance Name" property with the value "NameTF" and choose "False" option for the "editable " property.

  1. Drop 11 JTextFields from SwingBeans.list tab of the Beans Palette.  Change the instance name as listed below.      

 

  1. Choose "False" option for the "editable " property for all the above JTextField components.

  2. Change the layout of the "Details_Panel" panel by right-clicking the Draw Area and select Layouts > GridBag Layout.

 

 

  1. Position the components in the  Details_Panel JPanel GridBag Layout Customizer (invoked by right-clicking the Draw Area and select Layouts Properties ) as given in the table below (also refer the figure above).

  2. In the GridBag Layout Customizer, set the following properties for all the components:

 

Property

Value

Grid Width

1

Grid Height

1

Fill

Horizontal

Anchor

Center

Insets

5,5,5,5

 

 

Component (Identified

with Instance Name)

Grid

GridX

GridY

NameL

0

1

DisplayL

0

2

TypeL

0

3

ManagedL

0

4

StatusL

0

5

ParentKeyL

0

6

SwitchL

0

7

PortTypeL

0

8

SpeedL

0

9

PortNoL

0

10

TrunkL

0

11

RemortPortL

0

12

NameTF

1

1

DisplayNameTF

1

2

TypeTF

1

3

ManagedTF

1

4

ParentKeyTF

1

5

StatusTF

1

6

SwitchTF

1

7

PortTypeTF

1

8

SpeedTF

1

9

PortNOTF

1

10

TrunkTF

1

11

RemortPortTF

1

12

 

Designing Button_Panel Panel

  1. Ensure that the layout of this panel is set as Flow Layout by right-clicking the Draw Area and select Layouts > Flow Layout.

  2. Drop a JButton from SwingBeans.list tab of the Beans Palette in the "Button_Panel" JPanel. Invoke the Property Form, provide the "Instance Name" property with the value "Close" and choose "text" property and provide the value "Close". Close the Property Form using the "Close" button.

  3. Right-click the "Close" button and select Interaction Wizard > action > actionPerformed to get a rubber-band line, drop the rubber-band line on to the "Close" button itself to invoke the Interaction Wizard.

  4. Move to the last screen of the Interaction wizard using the "Next" button (by clicking the button twice).

  5. Insert the following code in the actionPerformed method

setVisible(false);

 

     6. Close the Interaction Wizard using the "Finish" button.

 

import java.io.*;

     import java.util.Properties;

     import com.adventnet.nms.mapui.MapClientAPI;

 

For the Property screen to show the properties of the Card and Port when the menu is invoked form Card and port respectively, insert the following user code just before the final "}" brace of the source in the source tab -

 

MapClientAPI api;

     public void setValue(String portname,String type)

     {

            String pn = null ;

            if( portname != null ) {

                   pn = portname;

            }

            else{

                   System.out.println(" portname is null . Please input the portname");

                   return;

             }

          setTitle("Property - "+pn);

          try{

                api=MapClientAPI.getInstance();

              }catch(Exception e)

              {

                   System.out.println("Error in getting Handle of MapClientAPI"+e);

              }

         try{

                   Properties prop=api.getManagedObjectProperties(pn);

                   NameTF.setText(prop.getProperty("name"));

                   SwitchTF.setText(prop.getProperty("switchnode"));

                   SpeedTF.setText(prop.getProperty("speed"));

                   PortTypeTF.setText(prop.getProperty("portType"));

                   DisplayNameTF.setText(prop.getProperty("displayName"));

                   ParentKeyTF.setText(prop.getProperty("parentKey"));

                   TypeTF.setText(prop.getProperty("type"));

                   ManagedTF.setText(prop.getProperty("managed"));

                   StatusTF.setText(prop.getProperty("status"));

                   PortNoTF.setText(prop.getProperty("portno"));

                   if(type.equals("Trunk"))

                   {

                        TrunkTF.setText(prop.getProperty("trunk"));

                        RemotePortTF.setText(prop.getProperty("remotePortID"));

                    }

                   if(type.equals("Access"))

                   {

                        TrunkL.setText("SNMP Interface");

                        TrunkTF.setText(prop.getProperty("snmpInterface"));

                        RemotePortL.setVisible(false);

                        RemotePortTF.setVisible(false);

                   }

                   if(type.equals("Card"))

                   {

                        SwitchL.setText("Card Type");

                        SwitchTF.setText(prop.getProperty("cardType"));

                        PortTypeL.setText("Serial Number");

                        PortTypeTF.setText(prop.getProperty("serialno"));

                        SpeedTF.setVisible(false);

                        StatusTF.setVisible(false);

                        PortNoTF.setVisible(false);

                        TrunkTF.setVisible(false);

                        RemotePortTF.setVisible(false);

                        SpeedL.setVisible(false);

                        StatusL.setVisible(false);

                        PortNoL.setVisible(false);

                        TrunkL.setVisible(false);

                        RemotePortL.setVisible(false);

                   }

           }catch (Exception remoteException)

          {

               System.out.println ( "Error in getting api.getByName using portname " + portname);

              remoteException.printStackTrace();

              return;

          }

     }

 

The design of "Property_Screen" screen dialog is complete.

 

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.