use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class ModalDialogBase method move.
public void move(Point p, boolean allowAnimation) {
if (!isShowing() || !allowAnimation) {
// Don't animate if not showing
setPopupPosition(p.getX(), p.getY());
return;
}
if (currentAnimation_ != null) {
currentAnimation_.cancel();
currentAnimation_ = null;
}
final int origLeft = getPopupLeft();
final int origTop = getPopupTop();
final int deltaX = p.getX() - origLeft;
final int deltaY = p.getY() - origTop;
currentAnimation_ = new Animation() {
@Override
protected void onUpdate(double progress) {
if (!isShowing())
cancel();
else {
setPopupPosition((int) (origLeft + deltaX * progress), (int) (origTop + deltaY * progress));
}
}
};
currentAnimation_.run(200);
}
use of org.rstudio.core.client.Point in project rstudio by rstudio.
the class WebWindowOpener method webOpenMinimalWindow.
// enable callers to prevent subclass implementations from taking
// the open window by calling this directly
private void webOpenMinimalWindow(GlobalDisplay globalDisplay, String url, NewWindowOptions options, int width, int height, boolean showLocation) {
String loc = showLocation ? "1" : "0";
String features = "width=" + width + "," + "height=" + height + "," + "menubar=0,toolbar=0,location=" + loc + "," + "status=0,scrollbars=1,resizable=1,directories=0";
// open window at specific position if specified
Point pos = options.getPosition();
if (pos != null) {
features += ",left=" + pos.x + ",top=" + pos.y;
}
openWindowInternal(globalDisplay, url, options, features, width, height);
}
use of org.rstudio.core.client.Point 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.Point in project rstudio by rstudio.
the class CommitDetail method setDetails.
@Override
public void setDetails(final DiffParser unifiedParser, final boolean suppressViewLink) {
setProgressVisible(false);
invalidation_.invalidate();
final Token token = invalidation_.getInvalidationToken();
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
@Override
public boolean execute() {
if (token.isInvalid())
return false;
final DiffFileHeader fileHeader = unifiedParser.nextFilePair();
if (fileHeader == null)
return false;
int filesCompared = 2;
ArrayList<ChunkOrLine> lines = new ArrayList<ChunkOrLine>();
DiffChunk chunk;
while (null != (chunk = unifiedParser.nextChunk())) {
if (!chunk.shouldIgnore())
filesCompared = chunk.getRanges().length;
lines.addAll(ChunkOrLine.fromChunk(chunk));
}
LineTableView view = new LineTableView(filesCompared);
view.setUseStartBorder(true);
view.setUseEndBorder(false);
view.setShowActions(false);
view.setData(lines, PatchMode.Stage);
view.setWidth("100%");
final DiffFrame diffFrame = new DiffFrame(null, fileHeader.getDescription(), null, commit_.getId(), view, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
fireEvent(new ViewFileRevisionEvent(commit_.getId(), fileHeader.getDescription().trim()));
}
}, suppressViewLink);
diffFrame.setWidth("100%");
detailPanel_.add(diffFrame);
CommitTocRow tocAnchor = new CommitTocRow(fileHeader.getDescription());
tocAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Point relativePosition = DomUtils.getRelativePosition(container_.getElement(), diffFrame.getElement());
container_.setVerticalScrollPosition(relativePosition.getY());
}
});
tocPanel_.add(tocAnchor);
return true;
}
});
}
Aggregations