Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }