コード例 #1
0
ファイル: JDFrame.java プロジェクト: yugesh/nids
  public JDFrame(JDCaptor captor) {
    this.captor = captor;
    this.tablePane = new JDTablePane(captor);
    captor.setJDFrame(this);

    setTitle("Network Intrusion Detection Syetem");

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu menu = new JMenu("System");
    menuBar.add(menu);
    JMenuItem item = new JMenuItem("New Window");
    item.setActionCommand("NewWin");
    item.addActionListener(this);
    menu.add(item);
    item = new JMenuItem("Exit");
    item.setActionCommand("Exit");
    item.addActionListener(this);
    menu.add(item);

    menu = new JMenu("File");
    menuBar.add(menu);
    this.openMenu = new JMenuItem("Open");

    this.openMenu.setActionCommand("Open");
    this.openMenu.addActionListener(this);
    menu.add(this.openMenu);
    this.saveMenu = new JMenuItem("Save");

    this.saveMenu.setActionCommand("Save");
    this.saveMenu.addActionListener(this);
    this.saveMenu.setEnabled(false);
    menu.add(this.saveMenu);

    // this is for Capture Operations
    menu = new JMenu("Capture");
    menuBar.add(menu);
    this.captureMenu = new JMenuItem("Start");

    this.captureMenu.setActionCommand("Start");
    this.captureMenu.addActionListener(this);
    menu.add(this.captureMenu);
    this.stopMenu = new JMenuItem("Stop");

    this.stopMenu.setActionCommand("Stop");
    this.stopMenu.addActionListener(this);
    this.stopMenu.setEnabled(false);
    menu.add(this.stopMenu);

    // to know the statistics like pie graph and X-Y graph
    this.statMenu = new JMenu("Statistics");
    menuBar.add(this.statMenu);
    menu = new JMenu("Cumulative");
    this.statMenu.add(menu);
    List stakers = JDStatisticsTakerLoader.getStatisticsTakers();
    for (int i = 0; i < stakers.size(); i++) {
      item = new JMenuItem(((JDStatisticsTaker) stakers.get(i)).getName());
      item.setActionCommand("CUMSTAT" + i);
      item.addActionListener(this);
      menu.add(item);
    }
    menu = new JMenu("Continuous");
    this.statMenu.add(menu);
    for (int i = 0; i < stakers.size(); i++) {
      item = new JMenuItem(((JDStatisticsTaker) stakers.get(i)).getName());
      item.setActionCommand("CONSTAT" + i);
      item.addActionListener(this);
      menu.add(item);
    }

    //  this is for all statistics of the system
    menu = new JMenu("View");
    menuBar.add(menu);
    this.tablePane.setTableViewMenu(menu);

    //  this is for the Signature Operations
    menu = new JMenu("Signature Operations");
    menuBar.add(menu);
    ruleAdd = new JMenuItem("Add New Rules");
    menu.add(ruleAdd);
    this.ruleAdd.addActionListener(this);

    ruleShow = new JMenuItem("Show All Rules");
    menu.add(ruleShow);
    this.ruleShow.addActionListener(this);

    //  this is for alet info
    menu = new JMenu("Intruder Info");
    menuBar.add(menu);
    alertMessage = new JMenuItem("Intruder");
    menu.add(alertMessage);
    this.alertMessage.addActionListener(this);

    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    this.openButton = new JButton(getImageIcon("/image/open.gif"));
    this.openButton.setActionCommand("Open");
    this.openButton.addActionListener(this);
    toolbar.add(this.openButton);
    this.saveButton = new JButton(getImageIcon("/image/save.gif"));
    this.saveButton.setActionCommand("Save");
    this.saveButton.addActionListener(this);
    this.saveButton.setEnabled(false);
    toolbar.add(this.saveButton);
    toolbar.addSeparator();
    this.captureButton = new JButton(getImageIcon("/image/capture.gif"));
    this.captureButton.setActionCommand("Start");
    this.captureButton.addActionListener(this);
    toolbar.add(this.captureButton);
    this.stopButton = new JButton(getImageIcon("/image/stopcap.gif"));
    this.stopButton.setActionCommand("Stop");
    this.stopButton.addActionListener(this);
    this.stopButton.setEnabled(false);
    toolbar.add(this.stopButton);

    this.statusLabel = new JLabel(" Intrusion Detection System started.");

    getContentPane().setLayout(new BorderLayout());

    getContentPane().add(this.statusLabel, "South");
    getContentPane().add(this.tablePane, "Center");
    // getContentPane().add(toolbar, "North");

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            JDFrame.this.saveProperty();
            JpcapDumper.closeWindow((JDFrame) evt.getSource());
          }
        });
    loadProperty();
  }