use of com.google.gwt.core.client.JavaScriptObject in project rstudio by rstudio.
the class ProfilerEditingTarget method saveNewFile.
private void saveNewFile(final String suggestedPath) {
FileSystemItem fsi;
if (suggestedPath != null)
fsi = FileSystemItem.createFile(suggestedPath).getParentPath();
else
fsi = workbenchContext_.getDefaultFileDialogDir();
fileDialogs_.saveFile("Save File - " + getName().getValue(), fileContext_, fsi, fileType_.getDefaultExtension(), false, new ProgressOperationWithInput<FileSystemItem>() {
public void execute(final FileSystemItem saveItem, final ProgressIndicator indicator) {
if (saveItem == null)
return;
workbenchContext_.setDefaultFileDialogDir(saveItem.getParentPath());
final String toPath = saveItem.getPath();
server_.copyProfile(htmlLocalPath_, toPath, new ServerRequestCallback<JavaScriptObject>() {
@Override
public void onResponseReceived(JavaScriptObject response) {
savePropertiesWithPath(saveItem.getPath());
persistDocumentProperty("isUserSaved", "saved");
isUserSaved_ = true;
indicator.onCompleted();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
indicator.onCompleted();
globalDisplay_.showErrorMessage("Failed to Save Profile", error.getMessage());
}
});
}
});
}
use of com.google.gwt.core.client.JavaScriptObject in project rstudio by rstudio.
the class EventBus method fireEvent.
private void fireEvent(GwtEvent<?> event, boolean fromOtherWindow) {
// the main window
if (event instanceof CrossWindowEvent && Satellite.isCurrentWindowSatellite() && !fromOtherWindow) {
CrossWindowEvent<?> crossWindow = (CrossWindowEvent<?>) (event);
if (crossWindow.forward()) {
JavaScriptObject jso = serializer_.serialize(event);
// raise the main window if requested
if (crossWindow.focusMode() == CrossWindowEvent.MODE_FOCUS)
pSatellite_.get().focusMainWindow();
else if (crossWindow.focusMode() == CrossWindowEvent.MODE_AUXILIARY && Desktop.isDesktop())
Desktop.getFrame().bringMainFrameBehindActive();
fireEventToMainWindow(jso, pSatellite_.get().getSatelliteName());
} else {
super.fireEvent(event);
}
} else {
super.fireEvent(event);
}
}
use of com.google.gwt.core.client.JavaScriptObject 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);
}
use of com.google.gwt.core.client.JavaScriptObject in project playn by threerings.
the class HtmlJson method parse.
@Override
public Object parse(String json) throws JsonParserException {
try {
JavaScriptObject jsonParse = jsonParse(json);
if (!isValueObject(jsonParse))
throw new JsonParserException(null, "Input JSON was not an object", -1, -1, -1);
HtmlObject object = (HtmlObject) unwrap0(jsonParse);
return object;
} catch (JavaScriptException e) {
throw new JsonParserException(e, "Failed to parse JSON", -1, -1, -1);
}
}
use of com.google.gwt.core.client.JavaScriptObject in project playn by threerings.
the class HtmlJson method parseArray.
@Override
public Array parseArray(String json) throws JsonParserException {
try {
JavaScriptObject jsonParse = jsonParse(json);
if (!isValueArray(jsonParse))
throw new JsonParserException(null, "Input JSON was not an array", -1, -1, -1);
HtmlArray array = (HtmlArray) unwrap0(jsonParse);
return array;
} catch (JavaScriptException e) {
throw new JsonParserException(e, "Failed to parse JSON", -1, -1, -1);
}
}
Aggregations