private void RefreshHirearchy()
        {
            if (schemaTabView.Selected.Identifier.ToString() == "Hierarchy")
            {
                if (objectClassesList.SelectedRows.Count > 0)
                {
                    HierarchyItemDatasource ds = new HierarchyItemDatasource(_currentObject);

                    var           mgr      = _serverDTO.Connection.SchemaManager;
                    var           dto      = mgr.GetObjectClass(_currentObject);
                    HierarchyItem rootItem = new HierarchyItem(_currentObject);
                    HierarchyItem prevItem = rootItem;
                    while (dto != null)
                    {
                        dto = mgr.GetObjectClass(dto.SuperClass);
                        if (dto != null)
                        {
                            HierarchyItem currItem = new HierarchyItem(dto.Name);
                            prevItem.Children.Add(currItem);
                            prevItem = currItem;
                        }
                        ds.Item = rootItem;
                    }
                    this.HierarchyOutlineView.DataSource = ds;
                    this.HierarchyOutlineView.ReloadData();
                }
            }
        }
Пример #2
0
        private void PromptAndDelete(HierarchyItem item, IVsHierarchyDeleteHandler deleteHandler, __VSDELETEITEMOPERATION deleteType, string message)
        {
            Guid unused = Guid.Empty;

            // show delete dialog...
            if (ErrorHandler.Succeeded(
                    _mockVs.UIShell.ShowMessageBox(
                        0,
                        ref unused,
                        null,
                        message,
                        null,
                        0,
                        OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL,
                        OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                        OLEMSGICON.OLEMSGICON_WARNING,
                        0,
                        out global::System.Int32 result
                        )) && result == DialogResult.OK)
            {
                int hr = deleteHandler.DeleteItem(
                    (uint)deleteType,
                    item.ItemId
                    );

                if (ErrorHandler.Failed(hr) && hr != VSConstants.OLE_E_PROMPTSAVECANCELLED)
                {
                    _mockVs.UIShell.ReportErrorInfo(hr);
                }
            }
        }
Пример #3
0
        private bool ShouldShowSpecificMessage(HierarchyItem item, int canRemoveItem, int canDeleteItem)
        {
            __VSDELETEITEMOPERATION op = 0;

            if (canRemoveItem != 0)
            {
                op |= __VSDELETEITEMOPERATION.DELITEMOP_RemoveFromProject;
            }
            if (canDeleteItem != 0)
            {
                op |= __VSDELETEITEMOPERATION.DELITEMOP_DeleteFromStorage;
            }

            IVsHierarchyDeleteHandler2 deleteHandler = item.Hierarchy as IVsHierarchyDeleteHandler2;

            if (deleteHandler != null)
            {
                deleteHandler.ShowSpecificDeleteRemoveMessage(
                    (uint)op,
                    1,
                    new[] { item.ItemId },
                    out global::System.Int32 dwShowStandardMessage,
                    out global::System.UInt32 pdwDelItemOp
                    );
                return(dwShowStandardMessage != 0);
            }
            return(false);
        }
        private void PopulateTree(TestSuiteCollection suites)
        {
            fixingChecks = true;

            // Preserve the original selection so that we can reselect them.
            Dictionary <string, bool> selectedTests = SelectedTestCases;

            // clear the current contents
            testsTreeView.Nodes.Clear();

            TreeNode      solutionNode = new TreeNode();
            HierarchyItem solHier      = new HierarchyItem(suites.Solution as IVsHierarchy);

            // Don't do anything if the solution is empty.
            if (solHier.Name == null)
            {
                return;
            }

            solutionNode.Text     = "Solution '" + solHier.Name + "'";
            solutionNode.ImageKey = solutionNode.SelectedImageKey = "Solution";
            testsTreeView.Nodes.Add(solutionNode);

            foreach (TestSuite suite in suites.Suites)
            {
                AddTestSuiteToNode(suite, solutionNode, selectedTests);
            }

            fixingChecks = false;

            testsTreeView.Sort();

            solutionNode.ExpandAll();
        }
Пример #5
0
        protected override TreeViewItem BuildRoot()
        {
            // TODO:Remove
            m_CachedSceneItems.Clear();
            using (var searching = new SearchingScope(IsSearching, m_HierarchySearchFilter))
            {
                var root = new HierarchyItem {
                    id = int.MaxValue, depth = -1, displayName = "Root"
                };
                for (var i = 0; i < m_SceneManager.LoadedSceneCount; ++i)
                {
                    var scene = m_SceneManager.GetLoadedSceneAtIndex(i);
                    if (m_CachedSceneItems.TryGetValue(scene.SceneGuid, out var item))
                    {
                        root.AddChild(item);
                    }
                    else
                    {
                        root.AddChild(LoadScene(scene, searching));
                    }
                }

                if (m_SceneManager.LoadedSceneCount == 0)
                {
                    root.AddChild(new TreeViewItem(0, 0, "No scene loaded"));
                }

                ShouldReload = false;
                return(root);
            }
        }
        public HierarchyCollection<Heading> GetHeadingHierarchy(string html)
        {
            var hierarchy = new HierarchyCollection<Heading>();
            var headingsStack = new Stack<HierarchyItem<Heading>>();

            foreach (var heading in GetHeadings(html))
            {
                var hiearchyItem = new HierarchyItem<Heading>(heading);

                var addedItem = false;
                while (headingsStack.Count > 0)
                {
                    // Keep looking up the heading hierarchy until we find the
                    // first item that is a higher heading type than the current
                    // heading
                    var parentHeading = headingsStack.Peek();
                    if (parentHeading.Item.HeadingType < heading.HeadingType)
                    {
                        headingsStack.Push(hiearchyItem);
                        parentHeading.Children.Add(hiearchyItem);
                        addedItem = true;
                        break;
                    }
                    headingsStack.Pop();
                }

                if (!addedItem)
                {
                    headingsStack.Push(hiearchyItem);
                    hierarchy.Add(hiearchyItem);
                }
            }

            return hierarchy;
        }
Пример #7
0
 //  -------------------------------------------------------------------
 /// <summary>
 /// Creates a new submittable physical item.
 /// </summary>
 /// <param name="rootPath">
 /// The root path of the solution that contains this item.
 /// </param>
 /// <param name="project">
 /// The project that contains this item.
 /// </param>
 /// <param name="hierItem">
 /// The hierarchy item that this item represents.
 /// </param>
 public SubmittablePhysicalItem(string rootPath, IVsProject project,
                                HierarchyItem hierItem)
 {
     this.rootPath  = rootPath;
     this.project   = project;
     this.hierarchy = hierItem;
 }
Пример #8
0
        private void DropUponSceneItem(HierarchyItem parent, List <ISceneGraphNode> nodes)
        {
            SceneGuid guid;

            switch (parent)
            {
            case EntityItem entityItem:
            {
                guid = m_EntityManager.GetSharedComponentData <SceneGuid>(entityItem.Entity);
                break;
            }

            case SceneItem sceneItem:
            {
                guid = sceneItem.Scene.SceneGuid;
                break;
            }
            }

            var graph = m_SceneManager.GetGraphForScene(guid);

            Assert.IsNotNull(graph);

            foreach (var node in nodes)
            {
                graph.Add(node);
            }
            SetSelectionAndExpandedState(nodes);
        }
Пример #9
0
 public override void OnFocus()
 {
     GameObject[] parentObjects;
     if (sceneOpen)
     {
         parentObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
     }
     else // Prefabs
     {
         var prefabs = ES3ReferenceMgr.Current.prefabs;
         parentObjects = new GameObject[prefabs.Count];
         for (int i = 0; i < prefabs.Count; i++)
         {
             if (prefabs[i] != null)
             {
                 parentObjects[i] = prefabs[i].gameObject;
             }
         }
     }
     hierarchy = new HierarchyItem[parentObjects.Length];
     for (int i = 0; i < parentObjects.Length; i++)
     {
         if (parentObjects[i] != null)
         {
             hierarchy[i] = new HierarchyItem(parentObjects[i].transform, null, this);
         }
     }
 }
        // ------------------------------------------------------
        /// <summary>
        /// Adds a tree node for the specified hierarchy item to a tree node
        /// collection.
        /// </summary>
        /// <param name="item">
        /// A hierarchy item.
        /// </param>
        /// <param name="coll">
        /// The <code>TreeNodeCollection</code> to add the new node to.
        /// </param>
        private void AddNode(HierarchyItem item,
                             TreeNodeCollection coll)
        {
            // Skip the item if it is not one of the visible types.

            Guid typeGuid = item.TypeGuid;

            if (visibleTypeGuids != null &&
                Array.IndexOf(visibleTypeGuids, typeGuid) == -1)
            {
                return;
            }

            // Add the item's icon to the end of the image list.

            imageList.Images.Add(item.Icon);
            int imageIndex = imageList.Images.Count - 1;

            TreeNode node = new TreeNode();

            node.Text       = item.Caption;
            node.ImageIndex = node.SelectedImageIndex = imageIndex;
            node.Tag        = item;

            coll.Add(node);

            // Recurse through the item's children.

            foreach (HierarchyItem child in item.Children)
            {
                AddNode(child, node.Nodes);
            }

            node.Expand();
        }
