1 20 21 package org.jdesktop.jdic.desktop.internal.impl; 22 23 import java.io.File ; 24 import java.io.IOException ; 25 26 import org.jdesktop.jdic.desktop.internal.LaunchFailedException; 27 import org.jdesktop.jdic.desktop.internal.LaunchService; 28 29 34 public class MacLaunchService implements LaunchService { 35 static { 36 System.loadLibrary("jdic"); 37 } 38 39 43 public File resolveLinkFile(File file) { 44 File resolvedFile = file; 45 try { 46 resolvedFile = file.getCanonicalFile(); 47 } catch (IOException e) { 48 } 49 50 return resolvedFile; 51 } 52 53 60 public void open(File file) throws LaunchFailedException { 61 boolean result = nativeOpenFile(file.toString()); 62 if (result == false) { 63 throw new LaunchFailedException("Failed to launch the associated " + 64 "application with the specified file."); 65 } 66 } 67 68 71 public boolean isEditable(File file) { 72 return false; 73 } 74 75 82 public void edit(File file) throws LaunchFailedException { 83 throw new LaunchFailedException("No application associated with the " + 84 "specified file and verb."); 85 } 86 87 90 public boolean isPrintable(File file) { 91 return true; 92 } 93 94 101 public void print(File file) throws LaunchFailedException { 102 boolean result = nativePrintFile(file.toString()); 103 if (result == false) { 104 throw new LaunchFailedException("Failed to launch the associated " + 105 "application with the specified file."); 106 } 107 } 108 109 private native boolean nativeOpenFile(String filePath); 110 private native boolean nativePrintFile(String filePath); 111 } 112 | Popular Tags |