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);
if (pos != null)
options.setPosition(pos);
options.setCallback(new OperationWithInput<WindowEx>()
{
@Override
public void execute(WindowEx win)
{
initializePdfJsWindow(win);
}
});
executeOnPdfJsLoad_ = loadPdf;
display_.openMinimalWindow(viewerUrl, false, width, height, options);
}
else
{
// we already have an open window, activate it
if (Desktop.isDesktop())
Desktop.getFrame().activateMinimalWindow(WINDOW_NAME);
loadPdf.execute();
}
}