mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 09:47:42 +00:00
Tweaked the ImageFilePanel so it can be used by any other DataSourceProcessor that needs
an image path, a timezone string and the "no fat orphans" flag.
This commit is contained in:
parent
0b985703b7
commit
1bdc69dc1e
@ -41,8 +41,8 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
|
||||
|
||||
/**
|
||||
* visual component for the first panel of add image wizard. Allows user to pick
|
||||
* data source and timezone.
|
||||
* visual component for the first panel of add image wizard.
|
||||
* Allows the user to choose the data source type and then select the data source
|
||||
*
|
||||
*/
|
||||
final class AddImageWizardChooseDataSourceVisual extends JPanel {
|
||||
|
@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.casemodule;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
@ -28,6 +29,16 @@ import javax.swing.filechooser.FileFilter;
|
||||
*/
|
||||
public class GeneralFilter extends FileFilter{
|
||||
|
||||
|
||||
// Extensions & Descriptions for commonly used filters
|
||||
public static final List<String> RAW_IMAGE_EXTS = Arrays.asList(new String[]{".img", ".dd", ".001", ".aa", ".raw", ".bin"});
|
||||
public static final String RAW_IMAGE_DESC = "Raw Images (*.img, *.dd, *.001, *.aa, *.raw, *.bin)";
|
||||
|
||||
public static final List<String> ENCASE_IMAGE_EXTS = Arrays.asList(new String[]{".e01"});
|
||||
public static final String ENCASE_IMAGE_DESC = "Encase Images (*.e01)";
|
||||
|
||||
|
||||
|
||||
private List<String> extensions;
|
||||
private String desc;
|
||||
|
||||
|
@ -21,6 +21,10 @@ package org.sleuthkit.autopsy.casemodule;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JPanel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor;
|
||||
@ -37,6 +41,8 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
|
||||
@ServiceProvider(service = DataSourceProcessor.class)
|
||||
public class ImageDSProcessor implements DataSourceProcessor {
|
||||
|
||||
|
||||
|
||||
static final Logger logger = Logger.getLogger(ImageDSProcessor.class.getName());
|
||||
|
||||
// Data source type handled by this processor
|
||||
@ -62,13 +68,35 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
private boolean noFatOrphans;
|
||||
|
||||
|
||||
|
||||
|
||||
static final GeneralFilter rawFilter = new GeneralFilter(GeneralFilter.RAW_IMAGE_EXTS, GeneralFilter.RAW_IMAGE_DESC);
|
||||
static final GeneralFilter encaseFilter = new GeneralFilter(GeneralFilter.ENCASE_IMAGE_EXTS, GeneralFilter.ENCASE_IMAGE_DESC);
|
||||
|
||||
static final List<String> allExt = new ArrayList<String>();
|
||||
static {
|
||||
allExt.addAll(GeneralFilter.RAW_IMAGE_EXTS);
|
||||
allExt.addAll(GeneralFilter.ENCASE_IMAGE_EXTS);
|
||||
}
|
||||
static final String allDesc = "All Supported Types";
|
||||
static final GeneralFilter allFilter = new GeneralFilter(allExt, allDesc);
|
||||
|
||||
static final List<FileFilter> filtersList = new ArrayList<FileFilter>();
|
||||
|
||||
static {
|
||||
filtersList.add(allFilter);
|
||||
filtersList.add(rawFilter);
|
||||
filtersList.add(encaseFilter);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* A no argument constructor is required for the NM lookup() method to create an object
|
||||
*/
|
||||
public ImageDSProcessor() {
|
||||
|
||||
// Create the config panel
|
||||
imageFilePanel = ImageFilePanel.getDefault();
|
||||
imageFilePanel = ImageFilePanel.createInstance(ImageDSProcessor.class.getName(), filtersList);
|
||||
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
<Component id="noFatOrphansCheckbox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="descLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="33" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -31,6 +31,7 @@ import javax.swing.JFileChooser;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
|
||||
@ -40,56 +41,51 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
*/
|
||||
public class ImageFilePanel extends JPanel implements DocumentListener {
|
||||
|
||||
private final String PROP_LASTIMAGE_PATH = "LBL_LastImage_PATH";
|
||||
|
||||
private static final String PROP_LASTIMAGE_PATH = "LBL_LastImage_PATH";
|
||||
|
||||
static final List<String> rawExt = Arrays.asList(new String[]{".img", ".dd", ".001", ".aa", ".raw"});
|
||||
static final String rawDesc = "Raw Images (*.img, *.dd, *.001, *.aa, *.raw)";
|
||||
static GeneralFilter rawFilter = new GeneralFilter(rawExt, rawDesc);
|
||||
static final List<String> encaseExt = Arrays.asList(new String[]{".e01"});
|
||||
static final String encaseDesc = "Encase Images (*.e01)";
|
||||
static GeneralFilter encaseFilter = new GeneralFilter(encaseExt, encaseDesc);
|
||||
static final List<String> allExt = new ArrayList<String>();
|
||||
|
||||
static {
|
||||
allExt.addAll(rawExt);
|
||||
allExt.addAll(encaseExt);
|
||||
}
|
||||
static final String allDesc = "All Supported Types";
|
||||
static GeneralFilter allFilter = new GeneralFilter(allExt, allDesc);
|
||||
|
||||
|
||||
|
||||
private static ImageFilePanel instance = null;
|
||||
private PropertyChangeSupport pcs = null;
|
||||
private JFileChooser fc = new JFileChooser();
|
||||
|
||||
// Externally supplied name is used to store settings
|
||||
private String contextName;
|
||||
|
||||
/**
|
||||
* Creates new form ImageFilePanel
|
||||
* @param context a string context name used to read/store last used settings
|
||||
* @param fileChooserFilters a list of filters to be used with the FileChooser
|
||||
*/
|
||||
public ImageFilePanel() {
|
||||
private ImageFilePanel(String context, List<FileFilter> fileChooserFilters) {
|
||||
initComponents();
|
||||
fc.setDragEnabled(false);
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.addChoosableFileFilter(rawFilter);
|
||||
fc.addChoosableFileFilter(encaseFilter);
|
||||
fc.setFileFilter(allFilter);
|
||||
|
||||
boolean firstFilter = true;
|
||||
for (FileFilter filter: fileChooserFilters ) {
|
||||
if (firstFilter) { // set the first on the list as the default selection
|
||||
fc.setFileFilter(filter);
|
||||
firstFilter = false;
|
||||
}
|
||||
else {
|
||||
fc.addChoosableFileFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
this.contextName = context;
|
||||
pcs = new PropertyChangeSupport(this);
|
||||
|
||||
createTimeZoneList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default instance of a ImageFilePanel.
|
||||
* Creates and returns an instance of a ImageFilePanel.
|
||||
*/
|
||||
public static synchronized ImageFilePanel getDefault() {
|
||||
if (instance == null) {
|
||||
instance = new ImageFilePanel();
|
||||
public static synchronized ImageFilePanel createInstance(String context, List<FileFilter> fileChooserFilters) {
|
||||
|
||||
ImageFilePanel instance = new ImageFilePanel(context, fileChooserFilters );
|
||||
|
||||
instance.postInit();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -230,7 +226,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
|
||||
|
||||
}
|
||||
|
||||
boolean getNoFatOrphans() {
|
||||
public boolean getNoFatOrphans() {
|
||||
return noFatOrphansCheckbox.isSelected();
|
||||
}
|
||||
|
||||
@ -263,12 +259,12 @@ public class ImageFilePanel extends JPanel implements DocumentListener {
|
||||
String imagePathName = getContentPaths();
|
||||
if (null != imagePathName ) {
|
||||
String imagePath = imagePathName.substring(0, imagePathName.lastIndexOf(File.separator) + 1);
|
||||
ModuleSettings.setConfigSetting(ImageFilePanel.class.getName(), PROP_LASTIMAGE_PATH, imagePath);
|
||||
ModuleSettings.setConfigSetting(contextName, PROP_LASTIMAGE_PATH, imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
public void readSettings() {
|
||||
String lastImagePath = ModuleSettings.getConfigSetting(ImageFilePanel.class.getName(), PROP_LASTIMAGE_PATH);
|
||||
String lastImagePath = ModuleSettings.getConfigSetting(contextName, PROP_LASTIMAGE_PATH);
|
||||
if (null != lastImagePath) {
|
||||
if (!lastImagePath.isEmpty())
|
||||
pathTextField.setText(lastImagePath);
|
||||
|
@ -24,12 +24,14 @@ import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.io.File;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.sleuthkit.autopsy.casemodule.ImageFilePanel;
|
||||
import org.sleuthkit.autopsy.casemodule.GeneralFilter;
|
||||
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
@ -44,6 +46,16 @@ public class MissingImageDialog extends javax.swing.JDialog {
|
||||
|
||||
|
||||
|
||||
static final GeneralFilter rawFilter = new GeneralFilter(GeneralFilter.RAW_IMAGE_EXTS, GeneralFilter.RAW_IMAGE_DESC);
|
||||
static final GeneralFilter encaseFilter = new GeneralFilter(GeneralFilter.ENCASE_IMAGE_EXTS, GeneralFilter.ENCASE_IMAGE_DESC);
|
||||
|
||||
static final List<String> allExt = new ArrayList<String>();
|
||||
static {
|
||||
allExt.addAll(GeneralFilter.RAW_IMAGE_EXTS);
|
||||
allExt.addAll(GeneralFilter.ENCASE_IMAGE_EXTS);
|
||||
}
|
||||
static final String allDesc = "All Supported Types";
|
||||
static final GeneralFilter allFilter = new GeneralFilter(allExt, allDesc);
|
||||
|
||||
private JFileChooser fc = new JFileChooser();
|
||||
|
||||
@ -57,10 +69,9 @@ public class MissingImageDialog extends javax.swing.JDialog {
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
|
||||
// borrow the filters from ImageFilePanel
|
||||
fc.addChoosableFileFilter(ImageFilePanel.rawFilter);
|
||||
fc.addChoosableFileFilter(ImageFilePanel.encaseFilter);
|
||||
fc.setFileFilter(ImageFilePanel.allFilter);
|
||||
fc.addChoosableFileFilter(rawFilter);
|
||||
fc.addChoosableFileFilter(encaseFilter);
|
||||
fc.setFileFilter(allFilter);
|
||||
|
||||
|
||||
customInit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user