// IVsPersistSolutionProps::QuerySaveSolutionProps public int QuerySaveSolutionProps([In] IVsHierarchy pHierarchy, [Out] VSQUERYSAVESLNPROPS[] pqsspSave) { // This function is called by the IDE to determine if something needs to be saved in the solution. // If the package returns that it has dirty properties, the shell will callback on SaveSolutionProps // We will write solution properties only for the solution // A provider may consider writing in the solution project-binding-properties for each controlled project // that could help it locating the projects in the store during operations like OpenFromSourceControl if (!SccService.IsProjectControlled(null)) { pqsspSave[0] = VSQUERYSAVESLNPROPS.QSP_HasNoProps; } else { if (SolutionHasDirtyProps) { pqsspSave[0] = VSQUERYSAVESLNPROPS.QSP_HasDirtyProps; } else { pqsspSave[0] = VSQUERYSAVESLNPROPS.QSP_HasNoDirtyProps; } } return(VSConstants.S_OK); }
//IList<SelectedFile> SelectedFiles { get; set; } /// <summary> /// Returns a list of source controllable files in the selection (recursive) /// </summary> internal IList <string> GetSelectedFilesInControlledProjectsInt( out IList <string> selectedFilesFolders, out IList <VSITEMSELECTION> selectedNodes, out Hashtable SelectedHierarchies, out bool isSolutionSelected) { IDictionary <string, object> sccFiles = new Dictionary <string, object>(); IDictionary <string, object> sccFilesFolders = new Dictionary <string, object>(); //SelectedFiles = new List<SelectedFile>(); selectedNodes = GetSelectedNodes(); isSolutionSelected = false; SelectedHierarchies = GetSelectedHierarchies(ref selectedNodes, out isSolutionSelected); if (isSolutionSelected) { // Replace the selection with the root items of all controlled projects selectedNodes.Clear(); SelectedHierarchies.Clear(); Hashtable hashControllable = GetLoadedControllableProjectsEnum(); foreach (IVsHierarchy pHier in hashControllable.Keys) { if (SccService.IsProjectControlled(pHier)) { VSITEMSELECTION vsItemSelection; SelectedHierarchies[pHier] = true; vsItemSelection.pHier = pHier; vsItemSelection.itemid = VSConstants.VSITEMID_ROOT; selectedNodes.Add(vsItemSelection); } } // Add the solution file to the list if (SccService.IsProjectControlled(null)) { IVsHierarchy solHier = (IVsHierarchy)GetService(typeof(SVsSolution)); SelectedHierarchies[solHier] = true; VSITEMSELECTION vsItemSelection; vsItemSelection.pHier = solHier; vsItemSelection.itemid = VSConstants.VSITEMID_ROOT; selectedNodes.Add(vsItemSelection); } } SccService.IsaControlledProjectSelected = false; // now look in the rest of selection and accumulate scc files foreach (VSITEMSELECTION vsItemSel in selectedNodes) { if (vsItemSel.itemid == VSConstants.VSITEMID_ROOT) { SccService.IsaControlledProjectSelected |= SccService.IsProjectControlled(vsItemSel.pHier); } IVsSccProject2 pscp2 = vsItemSel.pHier as IVsSccProject2; if (pscp2 == null) { string solutionFileName = GetSolutionFileName(); // solution case sccFiles[solutionFileName] = null; string solutionFolder = Path.GetDirectoryName(solutionFileName); solutionFolder = string.Format("{0}\\...", solutionFolder); sccFilesFolders[solutionFolder] = true; } else { // if this is a project, add the projects directory to the list of selected folders string path = string.Empty; IVsProject pscp = pscp2 as IVsProject; if (pscp != null) { bool addSubFiles = false; if (isSolutionSelected == false) { //only add subpaths if the folder is not selected pscp.GetMkDocument(vsItemSel.itemid, out path); if ((path != null) && (vsItemSel.itemid == VSConstants.VSITEMID_ROOT)) { // if it's a project path = Path.GetDirectoryName(path); path = string.Format("{0}\\...", path); sccFilesFolders[path] = null; } else if ((path != null) && path.EndsWith("\\")) { // if it's a folder path = string.Format("{0}...", path); sccFilesFolders[path] = null; } else { addSubFiles = true; } } IList <string> nodefilesrec = GetProjectFiles(pscp2, vsItemSel.itemid); foreach (string file in nodefilesrec) { sccFiles[file] = null; if (addSubFiles) { sccFilesFolders[file] = null; } } } } } selectedFilesFolders = sccFilesFolders.Keys.ToList(); return(sccFiles.Keys.ToList()); }
// Used to open a connection to a Perforce depot public void OpenConnection(string Port, string User, string Workspace) { #if DB_DEBUG P4VsOutputWindow.AppendMessage(string.Format("Opening connection, CurrentScm scm ID:{0}", CurrentScm != null?CurrentScm.__Id:-1)); #endif P4ScmProvider scm = new P4ScmProvider(SccService); scm.LoadingSolution = !string.IsNullOrEmpty(SccService.LoadingControlledSolutionLocation); #if DB_DEBUG P4VsOutputWindow.AppendMessage(string.Format("Opening connection, new scm ID:{0}", scm.__Id)); #endif bool noUi = InCommandLineMode() || (Port != null) && (User != null) && (Workspace != null); // trigger the connection dialog scm.Connection.Connect(Port, User, Workspace, noUi, null); if (scm.Connected) { #if DB_DEBUG P4VsOutputWindow.AppendMessage(string.Format("Opening connection user clicked OK, new scm ID:{0}", scm.__Id)); #endif if (SccService.ScmProvider != null) { BroadcastNewConnection(null); SccService.Dispose(); SccService.ScmProvider = null; } SccService.ScmProvider = scm; createActiveChangelists(SccService); if (string.IsNullOrEmpty(SccService.ScmProvider.SolutionFile)) { string solutionFile = GetSolutionFileName(); if (string.IsNullOrEmpty(solutionFile) == false) { SccService.ScmProvider.SolutionFile = GetSolutionFileName(); if (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; } } if (!SccService.IsProjectControlled(null)) { SccService.OnAfterOpenSolution(null, 0); } } Cursor oldCursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; // now refresh the selected nodes' glyphs if (Preferences.LocalSettings.GetBool("LazyLoadStatus", false) == false) { Glyphs.RefreshNodesGlyphs(null, null); } } finally { Cursor.Current = oldCursor; } BroadcastNewConnection(SccService.ScmProvider); MRUList recentConnections = (MRUList)Preferences.LocalSettings["RecentConnections"]; currentConnectionDropDownComboChoice = recentConnections[0].ToString(); SuppressConnection = true; LastConnectionInfo = new ConnectionData(); LastConnectionInfo.ServerPort = SccService.ScmProvider.Connection.Port; LastConnectionInfo.UserName = SccService.ScmProvider.Connection.User; LastConnectionInfo.Workspace = SccService.ScmProvider.Connection.Workspace; #if _DBB_DEBUG // How to set a setting for the ide (Generally from tool/options dialog) // The category and page values are listed on MSDN at: // http://msdn.microsoft.com/en-us/library/ms165643(v=vs.100).aspx // The category and pages no longer follow the layout in the options dialog, // they seem to still follow the old layout fro VS 2003. There's a general // discussion on MSDN about properties here: // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.100).aspx // and: // http://msdn.microsoft.com/en-us/library/awdwz11a(v=vs.100).aspx // The Property object is documented here: // http://msdn.microsoft.com/en-us/library/envdte.property(v=vs.100).aspx // The Properties interface is documented here: // http://msdn.microsoft.com/en-us/library/envdte.properties(v=vs.100).aspx try { EnvDTE.DTE dte2; dte2 = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); EnvDTE.Properties generalPnS = dte2.DTE.Properties["Environment", "ProjectsAndSolution"]; EnvDTE.Property prop2 = generalPnS.Item("ProjectsLocation"); string val = prop2.Value as string; //dynamic v2 = val + "\\temp"; prop2.Value = val; val = prop2.Value as string; } catch (Exception ex) { string msg = ex.Message; MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); } #endif // How to set a setting for the ide (Generally from tool/options dialog) // The category and page values are listed on MSDN at: // http://msdn.microsoft.com/en-us/library/ms165643(v=vs.100).aspx // The category and pages no longer follow the layout in the options dialog, // they seem to still follow the old layout fro VS 2003. There's a general // discussion on MSDN about properties here: // http://msdn.microsoft.com/en-us/library/ms165641(v=vs.100).aspx // and: // http://msdn.microsoft.com/en-us/library/awdwz11a(v=vs.100).aspx // The Property object is documented here: // http://msdn.microsoft.com/en-us/library/envdte.property(v=vs.100).aspx // The Properties interface is documented here: // http://msdn.microsoft.com/en-us/library/envdte.properties(v=vs.100).aspx if (Preferences.LocalSettings.GetBool("SetProjectFileLocation", true) && !string.IsNullOrEmpty(scm.Connection.WorkspaceRoot)) { try { EnvDTE.Property prop = null; EnvDTE.DTE dte2; dte2 = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); EnvDTE.Properties generalPnS = dte2.get_Properties("Environment", "ProjectsAndSolution"); foreach (EnvDTE.Property temp in generalPnS) { prop = temp; if (prop.Name == "ProjectsLocation") { if (Directory.Exists(scm.Connection.WorkspaceRoot)) { prop.Value = scm.Connection.WorkspaceRoot.Replace("/", "\\"); } } } } catch (Exception ex) { string msg = ex.Message; MessageBox.Show(msg, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } #if DB_DEBUG P4VsOutputWindow.AppendMessage(string.Format("Leaving open connection, CurrentScm scm ID:{0}", CurrentScm != null ? CurrentScm.__Id : -1)); #endif }