mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Loading UI settings based on input configuration, bug fixes
This commit is contained in:
parent
17580c484d
commit
269662c591
@ -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<TagName> 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<BlackboardArtifact.Type> 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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -36,8 +36,10 @@ class ReportWizardFileOptionsPanel implements WizardDescriptor.FinishablePanel<W
|
||||
private WizardDescriptor wiz;
|
||||
private ReportWizardFileOptionsVisualPanel component;
|
||||
private final JButton finishButton;
|
||||
private final FileReportSettings settings;
|
||||
|
||||
ReportWizardFileOptionsPanel(FileReportSettings fileReportSettings) {
|
||||
ReportWizardFileOptionsPanel(FileReportSettings settings) {
|
||||
this.settings = settings;
|
||||
finishButton = new JButton(
|
||||
NbBundle.getMessage(this.getClass(), "ReportWizardFileOptionsPanel.finishButton.text"));
|
||||
finishButton.setEnabled(false);
|
||||
@ -65,7 +67,7 @@ class ReportWizardFileOptionsPanel implements WizardDescriptor.FinishablePanel<W
|
||||
@Override
|
||||
public ReportWizardFileOptionsVisualPanel getComponent() {
|
||||
if (component == null) {
|
||||
component = new ReportWizardFileOptionsVisualPanel(this);
|
||||
component = new ReportWizardFileOptionsVisualPanel(this, settings);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
@ -21,10 +21,12 @@ package org.sleuthkit.autopsy.report;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
@ -39,15 +41,15 @@ import org.openide.util.NbBundle;
|
||||
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
|
||||
class ReportWizardFileOptionsVisualPanel extends javax.swing.JPanel {
|
||||
|
||||
private List<FileReportDataTypes> options;
|
||||
private List<FileReportDataTypes> options = new ArrayList<>();
|
||||
private final Map<FileReportDataTypes, Boolean> optionStates = new EnumMap<>(FileReportDataTypes.class);
|
||||
private ListModel<FileReportDataTypes> 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<FileReportDataTypes, Boolean> 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();
|
||||
|
@ -33,9 +33,11 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
||||
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<WizardDescriptor> {
|
||||
@Override
|
||||
public ReportVisualPanel2 getComponent() {
|
||||
if (component == null) {
|
||||
component = new ReportVisualPanel2(this, useCaseSpecificData);
|
||||
component = new ReportVisualPanel2(this, useCaseSpecificData, settings);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ final class TableReportSettings implements Serializable {
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
|
||||
private List<String> tagNames = new ArrayList<>();
|
||||
private boolean useCaseSpecificData = false;
|
||||
private TableReportType reportType = TableReportType.ALL_RESULTS;
|
||||
private final List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
|
||||
private final List<String> 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<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> 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<BlackboardArtifact.Type> artifactTypes, List<String> 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<BlackboardArtifact.Type> getArtifactSelections() {
|
||||
return artifactTypes;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user