示例#1
0
 static ITreeNode AddSupportingFiles(ITreeNode node)
 {
     node.AddChild(new TreeNode("_Research"));
     node.AddChild(new TreeNode("_Development"));
     node.AddChild(new TreeNode("_Final"));
     return(node);
 }
示例#2
0
 public void TestInitialize()
 {
     root   = new TreeNode <string>("top");
     child1 = root.AddChild("child1");
     child2 = root.AddChild("child2");
     child3 = root.AddChild("child3");
     child4 = child3.AddChild("child4");
     child5 = child4.AddChild("child5");
     child6 = child5.AddChild("child6");
 }
        protected override void Context()
        {
            base.Context();
            _group1 = new Group {
                Name = "_group1"
            };
            _group2 = new Group {
                Name = "_group2"
            };
            _group3 = new Group {
                Name = "_group3"
            };
            _group11 = new Group {
                Name = "_group11"
            };
            _group21 = new Group {
                Name = "_group21"
            };
            _group22 = new Group {
                Name = "_group22"
            };
            _group31 = new Group {
                Name = "_group31"
            };

            _topNode = new GroupNode(_topGroup);
            _node1   = new GroupNode(_group1);
            _node2   = new GroupNode(_group2);
            _node3   = new GroupNode(_group3);
            _node11  = new GroupNode(_group11);
            _node21  = new GroupNode(_group21);
            _node22  = new GroupNode(_group22);
            _node31  = new GroupNode(_group31);

            _topNode.AddChild(_node1);
            _topNode.AddChild(_node2);
            _topNode.AddChild(_node3);
            _node1.AddChild(_node11);
            _node2.AddChild(_node21);
            _node2.AddChild(_node22);
            _node3.AddChild(_node31);


            var p11 = A.Fake <IParameter>().WithGroup(_group11.Name);
            var p21 = A.Fake <IParameter>().WithGroup(_group21.Name);

            _allParameters.Add(p11);
            _allParameters.Add(p21);
            A.CallTo(() => _parameterGroupToTreeNodeMapper.MapFrom(_topGroup)).Returns(_topNode);
        }
示例#4
0
        public NodeViewModel Add(string name, IMasterPage masterPage = null)
        {
            _document.IsDirty = true;
            NodeViewModel newNode;

            if (this.IsRootNode)
            {
                ITreeNode treeNode = _treeNodeObject.AddChild(TreeNodeType.MasterPage);
                if (masterPage == null)
                {
                    treeNode.AttachedObject = CreatePage(name);
                }
                else
                {
                    treeNode.AttachedObject = masterPage;
                }
                newNode = new NodeViewModel(_undoManager, treeNode, this);
                Children.Add(newNode);
            }
            else
            {
                newNode = AddNodeAfter(name, masterPage);
            }
            return(newNode);
        }
        protected override void Context()
        {
            base.Context();

            _parentClassification = new Classification {
                ClassificationType = ClassificationType.Simulation, Name = "parent"
            };
            _childClassification = new Classification {
                ClassificationType = ClassificationType.Simulation, Name = "child", Parent = _parentClassification
            };

            sut.AddClassificationsToTree(new[] { _childClassification, _parentClassification });

            //do that after so that real node and node fakes are created when adding the classificaiton to the tree
            _project.AddClassification(_childClassification);
            _project.AddClassification(_parentClassification);

            _simulation = new ClassifiableSimulation {
                Parent = _childClassification, Subject = A.Fake <ISimulation>().WithId("Sim")
            };

            _childClassificationNode = _classificationNodesCache[_childClassification];
            _simulationNode          = new SimulationNode(_simulation);
            _childClassificationNode.AddChild(_simulationNode);

            _parentClassificationNode = _childClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >();
        }
        protected override void Context()
        {
            base.Context();
            var existingProcess = new TFirstProcess {
                MoleculeName = "CYP", DataSource = "Lab", Id = "1"
            };

            _newProcess = new TFirstProcess {
                MoleculeName = "CYP", DataSource = "Lab2", Id = "2"
            };
            _compoundProcessNode1 = new CompoundProcessNode(existingProcess);
            _compoundProcessNode2 = new CompoundProcessNode(_newProcess);

            _moleculeNode1 = new PartialProcessMoleculeNode("CYP", new TFirstProcess());
            _moleculeNode1.AddChild(_compoundProcessNode1);

            var moleculeNode2 = new PartialProcessMoleculeNode("CYP", new TSeconProcess());

            moleculeNode2.AddChild(_compoundProcessNode2);

            A.CallTo(() => _partialProcessNodeMapper.MapFrom(existingProcess)).Returns(_moleculeNode1);
            A.CallTo(() => _partialProcessNodeMapper.MapFrom(_newProcess)).Returns(moleculeNode2);

            A.CallTo(() => _view.TreeView.NodeById(_moleculeNode1.Id)).Returns(_moleculeNode1);

            sut.Handle(new AddCompoundProcessEvent {
                Entity = existingProcess
            });
        }
        private void addParentRegion(string path, ITreeNode model)
        {
            string    name         = getDirectoryName(path);
            ITreeNode regionParent = new ParentRegion(name);

            model.AddChild(regionParent);
        }
