/// <summary> /// Handles the exclude from project command. /// </summary> /// <returns></returns> internal override int ExcludeFromProject() { Debug.Assert(this.ProjectMgr != null, "The project item " + this.ToString() + " has not been initialised correctly. It has a null ProjectMgr"); if (!ProjectMgr.QueryEditProjectFile(false) || !ProjectMgr.Tracker.CanRemoveItems(new[] { Url }, new[] { VSQUERYREMOVEFILEFLAGS.VSQUERYREMOVEFILEFLAGS_NoFlags })) { return(VSConstants.E_FAIL); } ResetNodeProperties(); ItemNode.RemoveFromProjectFile(); if (!File.Exists(Url) || IsLinkFile) { ProjectMgr.OnItemDeleted(this); Parent.RemoveChild(this); } else { ItemNode = new AllFilesProjectElement(Url, ItemNode.ItemTypeName, ProjectMgr); if (!ProjectMgr.IsShowingAllFiles) { IsVisible = false; ProjectMgr.OnInvalidateItems(Parent); } ProjectMgr.ReDrawNode(this, UIHierarchyElement.Icon); ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, 0); } ((IVsUIShell)GetService(typeof(SVsUIShell))).RefreshPropertyBrowser(0); return(VSConstants.S_OK); }
/// <summary> /// Overridden method. The method updates the build dependency list before removing the node from the hierarchy. /// </summary> public override void Remove(bool removeFromStorage) { if (ProjectMgr == null) { return; } ItemNode.RemoveFromProjectFile(); base.Remove(removeFromStorage); }
/// <summary> /// Overridden method. The method updates the build dependency list before removing the node from the hierarchy. /// </summary> public override bool Remove(bool removeFromStorage) { if (ProjectMgr == null) { return(false); } ItemNode.RemoveFromProjectFile(); return(base.Remove(removeFromStorage)); }
/// <summary> /// Overridden method. The method updates the build dependency list before removing the node from the hierarchy. /// </summary> public override void Remove(bool removeFromStorage) { if (ProjectMgr == null) { return; } var interp = ((PythonProjectNode)ProjectMgr).GetInterpreter() as IPythonInterpreterWithProjectReferences; if (interp != null) { interp.RemoveReference(new ProjectReference(_filename, ProjectReferenceKind.ExtensionModule)); } ItemNode.RemoveFromProjectFile(); base.Remove(removeFromStorage); }
/// <summary> /// Overridden method. The method updates the build dependency list before removing the node from the hierarchy. /// </summary> public override bool Remove(bool removeFromStorage) { if (ProjectMgr == null) { return(false); } var interp = ((PythonProjectNode)ProjectMgr).GetAnalyzer(); if (interp != null) { interp.RemoveReferenceAsync(new ProjectReference(_filename, ProjectReferenceKind.ExtensionModule)).Wait(); } ItemNode.RemoveFromProjectFile(); return(base.Remove(removeFromStorage)); }
/// <summary> /// Handles the exclude from project command. /// </summary> /// <returns></returns> internal override int ExcludeFromProject() { ProjectMgr.Site.GetUIThread().MustBeCalledFromUIThread(); Debug.Assert(this.ProjectMgr != null, "The project item " + this.ToString() + " has not been initialised correctly. It has a null ProjectMgr"); if (!ProjectMgr.QueryEditProjectFile(false) || !ProjectMgr.QueryFolderRemove(Parent, Url)) { return(VSConstants.E_FAIL); } for (var child = FirstChild; child != null; child = child.NextSibling) { // we automatically exclude all children below us too int hr = child.ExcludeFromProject(); if (ErrorHandler.Failed(hr)) { return(hr); } } ResetNodeProperties(); ItemNode.RemoveFromProjectFile(); if (!Directory.Exists(CommonUtils.TrimEndSeparator(Url))) { ProjectMgr.OnItemDeleted(this); Parent.RemoveChild(this); } else { ItemNode = new AllFilesProjectElement(Url, ItemNode.ItemTypeName, ProjectMgr); if (!ProjectMgr.IsShowingAllFiles) { IsVisible = false; ProjectMgr.OnInvalidateItems(Parent); } ProjectMgr.ReDrawNode(this, UIHierarchyElement.Icon); ProjectMgr.OnPropertyChanged(this, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, 0); } // PERFORMANCE: call it once only! // ((IVsUIShell)GetService(typeof(SVsUIShell))).RefreshPropertyBrowser(0); return(VSConstants.S_OK); }
int IProjectSourceNode.ExcludeFromProject() { NemerleProjectNode projectNode = ProjectMgr as NemerleProjectNode; if (projectNode == null || projectNode.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } if (IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } ((NemerlePackage)ProjectMgr.Package).SetWaitCursor(); // Check out the project file. if (!projectNode.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } // remove children, if any, before removing from the hierarchy for (HierarchyNode child = FirstChild; child != null; child = child.NextSibling) { IProjectSourceNode node = child as IProjectSourceNode; if (node == null) { continue; } int result = node.ExcludeFromProject(); if (result != VSConstants.S_OK) { return(result); } } if (projectNode.ShowAllFilesEnabled && Directory.Exists(Url)) { string url = Url; SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); ItemNode.RemoveFromProjectFile(); ItemNode = new ProjectElement(ProjectMgr, null, true); // now we have to create a new ItemNode to indicate that this is virtual node. ItemNode.Rename(url); ItemNode.SetMetadata(ProjectFileConstants.Name, Url); ReDraw(UIHierarchyElement.Icon); // we have to redraw the icon of the node as it is now not a member of the project and shoul be drawn using a different icon. } else if (Parent != null) // the project node has no parentNode { // this is important to make it non member item. otherwise, the multi-selection scenario would // not work if it has any parent child relation. SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // remove from the hierarchy OnItemDeleted(); Parent.RemoveChild(this); ItemNode.RemoveFromProjectFile(); } HierarchyHelpers.RefreshPropertyBrowser(this); return(VSConstants.S_OK); }
int IProjectSourceNode.ExcludeFromProject() { if (ProjectMgr == null || ProjectMgr.IsClosed) { return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED); } if (IsNonMemberItem) { return(VSConstants.S_OK); // do nothing, just ignore it. } ((NemerlePackage)ProjectMgr.Package).SetWaitCursor(); // Ask Document tracker listeners if we can remove the item. { // just to limit the scope. string documentToRemove = GetMkDocument(); string[] filesToBeDeleted = new[] { documentToRemove }; VSQUERYREMOVEFILEFLAGS[] queryRemoveFlags = GetQueryRemoveFileFlags(filesToBeDeleted); if (!ProjectMgr.Tracker.CanRemoveItems(filesToBeDeleted, queryRemoveFlags)) { return((int)OleConstants.OLECMDERR_E_CANCELED); } // Close the document if it has a manager. DocumentManager manager = GetDocumentManager(); if (manager != null) { if (manager.Close(__FRAMECLOSE.FRAMECLOSE_PromptSave) == VSConstants.E_ABORT) { return(VSConstants.OLE_E_PROMPTSAVECANCELLED); } } if (!ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } } // close the document window if open. CloseDocumentWindow(this); NemerleProjectNode projectNode = ProjectMgr as NemerleProjectNode; if (projectNode != null && projectNode.ShowAllFilesEnabled && File.Exists(Url)) { string url = Url; // need to store before removing the node. ItemNode.RemoveFromProjectFile(); ProjectMgr.Tracker.OnItemRemoved(url, VSREMOVEFILEFLAGS.VSREMOVEFILEFLAGS_NoFlags); SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true); // Set it as non member item ItemNode = new ProjectElement(ProjectMgr, null, true); // now we have to set a new ItemNode to indicate that this is virtual node. ItemNode.Rename(url); ItemNode.SetMetadata(ProjectFileConstants.Name, url); //ProjectMgr.OnItemDeleted(); var proj = ProjectInfo.FindProject(ProjectMgr); if (proj != null) { proj.RemoveSource(this.Url); } ReDraw(UIHierarchyElement.Icon); // We have to redraw the icon of the node as it is now not a member of the project and should be drawn using a different icon. ReDraw(UIHierarchyElement.SccState); // update the SCC state icon. } else if (Parent != null) // the project node has no parentNode { // Remove from the Hierarchy OnItemDeleted(); Parent.RemoveChild(this); ItemNode.RemoveFromProjectFile(); } ResetProperties(); HierarchyHelpers.RefreshPropertyBrowser(this); return(VSConstants.S_OK); }