Esempio n. 1
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Build a XmlTree from a xml NAnt script file.
        /// </summary>
        /// <param name="filename">Xml fileName.</param>
        /// <param name="showInclude">Add include file in tree.</param>
        /// <returns>XmlTree for the script file.</returns>
        //////////////////////////////////////////////////////////////////////////

        internal static XmlTree CreateXmlTree(string filename, bool showInclude)
        {
            XmlTree nodeTree = null;

            try
            {
                // Parse the file
                XmlNode rootNode = ParseXmlFile(filename);

                // Create the tree from the root node
                if (rootNode != null)
                {
                    nodeTree = new XmlTree(rootNode);

                    // Insert include script in the three
                    if (showInclude)
                    {
                        // Folder of the script to resolve include
                        string folder = Path.GetDirectoryName(filename);
                        ParseIncludeFiles(folder, nodeTree);
                    }
                }
            }
            catch
            {
                // The exception has to be catched by the caller
                throw;
            }

            return(nodeTree);
        }
Esempio n. 2
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Build the NAnt Addin tree view from an NAntTree.
        /// </summary>
        /// <param name="treeView">The NAnt Addin tree.</param>
        /// <param name="nantTree">The NAntTree.</param>
        /// <param name="title">The title to display.</param>
        //////////////////////////////////////////////////////////////////////////

        public static void CreateTree(TreeView treeView, XmlTree nantTree, string title)
        {
            if (nantTree == null)
            {
                return;
            }

            // Initialize the treeview and its root node
            treeView.Nodes.Clear();

            // Create root node
            TreeNode rootNode = new TreeNode(title);

            rootNode.Tag = nantTree.Root;
            treeView.Nodes.Add(rootNode);


            // Build properties
            if (nantTree.Properties != null)
            {
                TreeNode treeNode = TreeViewFactory.CreateTreeNode(nantTree.Properties, "Properties");
                rootNode.Nodes.Add(treeNode);
            }

            // Build targets in two groups
            if (Properties.Settings.Default.NANT_SPLIT_TARGETS)
            {
                // Build public targets
                if (nantTree.PublicTargets != null)
                {
                    TreeNode publicNodes = TreeViewFactory.CreateTreeNode(nantTree.PublicTargets, "Public targets");
                    rootNode.Nodes.Add(publicNodes);
                    publicNodes.Expand();
                }

                // Build private targets
                if (nantTree.PrivateTargets != null)
                {
                    TreeNode privateNodes = TreeViewFactory.CreateTreeNode(nantTree.PrivateTargets, "Private targets");
                    rootNode.Nodes.Add(privateNodes);
                }
            }
            // Build target all together
            else
            {
                // Build all targets
                if (nantTree.AllTargets != null)
                {
                    TreeNode allNodes = TreeViewFactory.CreateTreeNode(nantTree.AllTargets, "Targets");
                    rootNode.Nodes.Add(allNodes);
                    allNodes.Expand();
                }
            }

            // Build icon
            TreeViewFactory.CreateIcons(treeView);

            // Finally expand the root node
            rootNode.Expand();
        }
Esempio n. 3
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Build the NAnt Addin tree view from an NAntTree.
        /// </summary>
        /// <param name="treeView">The NAnt Addin tree.</param>
        /// <param name="nantTree">The NAntTree.</param>
        /// <param name="title">The title to display.</param>
        //////////////////////////////////////////////////////////////////////////
        public static void CreateTree(TreeView treeView, XmlTree nantTree, string title)
        {
            if (nantTree == null)
                return;

            // Initialize the treeview and its root node
            treeView.Nodes.Clear();

            // Create root node
            TreeNode rootNode = new TreeNode(title);
            rootNode.Tag = nantTree.Root;
            treeView.Nodes.Add(rootNode);

            // Build properties
            if (nantTree.Properties != null)
            {
                TreeNode treeNode = TreeViewFactory.CreateTreeNode(nantTree.Properties, "Properties");
                rootNode.Nodes.Add(treeNode);
            }

            // Build targets in two groups
            if (Properties.Settings.Default.NANT_SPLIT_TARGETS)
            {
                // Build public targets
                if (nantTree.PublicTargets != null)
                {
                    TreeNode publicNodes = TreeViewFactory.CreateTreeNode(nantTree.PublicTargets, "Public targets");
                    rootNode.Nodes.Add(publicNodes);
                    publicNodes.Expand();
                }

                // Build private targets
                if (nantTree.PrivateTargets != null)
                {
                    TreeNode privateNodes = TreeViewFactory.CreateTreeNode(nantTree.PrivateTargets, "Private targets");
                    rootNode.Nodes.Add(privateNodes);
                }
            }
            // Build target all together
            else
            {
                // Build all targets
                if (nantTree.AllTargets != null)
                {
                    TreeNode allNodes = TreeViewFactory.CreateTreeNode(nantTree.AllTargets, "Targets");
                    rootNode.Nodes.Add(allNodes);
                    allNodes.Expand();
                }
            }

            // Build icon
            TreeViewFactory.CreateIcons(treeView);

            // Finally expand the root node
            rootNode.Expand();
        }
