Added main menu command to open system file explorer at the workspace directory.
Made project manager more careful at disposing projects, in case any of them is null. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1272 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
2609c4049d
commit
362a277c58
@ -66,7 +66,9 @@ public abstract class ProjectManager {
|
||||
save(true); // complete save
|
||||
|
||||
for (Project project : _projects.values()) {
|
||||
project.dispose();
|
||||
if (project != null) {
|
||||
project.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
_projects.clear();
|
||||
|
@ -0,0 +1,37 @@
|
||||
package com.google.gridworks.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.gridworks.ProjectManager;
|
||||
import com.google.gridworks.io.FileProjectManager;
|
||||
|
||||
public class OpenWorkspaceDirCommand extends Command {
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
String serverName = request.getServerName();
|
||||
|
||||
if (!"127.0.0.1".equals(serverName) && !"localhost".equals(serverName)) {
|
||||
respond(response, "{ \"code\" : \"error\", \"message\" : \"Workspace directory can only be opened on the local machine where Gridworks is run.\" }");
|
||||
} else if (ProjectManager.singleton instanceof FileProjectManager) {
|
||||
File dir = ((FileProjectManager) ProjectManager.singleton).getWorkspaceDir();
|
||||
|
||||
Runtime.getRuntime().exec(
|
||||
"open .",
|
||||
new String[] {},
|
||||
dir
|
||||
);
|
||||
|
||||
respond(response, "{ \"code\" : \"ok\" }");
|
||||
} else {
|
||||
respond(response, "{ \"code\" : \"error\", \"message\" : \"Workspace is not stored on the file system.\" }");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -99,6 +99,7 @@ function registerCommands() {
|
||||
GS.registerCommand(module, "get-preference", new Packages.com.google.gridworks.commands.GetPreferenceCommand());
|
||||
GS.registerCommand(module, "get-all-preferences", new Packages.com.google.gridworks.commands.GetAllPreferencesCommand());
|
||||
GS.registerCommand(module, "set-preference", new Packages.com.google.gridworks.commands.SetPreferenceCommand());
|
||||
GS.registerCommand(module, "open-workspace-dir", new Packages.com.google.gridworks.commands.OpenWorkspaceDirCommand());
|
||||
}
|
||||
|
||||
function registerOperations() {
|
||||
|
@ -73,6 +73,12 @@ MenuBar.MenuItems = [
|
||||
"id" : "core/export-project",
|
||||
"label": "Export Project",
|
||||
"click": function() { MenuBar.handlers.exportProject(); }
|
||||
},
|
||||
{},
|
||||
{
|
||||
"id" : "core/open-workspace-dir",
|
||||
"label": "Open Workspace Directory",
|
||||
"click": function() { MenuBar.handlers.openWorkspaceDir(); }
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -318,6 +324,19 @@ MenuBar.handlers.renameProject = function() {
|
||||
});
|
||||
};
|
||||
|
||||
MenuBar.handlers.openWorkspaceDir = function() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/command/core/open-workspace-dir",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code != "ok" && "message" in data) {
|
||||
alert(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
MenuBar.handlers.autoSchemaAlignment = function() {
|
||||
//SchemaAlignment.autoAlign();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user