Search in sources :

Example 21 with JSONArray

use of com.google.gwt.json.client.JSONArray in project rstudio by rstudio.

the class RemoteServer method renameFile.

public void renameFile(FileSystemItem file, FileSystemItem targetFile, ServerRequestCallback<Void> requestCallback) {
    JSONArray paramArray = new JSONArray();
    paramArray.set(0, new JSONString(file.getPath()));
    paramArray.set(1, new JSONString(targetFile.getPath()));
    sendRequest(RPC_SCOPE, RENAME_FILE, paramArray, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 22 with JSONArray

use of com.google.gwt.json.client.JSONArray in project rstudio by rstudio.

the class RemoteServer method readJSON.

public void readJSON(String path, boolean logErrorIfNotFound, ServerRequestCallback<JavaScriptObject> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(path));
    params.set(1, JSONBoolean.getInstance(logErrorIfNotFound));
    sendRequest(RPC_SCOPE, "read_json", params, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 23 with JSONArray

use of com.google.gwt.json.client.JSONArray in project rstudio by rstudio.

the class RemoteServer method svnApplyPatch.

@Override
public void svnApplyPatch(String path, String patch, String sourceEncoding, ServerRequestCallback<Void> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(path));
    params.set(1, new JSONString(patch));
    params.set(2, new JSONString(sourceEncoding));
    sendRequest(RPC_SCOPE, SVN_APPLY_PATCH, params, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 24 with JSONArray

use of com.google.gwt.json.client.JSONArray in project rstudio by rstudio.

the class RemoteServer method sendRemoteServerRequest.

// this code runs in the main workbench and implements the server request
// and then calls back the satellite on the provided js responseCallback
private void sendRemoteServerRequest(final JavaScriptObject sourceWindow, final String scope, final String method, final JavaScriptObject params, final boolean redactLog, final JavaScriptObject responseCallback) {
    // get the WindowEx from the sourceWindow
    final WindowEx srcWnd = sourceWindow.<WindowEx>cast();
    // unwrap the parameter array
    JsArrayEx array = params.cast();
    final JSONArray jsonParams = array.toJSONArray();
    // setup an rpc response handler that proxies back to the js object
    class ResponseHandler extends RpcResponseHandler {

        @Override
        public void onResponseReceived(RpcResponse response) {
            if (!srcWnd.isClosed())
                performCallback(responseCallback, response);
        }

        public void onError(RpcError error) {
            RpcResponse errorResponse = RpcResponse.create(error);
            if (!srcWnd.isClosed())
                performCallback(responseCallback, errorResponse);
        }

        private native void performCallback(JavaScriptObject responseCallback, RpcResponse response);
    }
    ;
    final ResponseHandler responseHandler = new ResponseHandler();
    // setup a retry handler which will call back the second time with
    // the same args (but no retryHandler, ensurin at most 1 retry)
    RetryHandler retryHandler = new RetryHandler() {

        public void onRetry() {
            // retry one time (passing null as last param ensures there
            // is no retry handler installed)
            sendRequest(getSourceWindowName(sourceWindow), scope, method, jsonParams, redactLog, responseHandler, null);
        }

        public void onError(RpcError error) {
            // propagate error which caused the retry to the caller
            responseHandler.onError(error);
        }
    };
    // submit request (retry same request up to one time)
    sendRequest(getSourceWindowName(sourceWindow), scope, method, jsonParams, redactLog, responseHandler, retryHandler);
}
Also used : JsArrayEx(org.rstudio.core.client.js.JsArrayEx) RpcResponseHandler(org.rstudio.core.client.jsonrpc.RpcResponseHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) RpcResponseHandler(org.rstudio.core.client.jsonrpc.RpcResponseHandler) JSONArray(com.google.gwt.json.client.JSONArray) RpcError(org.rstudio.core.client.jsonrpc.RpcError) WindowEx(org.rstudio.core.client.dom.WindowEx) RpcResponse(org.rstudio.core.client.jsonrpc.RpcResponse)

Example 25 with JSONArray

use of com.google.gwt.json.client.JSONArray in project rstudio by rstudio.

the class RemoteServer method gitCreateBranch.

@Override
public void gitCreateBranch(String branch, ServerRequestCallback<ConsoleProcess> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(branch));
    sendRequest(RPC_SCOPE, GIT_CREATE_BRANCH, params, new ConsoleProcessCallbackAdapter(requestCallback));
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

JSONArray (com.google.gwt.json.client.JSONArray)260 JSONString (com.google.gwt.json.client.JSONString)182 JSONNumber (com.google.gwt.json.client.JSONNumber)68 JSONObject (com.google.gwt.json.client.JSONObject)62 JSONValue (com.google.gwt.json.client.JSONValue)10 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)8 Point (org.rstudio.studio.client.workbench.views.plots.model.Point)8 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Date (java.util.Date)5 Map (java.util.Map)5 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2 JSONBoolean (com.google.gwt.json.client.JSONBoolean)2 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)2 ContactOrganisation (com.googlecode.gwtphonegap.client.contacts.ContactOrganisation)2 Test (org.junit.Test)2 EntryPoint (com.google.gwt.core.client.EntryPoint)1 Style (com.google.gwt.dom.client.Style)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1