private void importCorrespondenceType(SQLPackage parentPackage, MocaNode eClassNode) { EClass eclass = MainImport.getInstance().EcoreImport.importEClass(parentPackage, eClassNode); MainImport.getInstance().MocaTaggableElements.Remove(eclass); eclass = new TGGCorrespondenceType(eclass.EaElement, sqlRep); eclass.deserializeFromMocaTree(eClassNode); MainImport.getInstance().MocaTaggableElements.Add(eclass); }
private void updateMocaTreeFragments() { // For all packages (recursively!) in TGG and Ecore projects foreach (EA.Package p in EAUtil.findAllMoflonPackages(repository)) { SQLPackage p2 = sqlRep.GetPackageByID(p.PackageID); if (p.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype) { TGG tgg = new TGG(sqlRep, p2); tgg.loadTreeFromTaggedValue(); tgg.saveTreeToEATaggedValue(false); } else if (p.Element.Stereotype == TGGModelingMain.TggRulePackageStereotype) { TGGRulePackage package = new TGGRulePackage(p2, sqlRep); package.loadTreeFromTaggedValue(); package.saveTreeToEATaggedValue(false); } else { EPackage package = new EPackage(p2, sqlRep); package.loadTreeFromTaggedValue(); package.saveTreeToEATaggedValue(false); } } foreach (EA.Element eClassElement in EAUtil.findAllEClasses(repository)) { EClass eClass = new EClass(sqlRep.GetElementByID(eClassElement.ElementID), sqlRep); eClass.saveTreeToEATaggedValue(false); } foreach (EA.Element ruleElement in EAUtil.findAllStereotypedElements(repository, TGGModelingMain.TggRuleStereotype)) { TGGRule rule = new TGGRule(sqlRep, sqlRep.GetElementByID(ruleElement.ElementID)); rule.loadTreeFromTaggedValue(); rule.saveTreeToEATaggedValue(false); } foreach (EA.Element corrTypeElement in EAUtil.findAllStereotypedElements(repository, TGGModelingMain.TggCorrespondenceTypeStereotype)) { TGGCorrespondenceType corrType = new TGGCorrespondenceType(sqlRep.GetElementByID(corrTypeElement.ElementID), sqlRep); corrType.loadTreeFromTaggedValue(); corrType.saveTreeToEATaggedValue(false); } }
public void processTGGCorrespondenceType(SQLElement eaClass) { SQLTaggedValue mocaTreeTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(eaClass, Main.MoflonExportTreeTaggedValueName); TGGCorrespondenceType tggCorrType = new TGGCorrespondenceType(eaClass, repository); tggCorrType.loadTreeFromTaggedValue(); MocaNode eClassMocaNode = new MocaNode(); eClassMocaNode.deserializeFromXmlTree(MocaTreeUtil.stringToXmlDocument(mocaTreeTag.Notes).DocumentElement.FirstChild as XmlElement); tggCorrType.addMocaAttributesDuringExport(eClassMocaNode); this.currentNode.appendChildNode(eClassMocaNode); foreach (SQLConnector ereference in eaClass.Connectors) { if (ereference.Type == Main.EAAssociationType) { MocaNode referencesNode = eClassMocaNode.getChildNodeWithName(EClass.ReferencesChildNodeName); if (ereference.ClientID != eaClass.ElementID && ereference.ClientEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.ClientEnd.End); } else if (ereference.SupplierID != eaClass.ElementID && ereference.SupplierEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.SupplierEnd.End); } if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.SupplierEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.SupplierEnd.End); } if (ereference.SupplierID == eaClass.ElementID && ereference.ClientID == eaClass.ElementID && ereference.ClientEnd.IsNavigable) { this.currentNode = referencesNode; processTggEReference(ereference, ereference.ClientEnd.End); } } } }
private EA.Element createNewCorrespondenceLink(EA.Package tggOutermostePackage, out EA.Connector connectorToSource, out EA.Connector connectorToTarget) { EA.Element tggLink = tggOutermostePackage.Elements.AddNew(textBoxLinkName.Text, Main.EAClassType) as EA.Element; tggLink.StereotypeEx = TGGModelingMain.TggCorrespondenceTypeStereotype; tggLink.Update(); TGGCorrespondenceType correspondenceType = new TGGCorrespondenceType(sqlRepository.GetElementByID(tggLink.ElementID), sqlRepository); correspondenceType.saveTreeToEATaggedValue(false); connectorToSource = tggLink.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector; connectorToSource.SupplierID = clientClassifier.ElementID; connectorToSource.Direction = Main.EASourceTargetDirection; connectorToSource.SupplierEnd.Role = "source"; connectorToSource.SupplierEnd.Navigable = "Navigable"; connectorToSource.SupplierEnd.Cardinality = "1"; connectorToSource.SupplierEnd.IsNavigable = true; connectorToSource.Update(); EReference refToSource = new EReference(sqlRepository.GetConnectorByID(connectorToSource.ConnectorID), sqlRepository); refToSource.saveTreeToEATaggedValue(true); tggLink.Connectors.Refresh(); connectorToTarget = tggLink.Connectors.AddNew("", ECOREModelingMain.EReferenceConnectorType) as EA.Connector; connectorToTarget.SupplierID = supplierClassifier.ElementID; connectorToTarget.Direction = Main.EASourceTargetDirection; connectorToTarget.SupplierEnd.Role = "target"; connectorToTarget.SupplierEnd.Cardinality = "1"; connectorToTarget.SupplierEnd.Navigable = "Navigable"; connectorToTarget.SupplierEnd.IsNavigable = true; connectorToTarget.Update(); EReference refToTarget = new EReference(sqlRepository.GetConnectorByID(connectorToTarget.ConnectorID), sqlRepository); refToTarget.saveTreeToEATaggedValue(true); selectedCorrespondenceLinkId = tggLink.ElementID; EA.Diagram curDiagram = null; EA.DiagramObject sourceDiagObj = null; EA.DiagramObject targetDiagObj = null; foreach (EA.Diagram diag in tggOutermostePackage.Diagrams) { foreach (EA.DiagramObject diagObj in diag.DiagramObjects) { if (diagObj.ElementID == clientClassifier.ElementID) { sourceDiagObj = diagObj; } else if (diagObj.ElementID == supplierClassifier.ElementID) { targetDiagObj = diagObj; } if (sourceDiagObj != null && targetDiagObj != null) { curDiagram = diag; } } } if (curDiagram != null) { sqlRepository.SaveDiagram(curDiagram.DiagramID); int sourceLeft = (sourceDiagObj == null) ? 0 : sourceDiagObj.left; int sourceRight = (sourceDiagObj == null) ? 0 : sourceDiagObj.right; int sourceBottom = (sourceDiagObj == null) ? 0 : sourceDiagObj.bottom; int sourceTop = (sourceDiagObj == null) ? 0 : sourceDiagObj.top; int targetLeft = (targetDiagObj == null) ? 0 : targetDiagObj.left; int targetRight = (targetDiagObj == null) ? 0 : targetDiagObj.right; int targetBottom = (targetDiagObj == null) ? 0 : targetDiagObj.bottom; int targetTop = (targetDiagObj == null) ? 0 : targetDiagObj.top; EA.DiagramObject tggLinkDiagObj = curDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject; tggLinkDiagObj.ElementID = tggLink.ElementID; tggLinkDiagObj.Update(); tggLinkDiagObj.left = (sourceLeft + targetLeft) / 2; tggLinkDiagObj.right = (sourceRight + targetRight) / 2; tggLinkDiagObj.bottom = (sourceBottom + targetBottom) / 2; tggLinkDiagObj.top = (sourceTop + targetTop) / 2; tggLinkDiagObj.Update(); curDiagram.DiagramObjects.Refresh(); sqlRepository.ReloadDiagram(curDiagram.DiagramID); tggOutermostePackage.Elements.Refresh(); } return(tggLink); }
private static void onNotifyCorrespondenceTypeModified(SQLRepository sqlRepository, EA.Element element) { TGGCorrespondenceType correspondenceType = new TGGCorrespondenceType(sqlRepository.GetElementByID(element.ElementID), sqlRepository); correspondenceType.saveTreeToEATaggedValue(false); }