public override UML.Profiles.TaggedValue createTaggedValue(UML.Classes.Kernel.Element owner, object objectToWrap)
 {
     UML.Profiles.TaggedValue newTaggedValue = null;
     if (objectToWrap is global::EA.TaggedValue)
     {
         newTaggedValue = this.createElementTag((Element)owner, (global::EA.TaggedValue)objectToWrap);
     }
     else if (objectToWrap is global::EA.AttributeTag)
     {
         newTaggedValue = this.createAttributeTag((Element)owner, (global::EA.AttributeTag)objectToWrap);
     }
     else if (objectToWrap is global::EA.MethodTag)
     {
         newTaggedValue = this.createOperationTag((Element)owner, (global::EA.MethodTag)objectToWrap);
     }
     else if (objectToWrap is global::EA.ConnectorTag)
     {
         newTaggedValue = this.createRelationTag((Element)owner, (global::EA.ConnectorTag)objectToWrap);
     }
     else if (objectToWrap is global::EA.ParamTag)
     {
         newTaggedValue = this.createParameterTag((Element)owner, (global::EA.ParamTag)objectToWrap);
     }
     else if (objectToWrap is global::EA.RoleTag)
     {
         newTaggedValue = this.createRoleTag((Element)owner, (global::EA.RoleTag)objectToWrap);
     }
     return(newTaggedValue);
 }
        /// create a new element as owned element of the given owner
        public override T createNewElement <T>(UML.Classes.Kernel.Element owner, String name)
        {
            T returnedValue = null;

            if (owner is Package)
            {
                returnedValue = ((Package)owner).addOwnedElement <T>(name);
            }
            else if (owner is ElementWrapper)
            {
                returnedValue = ((ElementWrapper)owner).addOwnedElement <T>(name);
            }
            else if (owner is Operation)
            {
                //We can only add Parameters as owned elements to an operation
                returnedValue = ((Operation)owner).addOwnedParameter(name) as T;
            }
            else
            {
                returnedValue = default(T);
            }
            //new elements are always dirty
            var returnedElement = returnedValue as Element;

            if (returnedElement != null)
            {
                returnedElement.isNew = true;
            }

            return(returnedValue);
        }
Ejemplo n.º 3
0
        /// clones a diagram cloning all diagramElements and their related
        /// elements
        public UML.Diagrams.Diagram cloneDiagram(UML.Classes.Kernel.Element owner,
                                                 UML.Diagrams.Diagram diagram)
        {
            Dictionary <UML.Diagrams.DiagramElement, UML.Diagrams.DiagramElement>
            diagramElementsMap = new Dictionary <UML.Diagrams.DiagramElement,
                                                 UML.Diagrams.DiagramElement>();
            Dictionary <UML.Classes.Kernel.Element, UML.Classes.Kernel.Element>
            elementsMap = new Dictionary <UML.Classes.Kernel.Element,
                                          UML.Classes.Kernel.Element>();

            UML.Diagrams.Diagram clonedDiagram = null;

            if (diagram is UML.Diagrams.ClassDiagram)
            {
                clonedDiagram = this.createNewDiagram <UML.Diagrams.ClassDiagram>(owner, diagram.name);
            }

            else if (diagram is UML.Diagrams.SequenceDiagram)
            {
                clonedDiagram = this.createNewDiagram <UML.Diagrams.SequenceDiagram>(owner, diagram.name);
            }

            clonedDiagram.name    = diagram.name;
            clonedDiagram.width   = diagram.width;
            clonedDiagram.height  = diagram.height;
            clonedDiagram.comment = diagram.comment;

            List <UML.Diagrams.DiagramElement> diagramElements =
                diagram.diagramElements.ToList();

            diagramElements = this.sortDiagramElements(diagramElements);

            foreach (UML.Diagrams.DiagramElement diagramElement in diagramElements)
            {
                UML.Diagrams.DiagramElement clonedDiagramElement =
                    this.cloneDiagramElement(clonedDiagram, diagramElement, elementsMap);
                if (clonedDiagramElement != null)
                {
                    diagramElementsMap.Add(diagramElement, clonedDiagramElement);
                    elementsMap.Add(diagramElement.element,
                                    clonedDiagramElement.element);
                }
            }

            foreach (UML.Classes.Kernel.Element element in elementsMap.Keys)
            {
                foreach (UML.Classes.Kernel.Element subElement in
                         element.ownedElements)
                {
                    this.cloneElement(elementsMap[element], subElement, elementsMap,
                                      true);
                }
            }
            return(clonedDiagram);
        }
