use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class UserCommandManager method onRegisterUserCommand.
private void onRegisterUserCommand(RegisterUserCommandEvent event) {
final String name = event.getData().getName();
JsArrayString shortcutStrings = event.getData().getShortcuts();
for (int i = 0; i < shortcutStrings.length(); i++) {
String shortcutString = shortcutStrings.get(i);
KeySequence sequence = KeySequence.fromShortcutString(shortcutString);
assert sequence != null : "Failed to parse string '" + shortcutString + "'";
KeyboardShortcut shortcut = new KeyboardShortcut(sequence);
UserCommand command = new UserCommand(name, new Command() {
@Override
public void execute() {
events_.fireEvent(new ExecuteUserCommandEvent(name));
}
});
commandMap_.put(shortcut, command);
}
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class RStudio method delayLoadApplication.
private void delayLoadApplication(final Command dismissProgressAnimation) {
final RunAsyncCallback runCallback = new RunAsyncCallback() {
public void onFailure(Throwable reason) {
dismissProgressAnimation.execute();
Window.alert("Error: " + reason.getMessage());
}
public void onSuccess() {
// TODO (gary) This early loading of XTermWidget dependencies needs to be
// removed once I figure out why XTermWidget.load in
// TerminalPane:createMainWidget) isn't sufficient. Suspect due to xterm.js
// loading its add-ons (fit.js) but need to investigate.
XTermWidget.load(new Command() {
public void execute() {
AceEditor.load(new Command() {
public void execute() {
ensureStylesInjected();
String view = Window.Location.getParameter("view");
if (VCSApplication.NAME.equals(view)) {
RStudioGinjector.INSTANCE.getVCSApplication().go(RootLayoutPanel.get(), dismissProgressAnimation);
} else if (HTMLPreviewApplication.NAME.equals(view)) {
RStudioGinjector.INSTANCE.getHTMLPreviewApplication().go(RootLayoutPanel.get(), dismissProgressAnimation);
} else if (ShinyApplicationSatellite.NAME.equals(view)) {
RStudioGinjector.INSTANCE.getShinyApplicationSatellite().go(RootLayoutPanel.get(), dismissProgressAnimation);
} else if (RmdOutputSatellite.NAME.equals(view)) {
RStudioGinjector.INSTANCE.getRmdOutputSatellite().go(RootLayoutPanel.get(), dismissProgressAnimation);
} else if (view != null && view.startsWith(SourceSatellite.NAME_PREFIX)) {
SourceSatellite satellite = new SourceSatellite(view);
satellite.go(RootLayoutPanel.get(), dismissProgressAnimation);
} else if (view != null && view.startsWith(ChunkSatellite.NAME_PREFIX)) {
ChunkSatellite satellite = new ChunkSatellite(view);
satellite.go(RootLayoutPanel.get(), dismissProgressAnimation);
} else {
RStudioGinjector.INSTANCE.getApplication().go(RootLayoutPanel.get(), dismissProgressAnimation);
}
}
});
}
});
}
};
GWT.runAsync(runCallback);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class RStudio method showProgress.
private Command showProgress() {
final Label background = new Label();
background.getElement().getStyle().setZIndex(1000);
background.getElement().getStyle().setBackgroundColor("#e1e2e5");
final RootLayoutPanel rootPanel = RootLayoutPanel.get();
rootPanel.add(background);
rootPanel.setWidgetTopBottom(background, 0, Style.Unit.PX, 0, Style.Unit.PX);
rootPanel.setWidgetLeftRight(background, 0, Style.Unit.PX, 0, Style.Unit.PX);
String progressUrl = ProgressImages.createLargeGray().getUrl();
StringBuilder str = new StringBuilder();
str.append("<img src=\"");
str.append(progressUrl);
str.append("\"");
if (BrowseCap.devicePixelRatio() > 1.0)
str.append("width=24 height=24");
str.append("/>");
final SimplePanel progressPanel = new SimplePanel();
final Element div = progressPanel.getElement();
div.setInnerHTML(str.toString());
div.getStyle().setWidth(100, Style.Unit.PCT);
div.getStyle().setMarginTop(200, Style.Unit.PX);
div.getStyle().setProperty("textAlign", "center");
div.getStyle().setZIndex(1000);
ElementIds.assignElementId(div, ElementIds.LOADING_SPINNER);
rootPanel.add(progressPanel);
return new Command() {
public void execute() {
try {
rootPanel.remove(progressPanel);
rootPanel.remove(background);
} catch (Exception e) {
Debug.log(e.toString());
}
}
};
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class ModalDialogBase method showModal.
public void showModal() {
if (mainWidget_ == null) {
mainWidget_ = createMainWidget();
// get the main widget to line up with the right edge of the buttons.
mainWidget_.getElement().getStyle().setMarginRight(2, Unit.PX);
mainPanel_.insert(mainWidget_, 0);
}
originallyActiveElement_ = DomUtils.getActiveElement();
if (originallyActiveElement_ != null)
originallyActiveElement_.blur();
// position the dialog
positionAndShowDialog(new Command() {
@Override
public void execute() {
// defer shown notification to allow all elements to render
// before attempting to interact w/ them programatically (e.g. setFocus)
Timer timer = new Timer() {
public void run() {
onDialogShown();
}
};
timer.schedule(100);
}
});
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class ApplicationQuit method prepareForQuit.
public void prepareForQuit(final String caption, final boolean forceSaveAll, final QuitContext quitContext) {
boolean busy = workbenchContext_.isServerBusy() || workbenchContext_.isTerminalBusy();
String msg = null;
if (busy) {
if (workbenchContext_.isServerBusy() && !workbenchContext_.isTerminalBusy())
msg = "The R session is currently busy.";
else if (workbenchContext_.isServerBusy() && workbenchContext_.isTerminalBusy())
msg = "The R session and the terminal are currently busy.";
else
msg = "The terminal is currently busy.";
}
eventBus_.fireEvent(new QuitInitiatedEvent());
if (busy && !forceSaveAll) {
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, caption, msg + " Are you sure you want to quit?", new Operation() {
@Override
public void execute() {
handleUnsavedChanges(caption, forceSaveAll, quitContext);
}
}, true);
} else {
// if we aren't restoring source documents then close them all now
if (!pUiPrefs_.get().restoreSourceDocuments().getValue()) {
sourceShim_.closeAllSourceDocs(caption, new Command() {
@Override
public void execute() {
handleUnsavedChanges(caption, forceSaveAll, quitContext);
}
});
} else {
handleUnsavedChanges(caption, forceSaveAll, quitContext);
}
}
}
Aggregations