use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class TextEditingTargetCompilePdfHelper method checkCompilers.
public void checkCompilers(final WarningBarDisplay display, TextFileType fileType) {
// for all tex files we need to parse magic comments and validate
// any explict latex proram directive
ArrayList<TexMagicComment> magicComments = null;
if (fileType.canCompilePDF()) {
magicComments = TexMagicComment.parseComments(docDisplay_.getCode());
String latexProgramDirective = detectLatexProgramDirective(magicComments);
if (latexProgramDirective != null) {
if (latexProgramRegistry_.findTypeIgnoreCase(latexProgramDirective) == null) {
// show warning and bail
display.showWarningBar("Unknown LaTeX program type '" + latexProgramDirective + "' specified (valid types are " + latexProgramRegistry_.getPrintableTypeNames() + ")");
return;
}
}
}
// for Rnw we first determine the RnwWeave type
RnwWeave rnwWeave = null;
RnwWeaveDirective rnwWeaveDirective = null;
if (fileType.isRnw()) {
rnwWeaveDirective = detectRnwWeaveDirective(magicComments);
if (rnwWeaveDirective != null) {
rnwWeave = rnwWeaveDirective.getRnwWeave();
if (rnwWeave == null) {
// show warning and bail
display.showWarningBar("Unknown Rnw weave method '" + rnwWeaveDirective.getName() + "' specified (valid types are " + rnwWeaveRegistry_.getPrintableTypeNames() + ")");
return;
}
} else {
rnwWeave = rnwWeaveRegistry_.findTypeIgnoreCase(prefs_.defaultSweaveEngine().getValue());
}
}
final SessionInfo sessionInfo = session_.getSessionInfo();
TexCapabilities texCap = sessionInfo.getTexCapabilities();
final boolean checkForTeX = fileType.canCompilePDF() && !texCap.isTexInstalled();
final boolean checkForRnwWeave = (rnwWeave != null) && !texCap.isRnwWeaveAvailable(rnwWeave);
if (checkForTeX || checkForRnwWeave) {
// alias variables to finals
final boolean hasRnwWeaveDirective = rnwWeaveDirective != null;
final RnwWeave fRnwWeave = rnwWeave;
server_.getTexCapabilities(new ServerRequestCallback<TexCapabilities>() {
@Override
public void onResponseReceived(TexCapabilities response) {
if (checkForTeX && !response.isTexInstalled()) {
String warning;
if (Desktop.isDesktop())
warning = "No TeX installation detected. Please install " + "TeX before compiling.";
else
warning = "This server does not have TeX installed. You " + "may not be able to compile.";
display.showWarningBar(warning);
} else if (checkForRnwWeave && !response.isRnwWeaveAvailable(fRnwWeave)) {
String forContext = "";
if (hasRnwWeaveDirective)
forContext = "this file";
else if (sessionInfo.getActiveProjectFile() != null)
forContext = "Rnw files for this project";
else
forContext = "Rnw files";
display.showWarningBar(fRnwWeave.getName() + " is configured to weave " + forContext + " " + "however the " + fRnwWeave.getPackageName() + " package is not installed.");
} else {
display.hideWarningBar();
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
} else {
display.hideWarningBar();
}
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class VersionControlPage method acceptNavigation.
@Override
protected boolean acceptNavigation() {
SessionInfo sessionInfo = RStudioGinjector.INSTANCE.getSession().getSessionInfo();
if (!sessionInfo.isVcsAvailable(getVcsId())) {
NewProjectResources.Styles styles = NewProjectResources.INSTANCE.styles();
VerticalPanel verticalPanel = new VerticalPanel();
verticalPanel.addStyleName(styles.vcsNotInstalledWidget());
if (Desktop.isDesktop()) {
HTML msg = new HTML("<p>" + getTitle() + " was not detected " + "on the system path.</p>" + "<p>To create projects from " + getTitle() + " " + "repositories you should install " + getTitle() + " " + "and then restart RStudio.</p>" + "<p>Note that if " + getTitle() + " is installed " + "and not on the path, then you can specify its location using " + "the " + (BrowseCap.isMacintosh() ? "Preferences" : "Options") + " dialog.</p>");
msg.setWidth("100%");
verticalPanel.add(msg);
HelpLink vcsHelpLink = new VcsHelpLink();
vcsHelpLink.setCaption("Using " + getTitle() + " with RStudio");
vcsHelpLink.addStyleName(styles.vcsHelpLink());
verticalPanel.add(vcsHelpLink);
} else {
HTML msg = new HTML("<p>An installation of " + getTitle() + " was not detected " + "on this system.</p>" + "<p>To create projects from " + getTitle() + " " + "repositories you should request that your server " + "administrator install the " + getTitle() + " package.</p>");
msg.setWidth("100%");
verticalPanel.add(msg);
}
MessageDialog dlg = new MessageDialog(MessageDialog.INFO, getTitle() + " Not Found", verticalPanel);
dlg.addButton("OK", (Operation) null, true, false);
dlg.showModal();
return false;
} else {
return true;
}
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class PresentationDispatcher method fireEventFromTutorialDirectory.
private void fireEventFromTutorialDirectory(final GwtEvent<?> event) {
SessionInfo sessionInfo = session_.getSessionInfo();
PresentationState state = sessionInfo.getPresentationState();
FileSystemItem projectDir = sessionInfo.getActiveProjectDir();
if (state.isTutorial() && (projectDir != null)) {
if (!workbenchContext_.getCurrentWorkingDir().equalTo(projectDir)) {
server_.setWorkingDirectory(projectDir.getPath(), new VoidServerRequestCallback() {
@Override
protected void onSuccess() {
eventBus_.fireEvent(event);
}
});
} else {
eventBus_.fireEvent(event);
}
} else {
eventBus_.fireEvent(event);
}
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class Application method go.
public void go(final RootLayoutPanel rootPanel, final Command dismissLoadingProgress) {
Widget w = view_.getWidget();
rootPanel.add(w);
rootPanel.setWidgetTopBottom(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
rootPanel.setWidgetLeftRight(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
// attempt init
pClientInit_.get().execute(new ServerRequestCallback<SessionInfo>() {
public void onResponseReceived(final SessionInfo sessionInfo) {
// initialize workbench after verifying agreement
verifyAgreement(sessionInfo, new Operation() {
public void execute() {
// directly to the user
if (ApplicationAction.isSwitchProject()) {
new Timer() {
@Override
public void run() {
dismissLoadingProgress.execute();
}
}.schedule(10000);
} else {
dismissLoadingProgress.execute();
}
session_.setSessionInfo(sessionInfo);
// initialize workbench
initializeWorkbench();
}
});
}
public void onError(ServerError error) {
Debug.logError(error);
dismissLoadingProgress.execute();
globalDisplay_.showErrorMessage("RStudio Initialization Error", error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class Application method initializeWorkbench.
private void initializeWorkbench() {
pAceThemes_.get();
// subscribe to ClientDisconnected event (wait to do this until here
// because there were spurious ClientDisconnected events occuring
// after a session interrupt sequence. we couldn't figure out why,
// and since this is a temporary hack why not add another temporary
// hack to go with it here :-)
// TOOD: move this back tot he constructor after we revise the
// interrupt hack(s)
events_.addHandler(ClientDisconnectedEvent.TYPE, this);
// create workbench
Workbench wb = workbench_.get();
eventBusProvider_.get().fireEvent(new SessionInitEvent());
// disable commands
SessionInfo sessionInfo = session_.getSessionInfo();
if (!sessionInfo.getAllowShell()) {
commands_.showShellDialog().remove();
removeTerminalCommands();
}
if (!sessionInfo.getAllowPackageInstallation()) {
commands_.installPackage().remove();
commands_.updatePackages().remove();
}
if (!sessionInfo.getAllowVcs()) {
commands_.versionControlProjectSetup().remove();
}
if (!sessionInfo.getAllowFileDownloads()) {
commands_.exportFiles().remove();
}
if (!sessionInfo.getAllowFileUploads()) {
commands_.uploadFile().remove();
}
// disable external publishing if requested
if (!SessionUtils.showExternalPublishUi(session_, uiPrefs_.get())) {
commands_.publishHTML().remove();
}
// hide the agreement menu item if we don't have one
if (!session_.getSessionInfo().hasAgreement())
commands_.rstudioAgreement().setVisible(false);
// remove knit params if they aren't supported
if (!sessionInfo.getKnitParamsAvailable())
commands_.knitWithParameters().remove();
// show the correct set of data import commands
if (uiPrefs_.get().useDataImport().getValue()) {
commands_.importDatasetFromFile().remove();
commands_.importDatasetFromURL().remove();
commands_.importDatasetFromCsvUsingReadr().setVisible(false);
commands_.importDatasetFromSAV().setVisible(false);
commands_.importDatasetFromSAS().setVisible(false);
commands_.importDatasetFromStata().setVisible(false);
commands_.importDatasetFromXML().setVisible(false);
commands_.importDatasetFromODBC().setVisible(false);
commands_.importDatasetFromJDBC().setVisible(false);
try {
String rVersion = sessionInfo.getRVersionsInfo().getRVersion();
if (ApplicationUtils.compareVersions(rVersion, "3.0.2") >= 0) {
commands_.importDatasetFromCsvUsingReadr().setVisible(true);
}
if (ApplicationUtils.compareVersions(rVersion, "3.1.0") >= 0) {
commands_.importDatasetFromSAV().setVisible(true);
commands_.importDatasetFromSAS().setVisible(true);
commands_.importDatasetFromStata().setVisible(true);
commands_.importDatasetFromXML().setVisible(true);
}
if (ApplicationUtils.compareVersions(rVersion, "3.0.0") >= 0) {
commands_.importDatasetFromODBC().setVisible(true);
}
if (ApplicationUtils.compareVersions(rVersion, "2.4.0") >= 0) {
commands_.importDatasetFromJDBC().setVisible(true);
}
} catch (Exception e) {
}
// Removing data import dialogs that are NYI
commands_.importDatasetFromXML().remove();
commands_.importDatasetFromJSON().remove();
commands_.importDatasetFromJDBC().remove();
commands_.importDatasetFromODBC().remove();
commands_.importDatasetFromMongo().remove();
} else {
commands_.importDatasetFromCsv().remove();
commands_.importDatasetFromCsvUsingBase().remove();
commands_.importDatasetFromCsvUsingReadr().remove();
commands_.importDatasetFromSAV().remove();
commands_.importDatasetFromSAS().remove();
commands_.importDatasetFromStata().remove();
commands_.importDatasetFromXLS().remove();
commands_.importDatasetFromXML().remove();
commands_.importDatasetFromJSON().remove();
commands_.importDatasetFromJDBC().remove();
commands_.importDatasetFromODBC().remove();
commands_.importDatasetFromMongo().remove();
}
// show workbench
view_.showWorkbenchView(wb.getMainView().asWidget());
// hide zoom actual size everywhere but cocoa desktop
if (!BrowseCap.isCocoaDesktop()) {
commands_.zoomActualSize().remove();
}
// hide zoom in and zoom out in web mode
if (!Desktop.isDesktop()) {
commands_.zoomIn().remove();
commands_.zoomOut().remove();
}
// show new session when appropriate
if (!Desktop.isDesktop()) {
if (sessionInfo.getMultiSession())
commands_.newSession().setMenuLabel("New Session...");
else
commands_.newSession().remove();
}
// toolbar (must be after call to showWorkbenchView because
// showing the toolbar repositions the workbench view widget)
showToolbar(uiPrefs_.get().toolbarVisible().getValue());
// sync to changes in the toolbar visibility state
uiPrefs_.get().toolbarVisible().addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
showToolbar(event.getValue());
}
});
clientStateUpdaterInstance_ = clientStateUpdater_.get();
// before we interrogate it for unsaved documents
if (ApplicationAction.hasAction()) {
new Timer() {
@Override
public void run() {
if (ApplicationAction.isQuit()) {
commands_.quitSession().execute();
} else if (ApplicationAction.isNewProject()) {
ApplicationAction.removeActionFromUrl();
events_.fireEvent(new NewProjectEvent(true, false));
} else if (ApplicationAction.isOpenProject()) {
ApplicationAction.removeActionFromUrl();
events_.fireEvent(new OpenProjectEvent(true, false));
} else if (ApplicationAction.isSwitchProject()) {
handleSwitchProjectAction();
}
}
}.schedule(500);
}
}
Aggregations