00001 package edu.stanford.hci.r3.actions.types;
00002
00003 import java.awt.Desktop;
00004 import java.io.File;
00005 import java.io.IOException;
00006
00007 import edu.stanford.hci.r3.actions.R3Action;
00008 import edu.stanford.hci.r3.util.DebugUtils;
00009
00022 public class OpenFileAction implements R3Action {
00023
00029 private File file;
00030
00034 public OpenFileAction(File fileToOpen) {
00035 file = fileToOpen;
00036 }
00037
00041 public void invoke() {
00042 if (file == null || !file.exists()) {
00043 DebugUtils.println("Cannot open the File. Returning from invocation.");
00044 return;
00045 }
00046 try {
00047 Desktop.getDesktop().open(file);
00048 } catch (IOException e) {
00049 e.printStackTrace();
00050 }
00051 DebugUtils.println("File Opened: " + file.getName());
00052 }
00053
00054 }