Пример #11
0
        private static HierarchyItem buildHierarchy(IEnumerable <Item> elements)
        {
            RootHierarchyItem root = new RootHierarchyItem();
            Dictionary <string, HierarchyItem> map = new Dictionary <string, HierarchyItem>();

            foreach (Item itm in elements)
            {
                HierarchyItem e = new HierarchyItem(itm);
                try
                {
                    map.Add(itm.OtherData["DbKey"], e);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            foreach (HierarchyItem i in map.Values)
            {
                if (i.AssociatedItem.OtherData["ParentDbKey"] != null && map.ContainsKey(i.AssociatedItem.OtherData["ParentDbKey"]))
                {
                    map[i.AssociatedItem.OtherData["ParentDbKey"]].AddChild(i);
                }
                else
                {
                    if (i.HasParent())
                    {
                    }
                    root.AddChild(i);
                }
            }
            return(root);
        }
Пример #12
0
        //~ Methods ..........................................................

        // ------------------------------------------------------
        /// <summary>
        /// Called when the Finish button is clicked in the wizard.
        /// </summary>
        /// <param name="e">
        /// An <code>EventArgs</code> object.
        /// </param>
        protected override void OnFinish(EventArgs e)
        {
            base.OnFinish(e);

            HierarchyItem projectItem     = page1.SelectedProject;
            string        suiteName       = page1.SuiteName;
            HierarchyItem headerUnderTest = page1.HeaderUnderTest;
            string        superclass      = page1.Superclass;
            bool          createSetUp     = page1.CreateSetUp;
            bool          createTearDown  = page1.CreateTearDown;

            VCCodeFunction[] functions = page2.SelectedFunctions;

            // Invoke the test suite generator to create the file and add it
            // to the project.

            TestSuiteGenerator generator = new TestSuiteGenerator(
                projectItem, suiteName, headerUnderTest, superclass,
                createSetUp, createTearDown, functions);

            generator.Generate();

            // Open the new test suite in the IDE.

            HierarchyItem suiteFile = generator.GeneratedSuiteFile;

            IVsProject     vsproj   = projectItem.Hierarchy as IVsProject;
            Guid           guidNull = Guid.Empty;
            IVsWindowFrame windowFrame;

            vsproj.OpenItem(suiteFile.ItemID, ref guidNull, IntPtr.Zero, out windowFrame);
        }
Пример #13
0
    private void AddChildItem(HierarchyItem item, bool isIncludeDelete)
    {
        if (isIncludeDelete)
        {
            foreach (HierarchyItem tvi in item.GetAllChildItem(true))
            {
                allDethChildItem.Add(tvi);

                if (tvi.GetChildrenCount() > 0)
                {
                    AddChildItem(tvi, true);
                }
            }
        }
        else
        {
            foreach (HierarchyItem tvi in item.GetAllChildItem(false))
            {
                allDethChildItem.Add(tvi);

                if (tvi.GetChildrenCount() > 0)
                {
                    AddChildItem(tvi, false);
                }
            }
        }
    }
Пример #14
0
        public string Dump(HierarchyItem <Account> account)
        {
            var shiftedName   = new string(' ', account.Level * 2) + account.Item.Name;
            var parentForDump = account.Item.Parent?.Id ?? 0;

            return(account.Item.Id + " ; " + shiftedName + " ; " + parentForDump + " ; " +
                   account.Item.IsFolder + " ; " + account.Item.IsClosed + " ; " + account.Item.IsExpanded);
        }
        private HierarchyItem CreateNode(XElement element, HierarchyData data)
        {
            HierarchyItem item;


            item = new HierarchyItem(data);

            item.Icons[(VSConstants.VSITEMID.Root, __VSHIERARCHYIMAGEASPECT.HIA_OpenFolderIcon)] = GetImageMoniker(element, "expanded");
Пример #16
0
 /// <summary>
 /// 移除资源树子物体
 /// </summary>
 public void RemoveChildren(HierarchyItem children)
 {
     if (_treeChildren == null)
     {
         return;
     }
     _treeChildren.Remove(children);
 }
 public static void Export(string path, HierarchyItem<Point3D> points)
 {
     Type tp;
     if (exporters.TryGetValue(Path.GetExtension(path).ToLowerInvariant(), out tp))
     {
         ((IHierarchyItemExporter<Point3D>)Activator.CreateInstance(tp)).Export(path, points);
     }
 }
Пример #18
0
        private void DropUponEntityItem(HierarchyItem parent, List <ISceneGraphNode> nodes)
        {
            var item       = parent as EntityItem;
            var parentNode = item.Node;
            var graph      = m_SceneManager.GetGraphForScene(m_EntityManager.GetSharedComponentData <SceneGuid>(item.Entity));

            graph.Insert(-1, nodes, parentNode);
            SetSelectionAndExpandedState(nodes);
        }
Пример #19
0
    /// <summary>
    ///  给资源树添加子物体
    /// </summary>
    public void AddChildren(HierarchyItem children)
    {
        if (_treeChildren == null)
        {
            _treeChildren = new List <HierarchyItem>();
        }

        _treeChildren.Add(children);
    }
        public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
        {
            string name   = new HierarchyItem(pHierarchy).CanonicalName;
            uint   cookie = hierarchyCookies[name];

            pHierarchy.UnadviseHierarchyEvents(cookie);

            return(VSConstants.S_OK);
        }
Пример #21
0
    public void SetParent(HierarchyItem parent)
    {
        this.parent = parent;
        var textPosition = parent.text.transform.localPosition;
        var x            = textPosition.x + Constants.HIERARCHY_ITEM_SPACE_LEVEL;
        var pos          = text.transform.localPosition;

        text.transform.localPosition = new Vector3(x, pos.y, pos.z);
        parent.arrowImage.enabled    = true;
    }
Пример #22
0
 /// <summary>
 ///  给资源树插入子物体
 /// </summary>
 public void InsertChildren(HierarchyItem indexOfItem, HierarchyItem insertItem)
 {
     if (_treeChildren == null)
     {
         _treeChildren = new List <HierarchyItem>();
         _treeChildren.Add(insertItem);
         return;
     }
     _treeChildren.Insert(_treeChildren.IndexOf(indexOfItem), insertItem);
 }
Пример #23
0
        private void ShowHierarchy(DataBand dataBand, int rowCount)
        {
            HierarchyItem rootItem = MakeHierarchy(dataBand, rowCount);

            if (rootItem == null)
            {
                return;
            }

            ShowHierarchy(dataBand, rootItem, 1, "");
        }
        internal void PopulateWithHeader(HierarchyItem headerUnderTest)
        {
            functionsTree.Nodes.Clear();

            ProjectItem projectItem = headerUnderTest.GetExtObjectAs<ProjectItem>();
            VCFileCodeModel codeModel = projectItem.FileCodeModel as VCFileCodeModel;

            PopulateRecursively(functionsTree.Nodes, codeModel.CodeElements);

            functionsTree.ExpandAll();
        }
Пример #25
0
        internal void PopulateWithHeader(HierarchyItem headerUnderTest)
        {
            functionsTree.Nodes.Clear();

            ProjectItem     projectItem = headerUnderTest.GetExtObjectAs <ProjectItem>();
            VCFileCodeModel codeModel   = projectItem.FileCodeModel as VCFileCodeModel;

            PopulateRecursively(functionsTree.Nodes, codeModel.CodeElements);

            functionsTree.ExpandAll();
        }
        // ------------------------------------------------------
        /// <summary>
        /// Gets the path to the executable file generated by the active
        /// configuration of the specified project.
        /// </summary>
        /// <param name="projectHier">
        /// The project to get the executable file for.
        /// </param>
        /// <returns>
        /// The full path to the executable generated by the active
        /// configuration for this project.
        /// </returns>
        private string GetActiveExecutablePath(HierarchyItem projectHier)
        {
            Project       project      = projectHier.GetExtObjectAs <Project>();
            Configuration activeConfig =
                project.ConfigurationManager.ActiveConfiguration;

            string outputPath =
                activeConfig.Properties.Item("OutputPath").Value as string;
            string outputName = ((object[])activeConfig.OutputGroups.Item(
                                     "Built").FileNames)[0] as string;

            return(Path.Combine(outputPath, outputName));
        }
Пример #27
0
        private void DropBetweenSceneItems(HierarchyItem parent, List <ISceneGraphNode> nodes, int insertAtIndex)
        {
            // Can't add entities before the first group.
            if (insertAtIndex <= 0)
            {
                return;
            }

            var graph = m_SceneManager.GetGraphForScene((parent.children[insertAtIndex - 1] as SceneItem).Scene.SceneGuid);

            graph.Add(nodes);
            SetSelectionAndExpandedState(nodes);
        }
Пример #28
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     if (draggedInstance.IsNotNull())
     {
         Destroy(draggedInstance.gameObject);
     }
     if (!draggable)
     {
         return;
     }
     draggedInstance = Instantiate <HierarchyItem>(this, eventData.position, Quaternion.identity, canvas.transform);
     draggedInstance.rectTransform.pivot = new Vector2(0f, 1f);
     dragging = true;
 }
        // ------------------------------------------------------
        /// <summary>
        /// Creates the test runner source file for the current startup
        /// project and adds it to the project.
        /// </summary>
        /// <param name="doNotRunTests">
        /// If true, the file will be generated but will not include any
        /// statements to run any tests. If false, the tests will be run
        /// based on the current selection in the CxxTest Suites view.
        /// </param>
        public void CreateTestRunnerFile(bool doNotRunTests)
        {
            TestSuiteCollection suites = AllTestSuites;

            Dictionary <string, bool> testsToRun;

            if (doNotRunTests)
            {
                testsToRun = null;
            }
            else
            {
                testsToRun = TryToGetTestsToRun();
            }

            HierarchyItem startupProject =
                VsShellUtils.GetStartupProject(this);

            string projectDir = startupProject.ProjectDirectory;
            string workingDir = GetActiveWorkingDirectory(startupProject);

            Project project = startupProject.GetExtObjectAs <Project>();

            string runnerPath = Path.Combine(
                projectDir, Constants.TestRunnerFilename);

            // Remove the file from the project if necessary, and delete it
            // from the file system if it exists.
            VCProject vcproj = (VCProject)project.Object;

            if (!vcproj.CanAddFile(runnerPath))
            {
                IVCCollection coll = (IVCCollection)vcproj.Files;
                vcproj.RemoveFile(coll.Item(Constants.TestRunnerFilename));
            }

            if (File.Exists(runnerPath))
            {
                File.Delete(runnerPath);
            }

            TestRunnerGenerator generator =
                new TestRunnerGenerator(runnerPath, suites, testsToRun);

            generator.Generate();

            // Add the file to the project.

            vcproj.AddFile(runnerPath);
        }
Пример #30
0
            //private AutoSaveWindow window;

            public HierarchyItem(Transform t, HierarchyItem parent, AutoSaveWindow window)
            {
                this.autoSave   = t.GetComponent <ES3AutoSave>();
                this.t          = t;
                this.components = t.GetComponents <Component>();

                children = new HierarchyItem[t.childCount];
                for (int i = 0; i < t.childCount; i++)
                {
                    children[i] = new HierarchyItem(t.GetChild(i), this, window);
                }

                //this.window = window;
            }
Пример #31
0
    /// <summary>
    /// change the visual of the editor config for this object
    /// </summary>
    /// <param name="selectedObject"></param>
    /// <param name="iconType"></param>
    /// <param name="_IsIconRecursive"></param>
    /// <param name="coreBackground"></param>
    /// <param name="_IsBackgroundRecursive"></param>
    public static void AddCustomEditorToObject(GameObject selectedObject, bool create = true,
                                               HierarchyIcon iconType = HierarchyIcon.None,
                                               bool _IsIconRecursive  = false,
                                               Borodar.RainbowCore.CoreBackground coreBackground = Borodar.RainbowCore.CoreBackground.None,
                                               bool _IsBackgroundRecursive = false)
    {
        GameObject           hierarchy            = GameObject.Find("RainbowHierarchyConf");
        HierarchySceneConfig hierarchySceneConfig = hierarchy.GetComponent <HierarchySceneConfig>();

        if (hierarchySceneConfig)
        {
            HierarchyItem newItem = hierarchySceneConfig.GetItem(selectedObject);
            if (newItem == null)
            {
                if (!create)
                {
                    return;
                }

                newItem = new HierarchyItem(HierarchyItem.KeyType.Object, selectedObject, selectedObject.name)
                {
                    IconType              = HierarchyIcon.None,
                    IsIconRecursive       = false,
                    BackgroundType        = Borodar.RainbowCore.CoreBackground.ClrIndigo,
                    IsBackgroundRecursive = false,
                };
                hierarchySceneConfig.AddItem(newItem);
            }
            else
            {
                if (!create)
                {
                    hierarchySceneConfig.RemoveAll(selectedObject, HierarchyItem.KeyType.Object);
                }
                else
                {
                    hierarchySceneConfig.RemoveAll(selectedObject, HierarchyItem.KeyType.Object);
                    newItem = new HierarchyItem(HierarchyItem.KeyType.Object, selectedObject, selectedObject.name)
                    {
                        IconType              = HierarchyIcon.None,
                        IsIconRecursive       = false,
                        BackgroundType        = Borodar.RainbowCore.CoreBackground.ClrIndigo,
                        IsBackgroundRecursive = false,
                    };
                    hierarchySceneConfig.AddItem(newItem);
                }
            }
        }
    }
        public TestSuiteGenerator(HierarchyItem project,
			string suiteName, HierarchyItem headerUnderTest,
			string superclass, bool createSetUp, bool createTearDown,
			VCCodeFunction[] functions)
        {
            this.project = project;
            this.suiteName = suiteName;
            this.headerUnderTest = headerUnderTest;
            this.superclass = superclass;
            this.createSetUp = createSetUp;
            this.createTearDown = createTearDown;
            this.functions = functions;

            GenerateUniqueStubNames();
        }
Пример #33
0
        public TestSuiteGenerator(HierarchyItem project,
                                  string suiteName, HierarchyItem headerUnderTest,
                                  string superclass, bool createSetUp, bool createTearDown,
                                  VCCodeFunction[] functions)
        {
            this.project         = project;
            this.suiteName       = suiteName;
            this.headerUnderTest = headerUnderTest;
            this.superclass      = superclass;
            this.createSetUp     = createSetUp;
            this.createTearDown  = createTearDown;
            this.functions       = functions;

            GenerateUniqueStubNames();
        }
Пример #34
0
        private void headerUnderTestBrowseButton_Click(object sender, EventArgs e)
        {
            HierarchyItemDialog dialog = new HierarchyItemDialog(serviceProvider);

            dialog.Message             = "Choose a header file in your project to generate a test suite from.";
            dialog.SelectableTypeGuids = new Guid[] { VSConstants.GUID_ItemType_PhysicalFile };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                HierarchyItem item = dialog.SelectedItem;
                this.headerUnderTest = item;

                headerUnderTestField.Text = item.ProjectRelativePath;
            }
        }
        public int OnAfterOpenProject(IVsHierarchy pHierarchy, int fAdded)
        {
            HierarchyEventsHandler events = new HierarchyEventsHandler(
                solution, pHierarchy);

            uint cookie;
            pHierarchy.AdviseHierarchyEvents(events, out cookie);

            string name = new HierarchyItem(pHierarchy).CanonicalName;
            hierarchyCookies[name] = cookie;

            if(fAdded != 0)
                CxxTestPackage.Instance.TryToRefreshTestSuitesView();

            return VSConstants.S_OK;
        }
        public virtual void BuildTableOfContentsItem(StringBuilder builder, HierarchyItem<Heading> heading)
        {
            if (builder == null)
                throw new ArgumentNullException("builder");
            if (heading == null)
                throw new ArgumentNullException("heading");

            StartHierarchyItem(builder);
            builder.Append("<a href=\"#");
            builder.Append(heading.Item.AnchorName);
            builder.Append("\">");
            builder.Append(heading.Item.Title);
            builder.Append("</a>");
            BuildTableOfContentsLayer(builder, heading.Children);
            EndHierarchyItem(builder);
        }
Пример #37
0
        public VsProjectViewFolder(ISparkSource source, IVsHierarchy hierarchy)
        {
            _source = source;
            _hierarchy = hierarchy;

            _root = new HierarchyItem(_hierarchy, 0xfffffffe);
            var child = _root.FirstChild;
            while (child != null)
            {
                if (string.Equals(child.Name, "Views", StringComparison.InvariantCultureIgnoreCase))
                {
                    _views = child;
                    break;
                }
                child = child.NextSibling;
            }
        }
        //~ Constructor ......................................................
        // ------------------------------------------------------
        /// <summary>
        /// Creates a new CxxTest suite generating wizard.
        /// </summary>
        /// <param name="sp">
        /// The service provider to use to access Visual Studio services.
        /// </param>
        /// <param name="headerUnderTest">
        /// The hierarchy item representing the header that the test suite
        /// should be generated from.
        /// </param>
        public NewCxxTestSuiteWizard(IServiceProvider sp,
			HierarchyItem headerUnderTest)
        {
            serviceProvider = sp;

            // Create the wizard pages and add them to the wizard.

            page1 = new NewCxxTestSuiteWizardPage1(sp, headerUnderTest);
            page2 = new NewCxxTestSuiteWizardPage2(sp);

            AddPage(page1);
            AddPage(page2);

            this.BannerTitle = "New CxxTest Suite";
            this.BannerMessage = "Select the name of the new CxxTest suite. " +
                "You have the options to specify the header of the class " +
                "under test and on the next page, the methods to be tested.";
        }
        internal NewCxxTestSuiteWizardPage1(IServiceProvider sp, HierarchyItem headerUnderTest)
        {
            InitializeComponent();

            serviceProvider = sp;
            this.headerUnderTest = headerUnderTest;

            // Initialize the project list.

            foreach (HierarchyItem item in VsShellUtils.GetLoadedProjects(serviceProvider))
            {
                existingProjectsCombo.Items.Add(new ProjectItem(item));
            }

            if (headerUnderTest != null)
            {
                string header = headerUnderTest.ProjectRelativePath;
                headerUnderTestField.Text = header;

                nameField.Text = Path.GetFileNameWithoutExtension(header) + "Tests";

                bool madeSelection = false;

                foreach (ProjectItem item in existingProjectsCombo.Items)
                {
                    if (item.Item.Equals(headerUnderTest.ContainingProject))
                    {
                        existingProjectsCombo.SelectedItem = item;
                        madeSelection = true;
                        break;
                    }
                }

                if (!madeSelection)
                {
                    existingProjectsCombo.SelectedIndex = 0;
                }
            }

            superclassField.Text = "CxxTest::TestSuite";
        }
        public void RefreshFromLastRun()
        {
            containingProject = CxxTestPackage.Instance.LastRunProject;
            suiteResults = CxxTestPackage.Instance.SuiteResultsOfLastRun;
            derefereeResults = CxxTestPackage.Instance.DerefereeResultsOfLastRun;

            if(hierarchyButton.Checked)
                SwitchToHierarchyView();
            else
                hierarchyButton.Checked = true;

            int total, failures, errors;
            CountTestCases(out total, out failures, out errors);

            testResultsProgress.Minimum = 0;
            testResultsProgress.Maximum = total;
            testResultsProgress.Value = total - failures - errors;
            testResultsProgress.Mode = PassFailBarMode.Bar;

            runsLabel.Text = string.Format("Runs: {0}", total);
            errorsLabel.Text = string.Format("Errors: {0}", errors);
            failuresLabel.Text = string.Format("Failures: {0}", failures);
        }
        // ------------------------------------------------------
        /// <summary>
        /// Called just before the form is closed.
        /// </summary>
        /// <param name="e">
        /// A <code>CancelEventArgs</code> object.
        /// </param>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            // Keep track of the user's selection if they verified it by
            // pressing OK.

            if (DialogResult == DialogResult.OK)
            {
                selectedItem =
                    (HierarchyItem)hierarchyItemTree.SelectedNode.Tag;
            }
        }
        // ------------------------------------------------------
        /// <summary>
        /// Adds a tree node for the specified hierarchy item to a tree node
        /// collection.
        /// </summary>
        /// <param name="item">
        /// A hierarchy item.
        /// </param>
        /// <param name="coll">
        /// The <code>TreeNodeCollection</code> to add the new node to.
        /// </param>
        private void AddNode(HierarchyItem item,
			TreeNodeCollection coll)
        {
            // Skip the item if it is not one of the visible types.

            Guid typeGuid = item.TypeGuid;

            if (visibleTypeGuids != null &&
                Array.IndexOf(visibleTypeGuids, typeGuid) == -1)
                return;

            // Add the item's icon to the end of the image list.

            imageList.Images.Add(item.Icon);
            int imageIndex = imageList.Images.Count - 1;

            TreeNode node = new TreeNode();
            node.Text = item.Caption;
            node.ImageIndex = node.SelectedImageIndex = imageIndex;
            node.Tag = item;

            coll.Add(node);

            // Recurse through the item's children.

            foreach (HierarchyItem child in item.Children)
                AddNode(child, node.Nodes);

            node.Expand();
        }
        private void PopulateTree(TestSuiteCollection suites)
        {
            fixingChecks = true;

            // Preserve the original selection so that we can reselect them.
            Dictionary<string, bool> selectedTests = SelectedTestCases;

            // clear the current contents
            testsTreeView.Nodes.Clear();

            TreeNode solutionNode = new TreeNode();
            HierarchyItem solHier = new HierarchyItem(suites.Solution as IVsHierarchy);

            // Don't do anything if the solution is empty.
            if (solHier.Name == null)
                return;

            solutionNode.Text = "Solution '" + solHier.Name + "'";
            solutionNode.ImageKey = solutionNode.SelectedImageKey = "Solution";
            testsTreeView.Nodes.Add(solutionNode);

            foreach(TestSuite suite in suites.Suites)
            {
                AddTestSuiteToNode(suite, solutionNode, selectedTests);
            }

            fixingChecks = false;

            testsTreeView.Sort();

            solutionNode.ExpandAll();
        }
        private void RefreshHirearchy ()
        {
            if (schemaTabView.Selected.Identifier.ToString () == "Hierarchy") {
                if (objectClassesList.SelectedRows.Count > 0) {
                    HierarchyItemDatasource ds = new HierarchyItemDatasource (_currentObject);

                    var mgr = _serverDTO.Connection.SchemaManager;
                    var dto = mgr.GetObjectClass (_currentObject);
                    HierarchyItem rootItem = new HierarchyItem (_currentObject);
                    HierarchyItem prevItem = rootItem;
                    while (dto != null) {
                        dto = mgr.GetObjectClass (dto.SuperClass);
                        if (dto != null) {
                            HierarchyItem currItem = new HierarchyItem (dto.Name);
                            prevItem.Children.Add (currItem);
                            prevItem = currItem;
                        }
                        ds.Item = rootItem;
                    }
                    this.HierarchyOutlineView.DataSource = ds;
                    this.HierarchyOutlineView.ReloadData ();
                }
            }
        }
        // ------------------------------------------------------
        /// <summary>
        /// Gets the path to the working directory used by the active
        /// configuration of the specified project.
        /// </summary>
        /// <param name="projectHier">
        /// The project to get the working directory for.
        /// </param>
        /// <returns>
        /// The full path to the working directory used by the active
        /// configuration for this project.
        /// </returns>
        private string GetActiveWorkingDirectory(HierarchyItem projectHier)
        {
            Project project = projectHier.GetExtObjectAs<Project>();
            Configuration activeConfig =
                project.ConfigurationManager.ActiveConfiguration;

            Property workingDirProp =
                activeConfig.Properties.Item("WorkingDirectory");
            string workingDir = workingDirProp.Value as string;

            if (string.IsNullOrEmpty(workingDir))
                workingDir = projectHier.ProjectDirectory;

            return workingDir;
        }
        public void Generate()
        {
            string projectDir = project.ProjectDirectory;
            string headerName = suiteName + ".h";

            string suitePath = Path.Combine(projectDir, headerName);

            StreamWriter writer = File.CreateText(suitePath);
            WriteHeaderFileContent(writer, suitePath);
            writer.Close();

            VCFilter testFilter = GetOrCreateTestFilter();
            VCProjectItem item = (VCProjectItem)testFilter.AddFile(suitePath);

            suiteFile = project.GetChildWithName(item.ItemName);
        }
