use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class WebWindowOpener method openWindowInternal.
private void openWindowInternal(GlobalDisplay globalDisplay, final String url, NewWindowOptions options, final String features, final int width, final int height) {
String name = options.getName();
final boolean focus = options.isFocus();
final OperationWithInput<WindowEx> openOperation = options.getCallback();
if (name == null)
name = "_blank";
if (!name.equals("_blank") && !name.equals("_top") && !name.equals("_parent") && !name.equals("_self")) {
name += "_" + clientId;
}
// Need to make the URL absolute because IE resolves relative URLs
// against the JavaScript file location, not the window.location like
// the other browsers do
final String absUrl = Pattern.create("^/|([a-zA-Z]+:)").match(url, 0) == null ? GWT.getHostPageBaseURL() + url : url;
final String finalName = name;
WindowEx window = doOpenWindow(absUrl, finalName, features, focus);
if (window == null) {
if (showPopupBlockedMessage()) {
globalDisplay.showPopupBlockedMessage(new Operation() {
public void execute() {
WindowEx window = doOpenWindow(absUrl, finalName, features, focus);
if (window != null) {
if (openOperation != null)
openOperation.execute(window);
}
}
});
}
} else {
if (openOperation != null)
openOperation.execute(window);
}
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class Packages method doUpdatePackages.
private void doUpdatePackages(final PackageInstallContext installContext) {
new CheckForUpdatesDialog(globalDisplay_, new ServerDataSource<JsArray<PackageUpdate>>() {
public void requestData(ServerRequestCallback<JsArray<PackageUpdate>> requestCallback) {
server_.checkForPackageUpdates(requestCallback);
}
}, new OperationWithInput<ArrayList<PackageUpdate>>() {
@Override
public void execute(ArrayList<PackageUpdate> updates) {
InstallCommand cmd = buildUpdatePackagesCommand(updates, installContext);
executeWithLoadedPackageCheck(cmd);
}
}, new Operation() {
@Override
public void execute() {
// cancel emits an empty console input line to clear
// the busy indicator
events_.fireEvent(new SendToConsoleEvent("", true));
}
}).showModal();
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class Packages method restartForInstallWithConfirmation.
private void restartForInstallWithConfirmation(final String installCmd) {
String msg = "One or more of the packages that will be updated by this " + "installation are currently loaded. Restarting R prior " + "to updating these packages is strongly recommended.\n\n" + "RStudio can restart R and then automatically continue " + "the installation after restarting (all work and " + "data will be preserved during the restart).\n\n" + "Do you want to restart R prior to installing?";
final boolean haveInstallCmd = installCmd.startsWith("install.packages");
globalDisplay_.showYesNoMessage(MessageDialog.WARNING, "Updating Loaded Packages", msg, true, new Operation() {
public void execute() {
events_.fireEvent(new SuspendAndRestartEvent(SuspendOptions.createSaveAll(true), installCmd));
}
}, new Operation() {
public void execute() {
server_.ignoreNextLoadedPackageCheck(new VoidServerRequestCallback() {
@Override
public void onSuccess() {
if (haveInstallCmd)
executePkgCommand(installCmd);
}
});
}
}, true);
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class FilesUpload method completeFileUploadOperation.
private Operation completeFileUploadOperation(final FileUploadToken token, final boolean commit) {
return new Operation() {
public void execute() {
String msg = (commit ? "Completing" : "Cancelling") + " file upload...";
final Command dismissProgress = globalDisplay_.showProgress(msg);
server_.completeUpload(token, commit, new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void response) {
dismissProgress.execute();
}
@Override
public void onError(ServerError error) {
dismissProgress.execute();
globalDisplay_.showErrorMessage("File Upload Error", error.getUserMessage());
}
});
}
};
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class Application method go.
public void go(final RootLayoutPanel rootPanel, final Command dismissLoadingProgress) {
Widget w = view_.getWidget();
rootPanel.add(w);
rootPanel.setWidgetTopBottom(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
rootPanel.setWidgetLeftRight(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
// attempt init
pClientInit_.get().execute(new ServerRequestCallback<SessionInfo>() {
public void onResponseReceived(final SessionInfo sessionInfo) {
// initialize workbench after verifying agreement
verifyAgreement(sessionInfo, new Operation() {
public void execute() {
// directly to the user
if (ApplicationAction.isSwitchProject()) {
new Timer() {
@Override
public void run() {
dismissLoadingProgress.execute();
}
}.schedule(10000);
} else {
dismissLoadingProgress.execute();
}
session_.setSessionInfo(sessionInfo);
// initialize workbench
initializeWorkbench();
}
});
}
public void onError(ServerError error) {
Debug.logError(error);
dismissLoadingProgress.execute();
globalDisplay_.showErrorMessage("RStudio Initialization Error", error.getUserMessage());
}
});
}
Aggregations