use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class SatelliteManager method registerAsSatellite.
// called by satellites to connect themselves with the main window
private void registerAsSatellite(final String name, JavaScriptObject wnd) {
// get the satellite and add it to our list. in some cases (such as
// the Ctrl+R reload of an existing satellite window) we actually
// already have a reference to this satellite in our list so in that
// case we make sure not to add a duplicate
WindowEx satelliteWnd = wnd.<WindowEx>cast();
ActiveSatellite satellite = new ActiveSatellite(name, satelliteWnd);
if (!satellites_.contains(satellite))
satellites_.add(satellite);
// augment the current session info with an up-to-date set of source
// documents
SessionInfo sessionInfo = session_.getSessionInfo();
sessionInfo.setSourceDocuments(pSourceWindowManager_.get().getSourceDocs());
// clone the session info so the satellites aren't reading/writing the
// same copy as the main window; pass the cloned copy along
JsObject sessionInfoJs = session_.getSessionInfo().cast();
callSetSessionInfo(satelliteWnd, sessionInfoJs.clone());
// call setParams
JavaScriptObject params = satelliteParams_.get(name);
if (params != null)
callSetParams(satelliteWnd, params);
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class DefaultGlobalDisplay method openRStudioLink.
@Override
public void openRStudioLink(String linkName, boolean includeVersionInfo) {
// build url
final SessionInfo sessionInfo = session_.getSessionInfo();
String url = "https://www.rstudio.org/links/";
url += URL.encodePathSegment(linkName);
if (includeVersionInfo) {
url += "?version=" + URL.encodeQueryString(sessionInfo.getRstudioVersion());
url += "&mode=" + URL.encodeQueryString(sessionInfo.getMode());
}
// open window
openWindow(url);
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class NewDirectoryPage method onAddWidgets.
@Override
protected void onAddWidgets() {
NewProjectResources.Styles styles = NewProjectResources.INSTANCE.styles();
HorizontalPanel panel = new HorizontalPanel();
panel.addStyleName(styles.wizardMainColumn());
// create the dir name label
dirNameLabel_ = new Label("Directory name:");
dirNameLabel_.addStyleName(styles.wizardTextEntryLabel());
// top panel widgets
onAddTopPanelWidgets(panel);
// dir name
VerticalPanel namePanel = new VerticalPanel();
namePanel.addStyleName(styles.newProjectDirectoryName());
namePanel.add(dirNameLabel_);
txtProjectName_ = new TextBox();
txtProjectName_.setWidth("100%");
txtProjectName_.getElement().setAttribute("spellcheck", "false");
namePanel.add(txtProjectName_);
panel.add(namePanel);
addWidget(panel);
onAddBodyWidgets();
addSpacer();
// project dir
newProjectParent_ = new DirectoryChooserTextBox("Create project as subdirectory of:", txtProjectName_);
addWidget(newProjectParent_);
// if git is available then add git init
UIPrefs uiPrefs = RStudioGinjector.INSTANCE.getUIPrefs();
SessionInfo sessionInfo = RStudioGinjector.INSTANCE.getSession().getSessionInfo();
HorizontalPanel optionsPanel = null;
if (getOptionsSideBySide())
optionsPanel = new HorizontalPanel();
chkGitInit_ = new CheckBox("Create a git repository");
chkGitInit_.addStyleName(styles.wizardCheckbox());
if (sessionInfo.isVcsAvailable(VCSConstants.GIT_ID)) {
chkGitInit_.setValue(uiPrefs.newProjGitInit().getValue());
chkGitInit_.getElement().getStyle().setMarginRight(7, Unit.PX);
if (optionsPanel != null) {
optionsPanel.add(chkGitInit_);
} else {
addSpacer();
addWidget(chkGitInit_);
}
}
// Initialize project with packrat
chkPackratInit_ = new CheckBox("Use packrat with this project");
chkPackratInit_.setValue(uiPrefs.newProjUsePackrat().getValue());
if (!sessionInfo.getPackratAvailable()) {
chkPackratInit_.setValue(false);
chkPackratInit_.setVisible(false);
}
if (optionsPanel != null) {
optionsPanel.add(chkPackratInit_);
} else {
addSpacer();
addWidget(chkPackratInit_);
}
if (optionsPanel != null) {
addSpacer();
addWidget(optionsPanel);
}
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class WorkbenchContext method getDefaultWorkingDir.
public FileSystemItem getDefaultWorkingDir() {
if (defaultWorkingDir_ == null) {
SessionInfo sessionInfo = session_.getSessionInfo();
defaultWorkingDir_ = FileSystemItem.createDir(sessionInfo.getDefaultWorkingDir());
}
return defaultWorkingDir_;
}
use of org.rstudio.studio.client.workbench.model.SessionInfo in project rstudio by rstudio.
the class PackageLibraryUtils method typeOfLibrary.
public static PackageLibraryType typeOfLibrary(Session session, String library) {
FileSystemItem projectDir = null;
SessionInfo sessionInfo = session.getSessionInfo();
if (sessionInfo != null)
projectDir = sessionInfo.getActiveProjectDir();
// belongs in the project library
if (StringUtil.isNullOrEmpty(library) || (projectDir != null && library.startsWith(projectDir.getPath()))) {
return PackageLibraryType.Project;
} else if (library.startsWith(FileSystemItem.HOME_PATH)) {
return PackageLibraryType.User;
} else {
return PackageLibraryType.System;
}
}
Aggregations