public RefreshState(IAnkhServiceProvider context, IVsHierarchy hier, IVsProject project, string projectDir) { _hier = hier; _cache = context.GetService <ISvnStatusCache>(); _walker = context.GetService <ISccProjectWalker>(); _project = project as IVsProject2; _projectDir = projectDir; if (projectDir != null) { _projectDirItem = Cache[projectDir]; } }
private bool RemoveItem(uint vsItemId) { IVsProject2 vsProject = hierarchy as IVsProject2; if (vsProject == null) { return(false); } int result = 0; int hr = vsProject.RemoveItem(0, vsItemId, out result); return(hr == VSConstants.S_OK && result == 1); }
public int OnElementValueChanged(uint elementid, object varValueOld, object varValueNew) { ThreadHelper.ThrowIfNotOnUIThread(); switch ((VSConstants.VSSELELEMID)elementid) { case VSConstants.VSSELELEMID.SEID_WindowFrame: _activeFrameObject = _activeFrameControl = null; _activeFrameTextView = null; _determinedActiveFrameTextView = false; _activeFrame = varValueNew as IVsWindowFrame; break; case VSConstants.VSSELELEMID.SEID_DocumentFrame: _activeDocumentFrameObject = _activeDocumentControl = null; _activeDocumentFrameTextView = null; _determinedActiveDocumentFrameTextView = false; _activeDocumentFrame = varValueNew as IVsWindowFrame; break; #if NEVER case VSConstants.VSSELELEMID.SEID_UserContext: IVsUserContext userContext = varValueNew as IVsUserContext; break; case VSConstants.VSSELELEMID.SEID_PropertyBrowserSID: IVsPropertyBrowser pb = varValueNew as IVsPropertyBrowser; break; case VSConstants.VSSELELEMID.SEID_ResultList: IOleCommandTarget ct = varValueNew as IOleCommandTarget; break; case VSConstants.VSSELELEMID.SEID_StartupProject: IVsProject2 pr = varValueNew as IVsProject2; break; case VSConstants.VSSELELEMID.SEID_UndoManager: IOleUndoManager ud = varValueNew as IOleUndoManager; break; #endif } _activeDocumentFileName = null; // Flush on every document state change ClearCache(); return(VSErr.S_OK); }
public IProjectNode Adapt(IVsProject2 from) { return(CreateNode((IVsHierarchy)from) as IProjectNode); }
private void UpdateSettingTabs() { ThreadHelper.ThrowIfNotOnUIThread(); string projectBase = null; string relativePath = null; string projectLocation = null; bool first = true; Uri projectUri = null; foreach (SccProject p in SelectedProjects) { ISccProjectInfo info; if (p.IsSolution || null == (info = ProjectMapper.GetProjectInfo(p)) || string.IsNullOrEmpty(info.ProjectDirectory)) { projectBase = null; break; } string pBase = info.SccBaseDirectory; string relPath = info.ProjectDirectory; string pLoc = null; Uri pUri; if (relPath.StartsWith(info.SccBaseDirectory)) { int pdLen = info.ProjectDirectory.Length; int sccLen = info.SccBaseDirectory.Length; if (pdLen == sccLen) { relPath = "."; } else if (sccLen < pdLen && info.ProjectDirectory[sccLen] == Path.DirectorySeparatorChar) { relPath = info.ProjectDirectory.Substring(sccLen + 1); } else { relPath = info.ProjectDirectory; } } if (p.RawHandle != null) { IVsProject2 ps = p.RawHandle as IVsProject2; if (ps != null) { string doc; if (VSErr.Succeeded(ps.GetMkDocument(VSItemId.Root, out doc))) { if (SvnItem.IsValidPath(doc)) { pLoc = SvnItem.MakeRelative(SolutionSettings.SolutionFilename, doc); } else { pLoc = doc; } } } } pUri = info.SccBaseUri; if (pUri == null && pBase != null) { SvnItem pi = StatusCache[pBase]; if (pi != null) { pUri = pi.Uri; } } KeepOneIgnoreCase(ref projectBase, pBase, first); KeepOneIgnoreCase(ref relativePath, relPath, first); KeepOneIgnoreCase(ref projectLocation, pLoc, first); KeepOne(ref projectUri, pUri, first); first = false; } if (projectBase == null) { relativePath = null; projectLocation = null; } shProjectLocation.Text = projectLocation ?? ""; shBindPath.Text = projectBase ?? ""; shRelativePath.Text = string.IsNullOrEmpty(relativePath) ? "." : relativePath; shProjectUrl.Text = (projectUri != null) ? projectUri.ToString() : ""; usProjectLocation.Text = projectLocation ?? ""; usBindPath.Text = projectBase ?? ""; usRelativePath.Text = string.IsNullOrEmpty(relativePath) ? "." : relativePath; usProjectUrl.Text = (projectUri != null) ? projectUri.ToString() : ""; slnProjectLocation.Text = SolutionSettings.SolutionFilename; slnBindPath.Text = SolutionSettings.ProjectRoot; string slRelativePath = Path.GetDirectoryName(SvnItem.MakeRelative(SolutionSettings.ProjectRoot, SolutionSettings.SolutionFilename)); slnRelativePath.Text = string.IsNullOrEmpty(slRelativePath) ? "." : slRelativePath; slnBindUrl.Text = (SolutionSettings.ProjectRootUri != null) ? SolutionSettings.ProjectRootUri.ToString() : ""; usProjectLocationBrowse.Visible = false; // enlistMode > SccEnlistMode.None; usProjectLocationBrowse.Enabled = false; // enlistMode > SccEnlistMode.SvnStateOnly; sharedProjectUrlBrowse.Enabled = false; // sharedBasePathBrowse.Visible sharedProjectUrlBrowse.Visible = false; //= (enlistMode > SccEnlistMode.None) //&& (projectBase != null) //&& (enlistMode > SccEnlistMode.SvnStateOnly || projectBase != SolutionSettings.ProjectRoot); slnBindBrowse.Enabled = (SolutionSettings.ProjectRootSvnItem != null) && SolutionSettings.ProjectRootSvnItem.WorkingCopy != null; }
public override void OnExecute(CommandEventArgs e) { List <SvnItem> toDelete = new List <SvnItem>(e.Selection.GetSelectedSvnItems(true)); AnkhMessageBox mb = new AnkhMessageBox(e.Context); string body; // We do as if we are Visual Studio here: Same texts, same behavior (same chance on data loss) if (toDelete.Count == 1) { body = string.Format(CommandStrings.XWillBeDeletedPermanently, toDelete[0].Name); } else { body = CommandStrings.TheSelectedItemsWillBeDeletedPermanently; } if (DialogResult.OK != mb.Show(body, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)) { return; // No delete } int hr = VSErr.S_OK; foreach (SvnItem item in toDelete) { { IVsUIHierarchy hier; uint id; IVsWindowFrame frame; if (VsShellUtilities.IsDocumentOpen(e.Context, item.FullPath, Guid.Empty, out hier, out id, out frame)) { hr = frame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave); if (!VSErr.Succeeded(hr)) { break; // Show error and cancel further actions } } } try { if (item.IsVersioned) { using (SvnClient cl = e.GetService <ISvnClientPool>().GetNoUIClient()) { SvnDeleteArgs da = new SvnDeleteArgs(); da.Force = true; cl.Delete(item.FullPath, da); } } else { SvnItem.DeleteNode(item.FullPath); } } finally { // TODO: Notify the working copy explorer here! // (Maybe via one of these methods below) e.GetService <ISvnStatusCache>().MarkDirtyRecursive(item.FullPath); e.GetService <IFileStatusMonitor>().ScheduleGlyphUpdate(item.FullPath); } // Ok, now remove the file from projects IProjectFileMapper pfm = e.GetService <IProjectFileMapper>(); List <SccProject> projects = new List <SccProject>(pfm.GetAllProjectsContaining(item.FullPath)); foreach (SccProject p in projects) { IVsProject2 p2 = p.RawHandle as IVsProject2; if (p2 == null) { continue; } VSDOCUMENTPRIORITY[] prio = new VSDOCUMENTPRIORITY[1]; int found; uint id; if (!VSErr.Succeeded(p2.IsDocumentInProject(item.FullPath, out found, prio, out id)) || found == 0) { continue; // Probably already removed (mapping out of synch?) } hr = p2.RemoveItem(0, id, out found); if (!VSErr.Succeeded(hr)) { break; } } } if (!VSErr.Succeeded(hr)) { mb.Show(Marshal.GetExceptionForHR(hr).Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public RefreshState(IAnkhServiceProvider context, IVsHierarchy hier, IVsProject project, string projectDir) { _hier = hier; _cache = context.GetService<IFileStatusCache>(); _walker = context.GetService<ISccProjectWalker>(); _project = project as IVsProject2; _projectDir = projectDir; if (projectDir != null) _projectDirItem = Cache[projectDir]; }