private static void onNotifyTGGOutermostPackageModified(SQLRepository sqlRepository, EA.Package pkg) { TGG tgg = new TGG(sqlRepository, sqlRepository.GetPackageByID(pkg.PackageID)); tgg.loadTreeFromTaggedValue(); tgg.saveTreeToEATaggedValue(true); }
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); } }
private void buttonImportCSP_Click(object sender, EventArgs e) { checkForFunctions(); if (activateExportImportCSPButton) { String pathToWrite = Path.GetDirectoryName(repository.ConnectionString); OpenFileDialog dialog = new OpenFileDialog(); dialog.AddExtension = true; dialog.DefaultExt = "txt"; dialog.InitialDirectory = pathToWrite; dialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; dialog.FileName = "csptemp.txt"; if (dialog.ShowDialog() == DialogResult.OK) { TGG tggPackage = new TGG(repository, repository.GetTreeSelectedPackage()); tggPackage.loadTreeFromTaggedValue(); String fileContent = File.ReadAllText(dialog.FileName); MocaNode dummyParent = MocaTreeUtil.mocaNodeFromXmlString(fileContent); foreach (MocaNode cspNode in dummyParent.Children) { CSPConstraint constraint = new CSPConstraint(); constraint.deserializeFromMocaTree(cspNode); Boolean alreadyIn = false; foreach (CSPConstraint existingCSP in tggPackage.Constraints) { if (existingCSP.Name == constraint.Name) { alreadyIn = true; break; } } if (!alreadyIn) { tggPackage.Constraints.Add(constraint); } } tggPackage.saveTreeToEATaggedValue(false); } } }
private void okButton_Click(object sender, EventArgs e) { if (this.selectedSourceMetamodel != null && this.selectedTargetMetamodel != null) { //create rule package if (newTGGProject.Packages.Count == 0) { EA.Package rulesPackage = newTGGProject.getRealPackage().Packages.AddNew("Rules", TGGModelingMain.TggRulePackageStereotype) as EA.Package; rulesPackage.Update(); TGGRulePackage rPackage = new TGGRulePackage(repository.GetPackageByID(rulesPackage.PackageID), repository); rPackage.saveTreeToEATaggedValue(true); EA.Diagram rulesDiagram = rulesPackage.Diagrams.AddNew("Rules", TGGModelingMain.TggRulesDiagramMetatype[0]) as EA.Diagram; rulesDiagram.Update(); newTGGProject.Packages.Refresh(); } Metamodel sourceMetamodel = new Metamodel(repository, this.selectedSourceMetamodel); Metamodel targetMetamodel = new Metamodel(repository, this.selectedTargetMetamodel); Metamodel correspondenceMetamodel = new Metamodel(repository, repository.GetPackageByID(newTGGProject.PackageID)); Domain sourceDomain = new Domain(sourceMetamodel, DomainType.SOURCE); Domain targetDomain = new Domain(targetMetamodel, DomainType.TARGET); Domain correspondenceDomain = new Domain(correspondenceMetamodel, DomainType.CORRESPONDENCE); tgg.Metamodels.Clear(); tgg.Domains.Clear(); tgg.Metamodels.Add(sourceMetamodel); tgg.Metamodels.Add(targetMetamodel); tgg.Metamodels.Add(correspondenceMetamodel); tgg.Domains.Add(sourceDomain); tgg.Domains.Add(targetDomain); tgg.Domains.Add(correspondenceDomain); tgg.EaPackage.getRealPackage().Name = textBoxName.Text; tgg.saveTreeToEATaggedValue(true); Close(); } }
internal override void saveConstraintContainer() { tgg.saveTreeToEATaggedValue(true); }