use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RnwWeaveSelectWidget method verifyAvailable.
protected void verifyAvailable(final RnwWeave weave) {
// first check if it was already available at startup
TexCapabilities texCap = session_.getSessionInfo().getTexCapabilities();
if (texCap.isRnwWeaveAvailable(weave))
return;
server_.getTexCapabilities(new ServerRequestCallback<TexCapabilities>() {
@Override
public void onResponseReceived(TexCapabilities capabilities) {
if (!capabilities.isRnwWeaveAvailable(weave)) {
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Confirm Change", "The " + weave.getPackageName() + " package is required " + "for " + weave.getName() + " weaving, " + "however it is not currently installed. You should " + "ensure that " + weave.getPackageName() + " is installed " + "prior to compiling a PDF." + "\n\nAre you sure you want to change this option?", false, new Operation() {
@Override
public void execute() {
}
}, new Operation() {
@Override
public void execute() {
setValue(rnwWeaveRegistry_.getTypes().get(0).getName());
}
}, false);
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class ChooseMirrorDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
// create progress container
final SimplePanelWithProgress panel = new SimplePanelWithProgress(ProgressImages.createLargeGray());
panel.setStylePrimaryName(RESOURCES.styles().mainWidget());
// show progress (with delay)
panel.showProgress(200);
// query data source for packages
mirrorSource_.requestData(new SimpleRequestCallback<JsArray<T>>() {
@Override
public void onResponseReceived(JsArray<T> mirrors) {
// keep internal list of mirrors
boolean haveInsecureMirror = false;
mirrors_ = new ArrayList<T>(mirrors.length());
// create list box and select default item
listBox_ = new ListBox();
listBox_.setMultipleSelect(false);
// all
listBox_.setVisibleItemCount(18);
listBox_.setWidth("100%");
if (mirrors.length() > 0) {
for (int i = 0; i < mirrors.length(); i++) {
T mirror = mirrors.get(i);
if (mirrorSource_.getLabel(mirror).startsWith("0-Cloud"))
continue;
mirrors_.add(mirror);
String item = mirrorSource_.getLabel(mirror);
String value = mirrorSource_.getURL(mirror);
if (!value.startsWith("https"))
haveInsecureMirror = true;
listBox_.addItem(item, value);
}
listBox_.setSelectedIndex(0);
enableOkButton(true);
}
// set it into the panel
panel.setWidget(listBox_);
// set caption
String protocolQualifer = !haveInsecureMirror ? " HTTPS" : "";
setText("Choose" + protocolQualifer + " CRAN Mirror");
// update ok button on changed
listBox_.addDoubleClickHandler(new DoubleClickHandler() {
@Override
public void onDoubleClick(DoubleClickEvent event) {
clickOkButton();
}
});
// if the list box is larger than the space we initially allocated
// then increase the panel height
final int kDefaultPanelHeight = 285;
if (listBox_.getOffsetHeight() > kDefaultPanelHeight)
panel.setHeight(listBox_.getOffsetHeight() + "px");
// set focus
FocusHelper.setFocusDeferred(listBox_);
}
@Override
public void onError(ServerError error) {
closeDialog();
super.onError(error);
}
});
return panel;
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Synctex method doDesktopInverseSearch.
private void doDesktopInverseSearch(String file, int line, int column) {
// apply concordance
final ProgressIndicator indicator = getSyncProgress();
server_.applyInverseConcordance(SourceLocation.create(file, line, column, true), new ServerRequestCallback<SourceLocation>() {
@Override
public void onResponseReceived(SourceLocation sourceLocation) {
indicator.onCompleted();
if (sourceLocation != null)
goToSourceLocation(sourceLocation);
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Synctex method doForwardSearch.
private void doForwardSearch(String rootDocument, JavaScriptObject sourceLocationObject) {
SourceLocation sourceLocation = sourceLocationObject.cast();
final ProgressIndicator indicator = getSyncProgress();
server_.synctexForwardSearch(rootDocument, sourceLocation, new ServerRequestCallback<PdfLocation>() {
@Override
public void onResponseReceived(PdfLocation location) {
indicator.onCompleted();
if (location != null)
eventBus_.fireEvent(new SynctexViewPdfEvent(location));
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class FileTypeRegistry method openFile.
public void openFile(final FileSystemItem file, final boolean canUseBrowser) {
FileType fileType = getTypeForFile(file);
if (fileType != null) {
fileType.openFile(file, eventBus_);
} else {
// build default command to use if we have an error or the
// file is not a text file
final Command defaultCommand = new Command() {
@Override
public void execute() {
if (canUseBrowser) {
if (session_.getSessionInfo().getAllowFileDownloads()) {
BROWSER.openFile(file, eventBus_);
} else {
globalDisplay_.showErrorMessage("File Download Error", "Unable to show file because file downloads are " + "restricted on this server.\n");
}
}
}
};
// check with the server to see if this is likely to be a text file
server_.isTextFile(file.getPath(), new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean isText) {
if (isText)
TEXT.openFile(file, eventBus_);
else
defaultCommand.execute();
}
@Override
public void onError(ServerError error) {
defaultCommand.execute();
}
});
}
}
Aggregations