remove flag, use context

This commit is contained in:
momo 2015-11-10 11:20:17 -05:00
parent 4cbec0d272
commit 6cefe96ca1
3 changed files with 19 additions and 50 deletions

View File

@ -105,6 +105,14 @@ class DirectoryTreeFilterNode extends FilterNode {
Directory dir = this.getLookup().lookup(Directory.class); Directory dir = this.getLookup().lookup(Directory.class);
if (dir != null) { if (dir != null) {
actions.add(ExtractAction.getInstance()); actions.add(ExtractAction.getInstance());
actions.add(new AbstractAction(
NbBundle.getMessage(this.getClass(), "DirectoryTreeFilterNode.action.runIngestMods.text")) {
@Override
public void actionPerformed(ActionEvent e) {
final RunIngestModulesDialog ingestDialog = new RunIngestModulesDialog(dir);
ingestDialog.display();
}
});
} }
final Image img = this.getLookup().lookup(Image.class); final Image img = this.getLookup().lookup(Image.class);
@ -124,14 +132,14 @@ class DirectoryTreeFilterNode extends FilterNode {
// 'run ingest' action and 'file search' action are added only if the // 'run ingest' action and 'file search' action are added only if the
// selected node is img node or a root level virtual directory or a directory. // selected node is img node or a root level virtual directory or a directory.
if (img != null || isRootVD || dir !=null) { if (img != null || isRootVD) {
actions.add(new FileSearchAction( actions.add(new FileSearchAction(
NbBundle.getMessage(this.getClass(), "DirectoryTreeFilterNode.action.openFileSrcByAttr.text"))); NbBundle.getMessage(this.getClass(), "DirectoryTreeFilterNode.action.openFileSrcByAttr.text")));
actions.add(new AbstractAction( actions.add(new AbstractAction(
NbBundle.getMessage(this.getClass(), "DirectoryTreeFilterNode.action.runIngestMods.text")) { NbBundle.getMessage(this.getClass(), "DirectoryTreeFilterNode.action.runIngestMods.text")) {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final RunIngestModulesDialog ingestDialog = new RunIngestModulesDialog(Collections.<Content>singletonList(content), dir != null); final RunIngestModulesDialog ingestDialog = new RunIngestModulesDialog(Collections.<Content>singletonList(content));
ingestDialog.display(); ingestDialog.display();
} }
}); });

View File

@ -58,7 +58,6 @@ public class IngestJobSettings {
private final List<IngestModuleTemplate> moduleTemplates; private final List<IngestModuleTemplate> moduleTemplates;
private boolean processUnallocatedSpace; private boolean processUnallocatedSpace;
private final List<String> warnings; private final List<String> warnings;
private final boolean isDir;
/** /**
* Constructs an ingest job settings object for a given context. * Constructs an ingest job settings object for a given context.
@ -70,23 +69,6 @@ public class IngestJobSettings {
this.moduleTemplates = new ArrayList<>(); this.moduleTemplates = new ArrayList<>();
this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT); this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT);
this.warnings = new ArrayList<>(); this.warnings = new ArrayList<>();
this.isDir = false;
this.createSavedModuleSettingsFolder();
this.load();
}
/**
* Constructs an ingest job settings object for a given context.
*
* @param context The context identifier string.
* @param isDir Whether the dataSources are directories
*/
public IngestJobSettings(String context, boolean isDir) {
this.context = context;
this.moduleTemplates = new ArrayList<>();
this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT);
this.warnings = new ArrayList<>();
this.isDir = isDir;
this.createSavedModuleSettingsFolder(); this.createSavedModuleSettingsFolder();
this.load(); this.load();
} }
@ -201,7 +183,7 @@ public class IngestJobSettings {
HashSet<String> loadedModuleNames = new HashSet<>(); HashSet<String> loadedModuleNames = new HashSet<>();
for(IngestModuleFactory moduleFactory : tempModuleFactories) { for(IngestModuleFactory moduleFactory : tempModuleFactories) {
if(!isDir || moduleFactory.isFileIngestModuleFactory()) if(!context.endsWith(".isDir") || moduleFactory.isFileIngestModuleFactory())
moduleFactories.add(moduleFactory); moduleFactories.add(moduleFactory);
} }

View File

@ -35,6 +35,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.Directory;
/** /**
* Dialog box that allows a user to configure and run an ingest job on one or * Dialog box that allows a user to configure and run an ingest job on one or
@ -43,7 +44,7 @@ import org.sleuthkit.datamodel.Content;
public final class RunIngestModulesDialog extends JDialog { public final class RunIngestModulesDialog extends JDialog {
private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text"); private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text");
private final boolean isDir; private final String context;
private static Dimension DIMENSIONS = new Dimension(500, 300); private static Dimension DIMENSIONS = new Dimension(500, 300);
private final List<Content> dataSources = new ArrayList<>(); private final List<Content> dataSources = new ArrayList<>();
private IngestJobSettingsPanel ingestJobSettingsPanel; private IngestJobSettingsPanel ingestJobSettingsPanel;
@ -60,23 +61,7 @@ public final class RunIngestModulesDialog extends JDialog {
public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources) { public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources) {
super(frame, title, modal); super(frame, title, modal);
this.dataSources.addAll(dataSources); this.dataSources.addAll(dataSources);
this.isDir = false; this.context = RunIngestModulesDialog.class.getCanonicalName();
}
/**
* Construct a dialog box that allows a user to configure and run an ingest
* job on one or more data sources.
*
* @param frame The dialog parent window.
* @param title The title for the dialog.
* @param modal True if the dialog should be modal, false otherwise.
* @param dataSources The data sources to be processed.
* @param isDir Whether the data sources are directories
*/
public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List<Content> dataSources, boolean isDir) {
super(frame, title, modal);
this.dataSources.addAll(dataSources);
this.isDir = isDir;
} }
/** /**
@ -89,15 +74,9 @@ public final class RunIngestModulesDialog extends JDialog {
this(new JFrame(TITLE), TITLE, true, dataSources); this(new JFrame(TITLE), TITLE, true, dataSources);
} }
/** public RunIngestModulesDialog(Directory dir) {
* Construct a dialog box that allows a user to configure and run an ingest this.dataSources.add(dir);
* job on one or more data sources. this.context = RunIngestModulesDialog.class.getCanonicalName() + ".isDir";
*
* @param dataSources The data sources to be processed.
* @param isDir Whether the data sources are directories
*/
public RunIngestModulesDialog(List<Content> dataSources, boolean isDir) {
this(new JFrame(TITLE), TITLE, true, dataSources, isDir);
} }
/** /**
@ -113,7 +92,7 @@ public final class RunIngestModulesDialog extends JDialog {
@Deprecated @Deprecated
public RunIngestModulesDialog(JFrame frame, String title, boolean modal) { public RunIngestModulesDialog(JFrame frame, String title, boolean modal) {
super(frame, title, modal); super(frame, title, modal);
this.isDir = false; this.context = RunIngestModulesDialog.class.getCanonicalName();
} }
/** /**
@ -159,7 +138,7 @@ public final class RunIngestModulesDialog extends JDialog {
* Get the default or saved ingest job settings for this context and use * Get the default or saved ingest job settings for this context and use
* them to create and add an ingest job settings panel. * them to create and add an ingest job settings panel.
*/ */
IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName(), isDir); IngestJobSettings ingestJobSettings = new IngestJobSettings(context);
RunIngestModulesDialog.showWarnings(ingestJobSettings); RunIngestModulesDialog.showWarnings(ingestJobSettings);
this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings); this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings);
add(this.ingestJobSettingsPanel, BorderLayout.PAGE_START); add(this.ingestJobSettingsPanel, BorderLayout.PAGE_START);