From 269662c591df480ac061ba2fdef56b3976e94a2c Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Tue, 20 Aug 2019 12:38:52 -0400 Subject: [PATCH] Loading UI settings based on input configuration, bug fixes --- .../autopsy/report/ReportVisualPanel2.java | 71 +++++++++++++------ .../autopsy/report/ReportWizardAction.java | 2 +- .../report/ReportWizardFileOptionsPanel.java | 6 +- .../ReportWizardFileOptionsVisualPanel.java | 25 +++++-- .../autopsy/report/ReportWizardPanel2.java | 6 +- .../autopsy/report/TableReportSettings.java | 30 ++------ 6 files changed, 83 insertions(+), 57 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java index 48eaa6ace4..03cdeb9160 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java @@ -68,25 +68,20 @@ final class ReportVisualPanel2 extends JPanel { /** * Creates new form ReportVisualPanel2 */ - public ReportVisualPanel2(ReportWizardPanel2 wizPanel, boolean useCaseSpecificData) { + public ReportVisualPanel2(ReportWizardPanel2 wizPanel, boolean useCaseSpecificData, TableReportSettings settings) { + this.useCaseSpecificData = useCaseSpecificData; initComponents(); initTags(); initArtifactTypes(); - tagsList.setEnabled(false); - selectAllButton.setEnabled(false); - deselectAllButton.setEnabled(false); - allResultsRadioButton.setSelected(true); - advancedButton.setEnabled(useCaseSpecificData); - specificTaggedResultsRadioButton.setEnabled(useCaseSpecificData); this.wizPanel = wizPanel; - this.useCaseSpecificData = useCaseSpecificData; + this.allResultsRadioButton.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); - advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData); + advancedButton.setEnabled(allResultsRadioButton.isSelected() && useCaseSpecificData); updateFinishButton(); } }); @@ -96,7 +91,7 @@ final class ReportVisualPanel2 extends JPanel { tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); - advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData); + advancedButton.setEnabled(allResultsRadioButton.isSelected() && useCaseSpecificData); updateFinishButton(); } }); @@ -106,16 +101,48 @@ final class ReportVisualPanel2 extends JPanel { tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); - advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData); + advancedButton.setEnabled(allResultsRadioButton.isSelected() && useCaseSpecificData); updateFinishButton(); } }); + + // enable things based on input settings + advancedButton.setEnabled(useCaseSpecificData); + specificTaggedResultsRadioButton.setEnabled(useCaseSpecificData); + TableReportSettings.TableReportType type = TableReportSettings.TableReportType.ALL_RESULTS; + if (settings != null) { + type = settings.getReportType(); + } + switch (type) { + case ALL_TAGGED_RESULTS: + allTaggedResultsRadioButton.setSelected(true); + tagsList.setEnabled(false); + selectAllButton.setEnabled(false); + deselectAllButton.setEnabled(false); + break; + case SPECIFIC_TAGGED_RESULTS: + specificTaggedResultsRadioButton.setSelected(useCaseSpecificData); + tagsList.setEnabled(useCaseSpecificData); + selectAllButton.setEnabled(useCaseSpecificData); + deselectAllButton.setEnabled(useCaseSpecificData); + break; + case ALL_RESULTS: + default: + allResultsRadioButton.setSelected(true); + tagsList.setEnabled(false); + selectAllButton.setEnabled(false); + deselectAllButton.setEnabled(false); + break; + } } // Initialize the list of Tags private void initTags() { - + List tagNamesInUse = new ArrayList<>(); + // NOTE: we do not want to load tag names that came from persisted settings + // because there might have been new/additional tag names that have been added + // by user. We should read tag names from the database each time. try { // only try to load tag names if we are displaying case specific data, otherwise // there may not be a case open. @@ -162,6 +189,12 @@ final class ReportVisualPanel2 extends JPanel { @SuppressWarnings("deprecation") private void initArtifactTypes() { + // only try to load existing artifact types if we are displaying case + // specific data, otherwise there may not be a case open. + if (!useCaseSpecificData) { + return; + } + try { Case openCase = Case.getCurrentCaseThrows(); ArrayList doNotReport = new ArrayList<>(); @@ -172,13 +205,8 @@ final class ReportVisualPanel2 extends JPanel { BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getLabel(), BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT.getDisplayName())); // output is too unstructured for table review - if (useCaseSpecificData) { - // get artifact types that exist in the current case - artifacts = openCase.getSleuthkitCase().getArtifactTypesInUse(); - } else { - // get all possible artifact types - openCase.getSleuthkitCase().getArtifactTypes().forEach(artifacts::add); - } + // get artifact types that exist in the current case + artifacts = openCase.getSleuthkitCase().getArtifactTypesInUse(); artifacts.removeAll(doNotReport); @@ -241,14 +269,15 @@ final class ReportVisualPanel2 extends JPanel { } /** - * @return true if the Specific Tags radio button is selected, false otherwise + * @return true if the Specific Tags radio button is selected, false + * otherwise */ TableReportSettings.TableReportType getSelectedReportType() { if (allTaggedResultsRadioButton.isSelected()) { return TableReportSettings.TableReportType.ALL_TAGGED_RESULTS; } else if (specificTaggedResultsRadioButton.isSelected()) { return TableReportSettings.TableReportType.SPECIFIC_TAGGED_RESULTS; - } + } return TableReportSettings.TableReportType.ALL_RESULTS; } diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java index 04a9c55423..7ab3a30751 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardAction.java @@ -57,7 +57,7 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr private static final Logger logger = Logger.getLogger(ReportWizardAction.class.getName()); private static final String REPORTING_CONFIGURATION_NAME = "ReportAction"; - private static final boolean DISPLAY_CASE_SPECIFIC_DATA = false; // ELTODO true; + private static final boolean DISPLAY_CASE_SPECIFIC_DATA = true; private static final boolean RUN_REPORTS = true; private final JButton toolbarButton = new JButton(); private static final String ACTION_NAME = NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.actionName.text"); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java index fa9ac57efe..de95271485 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardFileOptionsPanel.java @@ -36,8 +36,10 @@ class ReportWizardFileOptionsPanel implements WizardDescriptor.FinishablePanel options; + private List options = new ArrayList<>(); private final Map optionStates = new EnumMap<>(FileReportDataTypes.class); private ListModel model; private final ReportWizardFileOptionsPanel wizPanel; - public ReportWizardFileOptionsVisualPanel(ReportWizardFileOptionsPanel wizPanel) { + public ReportWizardFileOptionsVisualPanel(ReportWizardFileOptionsPanel wizPanel, FileReportSettings settings) { this.wizPanel = wizPanel; initComponents(); - initOptionsList(); + initOptionsList(settings); } @Override @@ -58,10 +60,19 @@ class ReportWizardFileOptionsVisualPanel extends javax.swing.JPanel { /** * Populate the list of File Report Information that can be selected. */ - private void initOptionsList() { - options = Arrays.asList(FileReportDataTypes.values()); - for (FileReportDataTypes col : options) { - optionStates.put(col, Boolean.FALSE); + private void initOptionsList(FileReportSettings settings) { + if (settings != null && settings.getFileProperties() != null && !settings.getFileProperties().isEmpty()) { + // load the configuration + for (Entry entry : settings.getFileProperties().entrySet()) { + optionStates.put(entry.getKey(), entry.getValue()); + options.add(entry.getKey()); + } + } else { + // load defaults + options = Arrays.asList(FileReportDataTypes.values()); + for (FileReportDataTypes entry : options) { + optionStates.put(entry, Boolean.FALSE); + } } model = new OptionsListModel(); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel2.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel2.java index ae6896fb41..6d78b74941 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardPanel2.java @@ -33,9 +33,11 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel { private final JButton nextButton; private WizardDescriptor wiz; private final boolean useCaseSpecificData; + private final TableReportSettings settings; - ReportWizardPanel2(boolean useCaseSpecificData, TableReportSettings tableReportSettings) { + ReportWizardPanel2(boolean useCaseSpecificData, TableReportSettings settings) { this.useCaseSpecificData = useCaseSpecificData; + this.settings = settings; finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text")); nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text")); nextButton.setEnabled(true); @@ -58,7 +60,7 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel { @Override public ReportVisualPanel2 getComponent() { if (component == null) { - component = new ReportVisualPanel2(this, useCaseSpecificData); + component = new ReportVisualPanel2(this, useCaseSpecificData, settings); } return component; } diff --git a/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java b/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java index 1eb49b74c3..b33595db68 100755 --- a/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java +++ b/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java @@ -41,10 +41,10 @@ final class TableReportSettings implements Serializable { } private static final long serialVersionUID = 1L; - private List artifactTypes = new ArrayList<>(); - private List tagNames = new ArrayList<>(); - private boolean useCaseSpecificData = false; - private TableReportType reportType = TableReportType.ALL_RESULTS; + private final List artifactTypes = new ArrayList<>(); + private final List tagNames = new ArrayList<>(); + private final boolean useCaseSpecificData; + private final TableReportType reportType; /** * Creates TableReportSettings object. This constructor is used when user @@ -55,6 +55,8 @@ final class TableReportSettings implements Serializable { * types to be included in the report. Only enabled entries will be kept. * @param tagNameSelections The enabled/disabled state of the tag names to * be included in the report. Only enabled entries will be kept. + * @param useCaseSpecificData Flag whether to use case specific tag and artifact data. + * @param reportType Table report type. */ TableReportSettings(Map artifactTypeSelections, Map tagNameSelections, boolean useCaseSpecificData, TableReportType reportType) { // Get the artifact types selected by the user @@ -76,26 +78,6 @@ final class TableReportSettings implements Serializable { this.useCaseSpecificData = useCaseSpecificData; } - // ELTODO remove this constructor? - /*TableReportSettings(List artifactTypes, List tagNames, boolean useCaseSpecificData) { - this.artifactTypes = artifactTypes; - this.tagNames = tagNames; - this.useCaseSpecificData = useCaseSpecificData; - }*/ - /** - * Creates TableReportSettings object. This constructor is used when user - * configures command line ingest. Most likely there will be no case open at - * the time, so tags and artifacts will have to be read from database at the - * report execution time. - * - * @param useCaseSpecificData - * @param reportType - */ - /*TableReportSettings(boolean useCaseSpecificData, TableReportType reportType) { - this.useCaseSpecificData = useCaseSpecificData; - this.reportType = reportType; - }*/ - List getArtifactSelections() { return artifactTypes; }