104 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
105 Bundle.ExternalViewerAction_actionPerformed_failure_exe_message(),
106 Bundle.ExternalViewerAction_actionPerformed_failure_title(
this.fileObject.getName()),
107 JOptionPane.ERROR_MESSAGE);
116 logger.log(Level.WARNING,
"Exception while getting open case.", ex);
123 tempFilePath = Files.createTempFile(
125 this.fileObject.getName(),
127 }
catch (IOException ex) {
128 logger.log(Level.WARNING,
"Can't create temporary file.", ex);
131 File tempFile = tempFilePath.toFile();
132 tempFile.deleteOnExit();
136 }
catch (IOException ex) {
137 logger.log(Level.WARNING,
"Can't save to temporary file.", ex);
157 public static void openFile(String mimeType, String ext, File file) {
162 String exePath = ExternalViewerRulesManager.getInstance().getExePathForName(mimeType);
163 if (exePath.equals(
"")) {
164 exePath = ExternalViewerRulesManager.getInstance().getExePathForName(ext);
166 if (!exePath.equals(
"")) {
167 Runtime runtime = Runtime.getRuntime();
168 String[] execArray =
new String[]{exePath, file.getAbsolutePath()};
170 runtime.exec(execArray);
171 }
catch (IOException ex) {
172 logger.log(Level.WARNING,
"Could not open the specified viewer for the given file: " + file.getName(), ex);
173 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), Bundle.ExternalViewerAction_actionPerformed_failure_IO_message(), Bundle.ExternalViewerAction_actionPerformed_failure_title(file.getName()), JOptionPane.ERROR_MESSAGE);
177 String localpath = file.getPath();
178 if (localpath.toLowerCase().contains(
"http")) {
179 String url_path = file.getPath().replaceAll(
"\\\\",
"/");
185 }
catch (IOException ex) {
186 logger.log(Level.WARNING,
"Could not find a viewer for the given file: " + file.getName(), ex);
187 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
188 Bundle.ExternalViewerAction_actionPerformed_failure_IO_message(),
189 Bundle.ExternalViewerAction_actionPerformed_failure_title(file.getName()),
190 JOptionPane.ERROR_MESSAGE);
191 }
catch (UnsupportedOperationException ex) {
192 logger.log(Level.WARNING,
"Platform cannot open " + file.getName() +
" in the defined editor.", ex);
193 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
194 Bundle.ExternalViewerAction_actionPerformed_failure_support_message(),
195 Bundle.ExternalViewerAction_actionPerformed_failure_title(file.getName()),
196 JOptionPane.ERROR_MESSAGE);
197 }
catch (IllegalArgumentException ex) {
198 logger.log(Level.WARNING,
"Could not find the given file: " + file.getName(), ex);
199 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
200 Bundle.ExternalViewerAction_actionPerformed_failure_missingFile_message(),
201 Bundle.ExternalViewerAction_actionPerformed_failure_title(file.getName()),
202 JOptionPane.ERROR_MESSAGE);
203 }
catch (SecurityException ex) {
204 logger.log(Level.WARNING,
"Could not get permission to open the given file: " + file.getName(), ex);
205 JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(),
206 Bundle.ExternalViewerAction_actionPerformed_failure_permission_message(),
207 Bundle.ExternalViewerAction_actionPerformed_failure_title(file.getName()),
208 JOptionPane.ERROR_MESSAGE);
209 }
catch (URISyntaxException ex) {
210 logger.log(Level.WARNING,
"Could not open URL provided: " + file.getPath(), ex);
211 JOptionPane.showMessageDialog(
null,
212 Bundle.ExternalViewerAction_actionPerformed_failure_open_url(),
213 Bundle.ExternalViewerAction_actionPerformed_failure_title(file.getName()),
214 JOptionPane.ERROR_MESSAGE);
227 String url_path = path.replaceAll(
"\\\\",
"/");
230 }
catch (IOException ex) {
231 logger.log(Level.WARNING,
"Could not find a viewer for the given URL: " + url_path, ex);
232 JOptionPane.showMessageDialog(
null,
233 Bundle.ExternalViewerAction_actionPerformed_failure_IO_message(),
234 Bundle.ExternalViewerAction_actionPerformed_urlFailure_title(),
235 JOptionPane.ERROR_MESSAGE);
236 }
catch (UnsupportedOperationException ex) {
237 logger.log(Level.WARNING,
"Platform cannot open " + url_path +
" in the defined editor.", ex);
238 JOptionPane.showMessageDialog(
null,
239 Bundle.ExternalViewerAction_actionPerformed_failure_support_message(),
240 Bundle.ExternalViewerAction_actionPerformed_urlFailure_title(),
241 JOptionPane.ERROR_MESSAGE);
242 }
catch (IllegalArgumentException ex) {
243 logger.log(Level.WARNING,
"Could not find the given URL: " + url_path, ex);
244 JOptionPane.showMessageDialog(
null,
245 Bundle.ExternalViewerAction_actionPerformed_failure_missingFile_message(),
246 Bundle.ExternalViewerAction_actionPerformed_urlFailure_title(),
247 JOptionPane.ERROR_MESSAGE);
248 }
catch (SecurityException ex) {
249 logger.log(Level.WARNING,
"Could not get permission to open the given URL: " + url_path, ex);
250 JOptionPane.showMessageDialog(
null,
251 Bundle.ExternalViewerAction_actionPerformed_failure_permission_message(),
252 Bundle.ExternalViewerAction_actionPerformed_urlFailure_title(),
253 JOptionPane.ERROR_MESSAGE);
254 }
catch (URISyntaxException ex) {
255 logger.log(Level.WARNING,
"Could not open URL provided: " + url_path, ex);
256 JOptionPane.showMessageDialog(
null,
257 Bundle.ExternalViewerAction_actionPerformed_failure_open_url(),
258 Bundle.ExternalViewerAction_actionPerformed_urlFailure_title(),
259 JOptionPane.ERROR_MESSAGE);