use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class RmdOutput method displayHTMLRenderResult.
private void displayHTMLRenderResult(RmdRenderResult result) {
// find the last known position for this file
int scrollPosition = 0;
String anchor = "";
if (scrollPositions_.containsKey(keyFromResult(result))) {
scrollPosition = scrollPositions_.get(keyFromResult(result));
}
if (anchors_.containsKey(keyFromResult(result))) {
anchor = anchors_.get(keyFromResult(result));
}
final RmdPreviewParams params = RmdPreviewParams.create(result, scrollPosition, anchor);
// get the default viewer type from prefs
int viewerType = prefs_.rmdViewerType().getValue();
// apply override from result, if any
if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_VIEWER)
viewerType = RMD_VIEWER_TYPE_PANE;
else if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_WINDOW)
viewerType = RMD_VIEWER_TYPE_WINDOW;
else if (result.getViewerType() == RmdEditorOptions.PREVIEW_IN_NONE)
viewerType = RMD_VIEWER_TYPE_NONE;
// slides well without help
if (result.isHtmlPresentation() && viewerType == RMD_VIEWER_TYPE_PANE)
viewerType = RMD_VIEWER_TYPE_WINDOW;
final int newViewerType = viewerType;
// we don't disturb the publish flow with a window popping up
if (newViewerType == RMD_VIEWER_TYPE_WINDOW && RSConnectPublishButton.isAnyRmdRenderPending()) {
return;
}
// get the window object if available
WindowEx win = null;
boolean needsReopen = false;
if (outputFrame_ != null) {
win = outputFrame_.getWindowObject();
if (outputFrame_.getViewerType() != newViewerType)
needsReopen = true;
}
// close it so that we can create a new one better suited to this doc type
if (needsReopen || (win != null && result_ != null && !result_.getFormatName().equals(result.getFormatName()))) {
outputFrame_.closeOutputFrame(false);
outputFrame_ = null;
win = null;
// let window finish closing before continuing
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
displayRenderResult(null, newViewerType, params);
}
});
} else {
displayRenderResult(win, newViewerType, params);
}
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class RmdOutputFrameSatellite method showRmdPreview.
@Override
public void showRmdPreview(RmdPreviewParams params, boolean activate) {
super.showRmdPreview(params);
WindowEx win = getWindowObject();
if (activate && win != null && !Desktop.isDesktop() && BrowseCap.isChrome()) {
satelliteManager_.forceReopenSatellite(RmdOutputSatellite.NAME, params, activate);
} else {
satelliteManager_.openSatellite(RmdOutputSatellite.NAME, params, params.getPreferredSize(), activate);
}
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class RmdOutputPanel method initToolbar.
@Override
protected void initToolbar(Toolbar toolbar, Commands commands) {
slideNavigationMenu_ = new SlideNavigationToolbarMenu(toolbar, 400, 100, true);
fileLabel_ = new ToolbarLabel();
fileLabel_.addStyleName(ThemeStyles.INSTANCE.subtitle());
fileLabel_.getElement().getStyle().setMarginRight(7, Unit.PX);
toolbar.addLeftWidget(fileLabel_);
fileLabelSeparator_ = toolbar.addLeftSeparator();
ToolbarButton popoutButton = commands.viewerPopout().createToolbarButton();
popoutButton.setText("Open in Browser");
toolbar.addLeftWidget(popoutButton);
findTextBox_ = new FindTextBox("Find");
findTextBox_.setIconVisible(true);
findTextBox_.setOverrideWidth(120);
findTextBox_.getElement().getStyle().setMarginRight(6, Unit.PX);
findSeparator_ = toolbar.addLeftSeparator();
toolbar.addLeftWidget(findTextBox_);
findTextBox_.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// enter key triggers a find
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
event.stopPropagation();
findInTopic(findTextBox_.getValue().trim(), findTextBox_);
findTextBox_.focus();
} else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
findTextBox_.setValue("");
}
}
private void findInTopic(String term, CanFocus findInputSource) {
// get content window
WindowEx contentWindow = getFrame().getWindow();
if (contentWindow == null)
return;
if (!contentWindow.find(term, false, false, true, false)) {
RStudioGinjector.INSTANCE.getGlobalDisplay().showMessage(MessageDialog.INFO, "Find in Page", "No occurences found", findInputSource);
}
}
});
toolbar.addLeftSeparator();
publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_DOCUMENT, true, null);
toolbar.addRightWidget(publishButton_);
toolbar.addRightSeparator();
toolbar.addRightWidget(commands.viewerRefresh().createToolbarButton());
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class HTMLPreviewPanel method print.
@Override
public void print() {
WindowEx window = previewFrame_.getWindow();
window.focus();
window.print();
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class HTMLPreviewPanel method createToolbar.
private Toolbar createToolbar(Commands commands) {
Toolbar toolbar = new Toolbar();
toolbar.addLeftWidget(new ToolbarLabel("Preview: "));
fileLabel_ = new ToolbarLabel();
fileLabel_.addStyleName(ThemeStyles.INSTANCE.subtitle());
fileLabel_.getElement().getStyle().setMarginRight(7, Unit.PX);
toolbar.addLeftWidget(fileLabel_);
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands.openHtmlExternal().createToolbarButton());
showLogButtonSeparator_ = toolbar.addLeftSeparator();
showLogButton_ = commands.showHtmlPreviewLog().createToolbarButton();
toolbar.addLeftWidget(showLogButton_);
saveHtmlPreviewAsSeparator_ = toolbar.addLeftSeparator();
if (Desktop.isDesktop()) {
saveHtmlPreviewAs_ = commands.saveHtmlPreviewAs().createToolbarButton();
toolbar.addLeftWidget(saveHtmlPreviewAs_);
} else {
ToolbarPopupMenu menu = new ToolbarPopupMenu();
menu.addItem(commands.saveHtmlPreviewAs().createMenuItem(false));
menu.addItem(commands.saveHtmlPreviewAsLocalFile().createMenuItem(false));
saveHtmlPreviewAs_ = toolbar.addLeftWidget(new ToolbarButton("Save As", commands.saveSourceDoc().getImageResource(), menu));
}
publishButtonSeparator_ = toolbar.addLeftSeparator();
toolbar.addLeftWidget(publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_DOCUMENT, true, null));
findTextBox_ = new FindTextBox("Find");
findTextBox_.setIconVisible(true);
findTextBox_.setOverrideWidth(120);
findTextBox_.getElement().getStyle().setMarginRight(6, Unit.PX);
toolbar.addRightWidget(findTextBox_);
findTextBox_.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// enter key triggers a find
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
event.stopPropagation();
findInTopic(findTextBox_.getValue().trim(), findTextBox_);
findTextBox_.focus();
} else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
findTextBox_.setValue("");
}
}
private void findInTopic(String term, CanFocus findInputSource) {
// get content window
WindowEx contentWindow = previewFrame_.getWindow();
if (contentWindow == null)
return;
if (!contentWindow.find(term, false, false, true, false)) {
RStudioGinjector.INSTANCE.getGlobalDisplay().showMessage(MessageDialog.INFO, "Find in Page", "No occurences found", findInputSource);
}
}
});
refreshButtonSeparator_ = toolbar.addRightSeparator();
refreshButton_ = toolbar.addRightWidget(commands.refreshHtmlPreview().createToolbarButton());
return toolbar;
}
Aggregations