use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class TextEditingTarget method doHtmlPreview.
private void doHtmlPreview(final Provider<HTMLPreviewParams> pParams) {
// command to show the preview window
final Command showPreviewWindowCommand = new Command() {
@Override
public void execute() {
HTMLPreviewParams params = pParams.get();
events_.fireEvent(new ShowHTMLPreviewEvent(params));
}
};
// command to run the preview
final Command runPreviewCommand = new Command() {
@Override
public void execute() {
final HTMLPreviewParams params = pParams.get();
server_.previewHTML(params, new SimpleRequestCallback<Boolean>());
}
};
if (pParams.get().isNotebook()) {
saveThenExecute(null, new Command() {
@Override
public void execute() {
generateNotebook(new Command() {
@Override
public void execute() {
showPreviewWindowCommand.execute();
runPreviewCommand.execute();
}
});
}
});
} else // due to popup activation rules but at least it will show up
if (isNewDoc()) {
saveThenExecute(null, CommandUtil.join(showPreviewWindowCommand, runPreviewCommand));
} else // beat the popup blockers) then save & run
if (dirtyState().getValue()) {
showPreviewWindowCommand.execute();
saveThenExecute(null, runPreviewCommand);
} else // otherwise show the preview window then run the preview
{
showPreviewWindowCommand.execute();
runPreviewCommand.execute();
}
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class ChunkOutputWidget method showChunkOutputUnit.
// Private methods ---------------------------------------------------------
private void showChunkOutputUnit(RmdChunkOutputUnit unit, int mode, boolean replay, boolean ensureVisible) {
// nothing to show)
if (unit.getType() == RmdChunkOutputUnit.TYPE_TEXT && unit.getArray().length() < 1)
return;
// are not visible)
if (unit.getType() != RmdChunkOutputUnit.TYPE_ORDINAL)
initializeOutput(unit.getType());
switch(unit.getType()) {
case RmdChunkOutputUnit.TYPE_TEXT:
presenter_.showConsoleOutput(unit.getArray());
break;
case RmdChunkOutputUnit.TYPE_HTML:
final RenderTimer widgetTimer = new RenderTimer();
presenter_.showHtmlOutput(unit.getString(), (NotebookHtmlMetadata) unit.getMetadata().cast(), unit.getOrdinal(), new Command() {
@Override
public void execute() {
widgetTimer.cancel();
}
});
break;
case RmdChunkOutputUnit.TYPE_PLOT:
final RenderTimer plotTimer = new RenderTimer();
presenter_.showPlotOutput(unit.getString(), (NotebookPlotMetadata) unit.getMetadata().cast(), unit.getOrdinal(), new Command() {
@Override
public void execute() {
plotTimer.cancel();
}
});
break;
case RmdChunkOutputUnit.TYPE_ERROR:
// override visibility flag when there's an error in batch mode
if (!replay && !options_.error() && mode == NotebookQueueUnit.EXEC_MODE_BATCH)
ensureVisible = true;
hasErrors_ = true;
presenter_.showErrorOutput(unit.getUnhandledError());
break;
case RmdChunkOutputUnit.TYPE_ORDINAL:
// used to reserve a plot placeholder
presenter_.showOrdinalOutput(unit.getOrdinal());
break;
case RmdChunkOutputUnit.TYPE_DATA:
presenter_.showDataOutput(unit.getOuputObject(), (NotebookFrameMetadata) unit.getMetadata().cast(), unit.getOrdinal());
break;
}
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class WebTextInput method promptForTextWithOption.
@Override
public void promptForTextWithOption(String title, String label, String initialValue, final boolean usePasswordMask, String extraOptionPrompt, boolean extraOptionDefault, int selectionStart, int selectionLength, String okButtonCaption, final ProgressOperationWithInput<PromptWithOptionResult> okOperation, Operation cancelOperation) {
// This variable introduces a level of pointer indirection that lets us
// get around passing TextEntryModalDialog a reference to itself in its
// own constructor.
final Value<TextEntryModalDialog> pDialog = new Value<TextEntryModalDialog>(null);
final TextEntryModalDialog dialog = new TextEntryModalDialog(title, label, initialValue, usePasswordMask, extraOptionPrompt, extraOptionDefault, false, selectionStart, selectionLength, okButtonCaption, 300, new ProgressOperationWithInput<String>() {
@Override
public void execute(String input, ProgressIndicator indicator) {
PromptWithOptionResult result = new PromptWithOptionResult();
result.input = input;
result.extraOption = pDialog.getValue().getExtraOption();
okOperation.execute(result, indicator);
}
}, cancelOperation) {
@Override
protected void positionAndShowDialog(final Command onCompleted) {
setPopupPositionAndShow(new PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
int left = (Window.getClientWidth() / 2) - (offsetWidth / 2);
int top = (Window.getClientHeight() / 2) - (offsetHeight / 2);
if (usePasswordMask)
top = 50;
setPopupPosition(left, top);
onCompleted.execute();
}
});
}
};
pDialog.setValue(dialog, false);
dialog.showModal();
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class MathJax method removeChunkOutputWidget.
private void removeChunkOutputWidget(final ChunkOutputWidget widget) {
final PinnedLineWidget plw = cowToPlwMap_.get(widget);
if (plw == null)
return;
FadeOutAnimation anim = new FadeOutAnimation(widget, new Command() {
@Override
public void execute() {
cowToPlwMap_.remove(widget);
lwToPlwMap_.remove(plw.getLineWidget());
plw.detach();
}
});
anim.run(400);
}
use of com.google.gwt.user.client.Command in project rstudio by rstudio.
the class SlideNavigationPresenter method onSlideNavigationChanged.
@Override
public void onSlideNavigationChanged(SlideNavigationChangedEvent event) {
slideNavigation_ = event.getNavigation();
SlideNavigationMenu navigationMenu = view_.getNavigationMenu();
navigationMenu.clear();
if (slideNavigation_ != null) {
JsArray<SlideNavigationItem> items = slideNavigation_.getItems();
for (int i = 0; i < items.length(); i++) {
// get slide
final SlideNavigationItem item = items.get(i);
// build html
SafeHtmlBuilder menuHtml = new SafeHtmlBuilder();
for (int j = 0; j < item.getIndent(); j++) menuHtml.appendHtmlConstant(" ");
menuHtml.appendEscaped(item.getTitle());
navigationMenu.addItem(new MenuItem(menuHtml.toSafeHtml(), new Command() {
@Override
public void execute() {
view_.navigate(item.getIndex());
}
}));
}
navigationMenu.setVisible(true);
navigationMenu.setDropDownVisible(slideNavigation_.getItems().length() > 1);
} else {
navigationMenu.setVisible(false);
}
}
Aggregations