Пример #1
0
        /// <summary>
        /// Adds a new file node to the hierarchy from an existing one.
        /// NOTE:The file has already been copied.
        /// </summary>
        /// <param name="parentNode">The parent of the new fileNode</param>
        /// <param name="fileName">The file name</param>
        protected override void AddNewFileNodeToHierarchyFrom(HierarchyNode parentNode, string fileName, string aOriginalFile)
        {
            HierarchyNode lChild;

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if (this.CanFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                lChild = this.CreateDependentFileNode(fileName);
                lChild.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (string.Compare(lChild.GetRelationalName(), parentNode.GetRelationalName(), true, CultureInfo.InvariantCulture) == 0)
                {
                    lChild.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                lChild = this.CreateFileNode(fileName);
            }

            parentNode.AddChild(lChild);
            // TODO : We need to call DelphiDPRFileNode AddUnitFile once it exits.

            AddDelphiDirectiveFiles(lChild as DelphiFileNode, Path.GetDirectoryName(aOriginalFile));

            this.Tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }
        /// <summary>
        /// Adds the new file node to hierarchy.
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="fileName">Name of the file.</param>
        protected override void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string path)
        {
            // If a lua file is being added, try to find a related FrameXML node
            if (MultiverseInterfaceProjectNode.IsPythonFile(path))
            {
                // Try to find a FrameXML node with a matching relational name
                string        fileName  = Path.GetFileNameWithoutExtension(path);
                HierarchyNode childNode = this.FirstChild;

                // Iterate through the children
                while (childNode != null)
                {
                    // If this child is an XML node and its relational name matches, break out of the loop
                    if (childNode is MultiverseInterfaceXmlFileNode && String.Compare(childNode.GetRelationalName(), fileName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        parentNode = childNode;
                        break;
                    }

                    // Move over to the next sibling
                    childNode = childNode.NextSibling;
                }
            }

            HierarchyNode child;

            if (this.CanFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                child = this.CreateDependentFileNode(path);
                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (String.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(path);
            }

            parentNode.AddChild(child);

            this.Tracker.OnItemAdded(path, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }
Пример #3
0
        /// <summary>
        /// Add a dependent file node to the hierarchy
        /// </summary>
        /// <param name="item">msbuild item to add</param>
        /// <param name="parentNode">Parent Node</param>
        /// <returns>Added node</returns>
        private HierarchyNode AddDependentFileNodeToNode(MSBuild.ProjectItem item, HierarchyNode parentNode)
        {
            FileNode node = this.CreateDependentFileNode(new ProjectElement(this, item, false));
            parentNode.AddChild(node);

            // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
            if (!node.HasParentNodeNameRelation && string.Compare(node.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
            {
                node.HasParentNodeNameRelation = true;
            }

            return node;
        }
Пример #4
0
        /// <summary>
        /// Adds a new file node to the hierarchy.
        /// </summary>
        /// <param name="parentNode">The parent of the new fileNode</param>
        /// <param name="fileName">The file name</param>
        protected virtual void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string fileName)
        {
            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }

            HierarchyNode child;

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if (this.canFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                child = this.CreateDependentFileNode(fileName);
                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(fileName);
            }

            parentNode.AddChild(child);

            // TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project?
            this.tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }
Пример #5
0
        // KLiss: body of this method is copy/pasted from base one (and modified),
        // as base implementation does not allow changing parent node on-the-fly.
        protected override void AddNewFileNodeToHierarchy(HierarchyNode parentNode, string fileName)
        {
            HierarchyNode child;
            HierarchyNode newParent;

            // KLiss: try to find possible parent file (ie, Form3.n would be parent for Form3.designer.n
            bool parentFound = TryFindParentFileNode(parentNode, fileName, out newParent);
            if (parentFound)
            {
                parentNode = newParent;

                // KLiss: when file is added to project, it is treated as code file,
                // regardless of SubType value, specified in the template.
                // SubType is assigned correct value later, and now we will make another
                // attempt to find out, whether it is OK for an item to have designer, or not.
                var nemerleParent = parentNode as NemerleFileNode;
                if (nemerleParent != null)
                {
                    nemerleParent.InferHasDesignerFromSubType();
                }
            }

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if (parentFound || parentNode is FileNode || parentNode is DependentFileNode)
            {
                child = this.CreateDependentFileNode(fileName);

                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent node if it is related to the parent by name
                if (!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(), parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(fileName);
            }

            parentNode.AddChild(child);

            var projectInfo = ProjectInfo;

            if (projectInfo != null)
                projectInfo.Engine.RequestOnBuildTypesTree();

            //// TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project?
            //this.tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }
Пример #6
0
        // !EFW
        /// <summary>
        /// Adds a new linked file node to the hierarchy.
        /// </summary>
        /// <param name="parentNode">The parent of the new fileNode</param>
        /// <param name="linkedFileName">The linked filename</param>
        /// <param name="fileName">The file name in the project heirarchy</param>
        protected virtual void AddNewLinkedFileNodeToHierarchy(
          HierarchyNode parentNode, string linkedFileName, string fileName)
        {
            // NOTE: The general process should match that of
            // AddNewFileNodeToHierarchy with the exception of the filename
            // used and the addition of the Link metadata.
            HierarchyNode child;

            // In the case of subitem, we want to create dependent file node
            // and set the DependentUpon property
            if(this.canFileNodesHaveChilds && (parentNode is FileNode || parentNode is DependentFileNode))
            {
                child = this.CreateDependentFileNode(linkedFileName);
                child.ItemNode.SetMetadata(ProjectFileConstants.Link,
                    PackageUtilities.MakeRelative(base.ProjectMgr.FileName, fileName));
                child.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon,
                    parentNode.ItemNode.GetMetadata(ProjectFileConstants.Include));

                // Make sure to set the HasNameRelation flag on the dependent
                // node if it is related to the parent by name
                if(!child.HasParentNodeNameRelation && string.Compare(child.GetRelationalName(),
                  parentNode.GetRelationalName(), StringComparison.OrdinalIgnoreCase) == 0)
                {
                    child.HasParentNodeNameRelation = true;
                }
            }
            else
            {
                //Create and add new filenode to the project
                child = this.CreateFileNode(linkedFileName);
                child.ItemNode.SetMetadata(ProjectFileConstants.Link,
                    PackageUtilities.MakeRelative(base.ProjectMgr.FileName, fileName));
            }

            parentNode.AddChild(child);

            // TODO : Revisit the VSADDFILEFLAGS here. Can it be a nested project?
            this.tracker.OnItemAdded(fileName, VSADDFILEFLAGS.VSADDFILEFLAGS_NoFlags);
        }