summaryrefslogtreecommitdiffstats
path: root/data/mnet/Common/Java/AlarmApplet
diff options
context:
space:
mode:
Diffstat (limited to 'data/mnet/Common/Java/AlarmApplet')
-rw-r--r--data/mnet/Common/Java/AlarmApplet/Alarm.java102
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java139
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java139
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java53
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java221
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java34
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java126
-rw-r--r--data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java469
-rw-r--r--data/mnet/Common/Java/AlarmApplet/FilterFrame.java337
-rw-r--r--data/mnet/Common/Java/AlarmApplet/FilterObject.java35
-rw-r--r--data/mnet/Common/Java/AlarmApplet/Makefile41
-rw-r--r--data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile40
12 files changed, 1736 insertions, 0 deletions
diff --git a/data/mnet/Common/Java/AlarmApplet/Alarm.java b/data/mnet/Common/Java/AlarmApplet/Alarm.java
new file mode 100644
index 0000000..cdf4b61
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/Alarm.java
@@ -0,0 +1,102 @@
+
+
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.String;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.net.UnknownHostException;
+import com.jetcell.MibWM.*;
+import java.net.*;
+
+
+public class Alarm{
+ public AlarmPanel alarmPanel = null;
+ JFrame f = null;
+ AlarmTCPThread commObj = null;
+ FilterFrame filterFrame = null;
+ public final static int AM_APPLET_PORT2 = 11798;
+ JPanel jpanel = null;
+
+ // Shrinivas 23rd Apr 01
+ public Alarm(String viperbaseIp, final String vipercellIp){
+ // Shrinivas end
+ JButton setFilterButton = new JButton("Set Filter");
+ final Dimension d = new JFrame().getToolkit().getScreenSize();
+ if (f == null){
+ alarmPanel = new AlarmPanel(viperbaseIp);
+ jpanel = alarmPanel.createPanel();
+ alarmPanel.setViperCellIp(vipercellIp);//passing on viperCellIp to panel
+ JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ southPanel.add(setFilterButton);
+
+ f = new JFrame("Alarm List for source: "+vipercellIp);
+ // Shrinivas 23rd Apr 01
+ f.addWindowListener(new WindowAdapter(){
+ public void windowClosing(WindowEvent evt){
+ AlarmStatusTable.removeAlarmSrcIp(vipercellIp);
+ destroy();
+ }
+ });
+ // Shrinivas end
+ if(Util.applet == null){
+ f.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ f.setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+
+ f.getContentPane().setLayout(new BorderLayout());
+ f.getContentPane().add(southPanel,BorderLayout.SOUTH);
+ f.getContentPane().add(jpanel,BorderLayout.CENTER);
+ f.setBounds(0,0, 720,400);
+ f.setLocation(d.width/5,d.height/5);
+ f.setVisible(true);
+ }
+ else
+ f.setVisible(true);
+
+ if (commObj == null)
+ commObj = new AlarmTCPThread(viperbaseIp, AM_APPLET_PORT2);
+ commObj.startReadThread(alarmPanel, vipercellIp, true);
+
+ setFilterButton.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ AlarmStatusApplet.logDM("Launch filter screen");
+ filterFrame = new FilterFrame(alarmPanel);
+ filterFrame.setLocation(d.width/4,d.width/5);
+ if(Util.applet == null){
+ filterFrame.setTitle("Filter for user : " + AlarmTCPThread.user.toUpperCase());
+ }
+ else{
+ filterFrame.setTitle("Filter Screen");
+ }
+ filterFrame.setResizable(false);
+ filterFrame.setVisible(true);
+ }
+ });
+
+ }
+
+ public void start(String vipercellIp){
+ f.setTitle("Alarm List for source: "+vipercellIp);
+ f.setVisible(true);
+ alarmPanel.setViperCellIp(vipercellIp);//passing on viperCellIp to panel
+ commObj.startReadThread(alarmPanel, vipercellIp, false);
+ }
+
+ public void destroy(){
+ System.out.println("Destroy method has been called");
+ commObj.finishReadThread();
+ }
+}
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java
new file mode 100644
index 0000000..cd3af38
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusApplet.java
@@ -0,0 +1,139 @@
+/*
+ * AlarmStatusApplet.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+import com.jetcell.MibWM.*;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.Calendar;
+import java.lang.String;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;import java.net.*;
+import java.net.UnknownHostException;
+
+public class AlarmStatusApplet extends JApplet{
+
+ public static String ip = null;
+ public static int port = 11798; /*11800;*/
+ AlarmStatusPanel alarmPanel = null;
+ JFrame f = null;
+ static AlarmTCPThread commObj = null;
+
+ public static boolean isDebug = false;
+
+ public void init(){
+ Util.applet = this;
+ String newin = getParameter("NEWWINDOW");
+ ip = getParameter("HOST");
+ port = Integer.parseInt(getParameter("PORT"));
+
+ createUIPanel(newin);
+ }
+ // changes by Shrinivas : the code under this method were under the above init() method
+ // earlier. Function split was done so that the code could run both as an applet and an application
+ protected void createUIPanel(String newin){
+ alarmPanel = new AlarmStatusPanel();
+ if (f != null){
+ f.setVisible(true);
+ }
+ else {
+ if (newin != null){
+ System.out.println("NEWWINDOW VALUE = " +newin);
+ if(newin.equals("FALSE") || newin.equals("false")){
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(alarmPanel.createPanel(this),BorderLayout.CENTER);
+ }
+ else {
+ f = new JFrame("Alarm Status List for " + ip);
+ f.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ f.getContentPane().setLayout(new BorderLayout());
+ f.getContentPane().add(alarmPanel.createPanel(this));
+ f.setBounds(0,0, 720,400);
+ f.setVisible(true);
+ }
+ }
+ else {
+ System.out.println("Please set NEWWINDOW parameter to TRUE or FALSE");
+ System.out.println("Assuming - no new window");
+ getContentPane().setLayout(new BorderLayout());
+ getContentPane().add(alarmPanel.createPanel(this),BorderLayout.CENTER);
+ }
+ }
+
+ commObj = new AlarmTCPThread(ip, port);
+ commObj.startReadThread(alarmPanel);
+ }
+
+ public void start(){
+ System.out.println("Applet started");
+ }
+
+ public void stop(){
+ System.out.println("Applet stopped");
+ if (commObj != null){
+ commObj.finishReadThread();
+ commObj = null;
+ }
+ }
+
+ public void destroy(){
+ System.out.println("Destroy method has been called");
+ }
+
+ public void sendRemoveReq(AlarmStatusData data){
+ commObj.sendRemoveReq(data);
+ }
+
+ public void sendUpdateReq(){
+ commObj.sendUpdateReq();
+ }
+
+ public static void logDM(String message){
+ if(isDebug){
+ System.out.println(message);
+ }
+ }
+
+ public static void stopAPM1(){
+ if(commObj != null)
+ commObj.finishReadThread();
+ }
+
+ public static void startAPM1(String ipStr,boolean debug,String user){
+
+ isDebug = debug;
+ final JFrame frame = new JFrame();
+
+ try {
+ InetAddress.getByName(ipStr);
+ }
+ catch (UnknownHostException ex) {
+ JOptionPane.showMessageDialog(frame,"Invalid Host ID:","Error",JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ ip = ipStr;
+ final JApplet applet = new AlarmStatusApplet();
+ ((AlarmStatusApplet)applet).createUIPanel("false");
+ AlarmTCPThread.user = user;
+ frame.setContentPane(applet.getContentPane());
+ frame.setBounds(0,0, 720,400);
+ frame.setTitle("Alarm Status List for " + ip);
+ frame.setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ Dimension d = new JFrame().getToolkit().getScreenSize();
+ frame.setLocation(d.width/10,d.height/10);
+ frame.setVisible(true);
+ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosed(WindowEvent e){
+ applet.stop();
+ }
+ });
+
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java
new file mode 100644
index 0000000..f989f88
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusData.java
@@ -0,0 +1,139 @@
+/*
+ * AlarmStatusData.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+import java.util.StringTokenizer;
+
+public class AlarmStatusData
+{
+ final static byte ALARM_SRC_TYPE_VC = (byte)128;
+ final static byte ALARM_SRC_TYPE_VB = (byte)129;
+
+ String source_type;
+ String source_ip;
+ String source_name;
+ String critical;
+ String major;
+ String minor;
+
+ public AlarmStatusData( String source_type, String source_ip, String source_name,
+ String critical, String major, String minor)
+ {
+ this.source_type = source_type;
+ this.source_ip = source_ip;
+ this.source_name = source_name;
+ this.critical = critical;
+ this.major = major;
+ this.minor = minor;
+ }
+
+ public AlarmStatusData(byte[] msg){
+ int i = AlarmTCPThread.ALARM_HEAD_SRC_TYPE_POS;
+ extractSrcType (msg, i);
+ i = AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ extractSrcIP (msg, i);
+ i += AlarmTCPThread.ALARM_MSG_SRC_IP_SIZE;
+ extractSrcName (msg, i);
+ i += AlarmTCPThread.ALARM_MSG_SRC_NAME_SIZE;
+ extractCriCount(msg, i);
+ i += AlarmTCPThread.ALARM_MSG_CRITICAL_SIZE;
+ extractMajCount(msg, i);
+ i += AlarmTCPThread.ALARM_MSG_MAJOR_SIZE;
+ extractMinCount(msg, i);
+
+ }
+
+ public byte[] getSrcIPByte(){
+ byte[] ip = new byte[AlarmTCPThread.ALARM_MSG_SRC_IP_SIZE];
+
+ StringTokenizer st = new StringTokenizer(source_ip, ".");
+ if(st.countTokens() != 4){
+ System.out.println("Error on getSrcIPByte: ip token count");
+ return null;
+ }
+ else{
+ int i = 0;
+ while (st.hasMoreTokens()) {
+ ip[i++] = (byte) Integer.parseInt(st.nextToken());
+ }
+ }
+ return ip;
+ }
+
+ public byte getSrcTypeByte(){
+ byte type = (byte)0xFF;
+ if(source_type.equals("ViperCell"))
+ type = AlarmStatusData.ALARM_SRC_TYPE_VC;
+ else if(source_type.equals("ViperBase"))
+ type = AlarmStatusData.ALARM_SRC_TYPE_VB;
+ return type;
+ }
+
+ public int extractSrcType(byte[] msg, int i){
+ switch(msg[i]){
+ case AlarmStatusData.ALARM_SRC_TYPE_VC:
+ this.source_type = new String("ViperCell");
+ break;
+ case AlarmStatusData.ALARM_SRC_TYPE_VB:
+ this.source_type = new String("ViperBase");
+ break;
+ default:
+ this.source_type = new String("Unknown");
+ }
+ return (int)msg[i];
+ }
+
+ public void extractSrcIP(byte[] msg, int i) {
+ int h1 = (int)msg[i] & 0x00FF;
+ int h2 = (int)msg[i+1] & 0x00FF;
+ int h3 = (int)msg[i+2] & 0x00FF;
+ int h4 = (int)msg[i+3] & 0x00FF;
+ this.source_ip = "" + (new Integer(h1)).toString() +
+ "." + (new Integer(h2)).toString() +
+ "." + (new Integer(h3)).toString() +
+ "." + (new Integer(h4)).toString();
+ }
+
+ public void extractSrcName(byte[] msg, int i){
+ byte[] name = new byte[AlarmTCPThread.ALARM_MSG_SRC_NAME_SIZE];
+ for(int j=0; j<AlarmTCPThread.ALARM_MSG_SRC_NAME_SIZE; j++)
+ name[j] = msg[i+j];
+ this.source_name = (new String(name)).trim();
+ }
+
+ public void extractCriCount(byte[] msg, int i){
+ this.critical = (new Integer((int)msg[i] & 0x00FF)).toString();
+ }
+
+ public void extractMajCount(byte[] msg, int i){
+ this.major = (new Integer((int)msg[i] & 0x00FF)).toString();
+ }
+
+ public void extractMinCount(byte[] msg, int i){
+ this.minor = (new Integer((int)msg[i] & 0x00FF)).toString();
+ }
+
+ public void dump(){
+ System.out.println("*****************************");
+ System.out.println("Source Type : " + source_type);
+ System.out.println("Source IP : " + source_ip);
+ System.out.println("Source Name : " + source_name);
+ System.out.println("Critical Count: " + critical);
+ System.out.println("Major Count : " + major);
+ System.out.println("Minor Count : " + minor);
+ System.out.println("*****************************");
+ }
+
+ public static void main(String[] argv){
+ byte[] msg = { (byte)128, 1, 0, 48, 10, 1, 2, (byte)250,
+ (byte)'V', (byte)'i', (byte)'p', (byte)'e', (byte)'r', (byte)'1', 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 };
+ AlarmStatusData data = new AlarmStatusData(msg);
+ data.dump();
+ }
+
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java
new file mode 100644
index 0000000..c4c0efd
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusPanel.java
@@ -0,0 +1,53 @@
+/*
+ * AlarmStatusPanel.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+import java.net.UnknownHostException;
+import java.awt.*;
+import java.util.*;
+
+public class AlarmStatusPanel{
+ static String host = null;
+ AlarmStatusTable alarmStatusTable = null;
+ JLabel statLabel = null;
+
+ public AlarmStatusPanel(){
+ }
+
+ public JPanel createPanel(JApplet applet){
+ JPanel panel = new JPanel();
+ panel.setBorder(new EmptyBorder(5, 5, 5, 5));
+ panel.setLayout(new BorderLayout());
+ AlarmStatusTableModel model = new AlarmStatusTableModel();
+ alarmStatusTable = new AlarmStatusTable(model, applet);
+ JScrollPane scroller= new JScrollPane( alarmStatusTable,
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED ,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ panel.add(scroller, BorderLayout.CENTER);
+ statLabel = new JLabel("Server Status");
+ panel.add(statLabel, BorderLayout.SOUTH);
+ return panel;
+ }
+
+ public void addEvent(AlarmStatusData alarm){
+ alarmStatusTable.setAlarmStatusData(alarm);
+ }
+
+ public void dispStatus(String status){
+ statLabel.setText(status);
+ }
+
+ public void clearEvents() {
+ alarmStatusTable.RemoveAll();
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java
new file mode 100644
index 0000000..ec23f91
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTable.java
@@ -0,0 +1,221 @@
+/*
+ * AlarmStatusTable
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.JTable;
+import javax.swing.table.*;
+import javax.swing.event.*;
+import java.util.Hashtable;
+import java.awt.*;
+import java.io.*;
+import java.net.*;
+import java.applet.*;
+import com.jetcell.MibWM.Util;
+// Shrinivas 23rd Apr 01
+import java.util.*;
+// Shrinivas end
+public class AlarmStatusTable extends JTable {
+
+ DefaultTableModel model;
+ JPopupMenu popupMenu = null;
+ JApplet applet = null;
+ // Shrinivas 23rd Apr 01
+ //Alarm alarm = null;
+ static Vector alarmSrcIpList = null;
+ // Shrinivas end
+ final int [] columnMinWidth = { 30, 60, 30, 30, 30, 0};
+ final int [] columnMaxWidth = {200, 150, 150, 150, 150, 0};
+ Hashtable alarmHashTable = null;
+
+ public AlarmStatusTable(DefaultTableModel model, JApplet applet){
+ super(model);
+ // Shrinivas 23rd Apr 01
+ alarmSrcIpList = new Vector(8,3);
+ // Shrinivas end
+ popupMenu = AlarmStatusTablePopupMenu.getPopupMenu();
+ this.applet = applet;
+
+ addMouseListener(new MouseHandler(this));
+ alarmHashTable = new Hashtable();
+ for (int i=0; i < model.getColumnCount(); i++ )
+ setColumnWidth(i, columnMinWidth[i], columnMaxWidth[i]);
+ TableColumnModel colModel = getColumnModel();
+ colModel.getColumn(AlarmStatusTableModel.CRITICAL).setCellRenderer(new CountCellRenderer());
+ colModel.getColumn(AlarmStatusTableModel.MAJOR).setCellRenderer(new CountCellRenderer());
+ colModel.getColumn(AlarmStatusTableModel.MINOR).setCellRenderer(new CountCellRenderer());
+
+ setRowSelectionAllowed(true);
+ setColumnSelectionAllowed(false);
+ setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
+ setShowGrid(true);
+ setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
+ getTableHeader().setReorderingAllowed(false);
+ }
+
+ public void setColumnWidth(int columnIndex, int minWidth, int maxWidth){
+ TableColumn column = (TableColumn)getColumn(getColumnName(columnIndex));
+ column.setMinWidth(minWidth);
+ column.setMaxWidth(maxWidth);
+ }
+
+ public boolean isCellEditable(int i, int j){
+ return false;
+ }
+
+ public AlarmStatusData getAlarmStatusData(String source_ip){
+ if (alarmHashTable != null)
+ return (AlarmStatusData) alarmHashTable.get(source_ip);
+ return null;
+ }
+
+ public int rowAlarmStatusData(String source_ip){
+ int row_count = ((DefaultTableModel)getModel()).getRowCount();
+ for(int i=0; i<row_count; i++){
+ String ip = (String)getValueAt(i, AlarmStatusTableModel.SRC_IP);
+ if(ip.equals(source_ip))
+ return i;
+ }
+ return -1;
+ }
+
+ public void setAlarmStatusData(AlarmStatusData alarm){
+ int row_index;
+ if (getAlarmStatusData(alarm.source_ip) != null){
+ alarmHashTable.remove(alarm.source_ip);
+ alarmHashTable.put(alarm.source_ip, alarm);
+ row_index = rowAlarmStatusData(alarm.source_ip);
+ setValueAt(alarm.source_ip, row_index, AlarmStatusTableModel.SRC_IP);
+ setValueAt(alarm.source_name, row_index, AlarmStatusTableModel.SRC_NAME);
+ setValueAt(alarm.critical, row_index, AlarmStatusTableModel.CRITICAL);
+ setValueAt(alarm.major, row_index, AlarmStatusTableModel.MAJOR);
+ setValueAt(alarm.minor, row_index, AlarmStatusTableModel.MINOR);
+ }
+ else{
+ alarmHashTable.put(alarm.source_ip, alarm);
+ row_index = ((DefaultTableModel)getModel()).getRowCount();
+ Object [] row = new Object[AlarmStatusTableModel.NUM_COL];
+ row[AlarmStatusTableModel.SRC_IP] = alarm.source_ip;
+ row[AlarmStatusTableModel.SRC_NAME] = alarm.source_name;
+ row[AlarmStatusTableModel.CRITICAL] = alarm.critical;
+ row[AlarmStatusTableModel.MAJOR] = alarm.major;
+ row[AlarmStatusTableModel.MINOR] = alarm.minor;
+ ((DefaultTableModel)getModel()).insertRow(row_index, row);
+ }
+ }
+
+ // Shrinivas 23rd Apr 01
+ public static void removeAlarmSrcIp(String ip){
+ alarmSrcIpList.remove(ip);
+ }
+ // Shrinivas end
+ public void OpenEvent(){
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1){
+ System.out.println("Open Event: no selection made");
+ return;
+ }
+ String ip = (String)getValueAt(selectedRow, AlarmStatusTableModel.SRC_IP);
+ //System.out.println("Open Event: " +ip);
+ // Shrinivas 23rd Apr 01
+ if(alarmSrcIpList.contains(ip)){
+ return;
+ }
+ else{
+ alarmSrcIpList.add(ip);
+ }
+ Alarm alarmList = new Alarm(AlarmStatusApplet.ip, ip);
+ /*if (alarm == null){
+ alarm = new Alarm(AlarmStatusApplet.ip, ip);
+ }
+ else
+ alarm.start(ip); */
+ // Shrinivas end
+ } // end OpenEvent()
+
+ public void Remove(){
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1){
+ System.out.println("Remove Event: no selection made");
+ return;
+ }
+ String ip = (String)getValueAt(selectedRow, AlarmStatusTableModel.SRC_IP);
+ System.out.println("Remove Event: " +ip);
+ AlarmStatusData data = getAlarmStatusData(ip);
+ if(data == null){
+ System.out.println("Remove Event: data not found");
+ }
+ else{
+ alarmHashTable.remove(ip);
+ int row_index = rowAlarmStatusData(ip);
+ ((DefaultTableModel)getModel()).removeRow(row_index);
+ }
+ ((AlarmStatusApplet)applet).sendRemoveReq(data);
+ }
+
+ public void RemoveAll(){
+ int row_count = ((DefaultTableModel)getModel()).getRowCount();
+ while(row_count != 0){
+ String ip = (String)getValueAt(0, AlarmStatusTableModel.SRC_IP);
+ alarmHashTable.remove(ip);
+ ((DefaultTableModel)getModel()).removeRow(0);
+ row_count = ((DefaultTableModel)getModel()).getRowCount();
+ }
+ }
+
+ public void Refresh(){
+ ((AlarmStatusApplet)applet).sendUpdateReq();
+ }
+
+
+ class MouseHandler extends MouseAdapter{
+ public AlarmStatusTable table;
+
+ public MouseHandler(AlarmStatusTable table){
+ this.table = table;
+ }
+
+ public void mouseReleased(MouseEvent e){
+ if (e.getClickCount() == 2 ){
+ OpenEvent();
+ }
+
+ if ( e.isPopupTrigger()){
+ // changes by Shrinivas on 17th Oct 2k
+ System.out.println("Event : Popup menu");
+ int selectedRow = rowAtPoint(new Point(e.getX(),e.getY()));
+ setRowSelectionInterval(selectedRow,selectedRow);
+ // end of changes
+ popupMenu.show(table, e.getX(), e.getY());
+ }
+ }
+ }
+
+ class CountCellRenderer extends JLabel implements TableCellRenderer{
+ Font defaultFont = new Font("Helvetica", Font.BOLD,12);
+ Font empFont = new Font("TimesRoman", Font.BOLD,18);
+
+ public CountCellRenderer(){
+ super("Unknown");
+ setHorizontalAlignment(JLabel.CENTER);
+ }
+
+ public Component getTableCellRendererComponent( JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column ){
+ setText((String)value);
+
+ return this;
+ }
+ }
+
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java
new file mode 100644
index 0000000..85aa726
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTableModel.java
@@ -0,0 +1,34 @@
+/*
+ * AlarmStatusTableModel.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+
+import javax.swing.*;
+import javax.swing.table.*;
+import java.awt.event.*;
+import java.awt.*;
+import java.util.*;
+
+public class AlarmStatusTableModel extends DefaultTableModel
+
+
+{
+ final static int SRC_IP = 0;
+ final static int SRC_NAME = 1;
+ final static int CRITICAL = 2;
+ final static int MAJOR = 3;
+ final static int MINOR = 4;
+
+ static String ColumnTitle[] = {"Source IP", "Source Name", "Critical Alarm", "Major Alarm", "Minor Alarm"};
+ final static int NUM_COL = ColumnTitle.length;
+
+ public AlarmStatusTableModel()
+ {
+ super(ColumnTitle, 0);
+ }
+}
+
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java
new file mode 100644
index 0000000..e91f3f4
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmStatusTablePopupMenu.java
@@ -0,0 +1,126 @@
+/*
+ * AlarmStatusTablePopupMenu.java
+ * Kevin Lim
+ * 03/20/00
+ */
+
+
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+
+public class AlarmStatusTablePopupMenu extends JPopupMenu implements ActionListener{
+ static JMenuItem openMenuItem;
+ static JMenuItem removeMenuItem;
+ static JMenuItem refreshMenuItem;
+ static boolean iconsLoaded = false;
+ protected static AlarmStatusTablePopupMenu popupMenu = new AlarmStatusTablePopupMenu();
+ static AlarmStatusTable invoker ;
+ static int x;
+ static int y;
+
+
+ /**
+ * You cannot instantiate this class. Use getPopupMenu() to get
+ * a shared instance!
+ */
+ protected AlarmStatusTablePopupMenu(){
+
+ openMenuItem = new JMenuItem(new String("Open Alarm"));
+ openMenuItem.setMnemonic('O');
+ openMenuItem.registerKeyboardAction(null, KeyStroke.getKeyStroke('O', Event.ALT_MASK, false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ openMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ openMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ openMenuItem.addActionListener(this);
+ add(openMenuItem);
+
+ removeMenuItem = new JMenuItem(new String("Remove"));
+ removeMenuItem.setMnemonic('m');
+ removeMenuItem.registerKeyboardAction(null, KeyStroke.getKeyStroke('m', Event.ALT_MASK, false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ removeMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ removeMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ removeMenuItem.addActionListener(this);
+ add(removeMenuItem);
+
+ // Shrinivas 20th Apr 01
+ /*refreshMenuItem = new JMenuItem(new String("Refresh"));
+ refreshMenuItem.setMnemonic('R');
+ refreshMenuItem.registerKeyboardAction(null, KeyStroke.getKeyStroke('R', Event.ALT_MASK, false),
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+ refreshMenuItem.setHorizontalTextPosition(SwingConstants.RIGHT);
+ refreshMenuItem.setHorizontalAlignment(SwingConstants.LEFT);
+ refreshMenuItem.addActionListener(this);
+ add(refreshMenuItem);*/
+ // Shrinivas end
+ }
+
+
+ /**
+ * returns shared instance of popupMenu
+ */
+ public static AlarmStatusTablePopupMenu getPopupMenu(){
+ return popupMenu;
+ }
+
+
+ /**
+ * update to use difference icons later!
+ */
+ void loadIcons(){
+ }
+
+
+ /**
+ * update to use shared clipboard access later
+ */
+ public void actionPerformed(ActionEvent e){
+ Object obj = e.getSource();
+ String selection = null;
+
+ if (obj == openMenuItem) {
+ invoker.OpenEvent();
+ }
+ else if (obj == removeMenuItem) {
+ invoker.Remove();
+ }
+ else if (obj == refreshMenuItem) {
+ invoker.Refresh();
+ }
+ }
+
+
+ /**
+ * force JTable only later
+ */
+ public void show(Component c, int x, int y){
+ invoker = (AlarmStatusTable)c;
+
+ Point p = new Point(x,y);
+ int row = invoker.rowAtPoint(p);
+ int col = invoker.columnAtPoint(p);
+
+ this.x = x;
+ this.y = y;
+ super.show(c,x,y);
+ }
+
+
+ void disableMenu() {
+ openMenuItem.setEnabled(false);
+ removeMenuItem.setEnabled(false);
+ refreshMenuItem.setEnabled(false);
+ }
+
+
+ void enableMenu(){
+ openMenuItem.setEnabled(true);
+ removeMenuItem.setEnabled(true);
+ refreshMenuItem.setEnabled(true);
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java b/data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java
new file mode 100644
index 0000000..3a4ed0d
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/AlarmTCPThread.java
@@ -0,0 +1,469 @@
+
+/*
+ * AlarmTCPThread.java
+ * Kevin Lim
+ * 03/21/00
+ */
+
+
+
+import java.net.*;
+import java.io.*;
+import javax.swing.*;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.event.*;
+import com.jetcell.MibWM.*;
+
+public class AlarmTCPThread extends Thread{
+
+ static private boolean FILTER = false;
+ private String filterVipercellIp = null;
+
+ static final int MAX_IN_BUF_SIZE = 4096;
+ static final int MAX_MSG_BUF_SIZE = 1024;
+ static final int ALARM_HEAD_SRC_TYPE_POS = 0;
+ static final int ALARM_HEAD_MSG_TYPE_POS = 1;
+ static final int ALARM_HEAD_MSG_SIZE_POS = 2;
+ static final int ALARM_MSG_HEADER_LEN = 4;
+ static final int ALARM_MSG_SRC_IP_SIZE = 4;
+ static final int ALARM_MSG_SRC_NAME_SIZE = 41;
+ static final int ALARM_MSG_CRITICAL_SIZE = 1;
+ static final int ALARM_MSG_MAJOR_SIZE = 1;
+ static final int ALARM_MSG_MINOR_SIZE = 1;
+
+ static final byte ALARM_MSG_TYPE_UPDATE_REQ = 1;
+ static final byte ALARM_MSG_TYPE_UPDATE_RSP = 2;
+ static final byte ALARM_MSG_TYPE_REMOVE_REQ = 3;
+ static final byte ALARM_MSG_TYPE_EVENT_REQ = 4;
+ static final byte ALARM_MSG_TYPE_EVENT_RSP = 5;
+ static final byte ALARM_MSG_TYPE_ACK = 6;
+
+ static final byte ALARM_MSG_SRC_TYPE_APPLET = (byte)0xFF;
+
+static final int MAX_MODULE_SPECIC_ALARM = 0xFFFF;
+ static final int ALARM_CRITICAL_START_POINT = 0x0001;
+ static final int ALARM_MAJOR_START_POINT = 0x0100;
+ static final int ALARM_MINOR_START_POINT = 0x0800;
+ static final int ALARM_INFO_START_POINT = 0x1000;
+ static final int ALARM_CRITICAL = 0;
+ static final int ALARM_MAJOR = 1;
+ static final int ALARM_MINOR = 2;
+ static final int ALARM_INFO = 3;
+ public static String user = null;
+
+ Socket socket;
+ String host;
+ int port;
+ int appletVipercellIp = 0;
+ int msgVipercellIp = 0;
+ AlarmStatusPanel panel = null;
+ AlarmPanel alarmPanel = null;
+ AlarmData alarmData = null;
+ BufferedInputStream in = null;
+ InputStreamReader isr = null;
+ public static BufferedOutputStream out = null;
+ boolean running;
+
+ public AlarmTCPThread(String host, int port) {
+ this.host = host;
+ this.port = port;
+ System.out.println("Connecting to the Server " + host + " at port " + port);
+ try {
+ socket = new Socket(host, port);
+ } catch(IOException e) {
+ System.out.println("Could not connect to the Server");
+ socket = null;
+ }
+ if(socket != null){
+ try {
+ in = new BufferedInputStream(socket.getInputStream()); // reading is done to byte arrays
+ out = new BufferedOutputStream(socket.getOutputStream()); // writing is done from byte arrays
+ out.flush();
+ } catch(IOException e) {
+ System.out.println("IO exception in AlarmTCPThread: ");
+ close_socket();
+ }
+ }
+ }
+
+ public void sendRemoveReq(AlarmStatusData data)
+ {
+ if(out == null) return;
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_REMOVE_REQ,
+ 0, 5, 0, 0, 0, 0, 0};
+ int i = AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ byte[] ip_addr = data.getSrcIPByte();
+ if(ip_addr == null){
+ System.out.println("Error on sendRemoveReq: getSrcIPByte failed");
+ return;
+ }
+ for(int j=0; j<AlarmTCPThread.ALARM_MSG_SRC_IP_SIZE; j++){
+ msg[i++] = ip_addr[j];
+ System.out.println("ip_addr "+ip_addr[j]);
+ }
+ byte type = data.getSrcTypeByte();
+ if(type == (byte)0xFF){
+ System.out.println("Error on sendRemoveReq: getSrcTypeByte returned unknown");
+ return;
+ }
+ msg[i++] = type;
+ out.write(msg, 0, i);
+ out.flush();
+ } catch(IOException ioe) {
+ System.out.println("IO exception in AlarmTCPThread:send "+ioe);
+ }
+ }
+
+ public void sendUpdateReq(){
+ if(out == null) return;
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_UPDATE_REQ,
+ 0, 0};
+ out.write(msg, 0, ALARM_MSG_HEADER_LEN);
+ out.flush();
+ } catch(IOException ioe) {
+ System.out.println("IO exception in AlarmTCPThread:send "+ioe);
+ }
+ }
+
+ // send alarm event msg update request to AlarmServer
+ static public void sendEventReq(String vipercellIp){
+ int index = 0;
+ String tmpStr = vipercellIp;
+ String valueStr;
+ Short [] ip = new Short[4];
+ if (out == null)
+ return;
+
+ // converting IP string into 4 octets
+ for (int i = 0; i < 4; i++){
+ index = tmpStr.indexOf(".");
+ valueStr = i == 3 ? tmpStr : tmpStr.substring(0, index);
+ ip[i] = new Short(valueStr);
+ tmpStr = tmpStr.substring(index + 1);
+ }
+
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_EVENT_REQ,
+ 0x00, 0x04, // length of data
+ ip[0].byteValue(), ip[1].byteValue(), ip[2].byteValue(),
+ ip[3].byteValue()};
+ out.write(msg, 0, ALARM_MSG_HEADER_LEN + 4);
+ out.flush();
+ }
+ catch(IOException ioe) {
+ System.out.println("IO exception in AlarmTCPThread:send "+ioe);
+ }
+ FILTER = false;
+ }
+
+ public static void sendAck(String srcIp,String alarmId,String recordNum){
+ int index = 0;
+ String tmpStr = srcIp;
+ String valueStr;
+ Short [] ip = new Short[4];
+
+ byte aid[] = new byte[4];
+ byte rec[] = new byte[4];
+
+
+ // converting IP string into 4 octets
+ for (int i = 0; i < 4; i++){
+ index = tmpStr.indexOf(".");
+ valueStr = i == 3 ? tmpStr : tmpStr.substring(0, index);
+ ip[i] = new Short(valueStr);
+ tmpStr = tmpStr.substring(index + 1);
+ }
+
+ // converting alarmID to bytes
+ aid = AlarmTCPThread.extractBytes(alarmId);
+ rec = AlarmTCPThread.extractBytes(recordNum);
+
+ try {
+ byte[] msg = {ALARM_MSG_SRC_TYPE_APPLET,
+ ALARM_MSG_TYPE_ACK,
+ 0x00, 0x0c, // length of data
+ ip[0].byteValue(), ip[1].byteValue(), ip[2].byteValue(),
+ ip[3].byteValue(),
+ aid[3],aid[2],aid[1],aid[0],
+ rec[3],rec[2],rec[1],rec[0]};
+ out.write(msg, 0, msg.length);
+ out.flush();
+ }
+ catch(IOException ioe) {
+ AlarmStatusApplet.logDM("IO exception in AlarmTCPThread: ack "+ioe);
+ }
+ }
+
+ public static byte[] extractBytes(String s){
+
+ byte store[] = new byte[4];
+ int intValue = Integer.parseInt(s);
+
+ store[0] = (byte)(intValue & 0x000000ff);
+ store[1] = (byte)((intValue >> 8) & 0x000000ff);
+ store[2] = (byte)((intValue >> 16) & 0x000000ff);
+ store[3] = (byte)((intValue >> 24) & 0x000000ff);
+
+ return store;
+ }
+
+ public void alarmMsgHandler(byte[] msg) {
+ int index = AlarmTCPThread.ALARM_HEAD_MSG_TYPE_POS;
+ switch(msg[index]){
+ case ALARM_MSG_TYPE_UPDATE_RSP:
+ if (panel != null)
+ {
+ AlarmStatusData alarm = new AlarmStatusData(msg);
+ panel.addEvent(alarm);
+ }
+ break;
+ case ALARM_MSG_TYPE_EVENT_RSP:
+ if (alarmPanel != null)
+ {
+ try {
+ alarmData = new AlarmData(parseEventData(msg));
+ }
+ catch(Exception e) {}
+ if (appletVipercellIp == msgVipercellIp){
+ alarmPanel.addEvent(alarmData);
+ }
+ }
+ break;
+ default:
+ System.out.println("Unknown message received "+(int)msg[index]);
+ int size = 0x00FF & (int)msg[AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS];
+ size = (size << 8) | (0x00FF & (int)msg[AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS+1]);
+ size += AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ if(size > AlarmTCPThread.MAX_MSG_BUF_SIZE) size = AlarmTCPThread.MAX_MSG_BUF_SIZE;
+ for(int i=0; i<size; i++) System.out.print(" " + (int)(msg[i] & 0x00FF));
+ System.out.println(" ");
+ }
+ }
+
+ public void close_socket() {
+ if(socket != null){
+ try {
+ socket.close();
+ System.out.println("closing socket at third window level...");
+ }
+ catch(IOException e) {
+ System.out.println("Couldn't close socket " + e);
+ }
+ }
+ }
+
+ public void reconnect() {
+ boolean done = false;
+ while(!done){
+ try {
+ if (panel != null)
+ panel.dispStatus("Attempting to reconnect to the Server...");
+ socket = new Socket(host, port);
+ done = true;
+ if (panel != null)
+ panel.dispStatus("Server on-line");
+ }
+ catch(IOException e) {
+ if (panel != null)
+ panel.dispStatus("Server off-line");
+ }
+ try {
+ sleep(1000);
+ }
+ catch (InterruptedException ie) {
+ System.out.println(" Interrupted Excution = " + ie);
+ }
+ }
+ if(socket != null){
+ try {
+ in = new BufferedInputStream(socket.getInputStream()); // reading is done to byte arrays
+ out = new BufferedOutputStream(socket.getOutputStream()); // writing is done from byte arrays
+ out.flush();
+ if (panel != null) {
+ panel.clearEvents();
+ sendUpdateReq();
+ }
+ }
+ catch(IOException e) {
+ System.out.println("IO exception in AlarmTCPThread: ");
+ close_socket();
+ }
+ }
+ }
+
+ public void run() {
+ // Shrinivas 01 June 01
+ if(socket == null && running ) reconnect();
+ byte[] buf = new byte[AlarmTCPThread.MAX_IN_BUF_SIZE];
+ byte[] msg = new byte[AlarmTCPThread.MAX_MSG_BUF_SIZE];
+ running = true;
+ int readBytes;
+ int index;
+ int msg_size;
+ int header_size = AlarmTCPThread.ALARM_MSG_HEADER_LEN;
+ while(running){
+ try {
+ readBytes = in.read(buf, 0, AlarmTCPThread.MAX_IN_BUF_SIZE);
+ if(readBytes == -1){
+ System.out.println("End of stream reached!");
+ close_socket();
+ // Shrinivas 01 June 01'
+ if(running){
+ reconnect();
+ }
+ // Shrinivas end
+ }
+ index = 0;
+ while ((index + header_size) <= readBytes){ // while there are msg at least size of header
+ msg_size = 0x00FF & (int)buf[index+AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS];
+ msg_size = (msg_size << 8)
+ | (0x00FF & (int)buf[index+AlarmTCPThread.ALARM_HEAD_MSG_SIZE_POS+1]);
+ if((header_size + msg_size) <= (readBytes - index)){ // about to copy msg within valid range
+ for(int i=0; i<(header_size + msg_size); i++){
+ msg[i] = buf[index++];
+ }
+ AlarmStatusApplet.logDM("Received msg with length: " + msg_size);
+ alarmMsgHandler(msg);
+ }
+ else{
+ System.out.println("Length Err. Msg Length specified : "+msg_size);
+ System.out.println("Length Err. Bytes left in read buf: "+(readBytes - index));
+ index = readBytes; // finish while
+ }
+ }
+ }
+ catch(IOException e) {
+ close_socket();
+ if(running != false){
+ reconnect();
+ }
+ System.out.println("Stopping thread.");
+ }
+ }
+ }
+
+ public void startReadThread(AlarmStatusPanel panel){
+ this.panel = panel;
+ start();
+ panel.dispStatus("Server on-line");
+ sendUpdateReq();
+ }
+
+ public void startReadThread(AlarmPanel panel, String vipercellIp, boolean startThread){
+ alarmPanel = panel;
+ alarmPanel.removeAllEvents();
+ setAppletVipercellIp(vipercellIp);
+ if (startThread)
+ start();
+ this.filterVipercellIp = vipercellIp;
+ sendEventReq(vipercellIp);
+ }
+
+ public void finishReadThread(){
+ System.out.println("TCP thread is being shutdown");
+ running = false;
+ close_socket();
+ stop();
+ }
+
+ private void setAppletVipercellIp(String vipercellIp){
+ String valueStr;
+ Short octetVal;
+ String tmpStr = vipercellIp;
+ int index = 0;
+ appletVipercellIp = 0;
+ for (int i = 0; i < 4; i++)
+ {
+ index = tmpStr.indexOf(".");
+ valueStr = i == 3 ? tmpStr : tmpStr.substring(0, index);
+ if (i > 1) // we use only last two octets
+ {
+ octetVal = new Short(valueStr);
+ if (i == 2)
+ appletVipercellIp = octetVal.shortValue() << 8;
+ else
+ appletVipercellIp += octetVal.shortValue();
+ }
+ tmpStr = tmpStr.substring(index + 1);
+ }
+ }
+
+ private int extractNumber(byte[] msg, int pos){
+ return ((msg[pos] << 24 & 0xff000000) +
+ (msg[pos+1] << 16 & 0xff0000) +
+ (msg[pos+2] << 8 & 0xff00) +
+ (msg[pos+3] & 0xff));
+ }
+
+ private int extractIp(byte[] msg, int pos){
+ // for now, we are only extracting last 2 octets of an IP address
+ return((msg[pos+2] << 8 & 0xff00) + (msg[pos+3] & 0xff));
+ }
+
+ public String extractSrcIP(byte[] msg, int i){
+ int h1 = (int)msg[i] & 0x00FF;
+ int h2 = (int)msg[i+1] & 0x00FF;
+ int h3 = (int)msg[i+2] & 0x00FF;
+ int h4 = (int)msg[i+3] & 0x00FF;
+ String source_ip = "" + (new Integer(h1)).toString() +
+ "." + (new Integer(h2)).toString() +
+ "." + (new Integer(h3)).toString() +
+ "." + (new Integer(h4)).toString();
+
+ return source_ip;
+ }
+
+ private int getSeverity(int errorCode){
+ int severity;
+
+ if (errorCode == 0)
+ return ALARM_INFO;
+
+ int tmp = (errorCode & MAX_MODULE_SPECIC_ALARM);
+ if (tmp < ALARM_MAJOR_START_POINT)
+ {
+ severity = ALARM_CRITICAL;
+ } else if (tmp < ALARM_MINOR_START_POINT) {
+ severity = ALARM_MAJOR;
+ } else if (tmp < ALARM_INFO_START_POINT) {
+ severity = ALARM_MINOR;
+ } else {
+ severity = ALARM_INFO;
+ }
+ return severity;
+ }
+
+ private String parseEventData(byte[] msg) {
+ int id = extractNumber(msg, 4);
+ int code = extractNumber(msg, 8);
+ int severity = getSeverity(code);
+ int timestamp = extractNumber(msg, 12);
+ int srcIp = extractIp(msg, 16);
+
+ String srcIpString = extractSrcIP(msg, 16);
+
+ if (0 == appletVipercellIp){
+ appletVipercellIp = srcIp;
+ msgVipercellIp = srcIp;
+ }
+ else
+ msgVipercellIp = srcIp;
+ int srcModule = extractNumber(msg, 64);
+ int opt1 = extractNumber(msg, 68);
+ int opt2 = extractNumber(msg, 72);
+ int ack = extractNumber(msg,76);
+ int recNumber = extractNumber(msg,80);
+ String srcName = new String(msg, 20, 41);
+ srcName = srcName.trim();
+ String eventData = new String(id+"|"+timestamp+"|"+severity+"|"+srcModule+"|"+
+ srcName+"|"+code+"|"+opt1+"|"+opt2+"|"+srcIpString+"|"+ack+"|"+recNumber+"|");
+ return eventData;
+ }
+}
+
diff --git a/data/mnet/Common/Java/AlarmApplet/FilterFrame.java b/data/mnet/Common/Java/AlarmApplet/FilterFrame.java
new file mode 100644
index 0000000..c130ca4
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/FilterFrame.java
@@ -0,0 +1,337 @@
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+import javax.swing.UIManager.*;
+import java.net.*;
+
+import com.jetcell.MibWM.*;
+
+ public class FilterFrame extends JFrame{
+
+ final FilterFrame ff = this;
+
+ Container contentPane = null;
+ JPanel centerPanel = null;
+ JPanel southPanel = null;
+
+ // Labels
+ JLabel alarms = null;
+ JLabel time = null;
+ JLabel severity = null;
+ JLabel acknowledge = null;
+
+ // Combo Boxes
+ JComboBox alarmCombo = new JComboBox();
+ JComboBox timeCombo = new JComboBox();
+ JComboBox severityCombo = new JComboBox();
+ JComboBox acknowledgeCombo = new JComboBox();
+
+ // Reference to "AlarmPanel"
+ AlarmPanel alarmPanel = null;
+
+ public static FilterObject filterObject = null;
+ public static FilterObject tempFilterObject = null;
+
+ public FilterFrame(){
+ if(Util.applet == null){
+ setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+ }
+
+ public FilterFrame(AlarmPanel panel){
+ this.alarmPanel = panel;
+ if(tempFilterObject == null)
+ tempFilterObject = filterObject;
+ try{
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ }
+ catch(Exception ex){
+ System.out.println("Error setting Look and Feel for Filter frame");
+ }
+ if(Util.applet == null){
+ setIconImage(Toolkit.getDefaultToolkit().getImage("../Images/app_icon.gif"));
+ }
+ else{
+ String iconPath = Util.applet.getCodeBase().toString();
+ iconPath += "Images/app_icon.gif";
+ URL iconPathURL = null;
+ try{
+ iconPathURL = new URL(iconPath);
+ }
+ catch(MalformedURLException exc){
+ System.out.println("Bad URL.");
+ }
+ System.out.println(iconPathURL);
+ setIconImage(Toolkit.getDefaultToolkit().getImage(iconPathURL));
+ }
+ JButton ok = new JButton(" OK ");
+ JButton cancel = new JButton("CANCEL");
+ JButton saveDefault = new JButton("Save As Default");
+ contentPane = getContentPane();
+ getCenterPanel(tempFilterObject);
+ if(tempFilterObject != null){
+ mapFilterOnFrame(tempFilterObject);
+ }
+ southPanel = new JPanel();
+ southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
+ southPanel.add(ok);
+ southPanel.add(cancel);
+ if(Util.applet == null){
+ southPanel.add(saveDefault);
+ }
+
+ contentPane.add(centerPanel,BorderLayout.CENTER);
+ contentPane.add(southPanel,BorderLayout.SOUTH);
+ setSize(400,200);
+ addWindowListener(new windowListener());
+
+ ok.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ AlarmStatusApplet.logDM("Handle filter selection");
+ handleFilterSave();
+ }
+ });
+
+ cancel.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ dispose();
+ AlarmStatusApplet.logDM("No filter selection");
+ }
+ });
+
+ saveDefault.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent evt){
+ handleFilterSave();
+ filterObject = tempFilterObject;
+
+ }
+ });
+
+ }
+
+ public void handleFilterSave(){
+
+ // alarms selected
+ tempFilterObject = new FilterObject();
+ String alarms = (String)alarmCombo.getSelectedItem();
+ if(alarms.equals("All")){
+ tempFilterObject.NUM_ALARMS = FilterObject.NONE;
+ }
+ else{
+ try{
+ tempFilterObject.NUM_ALARMS = Integer.parseInt(alarms);
+ }
+ catch(NumberFormatException nfex){
+ JOptionPane.showMessageDialog(ff,"Bad Alarm number criteria.Default value assumed. ","Invalid number",JOptionPane.ERROR_MESSAGE);
+ tempFilterObject.NUM_ALARMS = FilterObject.NONE;
+ }
+ }
+
+ // time selected
+ int timeIndex = timeCombo.getSelectedIndex();
+
+ if(timeIndex == 1){
+ tempFilterObject.TIME = FilterObject.MIN_15;
+ }
+ else if(timeIndex == 2){
+ tempFilterObject.TIME = FilterObject.HR_1;
+ }
+ else if(timeIndex == 3){
+ tempFilterObject.TIME = FilterObject.HR_12;
+ }
+ else if(timeIndex == 4){
+ tempFilterObject.TIME = FilterObject.HR_24;
+ }
+ else
+ tempFilterObject.TIME = FilterObject.NONE;
+
+ // severity selected
+ int severityIndex = severityCombo.getSelectedIndex();
+
+ if(severityIndex == 1){
+ tempFilterObject.SEVERITY = FilterObject.CRITICAL;
+ }
+ else if(severityIndex == 2){
+ tempFilterObject.SEVERITY = FilterObject.MAJOR;
+ }
+ else if(severityIndex == 3){
+ tempFilterObject.SEVERITY = FilterObject.MINOR;
+ }
+ else
+ tempFilterObject.SEVERITY = FilterObject.NULL;
+
+ // acknowledge selected
+ int ackIndex = acknowledgeCombo.getSelectedIndex();
+ if(ackIndex == 1){
+ tempFilterObject.ACKNOWLEDGE = FilterObject.ALL_ACK;
+ }
+ else if(ackIndex == 2){
+ tempFilterObject.ACKNOWLEDGE = FilterObject.NO_ACK;
+ }
+ else
+ tempFilterObject.ACKNOWLEDGE = FilterObject.NONE;
+ this.dispose();
+ // Ananth
+ /*if (tempFilterObject.NUM_ALARMS == FilterObject.NONE &&
+ tempFilterObject.SEVERITY == FilterObject.NULL &&
+ tempFilterObject.TIME == FilterObject.NONE &&
+ tempFilterObject.ACKNOWLEDGE == FilterObject.NONE){
+ Util.setBorderTitle("Alarm List");
+ }
+ else{
+ Util.setBorderTitle("Alarm List (Filtered)");
+ }*/
+
+ if(alarmPanel!=null){
+ alarmPanel.handleFilterEvent(tempFilterObject);
+ alarmPanel.getAlarmTable().Refresh();
+ }
+ else{
+ filterObject = tempFilterObject;
+ }
+
+ }
+
+ private void mapFilterOnFrame(FilterObject tempFilterObject){
+
+ if(tempFilterObject.NUM_ALARMS != FilterObject.NONE){
+ String alarms = Integer.toString(tempFilterObject.NUM_ALARMS);
+ alarmCombo.getEditor().setItem(alarms);
+ }
+ else{
+ alarmCombo.setSelectedIndex(0);
+ }
+
+ if(tempFilterObject.TIME != FilterObject.NONE){
+
+ if(tempFilterObject.TIME == FilterObject.MIN_15)
+ timeCombo.setSelectedIndex(1);
+ else if(tempFilterObject.TIME == FilterObject.HR_1)
+ timeCombo.setSelectedIndex(2);
+ else if(tempFilterObject.TIME == FilterObject.HR_12)
+ timeCombo.setSelectedIndex(3);
+ else if(tempFilterObject.TIME == FilterObject.HR_24)
+ timeCombo.setSelectedIndex(4);
+ }
+ else{
+ timeCombo.setSelectedIndex(0);
+ }
+
+ if(!tempFilterObject.SEVERITY.equals(FilterObject.NULL)){
+
+ if(tempFilterObject.SEVERITY.equals(FilterObject.CRITICAL))
+ severityCombo.setSelectedIndex(1);
+ else if(tempFilterObject.SEVERITY.equals(FilterObject.MAJOR))
+ severityCombo.setSelectedIndex(2);
+ else if(tempFilterObject.SEVERITY.equals(FilterObject.MINOR))
+ severityCombo.setSelectedIndex(3);
+ }
+ else{
+ severityCombo.setSelectedIndex(0);
+ }
+
+ if(tempFilterObject.ACKNOWLEDGE != FilterObject.NONE){
+
+ if(tempFilterObject.ACKNOWLEDGE == FilterObject.ALL_ACK)
+ acknowledgeCombo.setSelectedIndex(1);
+ else if(tempFilterObject.ACKNOWLEDGE == FilterObject.NO_ACK)
+ acknowledgeCombo.setSelectedIndex(2);
+ }
+ else{
+ acknowledgeCombo.setSelectedIndex(0);
+ }
+ }
+
+ public JPanel getCenterPanel(FilterObject filterObj){
+
+ centerPanel = Util.makeBorderPanel("Filter Screen");
+ centerPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
+ alarms = new JLabel(" Alarms ");
+ alarms.setToolTipText("Check to set Alarm filter / Uncheck to set Default (All)");
+ time = new JLabel(" Time ");
+ time.setToolTipText("Check to set Time filter / Uncheck to set Default(All)");
+ severity = new JLabel(" Severity ");
+ severity.setToolTipText("Check to set Severity filter / Uncheck to set Default (All)");
+ acknowledge = new JLabel(" Acknowledge ");
+ acknowledge.setToolTipText("Check to set Acknowledge filter / Uncheck to set Default (All)");
+
+ // Alarms
+ alarmCombo.setPreferredSize(new Dimension(50,20));
+ alarmCombo.setEditable(true);
+ alarmCombo.addItem("All");
+ for(int i=1;i<=20;i++){
+ alarmCombo.addItem(Integer.toString(i));
+ }
+
+ // Time
+ timeCombo.addItem("All");
+ timeCombo.addItem("15 mins");
+ timeCombo.addItem("1 hour");
+ timeCombo.addItem("12 hours");
+ timeCombo.addItem("24 hours");
+
+ // Severity
+ severityCombo.addItem("All");
+ severityCombo.addItem("Critical");
+ severityCombo.addItem("Critical-Major");
+ severityCombo.addItem("Critical-Minor");
+
+ // Acknowledge
+ acknowledgeCombo.addItem("All");
+ acknowledgeCombo.addItem("Acknowledged");
+ acknowledgeCombo.addItem("Unacknowledged");
+
+ // Alarms
+ final JPanel p1 = new JPanel();
+ p1.setLayout(new FlowLayout(FlowLayout.LEFT));
+ p1.add(alarms);
+ p1.add(alarmCombo);
+ p1.add(acknowledge);
+ p1.add(acknowledgeCombo);
+
+
+ // Time
+ final JPanel p2 = new JPanel();
+ p2.setLayout(new FlowLayout(FlowLayout.LEFT));
+ p2.add(severity);
+ p2.add(severityCombo);
+ p2.add(time);
+ p2.add(timeCombo);
+
+ // Severity
+
+ // Acknowledge
+
+
+ centerPanel.add(p1);
+
+ centerPanel.add(p2);
+
+ if(filterObj != null){
+ mapFilterOnFrame(filterObj);
+ }
+ return centerPanel;
+ }
+
+
+ class windowListener extends WindowAdapter{
+ public void windowClosing(WindowEvent evt){
+ dispose();
+ AlarmStatusApplet.logDM("Closing Filter Screen");
+ }
+ }
+
+ }
diff --git a/data/mnet/Common/Java/AlarmApplet/FilterObject.java b/data/mnet/Common/Java/AlarmApplet/FilterObject.java
new file mode 100644
index 0000000..dc7f403
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/FilterObject.java
@@ -0,0 +1,35 @@
+import java.io.Serializable;
+
+public class FilterObject implements Serializable{
+
+ // filter criteria
+ public int NUM_ALARMS;
+ public int TIME;
+ public String SEVERITY;
+ public int ACKNOWLEDGE;
+
+ public static int NONE = 0;
+
+ // Alarm number constants
+ public static int N1 = 2;
+ public static int N2 = 4;
+ public static int N3 = 6;
+ public static int N4 = 8;
+
+ // Severtiy constants
+ public static String CRITICAL = "CRITICAL";
+ public static String MAJOR = "MAJOR";
+ public static String MINOR = "MINOR";
+ public static String WARNING = "WARNING";
+ public static String NULL = "NULL";
+
+ // Ack constants
+ public static int NO_ACK = 1;
+ public static int ALL_ACK = 2;
+
+ // Time stamp constants
+ public static int MIN_15 = 1;
+ public static int HR_1 = 2;
+ public static int HR_12 = 3;
+ public static int HR_24 = 4;
+}
diff --git a/data/mnet/Common/Java/AlarmApplet/Makefile b/data/mnet/Common/Java/AlarmApplet/Makefile
new file mode 100644
index 0000000..24ded19
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/Makefile
@@ -0,0 +1,41 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This makefile creates the vipercell related class
+# files
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Kevin Lim|03/28/00| Initial Draft
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+CODEBASE = ..
+ALARMARCH = $(CODEBASE)\Java\AlarmStatus.jar
+
+include $(CODEBASE)\java.mk
+
+
+all: $(CLASS_LIST) $(ALARMARCH)
+
+$(ALARMARCH):
+ $(JAR) cvf $@ *.class com\jetcell\MibWM\*.class
+
+clean:
+ -$(RM) *.class
+
+cleanall:
+ -$(RM) *.class
+ -$(RM) $(ALARMARCH)
+
diff --git a/data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile b/data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile
new file mode 100644
index 0000000..e8c30ce
--- /dev/null
+++ b/data/mnet/Common/Java/AlarmApplet/com/jetcell/MibWM/Makefile
@@ -0,0 +1,40 @@
+####################################################################
+#
+# FILE NAME: Makefile
+#
+# DESCRIPTION: This makefile creates the vipercell related class
+# files
+# COMPONENTS:
+#
+#
+# NOTES:
+#
+# (C) Copyright 1999 JetCell Inc., CA, USA http://www.jetcell.com/
+#
+# REVISION HISTORY
+#__________________________________________________________________
+#----------+--------+----------------------------------------------
+# Name | Date | Reason
+#----------+--------+----------------------------------------------
+# Bhawani |11/28/99| Initial Draft
+#----------+--------+----------------------------------------------
+####################################################################
+#/
+
+CODEBASE = ../../../../
+
+
+include $(CODEBASE)/java.mk
+
+
+all: $(CLASS_LIST)
+
+
+clean:
+ -$(RM) *.java
+ -$(RM) *.class
+
+cleanall:
+ -$(RM) *.java
+ -$(RM) *.class
+