private void checkContext(TSF_EA.ElementWrapper context) { // clean up for new context build-up this.clear(); this.notify("Please select a Data Item or Table"); this.context = null; this.syncButton.Enabled = false; this.addButton.Enabled = false; this.filterButton.Enabled = false; // validate context if (context != null && context is TSF_EA.Class) { TSF_EA.Class clazz = context as TSF_EA.Class; if (clazz.HasStereotype("Data Item") || clazz.HasStereotype("table")) { this.context = clazz; this.addButton.Enabled = true; this.filterButton.Enabled = true; this.hideNotifications(); } } this.refreshTree(); }
public static List <MappingLogic> getMappingLogicsFromString(string logicsString, TSF_EA.Model model) { var mappingLogics = new List <MappingLogic>(); if (!string.IsNullOrEmpty(logicsString)) { try { XDocument xdoc = XDocument.Load(new System.IO.StringReader(logicsString)); foreach (var logicNode in xdoc.Descendants("mappingLogic")) { string contextID = logicNode.Elements("context").FirstOrDefault()?.Value; TSF_EA.ElementWrapper contextElement = model.getElementWrapperByGUID(contextID); string description = logicNode.Elements("description").FirstOrDefault()?.Value; //only create mapping logic if the description exists, or the contextElement exists. if (!string.IsNullOrEmpty(description) || contextElement != null) { mappingLogics.Add(new MappingLogic(description, contextElement)); } } } catch (System.Xml.XmlException) { //no xml found, just plain text mappingLogics.Add(new MappingLogic(logicsString)); } } return(mappingLogics); }
private TSF_EA.Association GetCorrespondingAssociation(TSF_EA.ElementWrapper sourceElement, TSF_EA.ElementWrapper targetElement, string sourceName, string targetName) { //first set the first part: string sqlGetCorrespondingAssociation = @"select c.Connector_ID from t_connector c where c.Connector_Type in ('Association', 'Aggregation') and c.Start_Object_ID = " + sourceElement.id + Environment.NewLine + "and c.End_Object_ID = " + targetElement.id; if (!string.IsNullOrEmpty(targetName)) { //target role is filled in sqlGetCorrespondingAssociation += @" and c.DestRole = '" + targetName + "'"; } if (!string.IsNullOrEmpty(sourceName)) { //source role is filled in sqlGetCorrespondingAssociation += @" and c.SourceRole = '" + sourceName + "'"; } //add the part checking for the md_guid sqlGetCorrespondingAssociation += @" and not exists (select tv.PropertyID from t_connectortag tv where tv.ElementID = c.Connector_ID and tv.Property = 'md_guid' and tv.VALUE is not null)" ; var correspondingAssociation = this.model.getRelationsByQuery(sqlGetCorrespondingAssociation).FirstOrDefault() as TSF_EA.Association; return(correspondingAssociation); }
void setPartitionSizes(TSF_EA.ElementWrapper eaElement, MDDiagramObject mdDiagramObject) { var orderedSplits = mdDiagramObject.ownedSplits.OrderBy(x => x.y).ToList(); int i = 0; int previousY = mdDiagramObject.y; foreach (global::EA.Partition partition in eaElement.WrappedElement.Partitions) { //get the corresponding split int partitionSize = 0; if (orderedSplits.Count > i) { var currentSplit = orderedSplits[i]; //calculate the size of this partition partitionSize = currentSplit.y - previousY; } else { //set the size to the bottom of the fragment partitionSize = mdDiagramObject.bottom - previousY; } if (partitionSize > 0) { partition.Size = partitionSize; eaElement.isDirty = true; } //up the counter i++; } //save the changes to the partitions by saving the EAElement eaElement.save(); }
private TSF_EA.Association createNewCorrespondingAssociation(TSF_EA.ElementWrapper sourceElement, TSF_EA.ElementWrapper targetElement, MDAssociation mdAssociation) { //create the actual association TSF_EA.Association newAssociation = this.model.factory.createNewElement <TSF_EA.Association>(sourceElement, string.Empty); //set target class newAssociation.target = targetElement; //set source name newAssociation.sourceEnd.name = mdAssociation.source.name; newAssociation.sourceEnd.aggregation = parseAggregationKind(mdAssociation.source.aggregationKind); //set target name newAssociation.targetEnd.name = mdAssociation.target.name; newAssociation.targetEnd.aggregation = parseAggregationKind(mdAssociation.target.aggregationKind); //set the target end navigable by default newAssociation.targetEnd.isNavigable = true; if (mdAssociation.stereotype == "participates") { newAssociation.targetEnd.isNavigable = false; } //set the stereotype newAssociation.addStereotype(this.model.factory.createStereotype(newAssociation, mdAssociation.stereotype)); //save the new association newAssociation.save(); //return return(newAssociation); }
/// <summary> /// Writes an IL 'XRef' declaration for element at the current indentation level. /// </summary> /// <param name="name"></param> /// <param name="elementWrapper"></param> /// <returns>The TransformationILWriter instance for use in concatenated output.</returns> public TransformationILWriter GenerateXRef(string name, UML.Classes.Kernel.Element element) { UTF_EA.ElementWrapper elementWrapper = element as UTF_EA.ElementWrapper; if (elementWrapper != null) { string sourceGuid = GetElementGuid(elementWrapper); return(GenerateXRef(name, sourceGuid)); } return(this); }
private void addElementPropertiesToChildNodes(TSF_EA.ElementWrapper virtualElement) { //figure out the if we have virtual element var element = virtualElement != null ? virtualElement : this.sourceElement; if (element == null) { return; //failsafe } //create child nodes for each attribute foreach (TSF_EA.Attribute ownedAttribute in element.ownedAttributes) { if (!this.allChildNodes.Any(x => x.source?.uniqueID == ownedAttribute.uniqueID)) { var childNode = new AttributeMappingNode(ownedAttribute, this, this.settings, this.structure, virtualElement); } } //create child nodes for all enum values var sourceEnum = element as TSF_EA.Enumeration; if (sourceEnum != null) { foreach (var enumLiteral in sourceEnum.ownedLiterals) { if (!this.allChildNodes.Any(x => x.source?.uniqueID == enumLiteral.uniqueID)) { var childNode = new AttributeMappingNode((TSF_EA.AttributeWrapper)enumLiteral, this, this.settings, this.structure, virtualElement); } } } //create child nodes for each owned classifier foreach (TSF_EA.ElementWrapper ownedClassifier in element.ownedElements.OfType <UML.Classes.Kernel.Namespace>()) { if (!this.allChildNodes.Any(x => x.source?.uniqueID == ownedClassifier.uniqueID)) { var childNode = new ClassifierMappingNode(ownedClassifier, this, this.settings, this.structure, virtualElement); } } //create child nodes for each owned association foreach (var ownedAssociation in element.getRelationships <TSF_EA.Association>()) { if ((ownedAssociation.targetEnd.isNavigable && ownedAssociation.sourceElement.uniqueID == element.uniqueID || ownedAssociation.sourceEnd.isNavigable && ownedAssociation.targetElement.uniqueID == element.uniqueID) && !this.allChildNodes.Any(x => x.source?.uniqueID == ownedAssociation.uniqueID)) { var childNode = new AssociationMappingNode(ownedAssociation, this, this.settings, this.structure, virtualElement); } } //do the same for all superclasses foreach (var superClass in element.superClasses) { addElementPropertiesToChildNodes((TSF_EA.ElementWrapper)superClass); } }
private void generateJSONSchema(TSF_EA.ElementWrapper element) { EAOutputLogger.log(this.model, outputName , $"{DateTime.Now.ToLongTimeString()} Generating Schema for element '{element.name}'" , element.id , LogTypeEnum.log); var eaJsonSchema = new EAJSONSchema(element); //print the schema to the file eaJsonSchema.print(); }
public global::EA.DiagramObject getdiagramObjectForElement (ElementWrapper element) { foreach (global::EA.DiagramObject diagramObject in this.wrappedDiagram.DiagramObjects) { if (diagramObject.ElementID == element.wrappedElement.ElementID) { return(diagramObject); } } return(null); }
public override TSF.UmlToolingFramework.UML.Extended.UMLItem getItemFromRelativePath(List <string> relativePath) { UML.Extended.UMLItem item = null; List <string> filteredPath = new List <string>(relativePath); if (ElementWrapper.filterName(filteredPath, this.name)) { if (filteredPath.Count == 1) { item = this; } } return(item); }
/// <summary> /// add the given diagram to this diagram /// </summary> /// <param name="diagram">the diagram to add</param> /// <returns>the diagramElement representing the diagram</returns> public UML.Diagrams.DiagramElement addToDiagram(UML.Diagrams.Diagram diagram) { if (this.owner is ElementWrapper) { ElementWrapper elementDiagram = ((ElementWrapper)this.owner).addOwnedElement <ElementWrapper>(diagram.name, "UMLDiagram"); elementDiagram.save(); //to make the elementDiagram actuall link to the diagram we need to set PDATA1 to the diagramID // and NType = 0 for Frame or 1 for Reference this.model.executeSQL("update t_object set Ntype = 0, PDATA1 = " + ((Diagram)diagram).DiagramID.ToString() + " where ea_guid = '" + elementDiagram.WrappedElement.ElementGUID + "'"); return(this.addToDiagram(elementDiagram)); } else { return(null); } }
/// <summary> /// select this diagram in the current diagram /// </summary> public void selectInCurrentDiagram() { //TODO implement // get the diagramObject for an element with type "UMLDiagram" and where PDATA1 contain this diagramID string SQLSelect = @"select o.Object_ID from (t_object o inner join t_diagramobjects do on o.Object_ID = do.Object_ID) where o.[Object_Type] = 'UMLDiagram' and do.[Diagram_ID] = " + ((Diagram)this.model.currentDiagram).DiagramID.ToString() + @" and o.PDATA1 = '" + this.DiagramID.ToString() + "'"; ElementWrapper elementDiagram = this.model.getElementWrappersByQuery(SQLSelect).FirstOrDefault(); if (elementDiagram != null) { elementDiagram.selectInCurrentDiagram(); } }
/// <summary> /// returns the elementwrappers that are identified by the Object_ID's returned by the given query /// </summary> /// <param name="sqlQuery">query returning the Object_ID's</param> /// <returns>elementwrappers returned by the query</returns> public List <ElementWrapper> getElementWrappersByQuery(string sqlQuery) { // get the nodes with the name "ObjectID" XmlDocument xmlObjectIDs = this.SQLQuery(sqlQuery); XmlNodeList objectIDNodes = xmlObjectIDs.SelectNodes("//Object_ID"); List <ElementWrapper> elements = new List <ElementWrapper>(); foreach (XmlNode objectIDNode in objectIDNodes) { ElementWrapper element = this.getElementWrapperByID(int.Parse(objectIDNode.InnerText)); if (element != null) { elements.Add(element); } } return(elements); }
public MappingSet getMappingSet(TSF_EA.ElementWrapper sourceRoot) { if (sourceRoot == null) { return(null); } //get target mapping root TSF_EA.ElementWrapper targetRootElement = null; var targets = sourceRoot.taggedValues.Where(x => x.name == this.settings.linkedElementTagName && !x.comment.Contains("<isEmptyMapping>True</isEmptyMapping>")) .Select(x => x.tagValue) .OfType <TSF_EA.ElementWrapper>(); if (targets.Count() == 1) { targetRootElement = targets.First(); } else if (targets.Count() > 1) { //let the user select the trace element var selectTargetForm = new SelectTargetForm(); //set items selectTargetForm.setItems(targets); //show form var dialogResult = selectTargetForm.ShowDialog(this.model.mainEAWindow); if (dialogResult == DialogResult.Cancel) { return(null); } targetRootElement = selectTargetForm.selectedItem as TSF_EA.ElementWrapper; } //log progress this.clearOutput(); //log progress var startTime = DateTime.Now; EAOutputLogger.log($"Start loading mapping for {sourceRoot.name}", sourceRoot.id); //create the mapping set var mappingSet = EA_MP.MappingFactory.createMappingSet(sourceRoot, targetRootElement, this.settings); //log progress var endTime = DateTime.Now; var processingTime = (endTime - startTime).TotalSeconds; EAOutputLogger.log($"Finished loading mapping for {sourceRoot.name} in {processingTime.ToString("N0")} seconds", sourceRoot.id); return(mappingSet); }
createBehaviourStateMachineRegions(ElementWrapper elementWrapper) { HashSet <UML.StateMachines.BehaviorStateMachines.Region> newRegions = new HashSet <UML.StateMachines.BehaviorStateMachines.Region>(); // Get the owning element ElementWrapper owningElement = getOwningElement(elementWrapper); global::EA.Diagram masterDiagram = null; if (owningElement != null) { // Get the master state diagram from the owning element if available masterDiagram = getMasterStateDiagram(owningElement, elementWrapper.wrappedElement); } if (masterDiagram == null) { // Get the master state diagram from the current element if available masterDiagram = getMasterStateDiagram(elementWrapper, elementWrapper.wrappedElement); } if (elementWrapper.wrappedElement.Partitions.Count == 0) { // Check if the wrapped element contains any sub states if (elementWrapper.wrappedElement.IsComposite || elementWrapper.wrappedElement.Type == "StateMachine") { // Create an implicit default region UML.StateMachines.BehaviorStateMachines.Region defaultRegion = new BehaviorStateMachines.Region(this.model as Model, elementWrapper, masterDiagram, null); newRegions.Add(defaultRegion); } } else { // Create a region for all partitions of the wrapped element short regionPos = 0; foreach (global::EA.Partition partition in elementWrapper.wrappedElement.Partitions) { UML.StateMachines.BehaviorStateMachines.Region newRegion = new BehaviorStateMachines.Region(this.model as Model, elementWrapper, masterDiagram, partition, regionPos); newRegions.Add(newRegion); ++regionPos; } } return(newRegions); }
internal global::EA.Diagram getMasterStateDiagram(ElementWrapper elementWrapper, global::EA.Element stateChartElement) { foreach (global::EA.Diagram diagram in elementWrapper.wrappedElement.Diagrams) { // Just return the first state chart diagram found that contains the stateChartElement if (diagram.Type == "Statechart") { foreach (global::EA.DiagramObject diagramObject in diagram.DiagramObjects) { if (stateChartElement.ElementID == diagramObject.ElementID) { return(diagram); } } } } return(null); }
private TSF_EA.ElementWrapper getParentRootSource(TSF_EA.ElementWrapper element) { TSF_EA.ElementWrapper sourceRoot = null; //find parent package with root tagged value if (element.owningPackage != null) { if (element.owningPackage.taggedValues.Any(x => x.name == this.settings.linkedElementTagName && !x.comment.Contains("<isEmptyMapping>True</isEmptyMapping>") && x.tagValue is TSF_EA.ElementWrapper)) { sourceRoot = (TSF_EA.ElementWrapper)element.owningPackage; } else { //go up this.getParentRootSource((TSF_EA.ElementWrapper)element.owningPackage); } } return(sourceRoot); }
private void handleContextChange(TSF_EA.ElementWrapper context) { //only do something when visible var ownerTabControl = this.Parent as TabControl; if (ownerTabControl != null && ownerTabControl.SelectedTab == this) { if (context == null) { return; } //turn notify off to avoid endless loop this.notifyProjectBrowser = false; //only do something if another element is selected then the already selected element or if no item is selected if (!HasItemSelected || !context.Equals(this.Current.Origin)) { //deselect previous selected item if (this.selectedItem != null) { this.selectedItem.Selected = false; } //find the corresponsing item and select it foreach (ListViewItem item in this.itemsList.Items) { var glossaryItem = item.Tag as GlossaryItem; if (glossaryItem != null && context.Equals(glossaryItem.Origin)) { item.Selected = true; break; } } } //turn notify back on this.notifyProjectBrowser = true; } }
private MappingLogic(TSF_EA.ElementWrapper context) { this._context = context; }
public ElementMappingNode(TSF_EA.ElementWrapper sourceElement, MappingNode parent, MappingSettings settings, MP.ModelStructure structure, bool isTarget) : this(sourceElement, parent, settings, structure, null, isTarget) { }
private void handleContextChange(TSF_EA.ElementWrapper context) { this.checkContext(context); }
/// creates a new EAElementWrapper based on the given EA.Element internal ElementWrapper createEAElementWrapper (global::EA.Element elementToWrap) { //first check if this element already exists in the cache if (this.EAModel.useCache) { var elementWrapper = this.EAModel.getElementFromCache(elementToWrap.ElementID); if (elementWrapper != null) { return(elementWrapper); } } ElementWrapper newElementWrapper; switch (elementToWrap.Type) { case "Class": //first check if this isn't an enumeration. // Enumerations are stored as type Class but with the stereotype enumeration if (elementToWrap.StereotypeEx.Contains("enumeration")) { newElementWrapper = new Enumeration(this.model as Model, elementToWrap); break; } else { //check if associationclass //elementToWrap.IsAssocationClass() returns an exception when used in a background thread so we use our own method to figure out if its an associationClass. if (this.isAssociationClass(elementToWrap)) { newElementWrapper = new AssociationClass(this.model as Model, elementToWrap); break; } else { //just a regular class newElementWrapper = new Class(this.model as Model, elementToWrap); break; } } case "Enumeration": // since version 10 there are also "real" enumerations Both are still supported newElementWrapper = new Enumeration(this.model as Model, elementToWrap); break; case "Interface": newElementWrapper = new Interface(this.model as Model, elementToWrap); break; case "Note": newElementWrapper = new NoteComment(this.model as Model, elementToWrap); break; case "Action": // figure out wether this Action is a standard action or a // specialized action //elementToWrap.Properties; XmlDocument descriptionXml = ((Model)this.model).SQLQuery(@"SELECT x.Description FROM t_object o inner join t_xref x on x.Client = o.ea_guid where o.Object_ID = " + elementToWrap.ElementID.ToString()); XmlNodeList descriptionNodes = descriptionXml.SelectNodes(((EA.Model) this.model).formatXPath("//Description")); foreach (XmlNode descriptionNode in descriptionNodes) { if (descriptionNode.InnerText.Contains("CallOperation")) { newElementWrapper = new CallOperationAction(this.model as Model, elementToWrap); break; } } // simple Action newElementWrapper = new Action(this.model as Model, elementToWrap); break; case "Interaction": newElementWrapper = new Interaction(this.model as Model, elementToWrap); break; case "Activity": newElementWrapper = new Activity(this.model as Model, elementToWrap); break; case "StateMachine": newElementWrapper = new BehaviorStateMachines.StateMachine(this.model as Model, elementToWrap); break; case "State": newElementWrapper = new BehaviorStateMachines.State(this.model as Model, elementToWrap, null); break; case "StateNode": string metaType = elementToWrap.MetaType; if (metaType == "Pseudostate" || metaType == "Synchronisation") { newElementWrapper = new BehaviorStateMachines.PseudoState(this.model as Model, elementToWrap, null); break; } else if (metaType == "FinalState") { newElementWrapper = new BehaviorStateMachines.FinalState(this.model as Model, elementToWrap, null); break; } newElementWrapper = new ElementWrapper(this.model as Model, elementToWrap); break; case "Package": int packageID; if (int.TryParse(elementToWrap.MiscData[0], out packageID)) { newElementWrapper = ((Model)this.model).getElementWrapperByPackageID(packageID); break; } else { throw new Exception("WrappedElement " + elementToWrap.Name + " is not a package"); } case "DataType": case "PrimitiveType": //TODO: fix primitive type so it can handle this newElementWrapper = new DataType(this.model as Model, elementToWrap); break; case "InformationItem": newElementWrapper = new InformationItem(this.model as Model, elementToWrap); break; case "ProxyConnector": newElementWrapper = new ProxyConnector(this.model as Model, elementToWrap); break; case "Part": newElementWrapper = new Property(this.model as Model, elementToWrap); break; case "InteractionFragment": newElementWrapper = new InteractionFragment(this.model as Model, elementToWrap); break; default: newElementWrapper = new ElementWrapper(this.model as Model, elementToWrap); break; } //add the element to the cache if needed if (this.EAModel.useCache) { this.EAModel.addElementToCache(newElementWrapper); } return(newElementWrapper); }
public int getImageIndex(UML.UMLItem element) { int imageIndex; if (element is UML.Classes.Kernel.Property) { imageIndex = this.attributeIndex; } else if (element is UML.Classes.Kernel.Operation) { imageIndex = this.operationIndex; } else if (element is UML.Classes.Kernel.Package) { if (element.owner == null) { imageIndex = this.rootPackageIndex; } else { //packaging components are both components as packages. if (element is UTF_EA.ElementWrapper && ((UTF_EA.ElementWrapper)element).subType == "PackagingComponent") { imageIndex = this.packagingComponentIndex; } else { imageIndex = this.packageIndex; } } } else if (element is UML.Diagrams.Diagram) { if (element is UML.Diagrams.ActivityDiagram) { imageIndex = this.activityDiagramIndex; } else if (element is UML.Diagrams.ClassDiagram) { imageIndex = this.classDiagramIndex; } else if (element is UML.Diagrams.CommunicationDiagram) { imageIndex = this.communicationDiagramIndex; } else if (element is UML.Diagrams.ComponentDiagram) { imageIndex = this.componentDiagramIndex; } else if (element is UML.Diagrams.CompositeStructureDiagram) { imageIndex = this.compositeStructureDiagramIndex; } else if (element is UML.Diagrams.DeploymentDiagram) { imageIndex = this.deploymentDiagramIndex; } else if (element is UML.Diagrams.InteractionOverviewDiagram) { imageIndex = this.interactionOverviewDiagramIndex; } else if (element is UML.Diagrams.ObjectDiagram) { imageIndex = this.objectDiagramIndex; } else if (element is UML.Diagrams.PackageDiagram) { imageIndex = this.packageDiagramIndex; } else if (element is UML.Diagrams.SequenceDiagram) { imageIndex = this.sequenceDiagramIndex; } else if (element is UML.Diagrams.StateMachineDiagram) { imageIndex = this.stateMachineDiagramIndex; } else if (element is UML.Diagrams.TimingDiagram) { imageIndex = this.timingDiagramIndex; } else if (element is UML.Diagrams.UseCaseDiagram) { imageIndex = this.useCaseDiagramIndex; } else { // default diagram image imageIndex = this.diagramIndex; } } else if (element is UML.Interactions.BasicInteractions.Interaction) { imageIndex = this.interactionIndex; } else if (element is UML.StateMachines.BehaviorStateMachines.StateMachine) { imageIndex = this.stateMachineIndex; } else if (element is UML.Activities.FundamentalActivities.Activity) { imageIndex = this.activityIndex; } else if (element is UML.Classes.Kernel.PrimitiveType) { imageIndex = this.primitiveIndex; } else if (element is UML.Classes.Kernel.Relationship) { imageIndex = this.messagIndex; } else if (element is UML.Actions.BasicActions.Action) { imageIndex = this.actionIndex; } else if (element is UML.Classes.Kernel.Class) { imageIndex = this.classIndex; } else if (element is UML.Classes.Kernel.Parameter) { imageIndex = this.parameterIndex; } else if (element is UML.Profiles.TaggedValue) { UML.Profiles.TaggedValue taggedValue = (UML.Profiles.TaggedValue)element; if (taggedValue.owner is UML.Classes.Kernel.Property) { imageIndex = this.attributeTagIndex; } else if (taggedValue.owner is UML.Classes.Kernel.Operation) { imageIndex = this.operationTagIndex; } else if (taggedValue.owner is UML.Classes.Kernel.Parameter) { imageIndex = this.parameterTagIndex; } else if (taggedValue.owner is UML.Classes.Kernel.Relationship) { imageIndex = this.relationTagIndex; } else if (taggedValue.owner is UML.Classes.Kernel.Element) { imageIndex = this.elementTagIndex; } else { imageIndex = this.taggedValueIndex; } } else if (element is UML.Classes.Kernel.Enumeration) { imageIndex = this.enumerationIndex; } else if (element is UML.Classes.Kernel.DataType) { imageIndex = this.dataTypeIndex; } else if (element is UML.Classes.Interfaces.Interface) { imageIndex = this.interfaceIndex; } else if (element is TSF.UmlToolingFramework.Wrappers.EA.ElementWrapper) { //workaround to be able to display the correct icon, even if the element type hasn't been implemented in the UMLTooling Framework, of in case of EA specific element types such as requirement. TSF.UmlToolingFramework.Wrappers.EA.ElementWrapper elementWrapper = (TSF.UmlToolingFramework.Wrappers.EA.ElementWrapper)element; switch (elementWrapper.subType) { case "Signal": imageIndex = this.signalIndex; break; case "Association": imageIndex = this.associationElementIndex; break; case "PackagingComponent": imageIndex = this.packagingComponentIndex; break; case "Component": imageIndex = this.componentIndex; break; case "ProvidedInterface": imageIndex = this.providedInterfaceIndex; break; case "RequiredInterface": imageIndex = this.requiredInterfaceIndex; break; case "Object": imageIndex = this.objectIndex; break; case "Port": imageIndex = this.portIndex; break; case "Artifact": imageIndex = this.artifactIndex; break; case "Part": imageIndex = this.partIndex; break; case "Collaboration": case "CollaborationOccurrence": imageIndex = this.collaborationIndex; break; case "Node": case "Device": case "ExecutionEnvironment": imageIndex = this.nodeIndex; break; case "DeploymentSpecification": imageIndex = this.deploymentSpecificationIndex; break; case "InformationItem": imageIndex = this.informationItemIndex; break; case "Actor": imageIndex = this.actorIndex; break; case "UseCase": imageIndex = this.usecaseIndex; break; case "Boundary": imageIndex = this.boundaryIndex; break; case "ActivityPartition": imageIndex = this.activityPartitionIndex; break; case "CentralBufferNode": imageIndex = this.classIndex; break; case "Decision": case "MergeNode": case "StateChoice": imageIndex = this.decisionIndex; break; case "Event": imageIndex = this.eventIndex; break; case "ActivityInitial": case "StateInitial": case "StateJunction": imageIndex = this.activityInitialIndex; break; case "ActivityFinal": case "StateFinal": imageIndex = this.activityFinalIndex; break; case "FlowFinal": case "StateExitPoint": case "StateTerminate": imageIndex = this.flowFinalNodeIndex; break; case "SynchronisationNode": imageIndex = this.synchronisationNodeIndex; break; case "InterruptibleActivityRegion": imageIndex = this.interuptableActivityRegionIndex; break; case "ExpansionRegion": imageIndex = this.expansionRegionIndex; break; case "ExceptionHandler": imageIndex = this.exceptionHandlerIndex; break; case "ObjectNode": imageIndex = this.objectNodeIndex; break; case "Synchronization": imageIndex = this.synchronizationIndex; break; case "Sequence": imageIndex = this.lifeLineIndex; break; case "MessageEndpoint": imageIndex = this.gateIndex; break; case "InteractionFragment": imageIndex = this.fragmentIndex; break; case "InteractionState": imageIndex = this.interactionStateIndex; break; case "State": imageIndex = this.stateIndex; break; case "StateHistory": case "StateEntryPoint": imageIndex = this.entryPointIndex; break; case "TimeLine": imageIndex = this.timeLineIndex; break; case "Requirement": imageIndex = this.requirementIndex; break; case "Feature": imageIndex = this.featureIndex; break; case "Risk": imageIndex = this.riskIndex; break; case "Issue": imageIndex = this.issueIndex; break; case "Change": imageIndex = this.changeIndex; break; case "Screen": imageIndex = this.screenIdex; break; case "GUIElement": imageIndex = this.uiControlIndex; break; case "Note": imageIndex = this.noteIndex; break; case "Constraint": imageIndex = this.constraintIndex; break; case "Text": imageIndex = this.textIndex; break; case "Legend": imageIndex = this.legendIndex; break; case "DiagramNotes": imageIndex = this.diagramNotesIndex; break; case "Hyperlink": imageIndex = this.hyperlinkIndex; break; default: imageIndex = this.elementIndex; break; } } else { imageIndex = this.elementIndex; } return(imageIndex); }
public void selectItem(UML.Extended.UMLItem itemToSelect) { if (itemToSelect is Operation) { bool found = false; //if the item is a relation or an operation then search through the links first foreach (DiagramLinkWrapper diagramLinkWrapper in this.diagramLinkWrappers) { if (itemToSelect is Operation && diagramLinkWrapper.relation is Message) { Message message = (Message)diagramLinkWrapper.relation; if (itemToSelect.Equals(message.calledOperation)) { this.wrappedDiagram.SelectedConnector = message.wrappedConnector; found = true; //done, no need to loop further break; } } } //The operation could also be called in an Action. if (!found) { List <UML.Actions.BasicActions.CallOperationAction> actions = ((Operation)itemToSelect).getDependentCallOperationActions().ToList(); List <UML.Diagrams.DiagramElement> diagramObjects = this.diagramObjectWrappers.ToList(); foreach (Action action in actions) { //try to find an diagramObjectwrapper that refrences the action UML.Diagrams.DiagramElement diagramObject = diagramObjects.Find( x => x.element.Equals(action)); if (diagramObject != null) { //found it, select the action and break out of for loop this.selectItem(action); found = true; break; } } } if (!found) { //can't find a message on this diagram that calls the operation. //then we try it with the operations parent this.selectItem(((Operation)itemToSelect).owner); } } else if (itemToSelect is ConnectorWrapper) { this.wrappedDiagram.SelectedConnector = ((ConnectorWrapper)itemToSelect).wrappedConnector; //check if it worked if (wrappedDiagram.SelectedConnector == null && itemToSelect is Message) { this.selectItem(((Message)itemToSelect).calledOperation); } } else if (itemToSelect is ElementWrapper) { ElementWrapper elementToSelect = (ElementWrapper)itemToSelect; this.wrappedDiagram.SelectedObjects.AddNew(elementToSelect.wrappedElement.ElementID.ToString(), elementToSelect.wrappedElement.Type); } }
public ElementMappingNode(TSF_EA.ElementWrapper sourceElement, MappingNode parent, MappingSettings settings, MP.ModelStructure structure, UML.Classes.Kernel.NamedElement virtualOwner, bool isTarget) : base(sourceElement, parent, settings, structure, virtualOwner, isTarget) { }
public DiagramObjectWrapper(Model model, ElementWrapper element, Diagram diagram) : this(model, diagram.getdiagramObjectForElement(element)) { }
public void handleDiagramObjectCreation(Repository repository, int elementID, int diagramID, string DUID) { try { changed = false; EA.Element el = repository.GetElementByID(elementID); EA.Diagram diag = repository.GetDiagramByID(diagramID); Wrapper.Diagram diagram = new Wrapper.Diagram(model, diag); Wrapper.ElementWrapper elWrapper = new Wrapper.ElementWrapper(model, el); DiagramObject cur = diagram.getdiagramObjectForElement(elWrapper); string coordinates = ""; coordinates += "l=" + cur.left + ";"; coordinates += "r=" + cur.right + ";"; coordinates += "t=" + cur.top + ";"; coordinates += "b=" + cur.bottom + ";"; currentDiagramObjectPositions.Add(cur.ElementID, coordinates); ItemCreation itemCreation = new ItemCreation(); itemCreation.modelGUID = model.getWrappedModel().GetPackageByID(1).PackageGUID; itemCreation.itemGUID = el.ElementGUID; itemCreation.diagramGUID = diag.DiagramGUID; itemCreation.elementType = 700; itemCreation.coordinates = ""; for (short i = 0; i < diag.DiagramObjects.Count; i++) { EA.DiagramObject diagramObject = (EA.DiagramObject)diag.DiagramObjects.GetAt(i); if (diagramObject.ElementID == el.ElementID) { coordinates = ""; coordinates += "l=" + diagramObject.left + ";"; coordinates += "r=" + diagramObject.right + ";"; coordinates += "t=" + diagramObject.top + ";"; coordinates += "b=" + diagramObject.bottom + ";"; itemCreation.coordinates = coordinates; break; } } changeService.saveChange(itemCreation); } catch (Exception ex) { } }
/// <summary> /// method moves diagram object of element in diagram /// </summary> /// <param name="Repository">EA repository</param> /// <param name="elementGUID">GUID of element which diagram object that should be moved belongs to</param> /// <param name="diagramGUID">GUID of diagram</param> /// <param name="coordinates">new coordinates of diagram object that should be moved</param> public void moveElementInDiagram(EA.Repository Repository, string elementGUID, string diagramGUID, string coordinates) { EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID); EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID); int left, right, top, bottom, pocet = 0; Wrapper.Diagram diagramWrapper = new Wrapper.Diagram(model, diagram); Wrapper.ElementWrapper elWrapper = new Wrapper.ElementWrapper(model, element); EA.DiagramObject diagramObject = diagramWrapper.getdiagramObjectForElement(elWrapper); string[] coordinate; string str; string[] parts = coordinates.Split(';'); str = parts[0]; coordinate = str.Split('='); diagramObject.left = Convert.ToInt32(coordinate[1]); left = Convert.ToInt32(coordinate[1]); str = parts[1]; coordinate = str.Split('='); diagramObject.right = Convert.ToInt32(coordinate[1]); right = Convert.ToInt32(coordinate[1]); str = parts[2]; coordinate = str.Split('='); diagramObject.top = Convert.ToInt32(coordinate[1]); top = Convert.ToInt32(coordinate[1]); str = parts[3]; coordinate = str.Split('='); diagramObject.bottom = Convert.ToInt32(coordinate[1]); bottom = Convert.ToInt32(coordinate[1]); for (short i = 0; i < diagram.DiagramObjects.Count; i++) { EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i); EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID); if (diagramObj.left >= left && diagramObj.right <= right && diagramObj.top <= top && diagramObj.bottom >= bottom) { if (diagramObj.ElementID != diagramObject.ElementID) { pocet++; } } } diagramObject.Sequence = 1 + pocet; diagramObject.Update(); for (short i = 0; i < diagram.DiagramObjects.Count; i++) { EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i); EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID); if (diagramObj.left <= left && diagramObj.right >= right && diagramObj.top >= top && diagramObj.bottom <= bottom) { if (diagramObj.ElementID != diagramObject.ElementID) { diagramObj.Sequence += 1; diagramObj.Update(); } } } int parentID = diagram.ParentID; EA.Package package = (EA.Package)Repository.GetPackageByID(diagram.PackageID); if (parentID == 0) { BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" + diagram.Name + "' (Location of diagram: package '" + package.Name + "')"); } else { EA.Element parent = (EA.Element)Repository.GetElementByID(parentID); BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" + diagram.Name + "' (Location of diagram: element '" + parent.Name + "' in package '" + package.Name + "')"); } diagram.DiagramObjects.Refresh(); }
public MappingLogic(string logicDescription, TSF_EA.ElementWrapper context = null) : this(context) { _description = logicDescription; }
public MappingLogic(TSF_EA.ElementWrapper wrappedElement, TSF_EA.ElementWrapper context) : this(context) { this.mappingElement = wrappedElement; }
private string GetElementGuid(UTF_EA.ElementWrapper elementWrapper) { return(elementWrapper.WrappedElement.ElementGUID); }
public MappingSet getMappingSet(TSF_EA.ElementWrapper sourceRoot) { if (sourceRoot == null) { return(null); } //find the actual source root and target roots var tagComments = sourceRoot.taggedValues.Where(x => (x.name == this.settings.linkedElementTagName || x.name == this.settings.linkedAssociationTagName || x.name == this.settings.linkedAttributeTagName) && x.comment.Contains("<mappingSet>")) .Select(x => x.comment); var mappingSets = new List <MappingSet>(); foreach (var tagComment in tagComments) { var xdoc = XDocument.Load(new StringReader(tagComment)); //get source root var actualSourceRootID = xdoc.Descendants(EA_MP.MappingFactory.mappingSetName).FirstOrDefault()? .Descendants(EA_MP.MappingFactory.mappingSetSourceName).FirstOrDefault()?.Value ?? string.Empty; var actualSourceRoot = this.model.getElementByGUID(actualSourceRootID) as TSF_EA.ElementWrapper; //get target root var actualTargetRootID = xdoc.Descendants(EA_MP.MappingFactory.mappingSetName).FirstOrDefault()? .Descendants(EA_MP.MappingFactory.mappingSetTargetName).FirstOrDefault()?.Value ?? string.Empty; var actualtargetRoot = this.model.getElementByGUID(actualTargetRootID) as TSF_EA.ElementWrapper; if (actualSourceRoot != null && actualtargetRoot != null) { //create the mappingSet var foundMappingSet = EA_MP.MappingFactory.createMappingSet(actualSourceRoot, actualtargetRoot, this.settings); //add to list mappingSets.Add(foundMappingSet); } } MappingSet mappingSet = null; if (mappingSets.Any()) { if (mappingSets.Count == 1) { mappingSet = mappingSets.First(); } else { //let the user select the trace element var selectTargetForm = new SelectTargetForm(); //set items var targets = mappingSets.Select(x => x.target.source); selectTargetForm.setItems(targets); //show form var dialogResult = selectTargetForm.ShowDialog(this.model.mainEAWindow); if (dialogResult == DialogResult.Cancel) { return(null); } var targetRootElement = selectTargetForm.selectedItem as TSF_EA.ElementWrapper; //get corresponding mapping set mappingSet = mappingSets.First(x => x.target.source == targetRootElement); } } else { //go up in the hierarchy to find an element that is a source root for a mapping var parentSourceRoot = this.getParentRootSource(sourceRoot); //TODO load only part of the mapping if (parentSourceRoot != null) { return(this.getMappingSet(parentSourceRoot)); } } //log progress this.clearOutput(); //log progress var startTime = DateTime.Now; EAOutputLogger.log($"Start loading mapping for {sourceRoot.name}", sourceRoot.id); //create the mapping set mappingSet.loadAllMappings(); //log progress var endTime = DateTime.Now; var processingTime = (endTime - startTime).TotalSeconds; EAOutputLogger.log($"Finished loading mapping for {sourceRoot.name} in {processingTime.ToString("N0")} seconds", sourceRoot.id); return(mappingSet); }