Esempio n. 1
0
        private void createActiveChangelists(P4VsProviderService P4Service)
        {
            string key = "ActiveChangelist_" + P4Service.ScmProvider.Connection.Repository.Connection.Server.Address.Uri.Replace(':', '_') +
                         "_" + P4Service.ScmProvider.Connection.User + "_" + P4Service.ScmProvider.Connection.Workspace;

            ChangeLists = new ActiveChangeListCombo(P4Service);
            string newActiveChangeListComboChoice = Preferences.LocalSettings.GetString(key, Resources.Changelist_Default);

            ChangeLists.SetActiveChangeList(newActiveChangeListComboChoice);
        }
Esempio n. 2
0
        internal void ConnectToScm(string port, string user, string workspace)
        {
            if (SuppressConnection)
            {
                SuppressConnection = false;
                if ((SccService.ScmProvider.Connection.Disconnected) && (LastConnectionInfo != null))
                {
                    if (SccService.ScmProvider != null)
                    {
                        BroadcastNewConnection(null);
                        SccService.ScmProvider.Dispose();
                        SccService.ScmProvider = null;
                    }
                    SccService.ScmProvider = new P4ScmProvider(SccService);
                    SccService.ScmProvider.Connection.Connect(LastConnectionInfo);
                    SccService.ScmProvider.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation);
                    ChangeLists = new ActiveChangeListCombo(SccService);
                }
                if (SccService.ScmProvider.Connected)
                {
                    return;
                }
            }
            bool showConnectDlg = false;

            ConnectionPreference pref = ConnectionPreference.ShowDialog;

            if (Preferences.LocalSettings.ContainsKey("ConnectPreference"))
            {
                pref = (ConnectionPreference)Preferences.LocalSettings["ConnectPreference"];
            }
            string _port      = null;
            string _user      = null;
            string _workspace = null;

            switch (pref)
            {
            default:
            case ConnectionPreference.ShowDialog:
                showConnectDlg = true;
                break;

            case ConnectionPreference.UseRecent:
                if ((SccService.ScmProvider != null) && (SccService.ScmProvider.CheckConnection()))
                {
                    //already connected
                    return;
                }
                MRUList _recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];
                if (_recentConnections != null)
                {
                    ConnectionData con = _recentConnections[0] as ConnectionData;
                    if (con != null)
                    {
                        _port      = con.ServerPort;
                        _user      = con.UserName;
                        _workspace = con.Workspace;
                    }
                }
                else
                {
                    // no recent connections
                    showConnectDlg = true;
                }
                break;

            case ConnectionPreference.UseSolution:
                if (string.IsNullOrEmpty(port) || string.IsNullOrEmpty(user) || string.IsNullOrEmpty(workspace))
                {
                    // didn't contain all the connection data, so show dialog
                    showConnectDlg = true;
                }
                else
                {
                    _port      = port;
                    _user      = user;
                    _workspace = workspace;
                }
                break;

            case ConnectionPreference.UseEnvironment:
                _port      = null;
                _user      = null;
                _workspace = null;
                break;
            }
            if (SccService.ScmProvider != null)
            {
                BroadcastNewConnection(null);
                SccService.ScmProvider.Dispose();
                SccService.ScmProvider = null;
            }
            SccService.ScmProvider = new P4ScmProvider(SccService);
            SccService.ScmProvider.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation);
            ChangeLists = new ActiveChangeListCombo(SccService);

            if ((showConnectDlg == false) || (InCommandLineMode()))
            {
                SccService.ScmProvider.Connection.Connect(_port, _user, _workspace, true, Path.GetDirectoryName(GetSolutionFileName()));
            }
            else if ((showConnectDlg || SccService.ScmProvider.Connection.Disconnected) && (!InCommandLineMode()))
            {
                SccService.ScmProvider.Connection.Connect();
            }
            if ((SolutionFileTagged == false) &&
                (Preferences.LocalSettings.GetBool("TagSolutionProjectFiles", false)))
            {
                // Need to tag sln file if tagging is enabled, so mark dirty props so
                // it'll get tagged
                SolutionHasDirtyProps = true;
            }

            BroadcastNewConnection(SccService.ScmProvider);

            if (SccService.ScmProvider.Connected)
            {
                ConnectionData cd = new ConnectionData();
                cd.ServerPort = SccService.ScmProvider.Connection.Port;
                cd.UserName   = SccService.ScmProvider.Connection.User;
                cd.Workspace  = SccService.ScmProvider.Connection.Workspace;

                MRUList recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"];

                if (recentConnections == null)
                {
                    recentConnections = new MRUList(5);
                }
                recentConnections.Add(cd);

                Preferences.LocalSettings["RecentConnections"] = recentConnections;

                currentConnectionDropDownComboChoice = cd.ToString();
                string key = "ActiveChangelist_" + SccService.ScmProvider.Connection.Repository.Connection.Server.Address.Uri.Replace(':', '_') +
                             "_" + SccService.ScmProvider.Connection.User + "_" + SccService.ScmProvider.Connection.Workspace;

                string newActiveChangeListComboChoice = Preferences.LocalSettings.GetString(key, Resources.Changelist_Default);
                ChangeLists.SetActiveChangeList(newActiveChangeListComboChoice);
            }

            if ((SccService.ScmProvider != null) && (SccService.ScmProvider.Connected))
            {
                SccService.ScmProvider.SolutionFile = GetSolutionFileName();
            }
        }