示例#8
0
        public void TestCreateCircularTree()
        {
            try
            {
                TreeNode <string>  alice   = new TreeNode <string>("Alice");
                ITreeNode <string> bob     = alice.AddChild("Bob");
                ITreeNode <string> charlie = bob.AddChild("Charlie");
                ITreeNode <string> dingus  = bob.AddChild("Dingus");
                dingus.AddChild(bob);

                Assert.IsTrue(false, "Circular tree structure was not caught.");
            }
            catch (ArgumentException)
            {
            }
        }
        protected override void Context()
        {
            base.Context();
            _parentClassification = new Classification {
                ClassificationType = ClassificationType.Simulation, Name = "parent"
            };
            _childEmptyClassification = new Classification {
                ClassificationType = ClassificationType.Simulation, Name = "childEmpty", Parent = _parentClassification
            };
            _childClassification = new Classification {
                ClassificationType = ClassificationType.Simulation, Name = "child", Parent = _parentClassification
            };
            _simulation = new ClassifiableSimulation {
                Subject = new IndividualSimulation()
            };
            sut.AddClassificationsToTree(new[] { _childEmptyClassification, _parentClassification, _childClassification });

            //do that after so that real node and node fakes are created when adding the classificaiton to the tree
            _project.AddClassification(_childEmptyClassification);
            _project.AddClassification(_parentClassification);
            _project.AddClassification(_childClassification);
            _childEmptyClassificationNode = _classificationNodesCache[_childEmptyClassification];
            _childClassificationNode      = _classificationNodesCache[_childClassification];
            _parentClassificationNode     = _childClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >();
            _simulationNode = new SimulationNode(_simulation);
            _childClassificationNode.AddChild(_simulationNode);
            _parentClassificationNode = _childClassificationNode.ParentNode.DowncastTo <ITreeNode <IClassification> >();
            A.CallTo(() => _explorerPresenter.NodeFor(_childEmptyClassification)).Returns(_childEmptyClassificationNode);
            A.CallTo(() => _explorerPresenter.NodeFor(_childClassification)).Returns(_childClassificationNode);
            A.CallTo(() => _explorerPresenter.NodeFor(_parentClassification)).Returns(_parentClassificationNode);
        }
示例#10
0
        public INodeViewModel Add(string name)
        {
            INodeViewModel newNode;

            if (this.IsRootNode)
            {
                ITreeNode treeNode = _treeNodeObject.AddChild(TreeNodeType.Page);
                treeNode.AttachedObject = CreatePage(name);
                newNode = new NodeViewModel(_document, _undoManager, treeNode, this);
                Children.Add(newNode);
            }
            else
            {
                newNode = InsertSiblingAfter(name);
            }
            return(newNode);
        }
示例#11
0
        /// <summary>
        /// Adds the node <paramref name="childNode"/> under the <paramref name="parentNode"/>.
        /// It does support <paramref name="parentNode"/> being <c>null</c>. In that case, nothing is happening
        /// </summary>
        public static T Under <T>(this T childNode, ITreeNode parentNode) where T : ITreeNode
        {
            if (parentNode != null)
            {
                parentNode.AddChild(childNode);
            }

            return(childNode);
        }
示例#12
0
 public virtual void SetParent(ITreeNode parent)
 {
     if (Parent != null)
     {
         throw new NotSupportedException("У узла не может быть 2 родителя.");
     }
     Parent = parent;
     parent.AddChild(this);
 }
        private void addParameterNode(ITreeNode node, IParameter parameter, PathElement pathElementDTO)
        {
            var representation = new RepresentationInfo {
                DisplayName = pathElementDTO.DisplayName, IconName = pathElementDTO.IconName
            };
            var parameterNode = _treeNodeFactory.CreateFor(parameter, representation);

            parameterNode.ToolTip = _toolTipPartCreator.ToolTipFor(_fullPathDisplayResolver.FullPathFor(parameter));
            node.AddChild(parameterNode);
        }
