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(); } } }
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); }
private void moveToDetails() { AlertItem item; synchronized (alerts) { int row = table.getSelectedRow(); item = (AlertItem) model.getAlert(row); } if (item != null) { showInDetails(item.getFlowId().getSourceIP()); } }
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(); } }
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); } }
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) { } } }
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); } }
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(); } }
public void showPolicy(PolicyItem item) { model.setPolicyVisible(item); model.fireListChanged(); }
public void showType(int type) { model.setTypeVisible(type); model.fireListChanged(); }