コード例 #1
0
        private void createRuleElementAndRuleDiagram()
        {
            this.newRuleElement            = rulesPackage.Elements.AddNew(this.textBoxRuleName.Text, "Class") as EA.Element;
            this.newRuleElement.Stereotype = TGGModelingMain.TggRuleStereotype;
            this.newRuleElement.Update();

            EA.Diagram rulesDiagram = rulesPackage.Diagrams.GetAt(0) as EA.Diagram;

            EA.DiagramObject newRuleDiagramObject = rulesDiagram.DiagramObjects.AddNew("", this.newRuleElement.Type) as EA.DiagramObject;
            if (this.addInheritanceLinkCheckBox.Checked)
            {
                EA.DiagramObject originalRuleDiagramObject = null;
                foreach (EA.DiagramObject diagramObject in rulesDiagram.DiagramObjects)
                {
                    if (diagramObject.ElementID == this.originalRuleElement.ElementID)
                    {
                        originalRuleDiagramObject = diagramObject;
                        break;
                    }
                }
                if (originalRuleDiagramObject != null)
                {
                    int verticalOffset = -(originalRuleDiagramObject.top - originalRuleDiagramObject.bottom + 40);
                    newRuleDiagramObject.left   = originalRuleDiagramObject.left - 10;
                    newRuleDiagramObject.right  = originalRuleDiagramObject.right + 10;
                    newRuleDiagramObject.top    = originalRuleDiagramObject.top + verticalOffset;
                    newRuleDiagramObject.bottom = originalRuleDiagramObject.bottom + verticalOffset;
                }
            }
            else
            {
                newRuleDiagramObject.left   = 10;
                newRuleDiagramObject.right  = 110;
                newRuleDiagramObject.top    = -10;
                newRuleDiagramObject.bottom = -80;
            }
            newRuleDiagramObject.ElementID = this.newRuleElement.ElementID;
            newRuleDiagramObject.Update();

            if (this.addInheritanceLinkCheckBox.Checked)
            {
                addInheritanceLinkToOriginalRule();
            }

            repository.ReloadDiagram(rulesDiagram.DiagramID);

            newRuleDiagram = newRuleElement.Diagrams.AddNew(this.textBoxRuleName.Text, TGGModelingMain.TggRuleDiagramMetatype[0]) as EA.Diagram;
            newRuleDiagram.Update();


            TGGRule rule = new TGGRule(repository, repository.GetElementByID(newRuleElement.ElementID));

            rule.saveTreeToEATaggedValue(true);
        }
コード例 #2
0
        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);
            }
        }