예제 #1
0
 public void valueChanged(ListSelectionEvent e) {
   Object o = e.getSource();
   if (o == table.getSelectionModel()) {
     int row = table.getSelectedRow();
     if (row >= 0) {
       AlertItem item = model.getAlert(row);
       editor.showAlert(item);
     }
   } else if (o == list) {
     if (!e.getValueIsAdjusting()) {
       model.setSelectedIPs(list.getSelectedValues());
       table.repaint();
     }
   }
 }
예제 #2
0
  public void locateAndShowHost(long ip) {
    synchronized (alerts) {
      int size = model.getRowCount();
      for (int i = 0; i < size; i++) {
        AlertItem item = model.getAlert(i);
        if (item.getFlowId().getSourceIP() == ip) {
          table.setRowSelectionInterval(i, i);
          table.scrollRectToVisible(table.getCellRect(i, 0, true));
          break;
        }
      }
    }

    showInDetails(ip);
  }
예제 #3
0
  private void moveToDetails() {
    AlertItem item;
    synchronized (alerts) {
      int row = table.getSelectedRow();
      item = (AlertItem) model.getAlert(row);
    }

    if (item != null) {
      showInDetails(item.getFlowId().getSourceIP());
    }
  }
예제 #4
0
  private void deleteAlertTypeForHost() {
    List ids = new ArrayList();
    long[] lids = null;

    synchronized (alerts) {
      int row = table.getSelectedRow();
      AlertItem item = (AlertItem) model.getAlert(row);

      if (item != null) {
        long ip = item.getFlowId().getSourceIP();
        long pId = item.getPolicyID();

        Iterator it = alerts.iterator();
        while (it.hasNext()) {
          AlertItem alert = (AlertItem) it.next();
          if (alert.getPolicyID() == pId && alert.getFlowId().getSourceIP() == ip) {
            ids.add(alert);
          }
        }
      }
    }

    if (JOptionPane.showConfirmDialog(this, "Delete " + ids.size() + " Alerts?")
        != JOptionPane.YES_OPTION) {
      return;
    }

    lids = new long[ids.size()];
    for (int i = 0; i < lids.length; i++) {
      AlertItem alert = (AlertItem) ids.get(i);
      lids[i] = alert.getAlertID();
      model.removeAlert(alert);
      deleteFromSource(alert);
    }

    try {
      main.deleteAlertList(lids);
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
예제 #5
0
  public void insertAlertItem(AlertItem ai, int type) {
    HostResolver.addRequest(ai);
    ai.getPolicyItem().addAlerts(1);
    if (ai.getStatus() == AlertItem.NEW) {
      ai.getPolicyItem().addNewAlerts(1);
    }

    synchronized (alerts) {
      alerts.add(ai);
      model.addAlert(ai);
    }
  }
예제 #6
0
  private void deleteAlerts(int[] rows) {
    long[] alertsIds = new long[rows.length];
    AlertItem[] alerts = new AlertItem[rows.length];

    for (int i = 0; i < rows.length; i++) {
      AlertItem item = model.getAlert(rows[i]);
      alerts[i] = item;
      alertsIds[i] = item.getAlertID();
    }

    for (int i = 0; i < alerts.length; i++) {
      model.removeAlert(alerts[i]);
      deleteFromSource(alerts[i]);
    }

    if (alertsIds != null) {
      try {
        main.deleteAlertList(alertsIds);
      } catch (IOException ex) {
      }
    }
  }
예제 #7
0
  public void deleteAlertsForPolicy(PolicyItem pi) {
    List ids = new ArrayList();
    synchronized (alerts) {
      Iterator it = alerts.iterator();
      while (it.hasNext()) {
        AlertItem alert = (AlertItem) it.next();
        if (alert.getPolicyItem() == pi) {
          ids.add(alert);
        }
      }
    }

    Iterator it = ids.iterator();
    while (it.hasNext()) {
      AlertItem alert = (AlertItem) it.next();
      model.removeAlert(alert);
      deleteFromSource(alert);
    }
  }
예제 #8
0
  private void markAlerts(int[] items, int mark) {
    List list = new ArrayList();
    for (int i = 0; i < items.length; i++) {
      AlertItem item = model.getAlert(items[i]);
      if (item.getStatus() != mark) {
        if (item.getStatus() == AlertItem.NEW) {
          item.getPolicyItem().addNewAlerts(-1);
        } else {
          item.getPolicyItem().addNewAlerts(mark == AlertItem.NEW ? 1 : 0);
        }

        list.add(item);
        item.setStatus(mark);
      }
    }

    try {
      main.saveAlertList(list);
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
예제 #9
0
 public void showPolicy(PolicyItem item) {
   model.setPolicyVisible(item);
   model.fireListChanged();
 }
예제 #10
0
 public void showType(int type) {
   model.setTypeVisible(type);
   model.fireListChanged();
 }