use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class Source method revertUnsavedTargets.
private void revertUnsavedTargets(Command onCompleted) {
// collect up unsaved targets
ArrayList<EditingTarget> unsavedTargets = new ArrayList<EditingTarget>();
for (EditingTarget target : editors_) if (isUnsavedTarget(target, TYPE_FILE_BACKED))
unsavedTargets.add(target);
// revert all of them
cpsExecuteForEachEditor(// targets the user chose not to save
unsavedTargets, // save each editor
new CPSEditingTargetCommand() {
@Override
public void execute(EditingTarget saveTarget, Command continuation) {
if (saveTarget.getPath() != null) {
// file backed document -- revert it
saveTarget.revertChanges(continuation);
} else {
// untitled document -- just close the tab non-interactively
view_.closeTab(saveTarget.asWidget(), false, continuation);
}
}
}, // onCompleted at the end
onCompleted);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class SourceWindowManager method handleUnsavedChangesBeforeExit.
public void handleUnsavedChangesBeforeExit(ArrayList<UnsavedChangesTarget> targets, Command onCompleted) {
// accumulate the unsaved change targets that represent satellite windows
final JsArray<UnsavedChangesItem> items = JsArray.createArray().cast();
for (UnsavedChangesTarget target : targets) {
if (target instanceof UnsavedChangesItem) {
items.push((UnsavedChangesItem) target);
}
}
// let each window have a crack at saving the targets (the windows will
// discard any targets they don't own)
doForAllSourceWindows(new SourceWindowCommand() {
@Override
public void execute(String windowId, WindowEx window, Command continuation) {
handleUnsavedChangesBeforeExit(window, items, continuation);
}
}, onCompleted);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class RStudio method onModuleLoad.
public void onModuleLoad() {
Debug.injectDebug();
Document.get().getBody().getStyle().setBackgroundColor("#e1e2e5");
Command dismissProgressAnimation = showProgress();
delayLoadApplication(dismissProgressAnimation);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class DesktopHooks method evaluateRCmd.
void evaluateRCmd(final String cmd) {
// inject a 100ms delay between execution of commands to prevent
// issues with commands being delivered out of order by cocoa
// networking to the server (it appears as if when you put e.g. 10
// requests in flight simultaneously it's not guarnateed that they
// will be received in the order they were sent).
commandQueue_.addCommand(new SerializedCommand() {
@Override
public void onExecute(final Command continuation) {
// execute the code
events_.fireEvent(new SendToConsoleEvent(cmd, true));
// wait 100ms to execute the next command in the queue
new Timer() {
@Override
public void run() {
continuation.execute();
}
}.schedule(100);
;
}
});
// make sure the queue is running
commandQueue_.run();
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class SlideLabel method show.
public static void show(String label, boolean asHtml, boolean showProgressSpinner, int autoHideMillis, final LayoutPanel panel) {
final SlideLabel slideLabel = showInternal(label, asHtml, showProgressSpinner, panel);
slideLabel.show(autoHideMillis, new Command() {
public void execute() {
panel.remove(slideLabel);
}
});
}
Aggregations