From cdc723507cdc47a5eec3a1bbc69d0808424dd786 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Sat, 9 Sep 2017 13:17:10 +0200 Subject: [PATCH 1/4] cleanup ImageFilePanel --- .../autopsy/casemodule/ImageFilePanel.java | 188 ++++++++---------- 1 file changed, 78 insertions(+), 110 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index 4373959707..ebab01ea79 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.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"); @@ -20,22 +20,24 @@ package org.sleuthkit.autopsy.casemodule; import java.io.File; import java.util.Calendar; +import java.util.LinkedList; import java.util.List; +import java.util.MissingResourceException; +import java.util.Optional; import java.util.SimpleTimeZone; import java.util.TimeZone; +import java.util.logging.Level; import javax.swing.JFileChooser; +import javax.swing.JPanel; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import javax.swing.JPanel; import javax.swing.filechooser.FileFilter; - import org.openide.util.NbBundle; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; -import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; -import java.util.logging.Level; import org.sleuthkit.autopsy.coreutils.DriveUtils; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; +import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PathValidator; /** @@ -43,68 +45,70 @@ import org.sleuthkit.autopsy.coreutils.PathValidator; */ public class ImageFilePanel extends JPanel implements DocumentListener { - private final String PROP_LASTIMAGE_PATH = "LBL_LastImage_PATH"; //NON-NLS private static final Logger logger = Logger.getLogger(ImageFilePanel.class.getName()); - private final JFileChooser fc = new JFileChooser(); + private static final String PROP_LASTIMAGE_PATH = "LBL_LastImage_PATH"; //NON-NLS - // Externally supplied name is used to store settings + private final JFileChooser fileChooser = new JFileChooser(); + + /** + * Externally supplied name is used to store settings + */ private final 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 + * @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. */ private ImageFilePanel(String context, List fileChooserFilters) { + this.contextName = context; + initComponents(); - fc.setDragEnabled(false); - fc.setFileSelectionMode(JFileChooser.FILES_ONLY); - fc.setMultiSelectionEnabled(false); + // load and add all timezone + for (String id : SimpleTimeZone.getAvailableIDs()) { + timeZoneComboBox.addItem(timeZoneToString(TimeZone.getTimeZone(id))); + } + // set the selected timezone to the current timezone + timeZoneComboBox.setSelectedItem(timeZoneToString(Calendar.getInstance().getTimeZone())); errorLabel.setVisible(false); - 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; + fileChooser.setDragEnabled(false); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(false); + LinkedList filters = new LinkedList<>(fileChooserFilters); + Optional.of(filters.poll()).ifPresent(fileChooser::setFileFilter); + filters.forEach(fileChooser::addChoosableFileFilter); } /** * Creates and returns an instance of a 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. + * * @return instance of the ImageFilePanel */ public static synchronized ImageFilePanel createInstance(String context, List fileChooserFilters) { ImageFilePanel instance = new ImageFilePanel(context, fileChooserFilters); - instance.postInit(); - instance.createTimeZoneList(); + // post-constructor initialization of listener support without leaking references of uninitialized objects + instance.pathTextField.getDocument().addDocumentListener(instance); return instance; } - //post-constructor initialization to properly initialize listener support - //without leaking references of uninitialized objects - private void postInit() { - pathTextField.getDocument().addDocumentListener(this); - } - /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -187,29 +191,21 @@ public class ImageFilePanel extends JPanel implements DocumentListener { .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents - @SuppressWarnings("deprecation") + private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed String oldText = pathTextField.getText(); // set the current directory of the FileChooser if the ImagePath Field is valid File currentDir = new File(oldText); if (currentDir.exists()) { - fc.setCurrentDirectory(currentDir); + fileChooser.setCurrentDirectory(currentDir); } - int retval = fc.showOpenDialog(this); + int retval = fileChooser.showOpenDialog(this); if (retval == JFileChooser.APPROVE_OPTION) { - String path = fc.getSelectedFile().getPath(); - pathTextField.setText(path); + pathTextField.setText(fileChooser.getSelectedFile().getPath()); } - try { - firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.FOCUS_NEXT.toString(), false, true); - } catch (Exception e) { - logger.log(Level.SEVERE, "ImageFilePanel listener threw exception", e); //NON-NLS - MessageNotifyUtil.Notify.show(NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr"), - NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr.msg"), - MessageNotifyUtil.MessageType.ERROR); - } + updateHelper(); }//GEN-LAST:event_browseButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables @@ -234,6 +230,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { /** * Set the path of the image file. + * * @param s path of the image file */ public void setContentPath(String s) { @@ -305,41 +302,40 @@ public class ImageFilePanel extends JPanel implements DocumentListener { } } } - /** - * Creates the drop down list for the time zones and then makes the local + * Populates the drop down list for the time zones and then makes the local * machine time zone to be selected. */ - public void createTimeZoneList() { - // load and add all timezone - String[] ids = SimpleTimeZone.getAvailableIDs(); - for (String id : ids) { - TimeZone zone = TimeZone.getTimeZone(id); - int offset = zone.getRawOffset() / 1000; - int hour = offset / 3600; - int minutes = (offset % 3600) / 60; - String item = String.format("(GMT%+d:%02d) %s", hour, minutes, id); //NON-NLS - /* - * DateFormat dfm = new SimpleDateFormat("z"); - * dfm.setTimeZone(zone); boolean hasDaylight = - * zone.useDaylightTime(); String first = dfm.format(new Date(2010, - * 1, 1)); String second = dfm.format(new Date(2011, 6, 6)); int mid - * = hour * -1; String result = first + Integer.toString(mid); - * if(hasDaylight){ result = result + second; } - * timeZoneComboBox.addItem(item + " (" + result + ")"); - */ - timeZoneComboBox.addItem(item); - } - // get the current timezone - TimeZone thisTimeZone = Calendar.getInstance().getTimeZone(); - int thisOffset = thisTimeZone.getRawOffset() / 1000; - int thisHour = thisOffset / 3600; - int thisMinutes = (thisOffset % 3600) / 60; - String formatted = String.format("(GMT%+d:%02d) %s", thisHour, thisMinutes, thisTimeZone.getID()); //NON-NLS + /** + * Get a string representation of a TimeZone for use in the drop down list. + * + * @param zone The TimeZone to make a string for + * + * @return A string representation of a TimeZone for use in the drop down + * list. + */ + static private String timeZoneToString(TimeZone zone) { + int offset = zone.getRawOffset() / 1000; + int hour = offset / 3600; + int minutes = (offset % 3600) / 60; + String item = String.format("(GMT%+d:%02d) %s", hour, minutes, zone.getID()); //NON-NLS + return item; + } - // set the selected timezone - timeZoneComboBox.setSelectedItem(formatted); + @Override + public void insertUpdate(DocumentEvent e) { + updateHelper(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + updateHelper(); + } + + @Override + public void changedUpdate(DocumentEvent e) { + updateHelper(); } /** @@ -347,42 +343,14 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * it's DocumentEventListener. Each update function fires a property change * to be caught by the parent panel. * - * @param e the event, which is ignored */ - @Override - public void insertUpdate(DocumentEvent e) { - + private void updateHelper() throws MissingResourceException { try { firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true); } catch (Exception ee) { logger.log(Level.SEVERE, "ImageFilePanel listener threw exception", ee); //NON-NLS - MessageNotifyUtil.Notify.show(NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr"), - NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr.msg"), - MessageNotifyUtil.MessageType.ERROR); - } - } - - @Override - public void removeUpdate(DocumentEvent e) { - try { - firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true); - } catch (Exception ee) { - logger.log(Level.SEVERE, "ImageFilePanel listener threw exception", ee); //NON-NLS - MessageNotifyUtil.Notify.show(NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr"), - NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr.msg"), - MessageNotifyUtil.MessageType.ERROR); - } - } - - @Override - public void changedUpdate(DocumentEvent e) { - - try { - firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true); - } catch (Exception ee) { - logger.log(Level.SEVERE, "ImageFilePanel listener threw exception", ee); //NON-NLS - MessageNotifyUtil.Notify.show(NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr"), - NbBundle.getMessage(this.getClass(), "ImageFilePanel.moduleErr.msg"), + MessageNotifyUtil.Notify.show(NbBundle.getMessage(ImageFilePanel.class, "ImageFilePanel.moduleErr"), + NbBundle.getMessage(ImageFilePanel.class, "ImageFilePanel.moduleErr.msg"), MessageNotifyUtil.MessageType.ERROR); } } From a50284ea730aba256ce2b4f61f3f46baff60a9ad Mon Sep 17 00:00:00 2001 From: millmanorama Date: Sat, 9 Sep 2017 13:25:55 +0200 Subject: [PATCH 2/4] minor cleanup --- .../autopsy/casemodule/ImageFilePanel.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index ebab01ea79..c28c4ab279 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -20,10 +20,8 @@ package org.sleuthkit.autopsy.casemodule; import java.io.File; import java.util.Calendar; -import java.util.LinkedList; import java.util.List; import java.util.MissingResourceException; -import java.util.Optional; import java.util.SimpleTimeZone; import java.util.TimeZone; import java.util.logging.Level; @@ -67,7 +65,8 @@ public class ImageFilePanel extends JPanel implements DocumentListener { this.contextName = context; initComponents(); - // load and add all timezone + + // Populate the drop down list of time zones for (String id : SimpleTimeZone.getAvailableIDs()) { timeZoneComboBox.addItem(timeZoneToString(TimeZone.getTimeZone(id))); } @@ -80,9 +79,11 @@ public class ImageFilePanel extends JPanel implements DocumentListener { fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(false); - LinkedList filters = new LinkedList<>(fileChooserFilters); - Optional.of(filters.poll()).ifPresent(fileChooser::setFileFilter); - filters.forEach(fileChooser::addChoosableFileFilter); + fileChooserFilters.forEach(fileChooser::addChoosableFileFilter); + if (fileChooserFilters.isEmpty() == false) { + fileChooser.setFileFilter(fileChooserFilters.get(0)); + } + } /** @@ -302,10 +303,6 @@ public class ImageFilePanel extends JPanel implements DocumentListener { } } } - /** - * Populates the drop down list for the time zones and then makes the local - * machine time zone to be selected. - */ /** * Get a string representation of a TimeZone for use in the drop down list. From 9984503bfe92a0b49bd6eda7559a999cdc7408b6 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Sat, 9 Sep 2017 14:04:18 +0200 Subject: [PATCH 3/4] more cleanup --- .../autopsy/casemodule/Bundle.properties | 3 - .../autopsy/casemodule/ImageFilePanel.java | 70 +++++++------------ 2 files changed, 27 insertions(+), 46 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index cdf46e4d8c..d806a605c2 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -145,8 +145,6 @@ GeneralFilter.executableDesc.text=Executables (*.exe) ImageDSProcessor.dsType.text=Disk Image or VM File GeneralFilter.graphicImageDesc.text=Images (*.png, *.jpg, *.jpeg, *.gif, *.bmp) ImageDSProcessor.allDesc.text=All Supported Types -ImageFilePanel.moduleErr=Module Error -ImageFilePanel.moduleErr.msg=A module caused an error listening to ImageFilePanel updates. See log to determine which module. Some data could be incomplete. LocalDiskDSProcessor.dsType.text=Local Disk LocalDiskPanel.localDiskModel.loading.msg=Loading local disks... LocalDiskPanel.localDiskModel.nodrives.msg=No Accessible Drives @@ -197,7 +195,6 @@ UpdateRecentCases.menuItem.clearRecentCases.text=Clear Recent Cases UpdateRecentCases.menuItem.empty=-Empty- AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text=Cancel ImageFilePanel.errorLabel.text=Error Label -DataSourceOnCDriveError.text=Warning\: Path to multi-user data source is on "C\:" drive NewCaseVisualPanel1.CaseFolderOnCDriveError.text=Warning: Path to multi-user case folder is on \"C:\" drive LocalFilesPanel.errorLabel.text=Error Label CollaborationMonitor.addingDataSourceStatus.msg={0} adding data source diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java index c28c4ab279..0fe51144eb 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageFilePanel.java @@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.casemodule; import java.io.File; import java.util.Calendar; import java.util.List; -import java.util.MissingResourceException; import java.util.SimpleTimeZone; import java.util.TimeZone; import java.util.logging.Level; @@ -30,7 +29,9 @@ import javax.swing.JPanel; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.filechooser.FileFilter; +import org.apache.commons.lang3.StringUtils; import org.openide.util.NbBundle; +import static org.sleuthkit.autopsy.casemodule.Bundle.*; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.DriveUtils; import org.sleuthkit.autopsy.coreutils.Logger; @@ -39,7 +40,9 @@ import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PathValidator; /** - * ImageTypePanel for adding an image file such as .img, .E0x, .00x, etc. + * Panel for adding an image file such as .img, .E0x, .00x, etc. Allows the user + * to select a file as well as choose the timezone and whether to ignore orphan + * files in FAT32. */ public class ImageFilePanel extends JPanel implements DocumentListener { @@ -63,7 +66,6 @@ public class ImageFilePanel extends JPanel implements DocumentListener { */ private ImageFilePanel(String context, List fileChooserFilters) { this.contextName = context; - initComponents(); // Populate the drop down list of time zones @@ -78,12 +80,10 @@ public class ImageFilePanel extends JPanel implements DocumentListener { fileChooser.setDragEnabled(false); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(false); - fileChooserFilters.forEach(fileChooser::addChoosableFileFilter); if (fileChooserFilters.isEmpty() == false) { fileChooser.setFileFilter(fileChooserFilters.get(0)); } - } /** @@ -97,11 +97,9 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * @return instance of the ImageFilePanel */ public static synchronized ImageFilePanel createInstance(String context, List fileChooserFilters) { - ImageFilePanel instance = new ImageFilePanel(context, fileChooserFilters); // post-constructor initialization of listener support without leaking references of uninitialized objects instance.pathTextField.getDocument().addDocumentListener(instance); - return instance; } @@ -194,16 +192,15 @@ public class ImageFilePanel extends JPanel implements DocumentListener { }// //GEN-END:initComponents private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed - String oldText = pathTextField.getText(); + String oldText = getContentPaths(); // set the current directory of the FileChooser if the ImagePath Field is valid File currentDir = new File(oldText); if (currentDir.exists()) { fileChooser.setCurrentDirectory(currentDir); } - int retval = fileChooser.showOpenDialog(this); - if (retval == JFileChooser.APPROVE_OPTION) { - pathTextField.setText(fileChooser.getSelectedFile().getPath()); + if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + setContentPath(fileChooser.getSelectedFile().getPath()); } updateHelper(); @@ -240,7 +237,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { public String getTimeZone() { String tz = timeZoneComboBox.getSelectedItem().toString(); - return tz.substring(tz.indexOf(")") + 2).trim(); + return tz.substring(tz.indexOf(')') + 2).trim(); } public boolean getNoFatOrphans() { @@ -257,34 +254,23 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * * @return true if a proper image has been selected, false otherwise */ + @NbBundle.Messages("DataSourceOnCDriveError.text=Warning: Path to multi-user data source is on \"C:\" drive") public boolean validatePanel() { errorLabel.setVisible(false); String path = getContentPaths(); - if (path == null || path.isEmpty()) { + if (StringUtils.isBlank(path)) { return false; } // display warning if there is one (but don't disable "next" button) - warnIfPathIsInvalid(path); - - boolean isExist = new File(path).isFile(); - boolean isPhysicalDrive = DriveUtils.isPhysicalDrive(path); - boolean isPartition = DriveUtils.isPartition(path); - - return (isExist || isPhysicalDrive || isPartition); - } - - /** - * Validates path to selected data source and displays warning if it is - * invalid. - * - * @param path Absolute path to the selected data source - */ - private void warnIfPathIsInvalid(String path) { - if (!PathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { + if (false == PathValidator.isValid(path, Case.getCurrentCase().getCaseType())) { errorLabel.setVisible(true); - errorLabel.setText(NbBundle.getMessage(this.getClass(), "DataSourceOnCDriveError.text")); + errorLabel.setText(Bundle.DataSourceOnCDriveError_text()); } + + return new File(path).isFile() + || DriveUtils.isPhysicalDrive(path) + || DriveUtils.isPartition(path); } public void storeSettings() { @@ -297,10 +283,8 @@ public class ImageFilePanel extends JPanel implements DocumentListener { public void readSettings() { String lastImagePath = ModuleSettings.getConfigSetting(contextName, PROP_LASTIMAGE_PATH); - if (null != lastImagePath) { - if (!lastImagePath.isEmpty()) { - pathTextField.setText(lastImagePath); - } + if (StringUtils.isNotBlank(lastImagePath)) { + setContentPath(lastImagePath); } } @@ -316,8 +300,7 @@ public class ImageFilePanel extends JPanel implements DocumentListener { int offset = zone.getRawOffset() / 1000; int hour = offset / 3600; int minutes = (offset % 3600) / 60; - String item = String.format("(GMT%+d:%02d) %s", hour, minutes, zone.getID()); //NON-NLS - return item; + return String.format("(GMT%+d:%02d) %s", hour, minutes, zone.getID()); //NON-NLS } @Override @@ -341,14 +324,15 @@ public class ImageFilePanel extends JPanel implements DocumentListener { * to be caught by the parent panel. * */ - private void updateHelper() throws MissingResourceException { + @NbBundle.Messages({"ImageFilePanel.moduleErr=Module Error", + "ImageFilePanel.moduleErr.msg=A module caused an error listening to ImageFilePanel updates." + + " See log to determine which module. Some data could be incomplete.\n"}) + private void updateHelper() { try { firePropertyChange(DataSourceProcessor.DSP_PANEL_EVENT.UPDATE_UI.toString(), false, true); - } catch (Exception ee) { - logger.log(Level.SEVERE, "ImageFilePanel listener threw exception", ee); //NON-NLS - MessageNotifyUtil.Notify.show(NbBundle.getMessage(ImageFilePanel.class, "ImageFilePanel.moduleErr"), - NbBundle.getMessage(ImageFilePanel.class, "ImageFilePanel.moduleErr.msg"), - MessageNotifyUtil.MessageType.ERROR); + } catch (Exception e) { + logger.log(Level.SEVERE, "ImageFilePanel listener threw exception", e); //NON-NLS + MessageNotifyUtil.Notify.error(ImageFilePanel_moduleErr(), ImageFilePanel_moduleErr_msg()); } } From cba65e8f4bdf463891299c626278ccab15436184 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Sun, 10 Sep 2017 10:05:18 +0200 Subject: [PATCH 4/4] clean up GeneralFilter.java --- .../autopsy/casemodule/Bundle.properties | 5 -- .../autopsy/casemodule/GeneralFilter.java | 48 ++++++++----------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index d806a605c2..85dd7443ae 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -138,12 +138,7 @@ IntervalErrorReport.TotalIssues=total issue(s) IntervalErrorReport.ErrorText=Database Connection Error CasePropertiesAction.window.title=Case Properties CueBannerPanel.title.text=Open Recent Case -GeneralFilter.rawImageDesc.text=Raw Images (*.img, *.dd, *.001, *.aa, *.raw, *.bin) -GeneralFilter.encaseImageDesc.text=Encase Images (*.e01) -GeneralFilter.virtualMachineImageDesc.text=Virtual Machines (*.vmdk, *.vhd) -GeneralFilter.executableDesc.text=Executables (*.exe) ImageDSProcessor.dsType.text=Disk Image or VM File -GeneralFilter.graphicImageDesc.text=Images (*.png, *.jpg, *.jpeg, *.gif, *.bmp) ImageDSProcessor.allDesc.text=All Supported Types LocalDiskDSProcessor.dsType.text=Local Disk LocalDiskPanel.localDiskModel.loading.msg=Loading local disks... diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/GeneralFilter.java b/Core/src/org/sleuthkit/autopsy/casemodule/GeneralFilter.java index f848722953..7d06ae23c3 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/GeneralFilter.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/GeneralFilter.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"); @@ -18,12 +18,11 @@ */ package org.sleuthkit.autopsy.casemodule; -import org.openide.util.NbBundle; - import java.io.File; -import java.util.List; import java.util.Arrays; +import java.util.List; import javax.swing.filechooser.FileFilter; +import org.openide.util.NbBundle; /** * FileFilter helper class. Matches files based on extension @@ -31,25 +30,28 @@ import javax.swing.filechooser.FileFilter; public class GeneralFilter extends FileFilter { // Extensions & Descriptions for commonly used filters - public static final List RAW_IMAGE_EXTS = Arrays.asList(new String[]{".img", ".dd", ".001", ".aa", ".raw", ".bin"}); //NON-NLS - public static final String RAW_IMAGE_DESC = NbBundle.getMessage(GeneralFilter.class, "GeneralFilter.rawImageDesc.text"); + public static final List RAW_IMAGE_EXTS = Arrays.asList(".img", ".dd", ".001", ".aa", ".raw", ".bin"); //NON-NLS + @NbBundle.Messages("GeneralFilter.rawImageDesc.text=Raw Images (*.img, *.dd, *.001, *.aa, *.raw, *.bin)") + public static final String RAW_IMAGE_DESC = Bundle.GeneralFilter_rawImageDesc_text(); - public static final List ENCASE_IMAGE_EXTS = Arrays.asList(new String[]{".e01"}); //NON-NLS - public static final String ENCASE_IMAGE_DESC = NbBundle.getMessage(GeneralFilter.class, - "GeneralFilter.encaseImageDesc.text"); + public static final List ENCASE_IMAGE_EXTS = Arrays.asList(".e01"); //NON-NLS + @NbBundle.Messages("GeneralFilter.encaseImageDesc.text=Encase Images (*.e01)") + public static final String ENCASE_IMAGE_DESC = Bundle.GeneralFilter_encaseImageDesc_text(); - public static final List VIRTUAL_MACHINE_EXTS = Arrays.asList(new String[]{".vmdk", ".vhd"}); //NON-NLS - public static final String VIRTUAL_MACHINE_DESC = NbBundle.getMessage(GeneralFilter.class, - "GeneralFilter.virtualMachineImageDesc.text"); + public static final List VIRTUAL_MACHINE_EXTS = Arrays.asList(".vmdk", ".vhd"); //NON-NLS + @NbBundle.Messages("GeneralFilter.virtualMachineImageDesc.text=Virtual Machines (*.vmdk, *.vhd)") + public static final String VIRTUAL_MACHINE_DESC = Bundle.GeneralFilter_virtualMachineImageDesc_text(); - public static final List EXECUTABLE_EXTS = Arrays.asList(new String[]{".exe"}); //NON-NLS - public static final String EXECUTABLE_DESC = NbBundle.getMessage(GeneralFilter.class, "GeneralFilter.executableDesc.text"); + public static final List EXECUTABLE_EXTS = Arrays.asList(".exe"); //NON-NLS + @NbBundle.Messages("GeneralFilter.executableDesc.text=Executables (*.exe)") + public static final String EXECUTABLE_DESC = Bundle.GeneralFilter_executableDesc_text(); - public static final List GRAPHIC_IMAGE_EXTS = Arrays.asList(new String[]{".png", ".jpeg", ".jpg", ".gif", ".bmp"}); //NON-NLS - public static final String GRAPHIC_IMG_DECR = NbBundle.getMessage(GeneralFilter.class, "GeneralFilter.graphicImageDesc.text"); + public static final List GRAPHIC_IMAGE_EXTS = Arrays.asList(".png", ".jpeg", ".jpg", ".gif", ".bmp"); //NON-NLS + @NbBundle.Messages("GeneralFilter.graphicImageDesc.text=Images (*.png, *.jpg, *.jpeg, *.gif, *.bmp)") + public static final String GRAPHIC_IMG_DECR = Bundle.GeneralFilter_graphicImageDesc_text(); - private List extensions; - private String desc; + private final List extensions; + private final String desc; public GeneralFilter(List ext, String desc) { super(); @@ -69,15 +71,8 @@ public class GeneralFilter extends FileFilter { if (f.isDirectory()) { return true; } else { - Boolean result = false; String name = f.getName().toLowerCase(); - - for (String ext : extensions) { - if (name.endsWith(ext)) { - result = result || true; - } - } - return result; + return extensions.stream().anyMatch(name::endsWith); } } @@ -90,5 +85,4 @@ public class GeneralFilter extends FileFilter { public String getDescription() { return desc; } - }