Updates to TableReportSettings

This commit is contained in:
Eugene Livis 2019-08-15 13:59:18 -04:00
parent a1026861e3
commit b64fcb129b
6 changed files with 74 additions and 34 deletions

View File

@ -124,6 +124,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
// get configuration for this module
ReportModuleConfig config = moduleConfigs.get(module.getClass().getCanonicalName());
if (config != null) {
// there is an existing configuration for this module
settings = config.getModuleSettings();
} else {
// ELTODO get default module configuration (API isn't implemented yet)

View File

@ -61,13 +61,15 @@ final class ReportVisualPanel2 extends JPanel {
ArtifactSelectionDialog dialog = new ArtifactSelectionDialog((JFrame) WindowManager.getDefault().getMainWindow(), true);
private Map<BlackboardArtifact.Type, Boolean> artifactStates = new HashMap<>();
private List<BlackboardArtifact.Type> artifacts = new ArrayList<>();
private TableReportSettings tableReportSettings;
private final boolean useCaseSpecificData;
private TagsListModel tagsModel;
private TagsListRenderer tagsRenderer;
/**
* Creates new form ReportVisualPanel2
*/
public ReportVisualPanel2(ReportWizardPanel2 wizPanel) {
public ReportVisualPanel2(ReportWizardPanel2 wizPanel, TableReportSettings tableReportSettings, boolean useCaseSpecificData) {
initComponents();
initTags();
initArtifactTypes();
@ -76,13 +78,15 @@ final class ReportVisualPanel2 extends JPanel {
deselectAllButton.setEnabled(false);
allResultsRadioButton.setSelected(true);
this.wizPanel = wizPanel;
this.tableReportSettings = tableReportSettings;
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());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData);
updateFinishButton();
}
});
@ -92,7 +96,7 @@ final class ReportVisualPanel2 extends JPanel {
tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected());
selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData);
updateFinishButton();
}
});
@ -102,7 +106,7 @@ final class ReportVisualPanel2 extends JPanel {
tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected());
selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData);
updateFinishButton();
}
});
@ -111,6 +115,16 @@ final class ReportVisualPanel2 extends JPanel {
// Initialize the list of Tags
private void initTags() {
List<TagName> tagNamesInUse;
if (tableReportSettings == null) {
// get default table report settings
tableReportSettings = TableReportGenerator.getDefaultTableReportSettings(useCaseSpecificData);
}
// use specified configuration
List<String> tagNames = tableReportSettings.getTagSelections();
// ELTODO convert List<String> tagNames to List<TagName> tagNamesInUse
// use this list instead of of calling Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse();
try {
tagNamesInUse = Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse();
} catch (TskCoreException | NoCurrentCaseException ex) {

View File

@ -58,7 +58,7 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDesc
private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels;
@SuppressWarnings({"rawtypes", "unchecked"})
ReportWizardIterator(String reportingConfigurationName, boolean displayCaseSpecificData, boolean runReports) {
ReportWizardIterator(String reportingConfigurationName, boolean useCaseSpecificData, boolean runReports) {
ReportingConfig config = null;
try {
@ -69,12 +69,12 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDesc
if (config != null) {
firstPanel = new ReportWizardPanel1(config.getModuleConfigs());
tableConfigPanel = new ReportWizardPanel2(config.getTableReportSettings());
tableConfigPanel = new ReportWizardPanel2(config.getTableReportSettings(), useCaseSpecificData);
fileConfigPanel = new ReportWizardFileOptionsPanel(config.getFileReportSettings());
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(config.getModuleConfigs());
} else {
firstPanel = new ReportWizardPanel1(null);
tableConfigPanel = new ReportWizardPanel2(null);
tableConfigPanel = new ReportWizardPanel2(null, useCaseSpecificData);
fileConfigPanel = new ReportWizardFileOptionsPanel(null);
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(null);
}

View File

@ -32,8 +32,13 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
private final JButton finishButton;
private final JButton nextButton;
private WizardDescriptor wiz;
private final TableReportSettings tableReportSettings;
private final boolean useCaseSpecificData;
ReportWizardPanel2(TableReportSettings tableReportSettings) {
ReportWizardPanel2(TableReportSettings tableReportSettings, boolean useCaseSpecificData) {
this.tableReportSettings = tableReportSettings;
this.useCaseSpecificData = useCaseSpecificData;
finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text"));
nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text"));
@ -57,7 +62,7 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
@Override
public ReportVisualPanel2 getComponent() {
if (component == null) {
component = new ReportVisualPanel2(this);
component = new ReportVisualPanel2(this, tableReportSettings, useCaseSpecificData);
}
return component;
}

View File

@ -61,8 +61,8 @@ import org.sleuthkit.datamodel.TskData;
class TableReportGenerator {
private final List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
private final HashSet<String> tagNamesFilter = new HashSet<>();
private List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
private HashSet<String> tagNamesFilter = new HashSet<>();
private final Set<Content> images = new HashSet<>();
private final ReportProgressPanel progressPanel;
@ -79,20 +79,23 @@ class TableReportGenerator {
this.columnHeaderMap = new HashMap<>();
errorList = new ArrayList<>();
// Get the artifact types selected by the user.
for (Map.Entry<BlackboardArtifact.Type, Boolean> entry : settings.getArtifactSelections().entrySet()) {
if (entry.getValue()) {
artifactTypes.add(entry.getKey());
}
}
artifactTypes = settings.getArtifactSelections();
// Get the tag names selected by the user and make a tag names filter.
if (null != settings.getTagSelections()) {
for (Map.Entry<String, Boolean> entry : settings.getTagSelections().entrySet()) {
if (entry.getValue() == true) {
tagNamesFilter.add(entry.getKey());
}
}
tagNamesFilter = new HashSet<>(settings.getTagSelections());
}
static TableReportSettings getDefaultTableReportSettings(boolean useCaseSpecificData) {
Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>();
Map<String, Boolean> tagNameSelections = new HashMap<>();
if (useCaseSpecificData) {
// get tags and artifact types from current case
} else {
// get all possible tag names and artifact types
}
return new TableReportSettings(artifactTypeSelections, tagNameSelections);
}
protected void execute() {

View File

@ -19,7 +19,8 @@
package org.sleuthkit.autopsy.report;
import java.io.Serializable;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.sleuthkit.datamodel.BlackboardArtifact;
@ -28,30 +29,46 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
* by the TableReportGenerator class to drive report generation by
* TableReportModules.
*/
final class TableReportSettings implements Serializable {
final class TableReportSettings implements Serializable {
private static final long serialVersionUID = 1L;
private Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>();
private Map<String, Boolean> tagNameSelections = new HashMap<>();
private List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
private List<String> tagNames = new ArrayList<>();
/**
* Creates TableReportSettings object.
*
* @param artifactTypeSelections The enabled/disabled state of the artifact
* types to be included in the report
* 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
* be included in the report. Only enabled entries will be kept.
*/
TableReportSettings(Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
this.artifactTypeSelections = artifactTypeSelections;
this.tagNameSelections = tagNameSelections;
// Get the artifact types selected by the user
for (Map.Entry<BlackboardArtifact.Type, Boolean> entry : artifactTypeSelections.entrySet()) {
if (entry.getValue()) {
artifactTypes.add(entry.getKey());
}
}
// Get the tag names selected by the user
for (Map.Entry<String, Boolean> entry : tagNameSelections.entrySet()) {
if (entry.getValue() == true) {
tagNames.add(entry.getKey());
}
}
}
TableReportSettings(List<BlackboardArtifact.Type> artifactTypes, List<String> tagNames) {
this.artifactTypes = artifactTypes;
this.tagNames = tagNames;
}
Map<BlackboardArtifact.Type, Boolean> getArtifactSelections() {
return artifactTypeSelections;
List<BlackboardArtifact.Type> getArtifactSelections() {
return artifactTypes;
}
Map<String, Boolean> getTagSelections() {
return tagNameSelections;
List<String> getTagSelections() {
return tagNames;
}
}