Example #1
0
        int IProjectSourceNode.IncludeInProject(bool recursive)
        {
            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();

            // Check out the project file.
            if (!ProjectMgr.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            // make sure that all parent folders are included in the project
            HierarchyHelpers.EnsureParentFolderIncluded(this);

            // now add this node to the project.
            AddToMSBuild(recursive);
            ReDraw(UIHierarchyElement.Icon);

            HierarchyHelpers.RefreshPropertyBrowser(this);

            return(VSConstants.S_OK);
        }
Example #2
0
        protected override int ExecCommandOnNode(Guid guidCmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            Debug.Assert(ProjectMgr != null, "The NemerleFileNode has no project manager");

            if (ProjectMgr == null)
            {
                throw new InvalidOperationException();
            }

            int returnCode;

            if (HierarchyHelpers.ExecCommandOnProjectSourceNode(this, guidCmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut, out returnCode))
            {
                return(returnCode);
            }

            if (guidCmdGroup == MenuCmd.guidNemerleProjectCmdSet && cmd == (uint)MenuCmd.SetAsMain.ID)
            {
                // Set the MainFile project property to the Filename of this Node.
                //
                ProjectMgr.SetProjectProperty(NemerleProjectNodeProperties.MainFilePropertyName, GetRelativePath());

                return(VSConstants.S_OK);
            }

            return(base.ExecCommandOnNode(guidCmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut));
        }
Example #3
0
        protected override int ExecCommandOnNode(Guid cmdGroup, uint cmd, uint cmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            int returnCode;

            if (HierarchyHelpers.ExecCommandOnProjectSourceNode(this, cmdGroup, cmd, cmdexecopt, pvaIn, pvaOut, out returnCode))
            {
                return(returnCode);
            }

            return(base.ExecCommandOnNode(cmdGroup, cmd, cmdexecopt, pvaIn, pvaOut));
        }
Example #4
0
        protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result)
        {
            int returnCode;

            if (HierarchyHelpers.QueryStatusOnProjectSourceNode(this, cmdGroup, cmd, ref result, out returnCode))
            {
                return(returnCode);
            }

            return(base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result));
        }
Example #5
0
 internal static void RemoveNonMemberItems(HierarchyNode project)
 {
     IList<HierarchyNode> nodeList = new List<HierarchyNode>();
     HierarchyHelpers.FindNodes(nodeList, project, IsNodeNonMemberItem, null);
     for (int index = nodeList.Count - 1; index >= 0; index--)
     {
         HierarchyNode parent = nodeList[index].Parent;
         nodeList[index].OnItemDeleted();
         parent.RemoveChild(nodeList[index]);
     }
 }
Example #6
0
        int IProjectSourceNode.IncludeInProject()
        {
            NemerleProjectNode projectNode = ProjectMgr as NemerleProjectNode;

            if (projectNode == null || projectNode.IsClosed)
            {
                return((int)OleConstants.OLECMDERR_E_NOTSUPPORTED);
            }

            if (!IsNonMemberItem)
            {
                return(VSConstants.S_OK);
            }

            ((NemerlePackage)ProjectMgr.Package).SetWaitCursor();

            // Check out the project file.
            if (!projectNode.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            HierarchyHelpers.EnsureParentFolderIncluded(this);

            SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, false);

            ItemNode = projectNode.CreateMsBuildFileProjectElement(Url);
            ProjectMgr.Tracker.OnItemAdded(Url, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);

            var proj = ProjectInfo.FindProject(ProjectMgr);

            if (proj != null)
            {
                proj.AddSource(this.Url);
            }

            //projectNode.OnItemAdded(Parent, this);

            ReDraw(UIHierarchyElement.Icon);             // We have to redraw the icon of the node as it is now a member of the project and should be drawn using a different icon.
            ReDraw(UIHierarchyElement.SccState);         // update the SCC state icon.

            ResetProperties();

            HierarchyHelpers.RefreshPropertyBrowser(this);

            return(VSConstants.S_OK);
        }
Example #7
0
        /// <summary>
        /// Handles the menuitems
        /// </summary>
        protected override int QueryStatusOnNode(
            Guid guidCmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result)
        {
            int returnCode;

            if (HierarchyHelpers.QueryStatusOnProjectSourceNode(this, guidCmdGroup, cmd, ref result, out returnCode))
            {
                return(returnCode);
            }

            if (guidCmdGroup == VsMenus.guidStandardCommandSet97)
            {
                switch ((VsCommands)cmd)
                {
                case VsCommands.AddNewItem:
                case VsCommands.AddExistingItem:
                case VsCommands.ViewCode:
                    result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
                    return(VSConstants.S_OK);

                case VsCommands.ViewForm:
                    if (HasDesigner)
                    {
                        result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
                    }
                    return(VSConstants.S_OK);
                }
            }
            else if (guidCmdGroup == MenuCmd.guidNemerleProjectCmdSet)
            {
                if (cmd == (uint)MenuCmd.SetAsMain.ID)
                {
                    result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
                    return(VSConstants.S_OK);
                }
            }

            return(base.QueryStatusOnNode(guidCmdGroup, cmd, pCmdText, ref result));
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }