/* * NetworkStatisticsView.java * * Copyright (c) 2003-2004 Digi International * This program and the information contained in it is confidential and * proprietary to Digi International and may not be used, copied, or re- * produced without the prior written permission of Digi International. * */ package com.digi.config.ui; import com.digi.config.core.*; import com.digi.config.util.*; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.util.*; import java.io.*; import java.net.*; /** * This class is a view panel that shows network statistics. * * This view can be embedded in other panels as desired. */ public class NetworkStatisticsView extends ConfigViewImpl { /** A KvpNode that holds just the state fields used in this view */ KvpNode viewStateTree; /** listens to the device for changes to state fields */ DeviceChangeListener stateChangeListener; GridContentPanel content; GridContentPanel ipContent; GridContentPanel tcpContent; GridContentPanel udpContent; GridContentPanel icmpContent; // The following field arrays are used to get field values from the device. // To get more fields simply add to the appropriate array below. // The fields will be layed out automatically on the panel. // Add labels for new fields in the resource bundle using the field name // and a prefix of "Lbl" (e.g. ipforwardingLbl). String ipFields[] = { "ipinreceives", "ipforwdatagrams", "ipforwarding", "ipoutnoroutes", "iproutingdiscards", "ipdefaultttl", }; String tcpFields[] = { "tcpinsegs", "tcpoutsegs", "tcpactiveopens", "tcppassiveopens", "tcpinerrs", "tcpattemptfails", "tcpretranssegs", "tcpestabresets", }; String udpFields[] = { "udpindatagrams", "udpoutdatagrams", "udpinerrors", "udpnoports", }; String icmpFields[] = { "icmpinmsgs", "icmpinerrors", "icmpindestunreachs", }; static final int NUM_FIELD_COLUMNS = 2; // UI Controls JLabel ipLabels[]; JLabel tcpLabels[]; JLabel udpLabels[]; JLabel icmpLabels[]; /** * Basic constructor. Sets up the tree view and the edit panel. */ public NetworkStatisticsView() throws Exception { super(false); setIncludeStateFields(true); setIncludeSettingsFields(false); // create the KvpNode and the change listener viewStateTree = new KvpNode(); stateChangeListener = new DeviceChangeListener() { public void deviceChanged(DeviceChangeEvent e) { refreshViewControls(); } }; // Create the panel that will hold the view controls content = new GridContentPanel(this.getName(),2); int fieldColumn = 0; boolean endRow = false; // IP controls content.addHeadingBar("ipStatisticsHeading"); ipLabels = new JLabel[ipFields.length]; for (int i=0; i