Search in sources :

Example 16 with SessionInfo

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);
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 17 with SessionInfo

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);
}
Also used : SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo)

Example 18 with SessionInfo

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);
    }
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) CheckBox(com.google.gwt.user.client.ui.CheckBox) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Label(com.google.gwt.user.client.ui.Label) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) TextBox(com.google.gwt.user.client.ui.TextBox) DirectoryChooserTextBox(org.rstudio.core.client.widget.DirectoryChooserTextBox) DirectoryChooserTextBox(org.rstudio.core.client.widget.DirectoryChooserTextBox) UIPrefs(org.rstudio.studio.client.workbench.prefs.model.UIPrefs)

Example 19 with SessionInfo

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_;
}
Also used : SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo)

Example 20 with SessionInfo

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;
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo)

Aggregations

SessionInfo (org.rstudio.studio.client.workbench.model.SessionInfo)21 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 SessionInitEvent (org.rstudio.studio.client.workbench.events.SessionInitEvent)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 Timer (com.google.gwt.user.client.Timer)3 JsObject (org.rstudio.core.client.js.JsObject)3 JsArrayString (com.google.gwt.core.client.JsArrayString)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 Inject (com.google.inject.Inject)2 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)2 Operation (org.rstudio.core.client.widget.Operation)2 InvalidSessionInfo (org.rstudio.studio.client.application.model.InvalidSessionInfo)2 GlobalToolbar (org.rstudio.studio.client.application.ui.GlobalToolbar)2 ServerError (org.rstudio.studio.client.server.ServerError)2 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)2 SessionInitHandler (org.rstudio.studio.client.workbench.events.SessionInitHandler)2 ClientInitState (org.rstudio.studio.client.workbench.model.ClientInitState)2 JSObjectStateValue (org.rstudio.studio.client.workbench.model.helper.JSObjectStateValue)2 StringStateValue (org.rstudio.studio.client.workbench.model.helper.StringStateValue)2 PresentationState (org.rstudio.studio.client.workbench.views.presentation.model.PresentationState)2