Esempio n. 4
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Load NAnt script file in the controller.
        /// </summary>
        //////////////////////////////////////////////////////////////////////////

        public void LoadFile(string filename)
        {
            if (m_Filename != null)
            {
                m_NantTree = XmlTreeFactory.CreateXmlTree(filename, false);
            }
            else
            {
                m_NantTree = null;
            }
        }
Esempio n. 5
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Insert script tree from include file in a XmlTree.
        /// </summary>
        /// <param name="folder">Folder base of the includer file.</param>
        /// <param name="tree">XmlTree to be updated.</param>
        //////////////////////////////////////////////////////////////////////////

        private static void ParseIncludeFiles(string folder, XmlTree tree)
        {
            foreach (XmlNode include in tree.Includes)
            {
                // Path of included file
                string includedPath = "";

                try
                {
                    // Try to combine the folder base and include path
                    includedPath = Path.Combine(folder, include[AppConstants.NANT_XML_BUILDFILE]);
                }
                catch
                {
                }

                // Build tree from file
                XmlTree subTree = XmlTreeFactory.CreateXmlTree(includedPath.ToString(), true);

                // Add to the main tree
                tree.Root.Add(subTree.Root.Children);
            }
        }
Esempio n. 6
0
 //////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Load NAnt script file in the controller.
 /// </summary>
 //////////////////////////////////////////////////////////////////////////
 public void LoadFile(string filename)
 {
     if (m_Filename != null)
     {
         m_NantTree = XmlTreeFactory.CreateXmlTree(filename, false);
     }
     else
     {
         m_NantTree = null;
     }
 }
Esempio n. 7
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Insert script tree from include file in a XmlTree.
        /// </summary>
        /// <param name="folder">Folder base of the includer file.</param>
        /// <param name="tree">XmlTree to be updated.</param>
        //////////////////////////////////////////////////////////////////////////
        private static void ParseIncludeFiles(string folder, XmlTree tree)
        {
            foreach (XmlNode include in tree.Includes)
            {
                // Path of included file
                string includedPath = "";

                try
                {
                    // Try to combine the folder base and include path
                    includedPath = Path.Combine(folder, include[AppConstants.NANT_XML_BUILDFILE]);
                }
                catch
                {
                }

                // Build tree from file
                XmlTree subTree = XmlTreeFactory.CreateXmlTree(includedPath.ToString(), true);

                // Add to the main tree
                tree.Root.Add(subTree.Root.Children);
            }
        }
Esempio n. 8
0
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Build a XmlTree from a xml NAnt script file.
        /// </summary>
        /// <param name="filename">Xml fileName.</param>
        /// <param name="showInclude">Add include file in tree.</param>
        /// <returns>XmlTree for the script file.</returns>
        //////////////////////////////////////////////////////////////////////////
        internal static XmlTree CreateXmlTree(string filename, bool showInclude)
        {
            XmlTree nodeTree = null;

            try
            {
                // Parse the file
                XmlNode rootNode = ParseXmlFile(filename);

                // Create the tree from the root node
                if (rootNode != null)
                {
                    nodeTree = new XmlTree(rootNode);

                    // Insert include script in the three
                    if (showInclude)
                    {
                        // Folder of the script to resolve include
                        string folder = Path.GetDirectoryName(filename);
                        ParseIncludeFiles(folder, nodeTree);
                    }
                }
            }
            catch
            {
                // The exception has to be catched by the caller
                throw;
            }

            return nodeTree;
        }