/// <summary> /// adds an element to the diagram to the given coördinates /// </summary> /// <param name="element">the element to add</param> /// <param name="x">the x position</param> /// <param name="y">th y position</param> /// <param name="newHeight">the height of the new diagramElement</param> /// <param name="newWidth">the width of the new diagramElement</param> /// <returns>the new diagramElement</returns> public UML.Diagrams.DiagramElement addToDiagram(UML.Classes.Kernel.Element element, int x = 0, int y = 0, int newHeight = 0, int newWidth = 0) { UML.Diagrams.DiagramElement diagramElement = null; if (element != null) { //first check whether this element is not already added to this diagram diagramElement = this.getDiagramElement(element); if (diagramElement == null) { if (element is EA.ElementWrapper) { string addNewString = createAddNewString(x, y, newHeight, newWidth); //first save the diagram to make sure we don't lose any unsaved changes this.model.saveOpenedDiagram(this); global::EA.DiagramObject newDiagramObject = this.wrappedDiagram.DiagramObjects.AddNew(addNewString, "") as global::EA.DiagramObject; diagramElement = ((Factory)this.model.factory).createDiagramElement(newDiagramObject); diagramElement.element = element; //save the element diagramObject ((DiagramObjectWrapper)diagramElement).save(); //add the diagramObject to the list this.diagramObjectWrappers.Add(diagramElement); // now refresh to make sure we see the new element on the diagram this.reFresh(); } else if (!(element.owner is UML.Classes.Kernel.Package)) { diagramElement = this.addToDiagram(element.owner); } } } return(diagramElement); }
/// <summary> /// creates subset tagged values for each of the tagged values that need to be synchronized. /// TODO: handle case where a single source element has multiple subset elements (e.g in case of inherited attributes) /// </summary> private void synchronizeTaggedValues() { foreach (var tuple in this.taggedValuesToSynchronize) { var sourceItem = tuple.Item1.tagValue; UML.Classes.Kernel.Element targetItem = null; if (sourceItem is TSF_EA.ElementWrapper) { targetItem = this.schemaElements.FirstOrDefault(x => x.sourceElement.Equals(sourceItem))?.subsetElement; } else if (sourceItem is TSF_EA.AttributeWrapper) { targetItem = getSubsetAttributeWrapper((TSF_EA.AttributeWrapper)sourceItem); } else if (tuple.Item1.tagValue is TSF_EA.ConnectorWrapper) { //get corresponding schema element targetItem = getSubsetConnector((TSF_EA.ConnectorWrapper)sourceItem); } if (targetItem != null) { //create the tagged value tuple.Item2.addTaggedValue(tuple.Item1.name, targetItem.uniqueID, null, true); } } //clear the taggedValues to be synchronized this.taggedValuesToSynchronize.Clear(); }
public static bool isItemUsedInASchema(UML.Classes.Kernel.Element element, TSF_EA.Model model) { var sqlGetCountSchemas = @"select count(*) as countresult from t_document d inner join t_object o on o.ea_guid = d.ElementID where d.DocType = 'SC_MessageProfile' " + $"and d.StrContent like '%{element.uniqueID}%'"; var resultXml = model.SQLQuery(sqlGetCountSchemas); var countNode = resultXml.SelectSingleNode(model.formatXPath("//countresult")); return(countNode.InnerText != "0"); }
/// <summary> /// returns the DiagramElement for the given element. /// Returns null if the element is not shown on this diagram /// </summary> /// <param name="element">the element that is used on this diagram</param> /// <returns>the diagramElement that represents the element shown on this diagram</returns> public UML.Diagrams.DiagramElement getDiagramElement(UML.Classes.Kernel.Element element) { if (element is ElementWrapper) { return(this.diagramObjectWrappers.FirstOrDefault(x => x.element != null && x.element.Equals(element))); } else if (element is ConnectorWrapper) { return(this.diagramLinkWrappers.FirstOrDefault(x => x.element != null && x.element.Equals(element))); } else { return(null); } }
/// <summary> /// indicates if the given element is shown on this diagram /// </summary> /// <param name="element">the element to look for</param> /// <returns>true if the given element is shown on this diagram, false otherwise</returns> public bool contains(UML.Classes.Kernel.Element element) { var elementWrapper = element as ElementWrapper; //check very quickly if this element is on the diagram if (elementWrapper != null) { string sqlContainsElement = "select 'true' AS ElementExists from t_diagramobjects do " + " where do.Diagram_ID = " + this.DiagramID + " and do.Object_ID = " + elementWrapper.id; var containsElementXml = this.model.SQLQuery(sqlContainsElement); var containsNode = containsElementXml.SelectSingleNode(this.model.formatXPath("//ElementExists")); return(containsNode != null && containsNode.InnerText == "true"); } //use the standard technique return(this.getDiagramElement(element) != null); }
/// <summary> /// returns the SchemaElement that corresponds with the given UML element /// </summary> /// <param name="umlElement">the source UMLElement</param> /// <returns></returns> internal EASchemaElement getSchemaElementForUMLElement(UML.Classes.Kernel.Element umlElement) { EASchemaElement result = null; foreach (EASchemaElement schemaElement in this.elements) { if (schemaElement.sourceElement != null && schemaElement.sourceElement.Equals(umlElement)) { if (result == null) { result = schemaElement; } else if (schemaElement.name == umlElement.name) { result = schemaElement; break; } } } return(result); }
public MappingLogic(TSF_EA.ElementWrapper wrappedElement, TSF_EA.ElementWrapper context) : this(context) { this.mappingElement = wrappedElement; }