From f8e5ea0bbbfb489ccd3c2028c3265e4033406ce4 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Fri, 17 Nov 2017 09:42:04 +0100 Subject: [PATCH] cleanup filtersPane, clear devices on case change. Devices unselected by default to simplify adding new ones and maintaining results --- .../communications/CVTTopComponent.form | 14 ++--- .../communications/CVTTopComponent.java | 14 ++--- .../autopsy/communications/FiltersPanel.form | 27 ---------- .../autopsy/communications/FiltersPanel.java | 51 +++++++++---------- 4 files changed, 39 insertions(+), 67 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.form b/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.form index ef764c80e1..6db797c284 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.form +++ b/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.form @@ -17,10 +17,10 @@ - - - - + + + + @@ -28,7 +28,7 @@ - + @@ -95,12 +95,12 @@ - + - + diff --git a/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.java b/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.java index b5ec0888a2..582453859b 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/communications/CVTTopComponent.java @@ -77,11 +77,11 @@ public final class CVTTopComponent extends TopComponent implements ExplorerManag jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 602, Short.MAX_VALUE) + .addGap(0, 591, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 718, Short.MAX_VALUE) + .addGap(0, 725, Short.MAX_VALUE) ); BrowseVisualizeTabPane.addTab(org.openide.util.NbBundle.getMessage(CVTTopComponent.class, "CVTTopComponent.TabConstraints.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/emblem-web.png")), jPanel1); // NOI18N @@ -95,16 +95,16 @@ public final class CVTTopComponent extends TopComponent implements ExplorerManag layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addGap(0, 0, 0) - .addComponent(filtersPane, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1344, Short.MAX_VALUE) + .addGap(6, 6, 6) + .addComponent(filtersPane, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(splitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1334, Short.MAX_VALUE) .addGap(0, 0, 0)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() + .addGap(6, 6, 6) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(filtersPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(splitPane)) diff --git a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.form b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.form index 2960e5e259..72a13e519e 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.form +++ b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.form @@ -1,33 +1,6 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java index ce4712f983..7f50087f2c 100644 --- a/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java +++ b/Core/src/org/sleuthkit/autopsy/communications/FiltersPanel.java @@ -22,6 +22,7 @@ import java.beans.PropertyChangeListener; import java.time.LocalDate; import java.time.ZoneId; import java.time.format.TextStyle; +import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -75,8 +76,6 @@ final public class FiltersPanel extends javax.swing.JPanel { setPreferredTimeZone(); updateFilters(); - setAllAccountTypesSelected(true); - setAllDevicesSelected(true); UserPreferences.addChangeListener(preferenceChangeEvent -> { if (preferenceChangeEvent.getKey().equals(UserPreferences.DISPLAY_TIMES_IN_LOCAL_TIME)) { setPreferredTimeZone(); @@ -91,7 +90,6 @@ final public class FiltersPanel extends javax.swing.JPanel { applyFiltersButton.setIcon(new ImageIcon("org/sleuthkit/autopsy/communications/images/reload.png")); } else if (eventType.equals(COMPLETED.toString())) { } else if (eventType.equals(CANCELLED.toString())) { - } else if (eventType.equals(CURRENT_CASE.toString())) { } }; @@ -106,7 +104,7 @@ final public class FiltersPanel extends javax.swing.JPanel { if (em != null) { applyFilters(); } -} + } private void setPreferredTimeZone() { dateRangeLabel.setText("Date Range ( " + Utils.getUserPreferredZoneId().getDisplayName(TextStyle.NARROW, Locale.getDefault()) + "):"); @@ -125,8 +123,17 @@ final public class FiltersPanel extends javax.swing.JPanel { * till this FiltersPanel is actaully added to a parent. */ em = ExplorerManager.find(this); - IngestManager.getInstance().removeIngestModuleEventListener(ingestListener); + IngestManager.getInstance().addIngestModuleEventListener(ingestListener); + Case.addEventTypeSubscriber(EnumSet.of(CURRENT_CASE), evt -> { + devicesMap.clear(); + devicesPane.removeAll(); + }); + } + @Override + public void removeNotify() { + super.removeNotify(); + IngestManager.getInstance().removeIngestModuleEventListener(ingestListener); } /** @@ -152,7 +159,7 @@ final public class FiltersPanel extends javax.swing.JPanel { + FiltersPanel.class.getResource("/org/sleuthkit/autopsy/communications/images/" + Utils.getIconFileName(type)) + "\"/>" + type.getDisplayName() + "", - false + true ); accountTypePane.add(jCheckBox); return jCheckBox; @@ -167,14 +174,16 @@ final public class FiltersPanel extends javax.swing.JPanel { */ private void updateDeviceFilter() { try { - final List dataSources = Case.getCurrentCase().getSleuthkitCase().getDataSources(); - dataSources.forEach( - dataSource -> devicesMap.computeIfAbsent(dataSource.getDeviceId(), ds -> { - final JCheckBox jCheckBox = new JCheckBox(dataSource.getDeviceId(), false); - devicesPane.add(jCheckBox); - return jCheckBox; - }) - ); + Case.getCurrentCase() + .getSleuthkitCase() + .getDataSources().stream().map(DataSource::getDeviceId) + .forEach( + deviceID -> devicesMap.computeIfAbsent(deviceID, ds -> { + final JCheckBox jCheckBox = new JCheckBox(deviceID, false); + devicesPane.add(jCheckBox); + return jCheckBox; + })); + } catch (IllegalStateException ex) { logger.log(Level.WARNING, "Communications Visualization Tool opened with no open case.", ex); } catch (TskCoreException tskCoreException) { @@ -191,13 +200,6 @@ final public class FiltersPanel extends javax.swing.JPanel { // //GEN-BEGIN:initComponents private void initComponents() { - jList1.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; - public int getSize() { return strings.length; } - public String getElementAt(int i) { return strings[i]; } - }); - jScrollPane1.setViewportView(jList1); - applyFiltersButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/communications/images/control-double.png"))); // NOI18N applyFiltersButton.setText(org.openide.util.NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.applyFiltersButton.text")); // NOI18N applyFiltersButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); @@ -428,11 +430,10 @@ final public class FiltersPanel extends javax.swing.JPanel { } catch (TskCoreException ex) { logger.log(Level.SEVERE, "There was a error loading the accounts.", ex); } - - + applyFiltersButton.setText("Apply"); applyFiltersButton.setIcon(new ImageIcon("org/sleuthkit/autopsy/communications/images/control-double.png")); - + } /** @@ -534,11 +535,9 @@ final public class FiltersPanel extends javax.swing.JPanel { private final javax.swing.JCheckBox endCheckBox = new javax.swing.JCheckBox(); private final com.github.lgooddatepicker.datepicker.DatePicker endDatePicker = new com.github.lgooddatepicker.datepicker.DatePicker(); private final javax.swing.JLabel filtersTitleLabel = new javax.swing.JLabel(); - private final javax.swing.JList jList1 = new javax.swing.JList<>(); private final javax.swing.JPanel jPanel2 = new javax.swing.JPanel(); private final javax.swing.JPanel jPanel3 = new javax.swing.JPanel(); private final javax.swing.JPanel jPanel4 = new javax.swing.JPanel(); - private final javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); private final javax.swing.JScrollPane jScrollPane2 = new javax.swing.JScrollPane(); private final javax.swing.JScrollPane jScrollPane3 = new javax.swing.JScrollPane(); private final javax.swing.JCheckBox startCheckBox = new javax.swing.JCheckBox();