Beispiel #1
0
        /// <summary>
        /// Finds dependent elements in <paramref name="diagram"/> or in whole model
        /// for all elements in <paramref name="elements"/>.
        /// </summary>
        /// <param name="elements">collection of elements for which dependent elements will be
        /// returned</param>
        /// <param name="diagram">diagram where dependent elements are searched, when set to <code>null</code>
        /// lookup will be performed in the whole model</param>
        /// <param name="dependency">type of dependencies</param>
        /// <returns><see cref="ElementDependencies"/></returns>
        private static ElementDependencies FindElementDependencies(IList <Element> elements, Diagram diagram, EDependency dependency)
        {
            ElementDependencies dependencies = new ElementDependencies();

            foreach (Element element in elements)
            {
                List <Element> dep = new List <Element>();
                GetDependentElements(diagram, element, dependency, ref dep, true);
                dep.RemoveAll(dependentElement => elements.Contains(dependentElement));
                if (dep.Count > 0)
                {
                    dependencies.Flags[element] = false;
                    dependencies[element]       = dep;
                }
            }
            return(dependencies);
        }
Beispiel #2
0
        /*
         * Possible dependencies in PSM diagram:
         *
         * PSMSuperordinateComponent (PSMClass, PSMContentContainer, PSMContentChoice)
         *  => Components (PSMAssociation, PSMAttributeContainer, PSMContentContainer, PSMContentChoice)
         *
         * PSMClassUnion
         *  => Components (PSMClass, PSMClassUnion)
         *
         * PSMAssociation
         *  => PSMAssociationChild (PSMClass, PSMClassUnion)
         *
         * PSMClass
         *  => Specifications (Generalization)
         *
         * Generalization
         *   => General, Specific (PSMClass)
         */
        public static ElementDependencies FindPSMDependencies(IEnumerable <Element> deletedElements)
        {
            ElementDependencies result = new ElementDependencies();

            result.elementsToDo = new Queue <KeyValuePair <Element, Element> >();
            foreach (Element element in deletedElements)
            {
                result.elementsToDo.Enqueue(new KeyValuePair <Element, Element>(element, element));
            }
            result.ignoredElements = deletedElements;
            while (result.elementsToDo.Count != 0)
            {
                KeyValuePair <Element, Element> pair = result.elementsToDo.Dequeue();
                if (pair.Value is PSMClass)
                {
                    result.AddClassDependencies(pair.Key, (PSMClass)pair.Value);
                }
                else if (pair.Value is PSMClassUnion)
                {
                    result.AddClassUnionDependencies(pair.Key, (PSMClassUnion)pair.Value);
                }
                else if (pair.Value is PSMAssociation)
                {
                    result.AddAssociationDependencies(pair.Key, (PSMAssociation)pair.Value);
                }
                else if (pair.Value is Generalization)
                {
                    result.AddGeneralizationDependencies(pair.Key, (Generalization)pair.Value);
                }
                else if (pair.Value is PSMSuperordinateComponent)
                {
                    result.AddSuperordinateComponentDependencies(pair.Key, (PSMSuperordinateComponent)pair.Value);
                }
            }
            return(result);
        }