diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index 7204664d2f..8b1a4dd1e0 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2014 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,7 @@ import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; +import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescriptorPanel; /** * The final panel of the add image wizard. It displays a progress bar and @@ -39,7 +40,7 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgress * {@link AddImageWizardIngestConfigPanel} (which is a bit weird if you ask m * -jm) */ -class AddImageWizardAddingProgressPanel implements WizardDescriptor.FinishablePanel { +class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { /** * flag to indicate that the image adding process is finished and this panel @@ -53,7 +54,7 @@ class AddImageWizardAddingProgressPanel implements WizardDescriptor.FinishablePa private AddImageWizardAddingProgressVisual component; private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0 - private DSPProgressMonitorImpl dspProgressMonitorImpl = new DSPProgressMonitorImpl(); + private final DSPProgressMonitorImpl dspProgressMonitorImpl = new DSPProgressMonitorImpl(); public DSPProgressMonitorImpl getDSPProgressMonitorImpl() { return dspProgressMonitorImpl; @@ -192,7 +193,7 @@ class AddImageWizardAddingProgressPanel implements WizardDescriptor.FinishablePa protected final void fireChangeEvent() { Iterator it; synchronized (listeners) { - it = new HashSet(listeners).iterator(); + it = new HashSet<>(listeners).iterator(); } ChangeEvent ev = new ChangeEvent(this); while (it.hasNext()) { @@ -239,8 +240,4 @@ class AddImageWizardAddingProgressPanel implements WizardDescriptor.FinishablePa getComponent().showErrors(errorString, critical); } - @Override - public boolean isFinishPanel() { - return true; - } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourcePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourcePanel.java index 88762ba96a..3d58017ecb 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourcePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourcePanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,18 +33,19 @@ import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.windows.WindowManager; import java.awt.Cursor; +import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescriptorPanel; /** * The "Add Image" wizard panel1 handling the logic of selecting image file(s) * to add to Case, and pick the time zone. */ -class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel, PropertyChangeListener { +class AddImageWizardChooseDataSourcePanel extends ShortcutWizardDescriptorPanel implements PropertyChangeListener { /** * The visual component that displays this panel. If you need to access the * component from this class, just use getComponent(). */ - private AddImageWizardAddingProgressPanel progressPanel; + private final AddImageWizardAddingProgressPanel progressPanel; private AddImageWizardChooseDataSourceVisual component; private boolean isNextEnable = false; private static final String PROP_LASTDATASOURCE_PATH = "LBL_LastDataSource_PATH"; //NON-NLS @@ -122,7 +123,7 @@ class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel listeners = new HashSet(1); // or can use ChangeSupport in NB 6.0 + private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0 /** * Adds a listener to changes of the panel's validity. @@ -155,7 +156,7 @@ class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel it; synchronized (listeners) { - it = new HashSet(listeners).iterator(); + it = new HashSet<>(listeners).iterator(); } ChangeEvent ev = new ChangeEvent(this); while (it.hasNext()) { @@ -218,8 +219,6 @@ class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,17 +30,19 @@ import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.event.ChangeListener; -import org.omg.CORBA.BAD_CONTEXT; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle.Messages; import org.sleuthkit.datamodel.Content; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; +import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettingsPanel; import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.IngestProfileSelectionWizardPanel; +import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescriptorPanel; /** * second panel of add image wizard, allows user to configure ingest modules. @@ -48,20 +50,19 @@ import org.sleuthkit.autopsy.ingest.IngestManager; * TODO: review this for dead code. think about moving logic of adding image to * 3rd panel( {@link AddImageWizardAddingProgressPanel}) separate class -jm */ -class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel { - @Messages("AddImageWizardIngestConfigPanel.name.text=Configure Ingest Modules") - private final IngestJobSettingsPanel ingestJobSettingsPanel; +class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { + @Messages("AddImageWizardIngestConfigPanel.name.text=Configure Ingest Modules") + private IngestJobSettingsPanel ingestJobSettingsPanel; /** * The visual component that displays this panel. If you need to access the * component from this class, just use getComponent(). */ private Component component = null; - + private String lastProfileUsed = AddImageWizardIngestConfigPanel.class.getCanonicalName(); private final List newContents = Collections.synchronizedList(new ArrayList()); private boolean ingested = false; private boolean readyToIngest = false; - // task that will clean up the created database file if the wizard is cancelled before it finishes private AddImageAction.CleanupTask cleanupTask; @@ -77,11 +78,12 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,6 +26,9 @@ import javax.swing.JComponent; import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.ingest.IngestProfiles; +import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.IngestProfileSelectionWizardPanel; +import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescriptorPanel; /** * The iterator class for the "Add Image" wizard panel. This class is used to @@ -34,8 +37,10 @@ import org.openide.util.NbBundle; class AddImageWizardIterator implements WizardDescriptor.Iterator { private int index = 0; - private List> panels; - private AddImageAction action; + private List panels; + private final AddImageAction action; + private int progressPanelIndex; + private final static String PROP_LASTPROFILE_NAME = "AIW_LASTPROFILE_NAME"; //NON-NLS AddImageWizardIterator(AddImageAction action) { this.action = action; @@ -45,19 +50,22 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator> getPanels() { + private List getPanels() { if (panels == null) { - panels = new ArrayList>(); + panels = new ArrayList<>(); AddImageWizardAddingProgressPanel progressPanel = new AddImageWizardAddingProgressPanel(); AddImageWizardChooseDataSourcePanel dsPanel = new AddImageWizardChooseDataSourcePanel(progressPanel); AddImageWizardIngestConfigPanel ingestConfigPanel = new AddImageWizardIngestConfigPanel(dsPanel, action, progressPanel); - panels.add(dsPanel); + List profiles = IngestProfiles.getIngestProfiles(); + if (!profiles.isEmpty()) { + panels.add(new IngestProfileSelectionWizardPanel(AddImageWizardIngestConfigPanel.class.getCanonicalName(), getPropLastprofileName())); + } panels.add(ingestConfigPanel); panels.add(progressPanel); - + progressPanelIndex = panels.indexOf(progressPanel); //Doing programatically because number of panels is variable String[] steps = new String[panels.size()]; for (int i = 0; i < panels.size(); i++) { Component c = panels.get(i).getComponent(); @@ -66,7 +74,7 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator current() { + public ShortcutWizardDescriptorPanel current() { if (panels != null) { return panels.get(index); } else { @@ -146,7 +171,14 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java index 40f14bf63a..8a056b2318 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/VirtualDirectoryNode.java @@ -48,7 +48,7 @@ import org.sleuthkit.datamodel.VirtualDirectory; */ public class VirtualDirectoryNode extends AbstractAbstractFileNode { - private static Logger logger = Logger.getLogger(VirtualDirectoryNode.class.getName()); + private static final Logger logger = Logger.getLogger(VirtualDirectoryNode.class.getName()); //prefix for special VirtualDirectory root nodes grouping local files public final static String LOGICAL_FILE_SET_PREFIX = "LogicalFileSet"; //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java index 22b4677c36..4cbf5fa283 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/DirectoryTreeTopComponent.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2016 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -297,6 +297,8 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat * only, i.e. deserialization routines; otherwise you could get a * non-deserialized instance. To obtain the singleton instance, use * {@link #findInstance}. + * + * @return instance - the default instance */ public static synchronized DirectoryTreeTopComponent getDefault() { if (instance == null) { @@ -308,6 +310,8 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat /** * Obtain the DirectoryTreeTopComponent instance. Never call * {@link #getDefault} directly! + * + * @return getDefault() - the default instance */ public static synchronized DirectoryTreeTopComponent findInstance() { WindowManager winManager = WindowManager.getDefault(); @@ -667,7 +671,7 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat try { displayName = content.getUniquePath(); } catch (TskCoreException ex) { - LOGGER.log(Level.SEVERE, "Exception while calling Content.getUniquePath() for node: " + originNode); //NON-NLS + LOGGER.log(Level.SEVERE, "Exception while calling Content.getUniquePath() for node: {0}", originNode); //NON-NLS } } else if (originNode.getLookup().lookup(String.class) != null) { displayName = originNode.getLookup().lookup(String.class); diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerOptionsPanelController.java index 5df5b89e56..ee65dfbf1c 100755 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerOptionsPanelController.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerOptionsPanelController.java @@ -1,15 +1,15 @@ /* * Autopsy Forensic Browser - * - * Copyright 2011-2016 Basis Technology Corp. + * + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java index 7ee74a726e..28bf7a623e 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanel.java @@ -42,8 +42,11 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen "IngestOptionsPanel.profilesTab.toolTipText=Settings for creating and editing profiles."}) private FilesSetDefsPanel filterPanel; + private final static int INDEX_OF_FILTER_PANEL = 0; private IngestSettingsPanel settingsPanel; + private final static int INDEX_OF_SETTINGS_PANEL = 2; private ProfileSettingsPanel profilePanel; + private final static int INDEX_OF_PROFILE_PANEL = 1; /** * This panel implements a property change listener that listens to ingest * job events so it can disable the buttons on the panel if ingest is @@ -63,11 +66,11 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen profilePanel = new ProfileSettingsPanel(); tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.text"), null, - filterPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.toolTipText"), 0); + filterPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.toolTipText"), INDEX_OF_FILTER_PANEL); tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null, - profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), 1); + profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), INDEX_OF_PROFILE_PANEL); tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.settingsTab.text"), null, - settingsPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.settingsTab.toolTipText"), 2); + settingsPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.settingsTab.toolTipText"), INDEX_OF_SETTINGS_PANEL); //Listener for when tabbed panes are switched, because we can have two file filter definitions panels open at the same time //we may wind up in a situation where the user has created and saved one in the profiles panel //so we need to refresh the filterPanel in those cases before proceeding. @@ -75,10 +78,15 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen @Override public void stateChanged(ChangeEvent e) { if (e.getSource() instanceof JTabbedPane) { - profilePanel.shouldFiltersBeRefreshed(); - { - filterPanel.load(); - } + //because we can have two filterPanels open at the same time + //we need to save the settings when we change tabs otherwise + //they could be overwritten with out of date + if (tabbedPane.getSelectedIndex() == INDEX_OF_FILTER_PANEL) { + filterPanel.load(); + } + else { + filterPanel.saveSettings(); + } } } }); @@ -152,10 +160,6 @@ public class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implemen */ @Override public void saveSettings() { - //if a new filter was created in the profilePanel we don't want to save over it accidently - if (profilePanel.shouldFiltersBeRefreshed()) { - filterPanel.load(); - } filterPanel.store(); settingsPanel.store(); } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanelController.java index b9c4ea9546..9c908d9ebb 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanelController.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestOptionsPanelController.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2017 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestTasksScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestTasksScheduler.java index f7c32930c0..a9ad8c7634 100755 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestTasksScheduler.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestTasksScheduler.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2012-2016 Basis Technology Corp. + * Copyright 2012-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,6 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.openide.util.Exceptions; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/ProfileSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/ProfileSettingsPanel.java index 1b1fbc40c0..1db29f0b5f 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/ProfileSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/ProfileSettingsPanel.java @@ -51,7 +51,6 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op private final DefaultListModel profilesListModel; private Map profiles; private ProfilePanel panel; - private boolean filtersShouldBeRefreshed; /** * Creates new form ProfileOptionsPanel @@ -59,7 +58,6 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op ProfileSettingsPanel() { this.profilesListModel = new DefaultListModel<>(); initComponents(); - this.filtersShouldBeRefreshed = false; this.profileList.setModel(profilesListModel); this.profileList.addListSelectionListener(new ProfileSettingsPanel.ProfileListSelectionListener()); ingestWarningLabel.setVisible(false); @@ -275,20 +273,6 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); }//GEN-LAST:event_deleteProfileButtonActionPerformed - /** - * Returns whether there were possible changes to the filter list since the - * last time this was called. - * - * Resets value to false after being called. - * - * @return true or false - */ - boolean shouldFiltersBeRefreshed() { - boolean shouldRefresh = filtersShouldBeRefreshed; - filtersShouldBeRefreshed = false; - return shouldRefresh; - } - /** * Enable / disable buttons, so they can be disabled while ingest is * running. diff --git a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestModulesConfigWizardPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestModulesConfigWizardPanel.java index 15a83b38cf..c330df974e 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestModulesConfigWizardPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestModulesConfigWizardPanel.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.ingest.runIngestModuleWizard; +import java.awt.Component; import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; @@ -25,9 +26,10 @@ import org.openide.util.NbBundle; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettingsPanel; -class IngestModulesConfigWizardPanel implements WizardDescriptor.FinishablePanel { - +class IngestModulesConfigWizardPanel extends ShortcutWizardDescriptorPanel { + @NbBundle.Messages("IngestModulesConfigWizardPanel.name.text=Configure Ingest Modules") + /** * The visual ingestJobSettingsPanel that displays this panel. If you need * to access the ingestJobSettingsPanel from this class, just use @@ -40,7 +42,7 @@ class IngestModulesConfigWizardPanel implements WizardDescriptor.FinishablePanel // but never displayed, or not all panels are displayed, it is better to // create only those which really need to be visible. @Override - public IngestJobSettingsPanel getComponent() { + public Component getComponent() { if (ingestJobSettingsPanel == null) { ingestJobSettingsPanel = new IngestJobSettingsPanel(new IngestJobSettings(RunIngestModulesAction.getDefaultContext())); } @@ -79,9 +81,4 @@ class IngestModulesConfigWizardPanel implements WizardDescriptor.FinishablePanel wiz.putProperty("executionContext", RunIngestModulesAction.getDefaultContext()); //NON-NLS } - @Override - public boolean isFinishPanel() { - return true; - } - } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionPanel.java index 7be4dcdc5f..46ee8370bf 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionPanel.java @@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.ingest.runIngestModuleWizard; import java.awt.Color; import java.awt.Component; - import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; @@ -91,7 +90,7 @@ final class IngestProfileSelectionPanel extends JPanel implements ItemListener { constraints.weighty = .0; constraints.anchor = GridBagConstraints.FIRST_LINE_START; - addRadioButton(CUSTOM_SETTINGS_DISPLAY_NAME, RunIngestModulesAction.getDefaultContext(), CUSTOM_SETTINGS_DESCRIPTION, gridBagLayout, constraints); + addRadioButton(CUSTOM_SETTINGS_DISPLAY_NAME, wizardPanel.getDefaultContext(), CUSTOM_SETTINGS_DESCRIPTION, gridBagLayout, constraints); for (IngestProfile profile : profiles) { constraints.weightx = 0; constraints.gridy++; @@ -275,7 +274,7 @@ final class IngestProfileSelectionPanel extends JPanel implements ItemListener { } } boolean wasLastPanel = isLastPanel; - isLastPanel = !selectedProfile.equals(RunIngestModulesAction.getDefaultContext()); + isLastPanel = !selectedProfile.equals(wizardPanel.getDefaultContext()); wizardPanel.fireChangeEvent(); this.firePropertyChange("LAST_ENABLED", wasLastPanel, isLastPanel); //NON-NLS } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionWizardPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionWizardPanel.java index ed164a585b..207e577bf1 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionWizardPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/IngestProfileSelectionWizardPanel.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.ingest.runIngestModuleWizard; +import java.awt.Component; import java.util.HashSet; import java.util.Set; import javax.swing.event.ChangeEvent; @@ -32,37 +33,60 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings; * selection panel and is only created when profiles exist. * */ -class IngestProfileSelectionWizardPanel implements WizardDescriptor.FinishablePanel { +public class IngestProfileSelectionWizardPanel extends ShortcutWizardDescriptorPanel { @Messages("IngestProfileWizardPanel.panelName=Ingest Profile Selection") private final Set listeners = new HashSet<>(1); - private final static String PROP_LASTPROFILE_NAME = "RIMW_LASTPROFILE_NAME"; //NON-NLS private final static String LAST_PROFILE_PROPERTIES_FILE = "IngestProfileSelectionPanel"; //NON-NLS /** - * The visual component that displays this panel. If you need to access the - * component from this class, just use getComponent(). + * The visual ingestProfileSelectionPanel that displays this panel. If you + * need to access the ingestProfileSelectionPanel from this class, just use + * getComponent(). */ - private IngestProfileSelectionPanel component; + private IngestProfileSelectionPanel ingestProfileSelectionPanel; private String lastProfileUsed; + private final String lastProfilePropertyName; + private final String defaultContext; - // Get the visual component for the panel. In this template, the component + public IngestProfileSelectionWizardPanel(String defaultContext, String lastProfilePropertyName) { + this.lastProfilePropertyName = lastProfilePropertyName; + this.defaultContext = defaultContext; + } + + /** + * @return the defaultContext + */ + String getDefaultContext() { + return defaultContext; + } + + /** + * Gets the name of the file which stores the last profile used properties. + * + * @return the LAST_PROFILE_PROPERTIES_FILE + */ + public static String getLastProfilePropertiesFile() { + return LAST_PROFILE_PROPERTIES_FILE; + } + + // Get the visual ingestProfileSelectionPanel for the panel. In this template, the ingestProfileSelectionPanel // is kept separate. This can be more efficient: if the wizard is created // but never displayed, or not all panels are displayed, it is better to // create only those which really need to be visible. @Override - public IngestProfileSelectionPanel getComponent() { - 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 = RunIngestModulesAction.getDefaultContext(); + public Component getComponent() { + if (ingestProfileSelectionPanel == null) { + if (!(ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, lastProfilePropertyName) == null) + && !ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, lastProfilePropertyName).isEmpty()) { + lastProfileUsed = ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, lastProfilePropertyName); } else { - lastProfileUsed = ModuleSettings.getConfigSetting(LAST_PROFILE_PROPERTIES_FILE, PROP_LASTPROFILE_NAME); + lastProfileUsed = getDefaultContext(); } - component = new IngestProfileSelectionPanel(this, lastProfileUsed); - component.setName(Bundle.IngestProfileWizardPanel_panelName()); + ingestProfileSelectionPanel = new IngestProfileSelectionPanel(this, lastProfileUsed); + ingestProfileSelectionPanel.setName(Bundle.IngestProfileWizardPanel_panelName()); } - return component; + return ingestProfileSelectionPanel; } @Override @@ -111,14 +135,18 @@ class IngestProfileSelectionWizardPanel implements WizardDescriptor.FinishablePa @Override public void storeSettings(WizardDescriptor wiz) { - lastProfileUsed = component.getLastSelectedProfile(); + lastProfileUsed = ingestProfileSelectionPanel.getLastSelectedProfile(); wiz.putProperty("executionContext", lastProfileUsed); //NON-NLS - ModuleSettings.setConfigSetting(LAST_PROFILE_PROPERTIES_FILE, PROP_LASTPROFILE_NAME, lastProfileUsed); + ModuleSettings.setConfigSetting(LAST_PROFILE_PROPERTIES_FILE, lastProfilePropertyName, lastProfileUsed); } @Override - public boolean isFinishPanel() { - return component.isLastPanel; + public boolean skipNextPanel() { + return ingestProfileSelectionPanel.isLastPanel; } + @Override + public boolean panelEnablesSkipping() { + return true; + } } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/RunIngestModulesWizardIterator.java b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/RunIngestModulesWizardIterator.java index c02b2153f4..ca242095fd 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/RunIngestModulesWizardIterator.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/RunIngestModulesWizardIterator.java @@ -34,8 +34,8 @@ import org.sleuthkit.autopsy.ingest.IngestProfiles; final class RunIngestModulesWizardIterator implements WizardDescriptor.Iterator { private int index; - - private List> panels; + private final static String PROP_LASTPROFILE_NAME = "RIMW_LASTPROFILE_NAME"; //NON-NLS + private List panels; /** * Gets the list of panels used by this wizard for iterating over. @@ -43,12 +43,12 @@ final class RunIngestModulesWizardIterator implements WizardDescriptor.Iterator< * * @return panels - the list of of WizardDescriptor panels */ - private List> getPanels() { + private List getPanels() { if (panels == null) { panels = new ArrayList<>(); List profiles = IngestProfiles.getIngestProfiles(); if (!profiles.isEmpty()) { - panels.add(new IngestProfileSelectionWizardPanel()); + panels.add(new IngestProfileSelectionWizardPanel(RunIngestModulesAction.getDefaultContext(), PROP_LASTPROFILE_NAME)); } panels.add(new IngestModulesConfigWizardPanel()); @@ -71,7 +71,7 @@ final class RunIngestModulesWizardIterator implements WizardDescriptor.Iterator< } @Override - public WizardDescriptor.FinishablePanel current() { + public ShortcutWizardDescriptorPanel current() { return getPanels().get(index); } @@ -82,7 +82,8 @@ final class RunIngestModulesWizardIterator implements WizardDescriptor.Iterator< @Override public boolean hasNext() { - return (index < getPanels().size() - 1) && !current().isFinishPanel(); + return (index < getPanels().size() - 1 + && !(current().panelEnablesSkipping() && current().skipNextPanel())); } @Override diff --git a/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/ShortcutWizardDescriptorPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/ShortcutWizardDescriptorPanel.java new file mode 100644 index 0000000000..589ebdee14 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/ingest/runIngestModuleWizard/ShortcutWizardDescriptorPanel.java @@ -0,0 +1,68 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2011-2017 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.ingest.runIngestModuleWizard; + +import org.openide.WizardDescriptor; + +/** + * An abstract class providing a methods which can be checked by the iterator + * containing panels of this type. So that Wizards containing these panels can + * skip panels, but still call necessary methods of those panels. + */ +public abstract class ShortcutWizardDescriptorPanel implements WizardDescriptor.Panel { + + /** + * Whether or not this panel under the correct conditions can enable the + * skipping of the panel after it. + * + * @return true or false + */ + public boolean panelEnablesSkipping() { + /* + * This method should be overriden by any panel that might want to + * enable the iterator to skip the panel that comes after it. + */ + return false; + } + + /** + * Whether or not the panel immediately following this one should be skipped + * . + * + * @return true or false + */ + public boolean skipNextPanel() { + /* + * This method should be overriden by any panel that might want to + * enable the iterator to skip the panel that comes after it. + */ + return false; + } + + /** + * Provides a method which will allow code to be executed in a panel you + * plan to skip + */ + public void processThisPanelBeforeSkipped() { + /* + * If you need to perform some actions of this panel before it is + * skipped override this method to have it call the necessary code. + */ + } +} diff --git a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchOptionsPanelController.java index 93eef3c0a0..be5d476c5b 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchOptionsPanelController.java +++ b/Core/src/org/sleuthkit/autopsy/modules/fileextmismatch/FileExtMismatchOptionsPanelController.java @@ -1,6 +1,20 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * Autopsy Forensic Browser + * + * Copyright 2011-2017 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.sleuthkit.autopsy.modules.fileextmismatch; diff --git a/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdOptionsPanelController.java index 434e17d463..624cdb747c 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdOptionsPanelController.java +++ b/Core/src/org/sleuthkit/autopsy/modules/filetypeid/FileTypeIdOptionsPanelController.java @@ -1,7 +1,20 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Autopsy Forensic Browser + * + * Copyright 2011-2017 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.sleuthkit.autopsy.modules.filetypeid; diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDatabaseOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDatabaseOptionsPanelController.java index c2c52a4097..cd320258ce 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDatabaseOptionsPanelController.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/HashDatabaseOptionsPanelController.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java index cbb3576b41..6fb44839b5 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSet.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2014 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetDefsPanel.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetDefsPanel.java index 184b5d8b46..b4743bd360 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetDefsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/FilesSetDefsPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2016 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsOptionsPanelController.java b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsOptionsPanelController.java index 7280f3b7ab..3a579d7b51 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsOptionsPanelController.java +++ b/Core/src/org/sleuthkit/autopsy/modules/interestingitems/InterestingItemDefsOptionsPanelController.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2014 Basis Technology Corp. + * Copyright 2011-2017 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License");