public void OnExecute(CommandEventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); SvnSccProvider scc = e.GetService <SvnSccProvider>(); SccHierarchy hier = EnumTools.GetSingle(e.Selection.GetSelectedHierarchies()); if (hier == null) { throw new InvalidOperationException(); } switch (e.Command) { case AnkhCommand.SccSccReCheckoutFailedProject: { scc.EnlistAndCheckout(hier.Hierarchy, hier.Name); IVsSolution s = e.GetService <IVsSolution>(typeof(SVsSolution)); ISccHelper helper = e.GetService <ISccHelper>(); if (s == null || helper == null) { return; } Guid projectGuid; if (!VSErr.Succeeded(s.GetGuidOfProject(hier.Hierarchy, out projectGuid))) { return; } helper.EnsureProjectLoaded(projectGuid, false); break; } case AnkhCommand.SccEditFailedProjectLocation: scc.EditEnlistment(hier.Hierarchy, hier.Name); break; } }
public void OnUpdate(CommandUpdateEventArgs e) { object fm = e.Selection.Cache[_failedProjectsKey]; IDictionary <string, object> map; #if !DEBUG if (e.Command == AnkhCommand.SccEditFailedProjectLocation) { e.Enabled = false; return; } #endif if (fm != null) { map = (fm as IDictionary <string, object>); } else { SvnSccProvider scc = e.GetService <SvnSccProvider>(); map = scc.GetProjectsThatNeedEnlisting(); e.Selection.Cache[_failedProjectsKey] = map ?? _failedProjectsKey; } if (map != null) { SccHierarchy hier = EnumTools.GetSingle(e.Selection.GetSelectedHierarchies()); // if ( hier != null && !String.IsNullOrEmpty(hier.Name) && map.ContainsKey(hier.Name) ) // alllucly1996-dũng: I saw IsNullOrEmpty(hier.Name) seems unnecessary if (hier != null && map.ContainsKey(hier.Name)) { return; } } e.Enabled = false; }
protected virtual string GetGlyphTipText(SccHierarchy phierHierarchy, uint itemidNode) { return(null); }
/// <summary> /// Provides ToolTip text based on the source control data for a specific node in the project's hierarchy Solution Explorer. /// </summary> /// <param name="hierarchy">[in] Owner hierarchy of node (null if it is a solution).</param> /// <param name="itemidNode">[in] The ID of the node for which the ToolTip is requested.</param> /// <param name="pbstrTooltipText">[out] ToolTip text.</param> /// <returns> /// If the method succeeds, it returns <see cref="F:Microsoft.VisualStudio.VSErr.S_OK"></see>. If it fails, it returns an error code. /// </returns> protected override string GetGlyphTipText(SccHierarchy hierarchy, uint itemidNode) { if (Walker == null || StatusCache == null) { return(null); } HybridCollection <string> files = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase); int n = 0; foreach (string file in Walker.GetSccFiles(hierarchy.Hierarchy, itemidNode, ProjectWalkDepth.Empty, null)) { if (files.Contains(file) || !SvnItem.IsValidPath(file)) { continue; } files.Add(file); SccProjectFile spf; if (ProjectMap.TryGetFile(file, out spf)) { foreach (string subfile in spf.FirstReference.GetSubFiles()) { if (!files.Contains(subfile)) { files.Add(subfile); } } } } StringBuilder sb = new StringBuilder(); string format = (files.Count > 0) ? "{0}: {1}" : "{1}"; int i = 0; foreach (string file in files) { SvnItem item = StatusCache[file]; if (i >= n) // This is a subitem! { if (item.IsModified) { sb.AppendFormat(format, item.Name, Resources.ToolTipModified).AppendLine(); } } if (item.IsConflicted) { sb.AppendFormat(format, item.Name, Resources.ToolTipConflict).AppendLine(); } if (item.IsObstructed) { sb.AppendFormat(format, item.Name, item.IsFile ? Resources.ToolTipFileObstructed : Resources.ToolTipDirObstructed).AppendLine(); } if (!item.Exists && item.IsVersioned && !item.IsDeleteScheduled) { sb.AppendFormat(format, item.Name, Resources.ToolTipDoesNotExist).AppendLine(); } if (item.IsLocked) { sb.AppendFormat(format, item.Name, Resources.ToolTipLocked).AppendLine(); } i++; if (sb.Length > 2048) { break; } } if (sb.Length > 0) { return(sb.ToString().Trim()); // We added newlines } return(null); }