use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class PDFViewer method openPdfUrl.
// Private methods ---------------------------------------------------------
private void openPdfUrl(final String url, final boolean synctex, boolean restorePosition) {
int width = 1070;
int height = 1200;
Point pos = null;
// if there's a window open, restore the position when we're done
if (restorePosition && url.equals(lastSuccessfulPdfUrl_)) {
// the window closed
if (haveActivePdfJsWindow())
locationHash_ = pdfJsWindow_.getLocationHash();
executeOnPdfLoad_ = createRestorePositionOperation();
}
// create the operation to load the PDF--we'll call this when the window
// is finished opening, or immediately if there's already a window open
Operation loadPdf = new Operation() {
@Override
public void execute() {
pdfJsWindow_.openPdf(server_.getApplicationURL(url), 0, synctex);
lastSuccessfulPdfUrl_ = url;
}
};
// in the browser we need to close and reopen the window
if (haveActivePdfJsWindow() && !Desktop.isDesktop()) {
width = pdfJsWindow_.getOuterWidth();
height = pdfJsWindow_.getOuterHeight();
pos = new Point(pdfJsWindow_.getLeft(), pdfJsWindow_.getTop());
pdfJsWindow_.close();
pdfJsWindow_ = null;
}
lastSuccessfulPdfUrl_ = null;
if (!haveActivePdfJsWindow()) {
// open the window and continue
String viewerUrl = server_.getApplicationURL("pdf_js/web/viewer.html?file=");
NewWindowOptions options = new NewWindowOptions();
options.setName(WINDOW_NAME);
options.setShowDesktopToolbar(false);
if (pos != null)
options.setPosition(pos);
options.setCallback(new OperationWithInput<WindowEx>() {
@Override
public void execute(WindowEx win) {
initializePdfJsWindow(win);
}
});
executeOnPdfJsLoad_ = loadPdf;
if (Desktop.isDesktop() && Desktop.getFrame().isCocoa()) {
// on cocoa, we can open a native window
display_.openMinimalWindow(viewerUrl, false, width, height, options);
} else {
// on Qt, we need to open a web window so window.opener is wired
display_.openWebMinimalWindow(viewerUrl, false, width, height, options);
}
} else {
// we already have an open window, activate it
if (Desktop.isDesktop())
Desktop.getFrame().activateMinimalWindow(WINDOW_NAME);
loadPdf.execute();
}
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class ShinyApplication method activateWindow.
private void activateWindow(ShinyApplicationParams params) {
WindowEx win = satelliteManager_.getSatelliteWindowObject(ShinyApplicationSatellite.NAME);
boolean isRefresh = win != null && (params == null || (params_ != null && params.getPath().equals(params_.getPath())));
boolean isChrome = !Desktop.isDesktop() && BrowseCap.isChrome();
if (params != null)
params_ = params;
if (win == null || (!isRefresh && !isChrome)) {
// If there's no window yet, or we're switching apps in a browser
// other than Chrome, do a normal open
satelliteManager_.openSatellite(ShinyApplicationSatellite.NAME, params_, new Size(960, 1100));
} else if (isChrome) {
// we have a window and we're Chrome, so force a close and reopen
satelliteManager_.forceReopenSatellite(ShinyApplicationSatellite.NAME, params_, true);
} else {
satelliteManager_.activateSatelliteWindow(ShinyApplicationSatellite.NAME);
}
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class HelpPane method createSecondaryToolbar.
@Override
protected SecondaryToolbar createSecondaryToolbar() {
SecondaryToolbar toolbar = new SecondaryToolbar();
toolbar.addLeftPopupMenu(title_ = new Label(), history_.getMenu());
if (isFindSupported()) {
final SmallButton btnNext = new SmallButton(">", true);
btnNext.setTitle("Find next (Enter)");
btnNext.setVisible(false);
btnNext.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
findNext();
}
});
final SmallButton btnPrev = new SmallButton("<", true);
btnPrev.setTitle("Find previous");
btnPrev.setVisible(false);
btnPrev.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
findPrev();
}
});
findTextBox_ = new FindTextBox("Find in Topic");
findTextBox_.setOverrideWidth(90);
toolbar.addLeftWidget(findTextBox_);
findTextBox_.addKeyUpHandler(new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
// ignore modifier key release
if (event.getNativeKeyCode() == KeyCodes.KEY_CTRL || event.getNativeKeyCode() == KeyCodes.KEY_ALT || event.getNativeKeyCode() == KeyCodes.KEY_SHIFT) {
return;
}
WindowEx contentWindow = getContentWindow();
if (contentWindow != null) {
// into the main content window
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
event.preventDefault();
event.stopPropagation();
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE)
clearTerm();
contentWindow.focus();
} else {
// minimizing or maximizing the help pane
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
event.stopPropagation();
}
// check for term
String term = findTextBox_.getValue().trim();
int modifier = KeyboardShortcut.getModifierValue(event.getNativeEvent());
boolean isShift = modifier == KeyboardShortcut.SHIFT;
// if there is a term then search for it
if (term.length() > 0) {
// make buttons visible
setButtonVisibility(true);
// perform the find (check for incremental)
if (isIncrementalFindSupported()) {
boolean incremental = !event.isAnyModifierKeyDown() && (event.getNativeKeyCode() != KeyCodes.KEY_ENTER);
performFind(term, !isShift, incremental);
} else {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
performFind(term, !isShift, false);
}
} else // no term means clear term and remove selection
{
if (isIncrementalFindSupported()) {
clearTerm();
contentWindow.removeSelection();
}
}
}
}
}
private void clearTerm() {
findTextBox_.setValue("");
setButtonVisibility(false);
}
private void setButtonVisibility(final boolean visible) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
btnNext.setVisible(visible);
btnPrev.setVisible(visible);
}
});
}
});
findTextBox_.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// from handling them
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB || event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
event.stopPropagation();
}
}
});
if (isIncrementalFindSupported()) {
btnPrev.getElement().getStyle().setMarginRight(3, Unit.PX);
toolbar.addLeftWidget(btnPrev);
toolbar.addLeftWidget(btnNext);
}
}
return toolbar;
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class HelpPane method performFind.
private void performFind(String term, boolean forwards, boolean incremental) {
WindowEx contentWindow = getContentWindow();
if (contentWindow == null)
return;
// if this is an incremental search then reset the selection first
if (incremental)
contentWindow.removeSelection();
contentWindow.find(term, false, !forwards, true, false);
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class Plots method onZoomPlot.
void onZoomPlot() {
Size windowSize = ZoomUtils.getZoomWindowSize(view_.getPlotFrameSize(), zoomWindowDefaultSize_);
// determine whether we should scale (see comment in ImageFrame.onLoad
// for why we wouldn't want to scale)
int scale = 1;
if (Desktop.isDesktop() && BrowseCap.isMacintosh())
scale = 0;
// compose url string
String url = server_.getGraphicsUrl("plot_zoom?" + "width=" + windowSize.width + "&" + "height=" + windowSize.height + "&" + "scale=" + scale);
// open the window
ZoomUtils.openZoomWindow("_rstudio_zoom", url, windowSize, new OperationWithInput<WindowEx>() {
@Override
public void execute(WindowEx input) {
zoomWindow_ = input;
}
});
}
Aggregations