Пример #47
0
        private static string GetDocumentPath(IVsHierarchy hierarchy, uint itemid)
        {
            var rootid = -2;
            var rootItem = new HierarchyItem(hierarchy, (uint)rootid);
            var viewItem = rootItem.FirstOrDefault(child => child.Name == "Views");

            var docItem = new HierarchyItem(hierarchy, itemid);
            var path = docItem.Name;
            while (!Equals(docItem.Parent, viewItem) &&
                   !Equals(docItem.Parent, rootItem))
            {
                docItem = docItem.Parent;
                path = docItem.Name + "\\" + path;
            }

            if (Equals(docItem.Parent, rootItem))
                path = "$\\" + path;

            return path;
        }
        // ------------------------------------------------------
        /// <summary>
        /// Gets the path to the executable file generated by the active
        /// configuration of the specified project.
        /// </summary>
        /// <param name="projectHier">
        /// The project to get the executable file for.
        /// </param>
        /// <returns>
        /// The full path to the executable generated by the active
        /// configuration for this project.
        /// </returns>
        private string GetActiveExecutablePath(HierarchyItem projectHier)
        {
            Project project = projectHier.GetExtObjectAs<Project>();
            Configuration activeConfig =
                project.ConfigurationManager.ActiveConfiguration;

            string outputPath =
                activeConfig.Properties.Item("OutputPath").Value as string;
            string outputName = ((object[]) activeConfig.OutputGroups.Item(
                "Built").FileNames)[0] as string;

            return Path.Combine(outputPath, outputName);
        }
