From 7f18e67d2216ada6f220751835ac5509caecd70a Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Mon, 6 Mar 2017 15:44:24 -0500 Subject: [PATCH 1/3] 2355 Should prevent over-writing of filters list with older list --- .../autopsy/ingest/IngestOptionsPanel.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java index 28bf7a623e..78c507a908 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java @@ -47,6 +47,7 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen private final static int INDEX_OF_SETTINGS_PANEL = 2; private ProfileSettingsPanel profilePanel; private final static int INDEX_OF_PROFILE_PANEL = 1; + private boolean fitlerPanelPreviouslySelected = true; /** * This panel implements a property change listener that listens to ingest * job events so it can disable the buttons on the panel if ingest is @@ -78,15 +79,17 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen @Override public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof JTabbedPane) { - //because we can have two filterPanels open at the same time - //we need to save the settings when we change tabs otherwise - //they could be overwritten with out of date - if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL) { - filterPanel.load(); - } - else { - filterPanel.saveSettings(); - } + //because we can have two filterPanels open at the same time + //we need to save the settings when we change tabs from the filterTab + //otherwise they could be overwritten with out of date + if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL) { + filterPanel.load(); + fitlerPanelPreviouslySelected = true; + } else if (fitlerPanelPreviouslySelected) { + filterPanel.saveSettings(); + fitlerPanelPreviouslySelected = false; + } + } } }); @@ -160,7 +163,11 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen */ @Override public void saveSettings() { - filterPanel.store(); + //Because we can create filters in two seperate windows here we need + //to be careful not to save an out of date list over the current list + if (fitlerPanelPreviouslySelected) { + filterPanel.store(); + } settingsPanel.store(); } From a9a9ae24faa343e0145c747e3a3fe4f47540525f Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 8 Mar 2017 15:37:06 -0500 Subject: [PATCH 2/3] 2355 simplified approach to handling multiple FileIngestFilter panels --- .../autopsy/ingest/IngestOptionsPanel.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java index 78c507a908..4785f561b5 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java @@ -47,7 +47,7 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen private final static int INDEX_OF_SETTINGS_PANEL = 2; private ProfileSettingsPanel profilePanel; private final static int INDEX_OF_PROFILE_PANEL = 1; - private boolean fitlerPanelPreviouslySelected = true; + private int indexOfPreviousTab; /** * This panel implements a property change listener that listens to ingest * job events so it can disable the buttons on the panel if ingest is @@ -59,6 +59,7 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen public IngestOptionsPanel() { initComponents(); customizeComponents(); + indexOfPreviousTab = tabbedPane.getSelectedIndex(); } private void customizeComponents() { @@ -79,17 +80,17 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen @Override public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof JTabbedPane) { - //because we can have two filterPanels open at the same time - //we need to save the settings when we change tabs from the filterTab - //otherwise they could be overwritten with out of date - if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL) { + + if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL && tabbedPane.getSelectedIndex() != indexOfPreviousTab) { + //If we are switching to a filter panel we should load + //load the filter panel to ensure it is up to date + //incase a filter was addded through the Profile->new->create new filter manner filterPanel.load(); - fitlerPanelPreviouslySelected = true; - } else if (fitlerPanelPreviouslySelected) { - filterPanel.saveSettings(); - fitlerPanelPreviouslySelected = false; } - + //save the contents of whichever Tab we just switched from + saveTabByIndex(indexOfPreviousTab); + //save the index of the current tab for the next time we switch + indexOfPreviousTab = tabbedPane.getSelectedIndex(); } } }); @@ -163,12 +164,25 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen */ @Override public void saveSettings() { + saveTabByIndex(tabbedPane.getSelectedIndex()); + } + + private void saveTabByIndex(int index) { //Because we can create filters in two seperate windows here we need //to be careful not to save an out of date list over the current list - if (fitlerPanelPreviouslySelected) { - filterPanel.store(); + switch (index) { + case (INDEX_OF_FILTER_PANEL): + filterPanel.saveSettings(); + break; + case (INDEX_OF_PROFILE_PANEL): + profilePanel.saveSettings(); + break; + case (INDEX_OF_SETTINGS_PANEL): + settingsPanel.saveSettings(); + break; + default: + //don't save anything if it wasn't a tab index that should exist } - settingsPanel.store(); } /** From d61042a6a445e64ad75c84f56dd0763b0e6bf5ab Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 8 Mar 2017 16:35:46 -0500 Subject: [PATCH 3/3] 2355 Adjusted comments in IngestOptionsPanel to come before what they refer to --- .../sleuthkit/autopsy/ingest/IngestOptionsPanel.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java index 4785f561b5..d10b987873 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java @@ -80,11 +80,10 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen @Override public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof JTabbedPane) { - + //If we are switching to a filter panel we should load + //load the filter panel to ensure it is up to date + //incase a filter was addded through the Profile->new->create new filter manner if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL && tabbedPane.getSelectedIndex() != indexOfPreviousTab) { - //If we are switching to a filter panel we should load - //load the filter panel to ensure it is up to date - //incase a filter was addded through the Profile->new->create new filter manner filterPanel.load(); } //save the contents of whichever Tab we just switched from @@ -167,6 +166,11 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen saveTabByIndex(tabbedPane.getSelectedIndex()); } + /** + * Save the panel which is in the tab corresponding to the specified index. + * + * @param index - the index of the tab you wish to save the contents of + */ private void saveTabByIndex(int index) { //Because we can create filters in two seperate windows here we need //to be careful not to save an out of date list over the current list