19 package org.sleuthkit.autopsy.directorytree;
 
   21 import java.awt.Desktop;
 
   22 import java.awt.event.ActionEvent;
 
   24 import java.io.IOException;
 
   25 import java.util.logging.Level;
 
   26 import javax.swing.AbstractAction;
 
   27 import javax.swing.JOptionPane;
 
   28 import org.openide.nodes.Node;
 
   29 import org.openide.util.NbBundle.Messages;
 
   45     final static String[] EXECUTABLE_EXT = {
".exe", 
".dll", 
".com", 
".bat", 
".msi", 
".reg", 
".scr", 
".cmd"}; 
 
   53         int extPos = fileName.lastIndexOf(
'.');
 
   55         boolean isExecutable = 
false;
 
   57             String extension = fileName.substring(extPos, fileName.length()).toLowerCase();
 
   58             fileObjectExt = extension;
 
   59             for (
int i = 0; i < EXECUTABLE_EXT.length; ++i) {
 
   60                 if (EXECUTABLE_EXT[i].equals(extension)) {
 
   73         if (!(size > 0) || extPos == -1 || isExecutable || (fileNode instanceof 
SlackFileNode)) {
 
   74             this.setEnabled(
false);
 
   90             tempFile.createNewFile();
 
   92         } 
catch (IOException ex) {
 
   93             logger.log(Level.WARNING, 
"Can't save to temporary file.", ex); 
 
   99         tempFile.deleteOnExit();
 
  111         "ExternalViewerAction.actionPerformed.failure.title=Open File Failure",
 
  112         "ExternalViewerAction.actionPerformed.failure.IO.message=There is no associated editor for files of this type or the associated application failed to launch.",
 
  113         "ExternalViewerAction.actionPerformed.failure.support.message=This platform (operating system) does not support opening a file in an editor this way.",
 
  114         "ExternalViewerAction.actionPerformed.failure.missingFile.message=The file no longer exists.",
 
  115         "ExternalViewerAction.actionPerformed.failure.permission.message=Permission to open the file was denied."})
 
  121         String exePath = ExternalViewerRulesManager.getInstance().getExePathForName(mimeType);
 
  122         if (exePath.equals(
"")) {
 
  123             exePath = ExternalViewerRulesManager.getInstance().getExePathForName(ext);
 
  125         if (!exePath.equals(
"")) {
 
  126             Runtime runtime = Runtime.getRuntime();
 
  127             String[] s = 
new String[]{exePath, file.getAbsolutePath()};
 
  130             } 
catch (IOException ex) {
 
  131                 logger.log(Level.WARNING, 
"Could not open the specified viewer for the given file: " + file.
getName(), ex); 
 
  132                 JOptionPane.showMessageDialog(null, Bundle.ExternalViewerAction_actionPerformed_failure_IO_message(), Bundle.ExternalViewerAction_actionPerformed_failure_title(), JOptionPane.ERROR_MESSAGE);
 
  136                 Desktop.getDesktop().open(file);
 
  137             } 
catch (IOException ex) {
 
  138                 logger.log(Level.WARNING, 
"Could not find a viewer for the given file: " + file.
getName(), ex); 
 
  139                 JOptionPane.showMessageDialog(null,
 
  140                         Bundle.ExternalViewerAction_actionPerformed_failure_IO_message(),
 
  141                         Bundle.ExternalViewerAction_actionPerformed_failure_title(),
 
  142                         JOptionPane.ERROR_MESSAGE);
 
  143             } 
catch (UnsupportedOperationException ex) {
 
  144                 logger.log(Level.WARNING, 
"Platform cannot open " + file.
getName() + 
" in the defined editor.", ex); 
 
  145                 JOptionPane.showMessageDialog(null,
 
  146                         Bundle.ExternalViewerAction_actionPerformed_failure_support_message(),
 
  147                         Bundle.ExternalViewerAction_actionPerformed_failure_title(),
 
  148                         JOptionPane.ERROR_MESSAGE);
 
  149             } 
catch (IllegalArgumentException ex) {
 
  150                 logger.log(Level.WARNING, 
"Could not find the given file: " + file.
getName(), ex); 
 
  151                 JOptionPane.showMessageDialog(null,
 
  152                         Bundle.ExternalViewerAction_actionPerformed_failure_missingFile_message(),
 
  153                         Bundle.ExternalViewerAction_actionPerformed_failure_title(),
 
  154                         JOptionPane.ERROR_MESSAGE);
 
  155             } 
catch (SecurityException ex) {
 
  156                 logger.log(Level.WARNING, 
"Could not get permission to open the given file: " + file.
getName(), ex); 
 
  157                 JOptionPane.showMessageDialog(null,
 
  158                         Bundle.ExternalViewerAction_actionPerformed_failure_permission_message(),
 
  159                         Bundle.ExternalViewerAction_actionPerformed_failure_title(),
 
  160                         JOptionPane.ERROR_MESSAGE);
 
String getTempDirectory()
 
static< T > long writeToFile(Content content, java.io.File outputFile, ProgressHandle progress, Future< T > worker, boolean source)
 
static final Logger logger
 
static void openFile(String mimeType, String ext, File file)
 
static Case getCurrentCase()
 
synchronized static Logger getLogger(String name)
 
org.sleuthkit.datamodel.AbstractFile fileObject
 
ExternalViewerAction(String title, Node fileNode)
 
void actionPerformed(ActionEvent e)