Пример #49
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="HierarchyTraversalInfo"/> class.
 /// </summary>
 /// <param name="hierarchyNode">The hierarchy node.</param>
 /// <param name="depth">The depth of the node.</param>
 // --------------------------------------------------------------------------------------------
 public HierarchyTraversalInfo(HierarchyItem hierarchyNode, int depth)
 {
     HierarchyNode = hierarchyNode;
       Depth = depth;
 }
        private void headerUnderTestBrowseButton_Click(object sender, EventArgs e)
        {
            HierarchyItemDialog dialog = new HierarchyItemDialog(serviceProvider);
            dialog.Message = "Choose a header file in your project to generate a test suite from.";
            dialog.SelectableTypeGuids = new Guid[] { VSConstants.GUID_ItemType_PhysicalFile };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                HierarchyItem item = dialog.SelectedItem;
                this.headerUnderTest = item;

                headerUnderTestField.Text = item.ProjectRelativePath;
            }
        }
        public int OnBeforeCloseProject(IVsHierarchy pHierarchy, int fRemoved)
        {
            string name = new HierarchyItem(pHierarchy).CanonicalName;
            uint cookie = hierarchyCookies[name];

            pHierarchy.UnadviseHierarchyEvents(cookie);

            return VSConstants.S_OK;
        }
        // ------------------------------------------------------
        /// <summary>
        /// Launches the tests for the solution.
        /// </summary>
        public void LaunchTests()
        {
            HierarchyItem startupProject =
                VsShellUtils.GetStartupProject(this);
            lastRunProject = startupProject;

            if (startupProject == null)
                return;

            TryToSetTestResultsText("Running the tests...");

            debuggerEvents.StartingTestRun = true;

            uint flags =
                (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd;

            string projectDir = startupProject.ProjectDirectory;
            string workingDir = GetActiveWorkingDirectory(startupProject);
            string exePath = GetActiveExecutablePath(startupProject);

            Guid guidNativeOnlyEng =
                new Guid("3B476D35-A401-11D2-AAD4-00C04F990171");

            VsDebugTargetInfo debugTarget = new VsDebugTargetInfo();
            debugTarget.bstrExe = exePath;
            debugTarget.bstrCurDir = workingDir;
            debugTarget.fSendStdoutToOutputWindow = 1;
            debugTarget.grfLaunch = flags;
            debugTarget.dlo = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            debugTarget.clsidCustom = guidNativeOnlyEng;
            VsShellUtilities.LaunchDebugger(this, debugTarget);
        }
 public ProjectItem(HierarchyItem item)
 {
     this.item = item;
 }
 // Constructor
 public HierarchyItemDatasource (string currentObject)
 {
     Item = new HierarchyItem (currentObject);
 }
Пример #55
0
 // --------------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="HierarchyTraversalInfo"/> class.
 /// </summary>
 /// <param name="hierarchyNode">The hierarchy node.</param>
 /// <param name="itemId">The item id.</param>
 /// <param name="depth">The depth of the node.</param>
 // --------------------------------------------------------------------------------------------
 public HierarchyTraversalInfo(IVsHierarchy hierarchyNode, uint itemId, int depth)
 {
     HierarchyNode = new HierarchyItem(hierarchyNode, itemId);
       Depth = depth;
 }