示例#14
0
        protected override void Context()
        {
            base.Context();
            _observedDataFolder = new ClassificationNode(new Classification());
            _anotherNode        = A.Fake <ITreeNode>();
            _repo1 = new DataRepository().WithId("1");
            _repo2 = new DataRepository().WithId("2");
            _observedDataFolder.AddChild(new ObservedDataNode(new ClassifiableObservedData {
                Subject = _repo1
            }));
            _observedDataFolder.AddChild(new ObservedDataNode(new ClassifiableObservedData {
                Subject = _repo2
            }));
            _observedDataFolder.AddChild(_anotherNode);

            A.CallTo(() => _observedDataTask.Delete(A <IEnumerable <DataRepository> > ._, false))
            .Invokes(x => _allObservedData = x.GetArgument <IEnumerable <DataRepository> >(0).ToList())
            .Returns(true);
        }
示例#15
0
        /// <summary>子ノードを追加する。</summary>
        /// <returns>正常に追加できたかどうか示す値と現在のノードを返す。</returns>
        public static ResultWithValue <T> MaybeAddChild <T>(this ITreeNode <T> self, T child) where T :  ITreeNode <T>
        {
            var cash  = self.Children.Count;
            var ncash = self.AddChild(child).Children.ToArray();

            if (cash + 1 == ncash.Length && ncash.Contains(child))
            {
                return(new ResultWithValue <T>((T)self));
            }
            return(new ResultWithValue <T>(false, (T)self));
        }
示例#16
0
 protected override void Context()
 {
     base.Context();
     sut.ShouldExpandAddedNode = false;
     sut.UseLazyLoading        = true;
     _parent     = new TestNode("Parent", "Parent");
     _child      = new TestNode("Child", "Child");
     _grandChild = new TestNode("GrandChild", "GrandChild");
     _child.AddChild(_grandChild);
     _parent.AddChild(_child);
 }
示例#17
0
        public void unit_test_get_the_farthest_depth_of_tree_incorrectly()
        {
            //arrange
            int expectedDepth = 5;

            child6.AddChild("child7");
            //act
            int actualDepth = root.Depth.Count;

            //assert
            Assert.IsFalse(expectedDepth.Equals(actualDepth));
        }
 public virtual void AddClassifiableNodeToView(ITreeNode classifiableNode, ITreeNode <IClassification> classificationNode = null)
 {
     if (classificationNode != null)
     {
         classificationNode.AddChild(classifiableNode);
         _view.AddNode(classificationNode);
     }
     else
     {
         _view.AddNode(classifiableNode);
     }
 }
示例#19
0
        /// <summary>
        /// Create a basic complete binary tree with an ITreeMode type
        /// </summary>
        /// <param name="elementsAfterFirst"></param>
        /// <returns></returns>
        public static ITreeNode <int> CreateBasicBinaryTree <T>(int elementsAfterFirst)
            where T : ITreeNode <int>, new()
        {
            // Create binary tree 0 to 10
            ITreeNode <int> t = new T();

            t.SetValue(0);

            Queue <ITreeNode <int> > nodes = new Queue <ITreeNode <int> >();

            Queue <int> num_stack = new Queue <int>();

            for (int i = 1; i <= elementsAfterFirst; i++)
            {
                num_stack.Enqueue(i);
            }

            nodes.Enqueue(t.Root);

            while (nodes.Count > 0)
            {
                ITreeNode <int> node = nodes.Dequeue();

                if (num_stack.Count == 0)
                {
                    break;
                }

                nodes.Enqueue(node.AddChild(num_stack.Dequeue()));

                if (num_stack.Count == 0)
                {
                    break;
                }

                nodes.Enqueue(node.AddChild(num_stack.Dequeue()));
            }

            return(t.Root);
        }
示例#20
0
        public void SetParent(ITreeNode <TItem> parent)
        {
            if (_parent == parent)
            {
                return;
            }
            ITreeNode <TItem> prevParent = _parent;

            _parent = parent;
            prevParent?.RemoveChild(Node);
            _parent?.AddChild(Node);
            fireParentChanged();
        }
