コード例 #1
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClass shapeClass = e.ModelElement as ShapeClass;

            if (shapeClass != null)
            {
                for (int i = shapeClass.Children.Count - 1; i >= 0; i--)
                {
                    shapeClass.Children[i].Delete();
                }
            }
        }
コード例 #2
0
        private static void FixUpDiagramView(LibraryModelContext model)
        {
            foreach (DiagramClass diagramClass in model.DiagramClasses)
            {
                DiagramClassView vm = new DiagramClassView(model.Store);
                vm.IsExpanded   = true;
                vm.DiagramClass = diagramClass;

                // add shapes views
                foreach (PresentationElementClass p in diagramClass.PresentationElements)
                {
                    if (p is ShapeClass)
                    {
                        ShapeClass shapeClass = p as ShapeClass;
                        if (shapeClass.Parent == null)
                        {
                            RootDiagramNode node = new RootDiagramNode(p.Store);
                            node.PresentationElementClass = p;

                            vm.RootDiagramNodes.Add(node);
                        }
                        else
                        {
                            EmbeddingDiagramNode newNode = new EmbeddingDiagramNode(model.Store);
                            newNode.PresentationElementClass = p;
                        }
                    }
                    else
                    {
                        RootDiagramNode node = new RootDiagramNode(p.Store);
                        node.PresentationElementClass = p;

                        vm.RootDiagramNodes.Add(node);
                    }
                }

                foreach (PresentationElementClass p in diagramClass.PresentationElements)
                {
                    if (p is ShapeClass)
                    {
                        ShapeClass shapeClass = p as ShapeClass;
                        if (shapeClass.Parent != null)
                        {
                            EmbeddingDiagramNode source = shapeClass.Parent.DiagramTreeNode as EmbeddingDiagramNode;
                            EmbeddingDiagramNode target = p.DiagramTreeNode as EmbeddingDiagramNode;

                            if (source != null && target != null)
                            {
                                new EmbeddingDiagramNodeHasEmbeddingDiagramNodes(source, target);
                            }
                        }
                    }
                }

                model.ViewContext.DiagramView.DiagramClassViews.Add(vm);
            }
        }
コード例 #3
0
        /// <summary>
        /// Verifies if a given shape class is within the children collection.
        /// </summary>
        /// <param name="shapeClass">ShapeClass to find.</param>
        /// <returns>True if the given shape class is within the children collection; False otherwise.</returns>
        public bool ContainsChild(ShapeClass shapeClass)
        {
            foreach (ShapeClass p in this.Children)
            {
                if (p == shapeClass)
                    return true;

                if (p.ContainsChild(shapeClass))
                    return true;
            }

            return false;
        }
コード例 #4
0
ファイル: ShapeClass.cs プロジェクト: ckimpel/FSE-2011-PDE
        /// <summary>
        /// Verifies if a given shape class is within the children collection.
        /// </summary>
        /// <param name="shapeClass">ShapeClass to find.</param>
        /// <returns>True if the given shape class is within the children collection; False otherwise.</returns>
        public bool ContainsChild(ShapeClass shapeClass)
        {
            foreach (ShapeClass p in this.Children)
            {
                if (p == shapeClass)
                {
                    return(true);
                }

                if (p.ContainsChild(shapeClass))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #5
0
        public static bool HasProperty(ShapeClass shapeClass, string name)
        {
            if (shapeClass == null)
                return false;

            ShapeClass d = shapeClass;
            while (d != null)
            {
                foreach (DomainProperty p in d.Properties)
                    if (p.Name == name)
                        return true;

                d = d.BaseShape;
            }

            return false;
        }