use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class RmdOutputPanel method createFrame.
@Override
protected AnchorableFrame createFrame(String url) {
AnchorableFrame frame = new AnchorableFrame();
// allow full screen
Element el = frame.getElement();
el.setAttribute("webkitallowfullscreen", "");
el.setAttribute("mozallowfullscreen", "");
el.setAttribute("allowfullscreen", "");
frame.navigate(url);
final Operation initSlides = new Operation() {
@Override
public void execute() {
if (getNavigationMenu().isVisible()) {
fireSlideIndexChanged();
slideChangeMonitor_.scheduleRepeating(100);
}
}
};
if (isShiny_) {
shinyFrame_.initialize(url, new Operation() {
@Override
public void execute() {
shinyFrame_.setScrollPosition(scrollPosition_);
initSlides.execute();
}
});
} else {
// poll for document availability then perform initialization
// tasks once it's available (addLoadHandler wasn't always
// getting called at least under Cocoa WebKit)
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
// see if the document is ready
AnchorableFrame frame = getFrame();
if (frame == null)
return true;
IFrameElementEx iframe = frame.getIFrame();
if (iframe == null)
return true;
Document doc = iframe.getContentDocument();
if (doc == null)
return true;
initSlides.execute();
// Even though the document exists, it may not have rendered all
// its content yet
ScrollUtil.setScrollPositionOnLoad(frame, scrollPosition_);
return false;
}
}, 50);
}
return frame;
}
use of org.rstudio.core.client.widget.Operation 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.widget.Operation in project rstudio by rstudio.
the class PDFViewer method viewPdfUrl.
public void viewPdfUrl(final String url, final Integer initialPage) {
if (initialPage != null) {
executeOnPdfLoad_ = new Operation() {
@Override
public void execute() {
pdfJsWindow_.goToPage(initialPage.intValue());
}
};
}
lastSuccessfulPdfPath_ = null;
openPdfUrl(url, false, initialPage == null);
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class ProjectSourceControlPreferencesPane method confirmGitRepo.
private void confirmGitRepo(final Command onConfirmed) {
final ProgressIndicator indicator = getProgressIndicator();
indicator.onProgress("Checking for git repository...");
final String projDir = session_.getSessionInfo().getActiveProjectDir().getPath();
server_.gitHasRepo(projDir, new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean result) {
indicator.onCompleted();
if (result) {
onConfirmed.execute();
} else {
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Confirm New Git Repository", "Do you want to initialize a new git repository " + "for this project?", false, new Operation() {
@Override
public void execute() {
server_.gitInitRepo(projDir, new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
onConfirmed.execute();
}
@Override
public void onFailure() {
setVcsSelection(VCSConstants.NO_ID);
}
});
}
}, new Operation() {
@Override
public void execute() {
setVcsSelection(VCSConstants.NO_ID);
indicator.onCompleted();
}
}, true);
}
}
@Override
public void onError(ServerError error) {
setVcsSelection(VCSConstants.NO_ID);
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.widget.Operation in project rstudio by rstudio.
the class RSAccountConnector method showShinyAppsDialog.
// Private methods --------------------------------------------------------
private void showShinyAppsDialog(final OperationWithInput<Boolean> onCompleted) {
RSConnectCloudDialog dialog = new RSConnectCloudDialog(new ProgressOperationWithInput<NewRSConnectAccountResult>() {
@Override
public void execute(NewRSConnectAccountResult input, ProgressIndicator indicator) {
processDialogResult(input, indicator, onCompleted);
}
}, new Operation() {
@Override
public void execute() {
onCompleted.execute(false);
}
});
dialog.showModal();
}
Aggregations