use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class CopyPlotToClipboardDesktopDialog method copyAsBitmap.
protected void copyAsBitmap(final Operation onCompleted) {
final ExportPlotSizeEditor sizeEditor = getSizeEditor();
sizeEditor.prepareForExport(new Command() {
@Override
public void execute() {
if (BrowseCap.isCocoaDesktop()) {
clipboard_.copyPlotToCocoaPasteboard(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {
@Override
public void execute() {
onCompleted.execute();
}
});
} else {
WindowEx win = sizeEditor.getPreviewIFrame().getContentWindow();
Document doc = win.getDocument();
NodeList<Element> images = doc.getElementsByTagName("img");
if (images.getLength() > 0) {
ElementEx img = images.getItem(0).cast();
DesktopFrame frame = Desktop.getFrame();
frame.copyImageToClipboard(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
}
onCompleted.execute();
}
}
});
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class SourceWindowManager method getLastFocusedSourceWindow.
private WindowEx getLastFocusedSourceWindow() {
String lastFocusedSourceWindow = MainWindowObject.lastFocusedSourceWindow().get();
// addressable window, there's nothing to do
if (StringUtil.isNullOrEmpty(lastFocusedSourceWindow) || !isSourceWindowOpen(lastFocusedSourceWindow))
return null;
WindowEx window = getSourceWindowObject(lastFocusedSourceWindow);
if (window != null && !window.isClosed()) {
return window;
}
return null;
}
use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class SourceWindowManager method openSourceWindow.
private void openSourceWindow(String windowId, Point position, String docId, SourcePosition sourcePosition) {
// create default options
Size size = new Size(800, 800);
Integer ordinal = null;
// if we have geometry for the window, apply it
SatelliteWindowGeometry geometry = windowGeometry_.getObject(windowId);
if (geometry != null) {
size = geometry.getSize();
ordinal = geometry.getOrdinal();
if (position == null)
position = geometry.getPosition();
}
// window may exactly overlap an existing source window)
if (geometry == null) {
if (!StringUtil.isNullOrEmpty(mostRecentSourceWindow_) && isSourceWindowOpen(mostRecentSourceWindow_)) {
WindowEx window = getSourceWindowObject(mostRecentSourceWindow_);
if (window != null && !window.isClosed()) {
size = new Size(window.getInnerWidth(), window.getInnerHeight());
if (position == null)
position = new Point(window.getScreenX() + 50, window.getScreenY() + 50);
}
}
}
// assign ordinal if not already assigned
if (ordinal == null)
ordinal = ++maxOrdinal_;
pSatelliteManager_.get().openSatellite(SourceSatellite.NAME_PREFIX + windowId, SourceWindowParams.create(ordinal, pWorkbenchContext_.get().createWindowTitle(), pWorkbenchContext_.get().getCurrentWorkingDir().getPath(), docId, sourcePosition), size, false, position);
mostRecentSourceWindow_ = windowId;
sourceWindows_.put(windowId, ordinal);
}
use of org.rstudio.core.client.dom.WindowEx 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 org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.
the class SourceWindowManager method doForAllSourceWindows.
// execute a command on all source windows (synchronously)
private void doForAllSourceWindows(OperationWithInput<Pair<String, WindowEx>> command) {
for (final String windowId : sourceWindows_.keySet()) {
final WindowEx window = getSourceWindowObject(windowId);
if (window == null || window.isClosed())
continue;
command.execute(new Pair<String, WindowEx>(windowId, window));
}
}
Aggregations