From bc6f05f41be1fd3d5ea2c72fd4e5f2c104b6dc34 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Tue, 28 Sep 2010 03:54:54 +0000 Subject: [PATCH] Issue 140 - Fix Open Workspace command for non-Mac platforms (requires Java 6) git-svn-id: http://google-refine.googlecode.com/svn/trunk@1372 7d457c2a-affb-35e4-300a-418c747d4874 --- .../commands/OpenWorkspaceDirCommand.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/main/src/com/google/refine/commands/OpenWorkspaceDirCommand.java b/main/src/com/google/refine/commands/OpenWorkspaceDirCommand.java index 706fcf3a5..631c9b339 100644 --- a/main/src/com/google/refine/commands/OpenWorkspaceDirCommand.java +++ b/main/src/com/google/refine/commands/OpenWorkspaceDirCommand.java @@ -1,5 +1,6 @@ package com.google.refine.commands; +import java.awt.Desktop; import java.io.File; import java.io.IOException; @@ -21,12 +22,17 @@ public class OpenWorkspaceDirCommand extends Command { respond(response, "{ \"code\" : \"error\", \"message\" : \"Workspace directory can only be opened on the local machine where Google Refine is run.\" }"); } else if (ProjectManager.singleton instanceof FileProjectManager) { File dir = ((FileProjectManager) ProjectManager.singleton).getWorkspaceDir(); - - Runtime.getRuntime().exec( - "open .", - new String[] {}, - dir - ); + + if (Desktop.isDesktopSupported()) { + Desktop desktop = Desktop.getDesktop(); + desktop.open(dir); + } else /* if Mac */ { + Process p = Runtime.getRuntime().exec( + "open .", + new String[] {}, + dir + ); + } respond(response, "{ \"code\" : \"ok\" }"); } else {