示例#21
0
        void run()
        {
            var owner      = new Employee("owner");
            var president  = new Employee("president");
            var cfo        = new Employee("cfo");
            var coo        = new Employee("coo");
            var ceo        = new Employee("ceo");
            var hr         = new Employee("hr");
            var it         = new Employee("it");
            var admin      = new Employee("admin");
            var mrkting    = new Employee("mrkting");
            var vendor     = new Employee("vendor");
            var contractor = new Employee("contractor");

            var external = new Employee("external");

            rootNode = new TreeNode <IEmployee>(owner);
            child11  = rootNode.AddChild(president);
            child12  = rootNode.AddChild(cfo);
            child13  = rootNode.AddChild(coo);
            child21  = child11.AddChild(ceo);
            child22  = child11.AddChild(hr);
            child31  = child21.AddChild(it);
            child41  = child31.AddChild(admin);
            child42  = child31.AddChild(mrkting);
            child51  = child42.AddChild(vendor);
            child52  = child42.AddChild(contractor);

            int depth = rootNode.Depth.Count;

            Console.WriteLine("The furthest depth in the tree is {0}", depth);
            var val = rootNode.Search(it);

            Console.WriteLine("The Searched item '{0}' is found in the tree:{1} ", it, val);
            val = rootNode.Search(external);
            Console.WriteLine("The Searched item '{0}' is found in the tree:{1} ", external, val);
            Console.ReadKey();
        }
        private ITreeNode createPathElementNodeFor(ITreeNode node, PathElementDTO pathElementDTO)
        {
            var pathElementNode = _treeNodeFactory.CreateFor(pathElementDTO.DisplayName, string.Format("{0}-{1}", node.Id, pathElementDTO.DisplayName), pathElementDTO.IconName);

            var existingNode = node.Children.Find(n => Equals(n.Id, pathElementNode.Id));

            if (existingNode != null)
            {
                return(existingNode);
            }

            node.AddChild(pathElementNode);
            return(pathElementNode);
        }
        private ITreeNode mapFrom(IGroup group, Func <IGroup, string> display)
        {
            ITreeNode node = _treeNodeFactory.CreateFor(group);

            node.Text = display(group);
            node.Icon = ApplicationIcons.IconByName(group.IconName);

            group.Children.Where(g => g.Visible)
            .OrderBy(g => g.Sequence)
            .ThenBy(display)
            .Each(childGroup => node.AddChild(mapFrom(childGroup, display)));

            return(node);
        }
 protected override void Context()
 {
     base.Context();
     _rootNode = A.Fake <ITreeNode>();
     _group1   = new GroupNode(new Group {
         Name = "_group1"
     });
     _group2 = new GroupNode(new Group {
         Name = "_group2"
     });
     _group3 = new GroupNode(new Group {
         Name = "_group3"
     });
     _rootNode = new GroupNode(new Group {
         Name = "_rootNode"
     });
     _parameterNode = new ObjectWithIdAndNameNode <IParameter>(new PKSimParameter());
     _rootNode.AddChild(_group1);
     _rootNode.AddChild(_group2);
     _rootNode.AddChild(_group3);
     _group3.AddChild(_parameterNode);
     _parameterNode = A.Fake <ITreeNode>();
 }
        private ITreeNode createPathElementNodeFor(ITreeNode node, PathElement pathElement)
        {
            var pathElementNode = _treeNodeFactory.CreateFor(pathElement.DisplayName, $"{node.Id}-{pathElement.DisplayName}", pathElement.IconName);

            var existingNode = node.Children.Find(n => Equals(n.Id, pathElementNode.Id));

            if (existingNode != null)
            {
                return(existingNode);
            }

            node.AddChild(pathElementNode);
            return(pathElementNode);
        }
示例#26
0
        /// <inheritdoc />
        public override ITreeNode <T> Copy(ITreeNode <T> newParent = null)
        {
            // Either make new tree, or make a node with new parent as parent
            ITreeNode <T> newNode = newParent == null ?
                                    new TreeNode <T>(Value) :
                                    newParent.AddChild(Value);

            foreach (ITreeNode <T> child in _children)
            {
                child.Copy(newNode);
            }

            return(newNode);
        }
