2198 additional comments and clean up for the RunIngestModulesWizard

This commit is contained in:
William Schaefer 2017-02-03 10:55:17 -05:00
parent b559ca70b8
commit c33a84179c
6 changed files with 60 additions and 34 deletions

View File

@ -21,7 +21,7 @@ package org.sleuthkit.autopsy.ingest.runIngestModuleWizard;
import org.openide.WizardDescriptor;
/**
* An abstract class which provides providing a method which can be checked by
* An abstract class providing a method which can be checked by
* the iterator containing panels of this type. So that Wizards containing these
* panels can enable finish before the last panel.
*/
@ -32,7 +32,7 @@ abstract class EarlyFinishWizardDescriptorPanel implements WizardDescriptor.Pane
*
* @return true or false
*/
boolean isLastPanel(){
boolean skipRemainingPanels(){
/*
* This class should be overriden by any panel that might want to
* enable the finish button early for its wizard.

View File

@ -75,7 +75,7 @@ final class IngestProfileSelectionPanel extends JPanel implements ItemListener {
*/
private void populateListOfCheckboxes() {
profiles = getProfiles();
addRadioButton(CUSTOM_SETTINGS_DISPLAY_NAME, RunIngestModuleWizardIterator.getDefaultContext(), CUSTOM_SETTINGS_DESCRIPTION);
addRadioButton(CUSTOM_SETTINGS_DISPLAY_NAME, RunIngestModulesAction.getDefaultContext(), CUSTOM_SETTINGS_DESCRIPTION);
for (IngestProfile profile : profiles) {
addRadioButton(profile.toString(), profile.toString(), profile.getDescription());
}
@ -243,7 +243,7 @@ final class IngestProfileSelectionPanel extends JPanel implements ItemListener {
}
}
boolean wasLastPanel = isLastPanel;
if (selectedProfile.equals(RunIngestModuleWizardIterator.getDefaultContext())) {
if (selectedProfile.equals(RunIngestModulesAction.getDefaultContext())) {
isLastPanel = false;
} else {
isLastPanel = true;

View File

@ -28,21 +28,22 @@ import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor;
import org.sleuthkit.autopsy.ingest.IngestProfileMap;
/**
* Iterator class for creating a wizard for run ingest modules.
*
*/
final class RunIngestModuleWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> {
private final static String DEFAULT_CONTEXT = "org.sleuthkit.autopsy.ingest.runIngestModuleAction";
private int index;
private List<EarlyFinishWizardDescriptorPanel> panels;
/**
* @return the DEFAULT_CONTEXT
* Gets the list of panels used by this wizard for iterating over.
* Constructing it when it is null.
*
* @return panels - the list of of WizardDescriptor panels
*/
static String getDefaultContext() {
return DEFAULT_CONTEXT;
}
private List<EarlyFinishWizardDescriptorPanel> getPanels() {
if (panels == null) {
panels = new ArrayList<>();
@ -80,9 +81,10 @@ final class RunIngestModuleWizardIterator implements WizardDescriptor.Iterator<W
return index + 1 + ". from " + getPanels().size();
}
@Override
public boolean hasNext() {
return (index < getPanels().size() - 1) && !current().isLastPanel();
return (index < getPanels().size() - 1) && !current().skipRemainingPanels();
}
@Override

View File

@ -26,6 +26,11 @@ import org.openide.WizardDescriptor;
import org.openide.util.HelpCtx;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
/**
* The first wizard panel of the run ingest modules wizard. Displays the profile
* selection panel and is only created when profiles exist.
*
*/
class RunIngestModuleWizardPanel1 extends EarlyFinishWizardDescriptorPanel {
private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
@ -47,7 +52,7 @@ class RunIngestModuleWizardPanel1 extends EarlyFinishWizardDescriptorPanel {
if (component == null) {
if (ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, PROP_LASTPROFILE_NAME) == null
|| ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, PROP_LASTPROFILE_NAME).isEmpty()) {
lastProfileUsed = RunIngestModuleWizardIterator.getDefaultContext();
lastProfileUsed = RunIngestModulesAction.getDefaultContext();
} else {
lastProfileUsed = ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, PROP_LASTPROFILE_NAME);
}
@ -56,8 +61,15 @@ class RunIngestModuleWizardPanel1 extends EarlyFinishWizardDescriptorPanel {
return component;
}
/**
* Returns whether or not this should be considered the last panel of the
* wizard. Returns true when a profile is selected, and false when
* custom settings is selected.
*
* @return true or false
*/
@Override
boolean isLastPanel() {
boolean skipRemainingPanels() {
return component.isLastPanel;
}
@ -71,12 +83,11 @@ class RunIngestModuleWizardPanel1 extends EarlyFinishWizardDescriptorPanel {
public boolean isValid() {
// If it is always OK to press Next or Finish, then:
return true;
// If it depends on some condition (form filled out...) and
// this condition changes (last form field filled in...) then
// use ChangeSupport to implement add/removeChangeListener below.
// WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
}
/**
* Fires a change event to notify listeners that changes have taken place.
*/
protected final void fireChangeEvent() {
Set<ChangeListener> ls;
synchronized (listeners) {

View File

@ -27,7 +27,6 @@ import org.sleuthkit.autopsy.ingest.IngestJobSettingsPanel;
class RunIngestModuleWizardPanel2 extends EarlyFinishWizardDescriptorPanel {
/**
* f
* The visual ingestJobSettingsPanel that displays this panel. If you need
* to access the ingestJobSettingsPanel from this class, just use
* getComponent().
@ -41,7 +40,7 @@ class RunIngestModuleWizardPanel2 extends EarlyFinishWizardDescriptorPanel {
@Override
public IngestJobSettingsPanel getComponent() {
if (ingestJobSettingsPanel == null) {
ingestJobSettingsPanel = new IngestJobSettingsPanel(new IngestJobSettings(RunIngestModuleWizardIterator.getDefaultContext()));
ingestJobSettingsPanel = new IngestJobSettingsPanel(new IngestJobSettings(RunIngestModulesAction.getDefaultContext()));
}
return ingestJobSettingsPanel;
}
@ -50,18 +49,12 @@ class RunIngestModuleWizardPanel2 extends EarlyFinishWizardDescriptorPanel {
public HelpCtx getHelp() {
// Show no Help button for this panel:
return HelpCtx.DEFAULT_HELP;
// If you have context help:
// return new HelpCtx("help.key.here");
}
@Override
public boolean isValid() {
// If it is always OK to press Next or Finish, then:
return true;
// If it depends on some condition (form filled out...) and
// this condition changes (last form field filled in...) then
// use ChangeSupport to implement add/removeChangeListener below.
// WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
}
@Override
@ -74,14 +67,13 @@ class RunIngestModuleWizardPanel2 extends EarlyFinishWizardDescriptorPanel {
@Override
public void readSettings(WizardDescriptor wiz) {
// use wiz.getProperty to retrieve previous panel state
}
@Override
public void storeSettings(WizardDescriptor wiz) {
IngestJobSettings ingestJobSettings = this.ingestJobSettingsPanel.getSettings();
ingestJobSettings.save();
wiz.putProperty("executionContext", RunIngestModuleWizardIterator.getDefaultContext()); //NON-NLS
wiz.putProperty("executionContext", RunIngestModulesAction.getDefaultContext()); //NON-NLS
}
}

View File

@ -39,15 +39,29 @@ import org.sleuthkit.datamodel.Directory;
* modules.
*/
public final class RunIngestModulesAction extends AbstractAction {
@Messages("RunIngestModulesAction.name=Run Ingest Modules")
private static final String DEFAULT_CONTEXT = "org.sleuthkit.autopsy.ingest.runIngestModuleAction";
/**
* Returns the name of the default context which will be used when profiles are not available.
*
* @return the DEFAULT_CONTEXT
*/
static String getDefaultContext() {
return DEFAULT_CONTEXT;
}
private final List<Content> dataSources = new ArrayList<>();
private final IngestJobSettings.IngestType ingestType;
/**
* the constructor
* @param dataSources
* Creates an action which will make a run ingest modules wizard when it
* is performed.
*
* @param dataSources - the data sources you want to run ingest on
*/
public RunIngestModulesAction(List<Content> dataSources) {
this.putValue(Action.NAME, Bundle.RunIngestModulesAction_name());
@ -56,8 +70,10 @@ public final class RunIngestModulesAction extends AbstractAction {
}
/**
* the constructor
* @param dir
* Creates an action which will make a run ingest modules wizard when it
* is performed.
*
* @param dir - the directory you want to run ingest on
*/
public RunIngestModulesAction(Directory dir) {
this.putValue(Action.NAME, Bundle.RunIngestModulesAction_name());
@ -65,7 +81,7 @@ public final class RunIngestModulesAction extends AbstractAction {
this.ingestType = IngestJobSettings.IngestType.FILES_ONLY;
}
/**
* Runs the ingest modules wizard on the data source.
* Opens a run ingest modules wizard with the list of data sources.
*
* @param e the action event
*/
@ -84,6 +100,11 @@ public final class RunIngestModulesAction extends AbstractAction {
}
}
/**
* Display any warnings that the ingestJobSettings have.
*
* @param ingestJobSettings
*/
private static void showWarnings(IngestJobSettings ingestJobSettings) {
List<String> warnings = ingestJobSettings.getWarnings();
if (warnings.isEmpty() == false) {