From 94f33d8bf109e7b2b3e612c990664cb6e9c84d12 Mon Sep 17 00:00:00 2001 From: Oliver Spohngellert Date: Fri, 24 Jun 2016 12:48:38 -0400 Subject: [PATCH 1/2] Fixed error handling of ExternalViewerAction. --- .../autopsy/directorytree/ExternalViewerAction.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java index 3a177d9f88..b10f6994be 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java @@ -24,7 +24,9 @@ import java.io.File; import java.io.IOException; import java.util.logging.Level; import javax.swing.AbstractAction; +import javax.swing.JOptionPane; import org.openide.nodes.Node; +import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.ContentUtils; @@ -67,6 +69,8 @@ public class ExternalViewerAction extends AbstractAction { } } + @Messages({"ExternalViewerAction.actionPerformed.failure.message=The given file could not be open, as the file type is not supported.", + "ExternalViewerAction.actionPerformed.failure.title=Open Failure"}) @Override public void actionPerformed(ActionEvent e) { // Get the temp folder path of the case @@ -91,6 +95,7 @@ public class ExternalViewerAction extends AbstractAction { } catch (IOException ex) { // if can't open the file, throw the error saying: "File type not supported." logger.log(Level.WARNING, "File type not supported.", ex); //NON-NLS + JOptionPane.showMessageDialog(null, Bundle.ExternalViewerAction_actionPerformed_failure_message(), Bundle.ExternalViewerAction_actionPerformed_failure_title(), JOptionPane.ERROR_MESSAGE); } // delete the file on exit From 0c846f218c7248b72963a10f5199cb5064c4a0b9 Mon Sep 17 00:00:00 2001 From: Oliver Spohngellert Date: Wed, 29 Jun 2016 15:06:09 -0400 Subject: [PATCH 2/2] Fixed error messages. --- .../autopsy/directorytree/ExternalViewerAction.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java index b10f6994be..4a904042c7 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java @@ -69,7 +69,7 @@ public class ExternalViewerAction extends AbstractAction { } } - @Messages({"ExternalViewerAction.actionPerformed.failure.message=The given file could not be open, as the file type is not supported.", + @Messages({"ExternalViewerAction.actionPerformed.failure.message=Could not find a viewer for the given file.", "ExternalViewerAction.actionPerformed.failure.title=Open Failure"}) @Override public void actionPerformed(ActionEvent e) { @@ -86,15 +86,13 @@ public class ExternalViewerAction extends AbstractAction { tempFile.createNewFile(); ContentUtils.writeToFile(fileObject, tempFile); } catch (IOException ex) { - // throw an error here logger.log(Level.WARNING, "Can't save to temporary file.", ex); //NON-NLS } try { Desktop.getDesktop().open(tempFile); } catch (IOException ex) { - // if can't open the file, throw the error saying: "File type not supported." - logger.log(Level.WARNING, "File type not supported.", ex); //NON-NLS + logger.log(Level.WARNING, "Could not find a viewer for the given file: " + tempFile.getName(), ex); //NON-NLS JOptionPane.showMessageDialog(null, Bundle.ExternalViewerAction_actionPerformed_failure_message(), Bundle.ExternalViewerAction_actionPerformed_failure_title(), JOptionPane.ERROR_MESSAGE); }