示例#27
0
        public void TestTreeConstructionAndTraversalMethodsOverNodeWrapperTree()
        {
            TreeNode <StringWrapper>  alice   = new TreeNode <StringWrapper>(new StringWrapper("Alice"));
            ITreeNode <StringWrapper> bob     = alice.AddChild(new StringWrapper("Bob"));
            ITreeNode <StringWrapper> charlie = alice.AddChild(new StringWrapper("Charlie"));
            ITreeNode <StringWrapper> dingus  = alice.AddChild(new StringWrapper("Dingus"));

            ITreeNode <StringWrapper> ethel  = bob.AddChild(new StringWrapper("Ethel"));
            ITreeNode <StringWrapper> frank  = bob.AddChild(new StringWrapper("Frank"));
            ITreeNode <StringWrapper> george = bob.AddChild(new StringWrapper("George"));

            StringBuilder sb = new StringBuilder();

            foreach (ITreeNode <StringWrapper> tns in alice.DescendantNodesBreadthFirst(true))
            {
                sb.AppendLine(tns.Payload.ToString());
            }
            foreach (ITreeNode <StringWrapper> tns in alice.DescendantNodesDepthFirst(true))
            {
                sb.AppendLine(tns.Payload.ToString());
            }
            foreach (StringWrapper s in alice.DescendantsBreadthFirst(true))
            {
                sb.AppendLine(s.ToString());
            }
            foreach (StringWrapper s in alice.DescendantsDepthFirst(true))
            {
                sb.AppendLine(s.ToString());
            }

            Console.WriteLine(
                "This test manipulates a tree that holds elements that have no knowledge of their participation in a tree.");
            Console.WriteLine(sb.ToString());
            Console.WriteLine();
            Assert.IsTrue(StripCRLF(sb.ToString()).Equals(StripCRLF(REQUIRED_ITERATIONSTRING1)),
                          "Expected \"" + REQUIRED_ITERATIONSTRING1 + "\", but got \"" + sb.ToString() + "\" instead.");
        }
示例#28
0
        public void TestNodeRemoval2()
        {
            TreeNode <string>  alice   = new TreeNode <string>("Alice");
            ITreeNode <string> bob     = alice.AddChild("Bob");
            ITreeNode <string> charlie = alice.AddChild("Charlie");
            ITreeNode <string> dingus  = alice.AddChild("Dingus");

            ITreeNode <string> ethel  = bob.AddChild("Ethel");
            ITreeNode <string> frank  = bob.AddChild("Frank");
            ITreeNode <string> george = bob.AddChild("George");

            bob.RemoveChild(frank);

            StringBuilder sb = new StringBuilder();

            foreach (ITreeNode <string> tns in alice.DescendantNodesBreadthFirst(true))
            {
                sb.AppendLine(tns.Payload);
            }
            foreach (ITreeNode <string> tns in alice.DescendantNodesDepthFirst(true))
            {
                sb.AppendLine(tns.Payload);
            }
            foreach (string s in alice.DescendantsBreadthFirst(true))
            {
                sb.AppendLine(s);
            }
            foreach (string s in alice.DescendantsDepthFirst(true))
            {
                sb.AppendLine(s);
            }

            Console.WriteLine("This test manipulates a tree that holds elements that have no knowledge of their participation in a tree, but with tree restructuring.");
            Console.WriteLine(sb.ToString());
            Console.WriteLine();
            Assert.AreEqual(StripCRLF(sb.ToString()), StripCRLF(REQUIRED_ITERATIONSTRING2), "Expected \"" + REQUIRED_ITERATIONSTRING2 + "\", but got \"" + sb.ToString() + "\" instead.");
        }
示例#29
0
        public void SetParent(ITreeNode <TItem> parent)
        {
            var node = Node;

            if (_parent == parent || node == null)
            {
                return;
            }
            ITreeNode <TItem> prevParent = _parent;

            _parent = parent;
            prevParent?.RemoveChild(node);
            _parent?.AddChild(node);
            fireParentChanged();
        }
示例#30
0
      protected override void Context()
      {
         base.Context();
         _node1 = new TestNode().WithText("node1");
         _node2 = new TestNode().WithText("node2");
         _leaf1 = new TestNode().WithText("leaf1");
         _node11 = new TestNode().WithText("node11");
         _leaf21 = new TestNode().WithText("leaf21");
         _leaf111 = new TestNode().WithText("leaf111");
         _node1.AddChild(_node11);
         _node11.AddChild(_leaf111);
         _node2.AddChild(_leaf21);
         sut = new TestNode { Text = "root" };
         sut.AddChild(_node1);
         sut.AddChild(_node2);
         sut.AddChild(_leaf1);

      }