Ejemplo n.º 4
0
        /// returns a collection of Elements based on the collection of objects to
        /// wrap all within the given owner object
        public ICollection <UML.Classes.Kernel.Element> createElements
            (IEnumerable objectsToWrap, UML.Classes.Kernel.Element owner)
        {
            List <UML.Classes.Kernel.Element> elements = new List <UML.Classes.Kernel.Element>();

            foreach (Object objectToWrap in objectsToWrap)
            {
                elements.Add(this.createElement(objectToWrap, owner));
            }
            return(elements);
        }
 public override T createNewDiagram <T>(UML.Classes.Kernel.Element owner, string name)
 {
     if (owner is ElementWrapper)
     {
         return(((ElementWrapper)owner).addOwnedDiagram <T>(name));
     }
     else
     {
         return(default(T));
     }
 }
Ejemplo n.º 6
0
        public virtual ICollection <UML.Profiles.TaggedValue> createTaggedValues(UML.Classes.Kernel.Element owner, IEnumerable taggedValuesToWrap)
        {
            List <UML.Profiles.TaggedValue> taggedValues = new List <UML.Profiles.TaggedValue>();

            foreach (object tagToWrap in taggedValuesToWrap)
            {
                UML.Profiles.TaggedValue taggedValue = this.createTaggedValue(owner, tagToWrap);
                if (taggedValue != null)
                {
                    taggedValues.Add(taggedValue);
                }
            }
            return(taggedValues);
        }
        public override UML.Profiles.TaggedValue createNewTaggedValue(UML.Classes.Kernel.Element owner, string name)
        {
            var myOwner = owner as Element;

            if (myOwner != null)
            {
                var eaTaggedValues = myOwner.eaTaggedValuesCollection;
                return(this.createTaggedValue(myOwner, eaTaggedValues.AddNew(name, "")));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
        /// creates a set of stereotypes based on the comma seperated names string
        /// and attaches it to the given element
        public HashSet <UML.Profiles.Stereotype> createStereotypes
            (UML.Classes.Kernel.Element owner, String names)
        {
            HashSet <UML.Profiles.Stereotype> newStereotypes =
                new HashSet <UML.Profiles.Stereotype>();

            String[] stereotypeNames = names.Split(',');
            foreach (String name in stereotypeNames)
            {
                if (name != String.Empty)
                {
                    UML.Profiles.Stereotype stereotype =
                        this.createStereotype(owner, name);
                    if (stereotype != null)
                    {
                        newStereotypes.Add(stereotype);
                    }
                }
            }
            return(newStereotypes);
        }
Ejemplo n.º 9
0
        public UML.Diagrams.DiagramElement cloneDiagramElement
            (UML.Diagrams.Diagram ownerDiagram,
            UML.Diagrams.DiagramElement diagramElement,
            Dictionary <UML.Classes.Kernel.Element, UML.Classes.Kernel.Element>
            clonedElementsMap)
        {
            // clone the element itself
            UML.Classes.Kernel.Element clonedElement =
                this.cloneElement(ownerDiagram.owner, diagramElement.element,
                                  clonedElementsMap, false);
            // create the new DiagramElement
            UML.Diagrams.DiagramElement clonedDiagramElement =
                this.createNewDiagramElement(ownerDiagram, clonedElement);

            if (clonedDiagramElement != null)
            {
                // copy the attributes
                clonedDiagramElement.xPosition = diagramElement.xPosition;
                clonedDiagramElement.yPosition = diagramElement.yPosition;
            }
            return(clonedDiagramElement);
        }
Ejemplo n.º 10
0
 public abstract UML.Diagrams.DiagramElement createNewDiagramElement
     (UML.Diagrams.Diagram owner, UML.Classes.Kernel.Element element);
Ejemplo n.º 11
0
        /// clone the given element as an owned element of the given owner
        public UML.Classes.Kernel.Element cloneElement
            (UML.Classes.Kernel.Element owner,
            UML.Classes.Kernel.Element element,
            Dictionary <UML.Classes.Kernel.Element, UML.Classes.Kernel.Element>
            clonedElementsMap,
            bool deep)
        {
            UML.Classes.Kernel.Element clonedElement = null;
            // check if the element is already cloned
            if (clonedElementsMap.TryGetValue(element, out clonedElement))
            {
                // do nothing, clonedElement is now filled in.
            }
            else if (element is UML.Classes.Kernel.Class)
            {
                UML.Classes.Kernel.Class sourceClass =
                    (UML.Classes.Kernel.Class)element;
                UML.Classes.Kernel.Class clonedClass =
                    this.createNewElement <UML.Classes.Kernel.Class>
                        (owner, ((UML.Classes.Kernel.Class)element).name);
                // copy (meta)attributes
                clonedClass.isAbstract = sourceClass.isAbstract;
                clonedElement          = clonedClass;
            }
            else if (element is UML.Profiles.Stereotype)
            {
                clonedElement =
                    this.createNewElement <UML.Profiles.Stereotype>
                        (owner, ((UML.Profiles.Stereotype)element).name);
            }
            else if (element is UML.Classes.Interfaces.Interface)
            {
                clonedElement =
                    this.createNewElement <UML.Classes.Interfaces.Interface>
                        (owner, ((UML.Classes.Interfaces.Interface)element).name);
            }
            else if (element is UML.Classes.Kernel.Operation)
            {
                UML.Classes.Kernel.Operation sourceOperation =
                    (UML.Classes.Kernel.Operation)element;
                UML.Classes.Kernel.Operation clonedOperation =
                    this.createNewElement <UML.Classes.Kernel.Operation>
                        (owner, ((UML.Classes.Kernel.Operation)element).name);
                clonedOperation.visibility = sourceOperation.visibility;
                clonedOperation.isAbstract = sourceOperation.isAbstract;
                clonedOperation.isStatic   = sourceOperation.isStatic;
                clonedElement = clonedOperation;
            }
            else if (element is UML.Classes.Kernel.Parameter)
            {
                UML.Classes.Kernel.Parameter sourceParameter =
                    (UML.Classes.Kernel.Parameter)element;
                UML.Classes.Kernel.Parameter clonedParameter =
                    this.createNewElement <UML.Classes.Kernel.Parameter>
                        (owner, sourceParameter.name);
                // if the type of the parameter is already cloned we take that.
                // otherwise we create a new primitive type
                UML.Classes.Kernel.Element clonedParameterType;
                if (clonedElementsMap.TryGetValue(sourceParameter.type, out
                                                  clonedParameterType))
                {
                    clonedParameter.type =
                        clonedParameterType as UML.Classes.Kernel.Type;
                }
                else
                {
                    clonedParameter.type =
                        this.createPrimitiveType(sourceParameter.type.name);
                }
                // set the direction
                clonedParameter.direction = sourceParameter.direction;
                clonedElement             = clonedParameter;
            }
            else if (element is UML.Classes.Kernel.Generalization)
            {
                UML.Classes.Kernel.Generalization clonedGeneralization =
                    this.createNewElement <UML.Classes.Kernel.Generalization>
                        (owner, string.Empty);
                // clone source
                clonedGeneralization.source =
                    this.cloneElement
                        (owner, ((UML.Classes.Kernel.Generalization)element).source,
                        clonedElementsMap, false);
                // clone target
                clonedGeneralization.target =
                    this.cloneElement
                        (owner, ((UML.Classes.Kernel.Generalization)element).target,
                        clonedElementsMap, false);
                clonedElement = clonedGeneralization;
            }
            else if (element is UML.Classes.Interfaces.InterfaceRealization)
            {
                UML.Classes.Interfaces.InterfaceRealization
                    clonedInterfaceRealization =
                    this.createNewElement <UML.Classes.Interfaces.InterfaceRealization>
                        (owner,
                        ((UML.Classes.Interfaces.InterfaceRealization)element).name);
                // clone source
                clonedInterfaceRealization.source =
                    this.cloneElement
                        (owner,
                        ((UML.Classes.Interfaces.InterfaceRealization)element).source,
                        clonedElementsMap, false);
                // clone target
                clonedInterfaceRealization.target =
                    this.cloneElement
                        (owner,
                        ((UML.Classes.Interfaces.InterfaceRealization)element).target,
                        clonedElementsMap, false);
                clonedElement = clonedInterfaceRealization;
            }
            else if (element is UML.Classes.Dependencies.Dependency)
            {
                UML.Classes.Dependencies.Dependency sourceDependency =
                    element as UML.Classes.Dependencies.Dependency;
                UML.Classes.Dependencies.Dependency clonedDependency =
                    this.createNewElement <UML.Classes.Dependencies.Dependency>
                        (owner, sourceDependency.name);
                // clone client and supplier
                clonedDependency.client =
                    this.cloneElement(owner, sourceDependency.client, clonedElementsMap,
                                      false) as UML.Classes.Kernel.NamedElement;
                clonedDependency.supplier =
                    this.cloneElement(owner, sourceDependency.supplier,
                                      clonedElementsMap, false)
                    as UML.Classes.Kernel.NamedElement;
                clonedElement = clonedDependency;
            }
            else if (element is UML.Classes.Kernel.Association)
            {
                clonedElement =
                    this.createNewElement <UML.Classes.Kernel.Association>
                        (owner, ((UML.Classes.Kernel.Association)element).name);
            }
            else if (element is UML.Classes.Kernel.Property)
            {
                UML.Classes.Kernel.Property sourceProperty =
                    (UML.Classes.Kernel.Property)element;
                UML.Classes.Kernel.Property clonedProperty =
                    this.createNewElement <UML.Classes.Kernel.Property>
                        (owner, sourceProperty.name);
                UML.Classes.Kernel.Element clonedPropertyType;
                if (clonedElementsMap.TryGetValue(sourceProperty.type, out
                                                  clonedPropertyType))
                {
                    clonedProperty.type = clonedPropertyType
                                          as UML.Classes.Kernel.Type;
                }
                else
                {
                    clonedProperty.type =
                        this.cloneElement(clonedProperty, sourceProperty.type,
                                          clonedElementsMap, false)
                        as UML.Classes.Kernel.Type;
                }
                clonedProperty.aggregation  = sourceProperty.aggregation;
                clonedProperty._isNavigable = sourceProperty._isNavigable;
                clonedProperty.visibility   = sourceProperty.visibility;
                clonedProperty.isStatic     = sourceProperty.isStatic;
                clonedElement = clonedProperty;
            }
            else if (element is UML.Classes.Kernel.PrimitiveType)
            {
                clonedElement =
                    this.createPrimitiveType
                        (((UML.Classes.Kernel.PrimitiveType)element).name);
            }
            else if (element is UML.Classes.Kernel.Comment)
            {
                UML.Classes.Kernel.Comment sourceComment =
                    (UML.Classes.Kernel.Comment)element;
                // comments do not have a name
                UML.Classes.Kernel.Comment clonedComment =
                    this.createNewElement <UML.Classes.Kernel.Comment>
                        (owner, string.Empty);
                // clone body
                clonedComment.body = sourceComment.body;
                //clone annotated elements
                foreach (UML.Classes.Kernel.Element annotatedElement in
                         sourceComment.annotatedElements)
                {
                    HashSet <UML.Classes.Kernel.Element> clonedAnnotatedElements =
                        new HashSet <UML.Classes.Kernel.Element>();
                    clonedAnnotatedElements.Add(
                        this.cloneElement(owner, annotatedElement,
                                          clonedElementsMap, false));
                    clonedComment.annotatedElements = clonedAnnotatedElements;
                }
                clonedElement = clonedComment;
            }

            // copy stereotypes
            if (clonedElement != null)
            {
                foreach (UML.Profiles.Stereotype stereotype in element.stereotypes)
                {
                    clonedElement.addStereotype(this.createStereotype(clonedElement,
                                                                      stereotype.name));
                }
            }
            if (deep)
            {
                foreach (UML.Classes.Kernel.Element ownedElement in
                         element.ownedElements)
                {
                    this.cloneElement(clonedElement, ownedElement, clonedElementsMap,
                                      true);
                }
            }
            return(clonedElement);
        }
Ejemplo n.º 12
0
 //create a new UML element based on the given object within the given owner
 public abstract UML.Classes.Kernel.Element createElement
     (Object objectToWrap, UML.Classes.Kernel.Element owner);
Ejemplo n.º 13
0
        public UML.Classes.Kernel.Element createNewElement(UML.Classes.Kernel.Element owner, string name, string UMLType)
        {
            switch (UMLType)
            {
            case "Action":
                return(createNewElement <UML.Actions.BasicActions.Action>(owner, name));

            case "CallBehaviorAction":
                return(createNewElement <UML.Actions.BasicActions.CallBehaviorAction>(owner, name));

            case "CallOperationAction":
                return(createNewElement <UML.Actions.BasicActions.CallOperationAction>(owner, name));

            case "Activity":
                return(createNewElement <UML.Activities.FundamentalActivities.Activity>(owner, name));

            case "AssociationClass":
                return(createNewElement <UML.Classes.AssociationClasses.AssociationClass>(owner, name));

            case "Abstraction":
                return(createNewElement <UML.Classes.Dependencies.Abstraction>(owner, name));

            case "Dependency":
                return(createNewElement <UML.Classes.Dependencies.Dependency>(owner, name));

            case "Realization":
                return(createNewElement <UML.Classes.Dependencies.Realization>(owner, name));

            case "Usage":
                return(createNewElement <UML.Classes.Dependencies.Usage>(owner, name));

            case "Interface":
                return(createNewElement <UML.Classes.Interfaces.Interface>(owner, name));

            case "Association":
                return(createNewElement <UML.Classes.Kernel.Association>(owner, name));

            case "Class":
                return(createNewElement <UML.Classes.Kernel.Class>(owner, name));

            case "Comment":
                return(createNewElement <UML.Classes.Kernel.Comment>(owner, name));

            case "Constraint":
                return(createNewElement <UML.Classes.Kernel.Constraint>(owner, name));

            case "DataType":
                return(createNewElement <UML.Classes.Kernel.DataType>(owner, name));

            case "Enumeration":
                return(createNewElement <UML.Classes.Kernel.Enumeration>(owner, name));

            case "EnumerationLiteral":
                return(createNewElement <UML.Classes.Kernel.EnumerationLiteral>(owner, name));

            case "Generalization":
                return(createNewElement <UML.Classes.Kernel.Generalization>(owner, name));

            case "LiteralBoolean":
                return(createNewElement <UML.Classes.Kernel.LiteralBoolean>(owner, name));

            case "LiteralInteger":
                return(createNewElement <UML.Classes.Kernel.LiteralInteger>(owner, name));

            case "LiteralNull":
                return(createNewElement <UML.Classes.Kernel.LiteralNull>(owner, name));

            case "LiteralString":
                return(createNewElement <UML.Classes.Kernel.LiteralString>(owner, name));

            case "LiteralUnlimitedNatural":
                return(createNewElement <UML.Classes.Kernel.LiteralUnlimitedNatural>(owner, name));

            case "Operation":
                return(createNewElement <UML.Classes.Kernel.Operation>(owner, name));

            case "Package":
                return(createNewElement <UML.Classes.Kernel.Package>(owner, name));

            case "Parameter":
                return(createNewElement <UML.Classes.Kernel.Parameter>(owner, name));

            case "PrimitiveType":
                return(createNewElement <UML.Classes.Kernel.PrimitiveType>(owner, name));

            case "Property":
                return(createNewElement <UML.Classes.Kernel.Property>(owner, name));

            case "InformationFlow":
                return(createNewElement <UML.InfomationFlows.InformationFlow>(owner, name));

            case "InformationItem":
                return(createNewElement <UML.InfomationFlows.InformationItem>(owner, name));

            case "Lifeline":
                return(createNewElement <UML.Interactions.BasicInteractions.Lifeline>(owner, name));

            case "Message":
                return(createNewElement <UML.Interactions.BasicInteractions.Message>(owner, name));

            case "Stereotype":
                return(createNewElement <UML.Profiles.Stereotype>(owner, name));

            default:
                return(createNewElement <UML.Classes.Kernel.Class>(owner, name));
            }
        }
Ejemplo n.º 14
0
 public abstract UML.Profiles.TaggedValue createNewTaggedValue(UML.Classes.Kernel.Element owner, string name);
        public override UML.Classes.Kernel.Element createElement(object objectToWrap, UML.Classes.Kernel.Element owner)
        {
            var newElement = this.createElement(objectToWrap);

            newElement.owner = owner;
            return(newElement);
        }
Ejemplo n.º 16
0
 public abstract UML.Profiles.TaggedValue createTaggedValue(UML.Classes.Kernel.Element owner, object objectToWrap);
Ejemplo n.º 17
0
 /// create a new element as owned element of the given owner
 public abstract T createNewElement <T>(UML.Classes.Kernel.Element owner,
                                        String name)
     where T : class, UML.Classes.Kernel.Element;
 /// returns a new stereotype based on the given name and attached to the
 /// given element
 public override UML.Profiles.Stereotype createStereotype
     (UML.Classes.Kernel.Element owner, String name)
 {
     return(new Stereotype(this.model as Model, owner as Element, name));
 }
Ejemplo n.º 19
0
 public abstract UML.Profiles.Stereotype createStereotype
     (UML.Classes.Kernel.Element owner, String name);
 public override UML.Diagrams.DiagramElement createNewDiagramElement
     (UML.Diagrams.Diagram owner, UML.Classes.Kernel.Element element)
 {
     return(owner.addToDiagram(element));
 }