Esempio n. 1
0
        private void mergeDiagrams(EA.Repository repository, EA.Package package)
        {
            Dictionary <int, EA.DiagramObject> dobjects = new Dictionary <int, EA.DiagramObject>();
            Dictionary <int, EA.DiagramLink>   dlinks   = new Dictionary <int, EA.DiagramLink>();

            foreach (EA.Diagram diagram in package.Diagrams)
            {
                foreach (EA.DiagramObject dobject in diagram.DiagramObjects)
                {
                    dobjects[dobject.ElementID] = dobject;
                }
                foreach (EA.DiagramLink dlink in diagram.DiagramLinks)
                {
                    dlinks[dlink.ConnectorID] = dlink;
                }
            }

            EA.Diagram mdiagram = (EA.Diagram)package.Diagrams.AddNew(string.Format("{0} (Merged)", package.Name), "Custom");
            mdiagram.Update();

            // copy objects
            int       left    = 10;
            int       top     = 10;
            const int width   = 100;
            const int height  = 80;
            const int padding = 10;

            foreach (EA.DiagramObject dobject in dobjects.Values)
            {
                EA.Element element = repository.GetElementByID(dobject.ElementID);
                if ("Boundary".Equals(element.Type))
                {
                    continue;
                }

                string dimensions = string.Format("l={0};r={1};t={2};b={3};", left, left + width, top, top + height);
                left += padding + width;
                EA.DiagramObject mobject = (EA.DiagramObject)mdiagram.DiagramObjects.AddNew(dimensions, "");
                mobject.ElementID = element.ElementID;
                mobject.Update();

                if (left == 1000)
                {
                    left = 10;
                    top += height;
                }
            }
            mdiagram.Update();

            // copy links (o.a. NoteLinks)
            foreach (EA.DiagramLink dlink in dlinks.Values)
            {
                EA.DiagramLink mlink = (EA.DiagramLink)mdiagram.DiagramLinks.AddNew("", "");
                mlink.ConnectorID = dlink.ConnectorID;
                mlink.Update();
            }

            package.Update();
            repository.OpenDiagram(mdiagram.DiagramID);
        }
Esempio n. 2
0
        private EA.Diagram CreateDiagramFromElement(EA.Element element)
        {
            EA.Diagram diagram = (EA.Diagram)element.Diagrams.AddNew(element.Name, "Requirements");
            diagram.Update();

            EA.DiagramObject fobj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(string.Format("l={0};r={1};t={2};b={3}", 10, 630, 10, 110), "");
            fobj.ElementID = element.ElementID;
            fobj.Update();

            int       left    = 10;
            int       top     = 210;
            const int width   = 200;
            const int height  = 100;
            const int padding = 10;

            foreach (EA.Element subElement in element.Elements)
            {
                string           dimensions = string.Format("l={0};r={1};t={2};b={3};", left, left + width, top, top + height);
                EA.DiagramObject obj        = (EA.DiagramObject)diagram.DiagramObjects.AddNew(dimensions, "");
                obj.ElementID = subElement.ElementID;
                obj.Update();

                left += width + padding;
                if (left > 600)
                {
                    left = 10;
                    top += height + padding;
                }
            }
            diagram.Update();
            return(diagram);
        }
Esempio n. 3
0
        // private static void appendTaggedValue()

        #endregion

        #region addDiagram methods

        private static void appendDiagram(EA.Package parentPackage, String diagramMetaType, EA.Repository repository)
        {
            if (parentPackage.Diagrams.Count == 0)
            {
                EA.Diagram diag = parentPackage.Diagrams.AddNew(parentPackage.Name, "") as EA.Diagram;
                diag.Update();
                diag.StyleEx = "MDGDgm=" + "eMoflon Ecore Diagrams::Ecore Diagram" + ";";
                diag.Update();
                repository.Execute("UPDATE t_diagram SET Diagram_Type='" + diagramMetaType + "' WHERE Diagram_ID=" + diag.DiagramID);
                MainImport.getInstance().DiagramsToBeFilled.Add(diag);
            }
        }
Esempio n. 4
0
        public static void VisualizePortForDiagramobject(int pos, EA.Diagram dia, EA.DiagramObject diaObjSource, EA.Element port, EA.Element interf)
        {
            // check if port already exists
            foreach (EA.DiagramObject diaObj in dia.DiagramObjects)
            {
                if (diaObj.ElementID == port.ElementID)
                {
                    return;
                }
            }

            // visualize ports
            int length = 6;
            // calculate target position
            int left  = diaObjSource.right - length / 2;
            int right = left + length;
            int top   = diaObjSource.top;

            top = top - 10 - pos * 10;
            int    bottom    = top - length;
            string position  = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
            var    diaObject = (EA.DiagramObject)dia.DiagramObjects.AddNew(position, "");

            dia.Update();
            if (port.Type.Equals("Port"))
            {
                // not showing label
                diaObject.Style = "LBL=CX=97:CY=13:OX=0:OY=0:HDN=1:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";
            }
            else
            {
                // not showing label
                diaObject.Style = "LBL=CX=97:CY=13:OX=39:OY=3:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";
            }
            diaObject.ElementID = port.ElementID;


            diaObject.Update();

            if (interf == null)
            {
                return;
            }

            // visualize interface
            var diaObject2 = (EA.DiagramObject)dia.DiagramObjects.AddNew(position, "");

            dia.Update();
            diaObject.Style      = "LBL=CX=69:CY=13:OX=-69:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";
            diaObject2.ElementID = interf.ElementID;
            diaObject2.Update();
        }
Esempio n. 5
0
        private int AddUCComponentToDiagram(EA.Package eAMainPackage, EA.Diagram diagram, int iElementID)
        {
            int iTopOffset         = 10;
            int iHeightOneStep     = 200;
            int iSpaceBetweenSteps = 20;

            int iL = 100;
            int iR = 200;
            int iT = iTopOffset + (iHeightOneStep * m_NoUseCaseComponents) + iSpaceBetweenSteps;
            int iB = iTopOffset + (iHeightOneStep * (m_NoUseCaseComponents + 1));

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.DiagramObject diagramObj = diagram.DiagramObjects.AddNew(strPos, "");
            if (diagramObj == null)
            {
                //EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(1);
            }

            diagramObj.ElementID = iElementID;
            diagramObj.Update();
            diagram.DiagramObjects.Refresh();
            eAMainPackage.Diagrams.Refresh();
            diagram.Update();

            m_NoUseCaseComponents++;

            return(0);
        }
Esempio n. 6
0
        /// <summary>
        /// AddDiagram
        /// </summary>
        /// <param name="ePackage"></param>
        /// <returns>EA.Diagram</returns>
        internal static EA.Diagram AddDiagram(EA.Package eAPackage, string strDiagramName, string strEADiagramType)
        {
            string strLogInfo = "Diagram: " + strEADiagramType + " " + strDiagramName;

            LogMsg(LogMsgType.Adding, strLogInfo);
            EA.Diagram diagram = null;

            try
            {
                diagram = eAPackage.Diagrams.GetByName(strDiagramName);
            }
            catch (Exception ex)
            {
                LogMsg(LogMsgType.MiscExceptions, m_Repository.Stereotypes.GetLastError() + " : " + ex.Message);
            }

            if (diagram == null)
            {
                diagram = eAPackage.Diagrams.AddNew(strDiagramName, strEADiagramType);
                diagram.Update();
                eAPackage.Diagrams.Refresh();
                LogMsg(LogMsgType.Added, strLogInfo);
            }
            else
            {
                LogMsg(LogMsgType.Exists, strLogInfo);
            }

            return(diagram);
        }
Esempio n. 7
0
        /// <summary>
        /// Sets a normal EA.Package as an UMM view package. This means, that a stereotype is
        /// applied and also the taggedvalues, which every "UMM view package" inherits
        /// from "BusinessLibrary" from UMM base. Additionally a package diagram is created if
        /// the package is stereotyped as BDV, BRV or BTV
        /// </summary>
        /// <param name="package">the EA.Package which should be modified to an UMM "view package"</param>
        /// <param name="stereotype">the stereotype, which should be applied</param>
        /// <returns>a reference to the modified package</returns>
        private EA.Package populateUMMView(EA.Package package, UMM stereotype)
        {
            // set the stereotype
            package.Element.Stereotype = stereotype.ToString();
            // add the tagged values
            foreach (string tv_string in Enum.GetNames(typeof(BusinessLibraryTV)))
            {
                EA.TaggedValue tv = (EA.TaggedValue)package.Element.TaggedValues.AddNew(tv_string, "");
                tv.Update();
            }

            /* if the stereotype is BRV or BCV the package is own of the core views.
             * then for a more convinient modeling, a package diagram is added */
            if (stereotype.Equals(UMM.bRequirementsV) || stereotype.Equals(UMM.bChoreographyV))
            {
                EA.Diagram diagram = (EA.Diagram)package.Diagrams.AddNew(package.Name, EA_Element.Package.ToString());
                diagram.ShowDetails = 0;
                diagram.Update();
            }
            //For the BIV we add a class diagram
            else if (stereotype.Equals(UMM.bInformationV))
            {
                EA.Diagram diagram = (EA.Diagram)package.Diagrams.AddNew(package.Name, EA_Element.Class.ToString());
                diagram.ShowDetails = 0;
                diagram.Update();
            }

            package.Update();
            return(package);
        }
Esempio n. 8
0
        /// <summary>
        /// adds a package with the given Stereotype as a Subpackage to the given package
        /// </summary>
        /// <param name="package">The package, which is the parent of the newly created package</param>
        /// <param name="cStereotype">The stereotype of which the newly created package should be type of</param>
        /// <param name="name">The name of the package to add</param>
        ///
        internal EA.Package addViewPackage(EA.Package package, UMM cStereotype, String name, EA_Element diagramType)
        {
            // at first add the new package to the parent package
            EA.Package childPackage = (EA.Package)package.Packages.AddNew(name, "");
            childPackage.Update();
            childPackage = this.populateUMMView(childPackage, cStereotype);

            /* also add the child package to the package diagram contained in the parent
             * package, if wanted. if the package diagram doenst exist than create it */


            EA.Diagram packageDiagram = (EA.Diagram)childPackage.Diagrams.AddNew(childPackage.Name, diagramType.ToString());
            packageDiagram.ShowDetails = 0;
            packageDiagram.Update();


            /* now add the child package to the package diagram of the parent */
            EA.Collection    diagramObjects = packageDiagram.DiagramObjects;
            EA.DiagramObject diagramObject  = (EA.DiagramObject)diagramObjects.AddNew("l=200;r=400;t=200;b=600;", "");
            diagramObject.ElementID = childPackage.Element.ElementID;
            diagramObject.Update();

            repository.RefreshModelView(package.PackageID);
            return(childPackage);
        }
Esempio n. 9
0
 private void buttonToggleMceVis_Click(object sender, EventArgs e)
 {
     checkFunctions();
     if (activateSDMVerboseButton)
     {
         EA.Diagram currentDiagram = repository.GetCurrentDiagram();
         if (currentDiagram.Notes.Contains("Moflon::MceVisualization=true"))
         {
             SDMUtil.setAllMceVisTags(false, repository, currentDiagram);
             currentDiagram.Notes = currentDiagram.Notes.Replace("Moflon::MceVisualization=true", "Moflon::MceVisualization=false");
         }
         else if (currentDiagram.Notes.Contains("Moflon::MceVisualization=false"))
         {
             SDMUtil.setAllMceVisTags(true, repository, currentDiagram);
             currentDiagram.Notes = currentDiagram.Notes.Replace("Moflon::MceVisualization=false", "Moflon::MceVisualization=true");
         }
         else
         {
             SDMUtil.setAllMceVisTags(false, repository, currentDiagram);
             currentDiagram.Notes = currentDiagram.Notes += "Moflon::MceVisualization=false";
         }
         currentDiagram.Update();
         repository.ReloadDiagram(currentDiagram.DiagramID);
     }
     else
     {
         MessageBox.Show("To use this function open a SDM Diagram");
     }
 }
Esempio n. 10
0
 private static void appendSdmDiagram(String name, EA.Element parentElement)
 {
     if (parentElement.Diagrams.Count == 0)
     {
         EA.Diagram sdmDiagram = parentElement.Diagrams.AddNew(name, SDMModelingMain.SdmDiagramMetatype[0]) as EA.Diagram;
         sdmDiagram.Update();
         parentElement.Diagrams.Refresh();
         MainImport.getInstance().DiagramsToBeFilled.Add(sdmDiagram);
     }
 }
        private bool Update(EA.Diagram drg)
        {
            bool result = drg.Update();

            if (result == false)
            {
                throw new Exception("Update Didn't work out properlly!!!");
            }
            return(result);
        }
        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);
        }
 /// <summary>
 /// Update Diagram
 /// </summary>
 private void Update()
 {
     try
     {
         _dia.Update();
     }
     catch (Exception e)
     {
         MessageBox.Show($"Style is possibly to long for DB field\r\n\r\n{e}", "Can't write Diagram Styles!");
     }
 }
Esempio n. 14
0
        public static bool ActivityIsSimple = true; // Create Activity from function in the simple form
        public static bool CreateDefaultElementsForActivity(EA.Repository rep,
                                                            EA.Diagram dia, EA.Element act)
        {
            // create init node
            CreateInitFinalNode(rep, dia, act, 100, @"l=350;r=370;t=70;b=90;");
            act.Elements.Refresh();
            dia.DiagramObjects.Refresh();
            dia.Update();
            rep.ReloadDiagram(dia.DiagramID);

            return(true);
        }
 public override void doRuleQuickFix(SQLElement eaElement, SQLRepository repository, int i, String errorMessage)
 {
     if (i == 0)
     {
         if (eaElement.Diagrams.Count == 1)
         {
             EA.Diagram evacDiag = (eaElement.Diagrams.GetAt(0) as SQLDiagram).getRealDiagram();
             evacDiag.Name = eaElement.Name;
             evacDiag.Update();
         }
     }
 }
Esempio n. 16
0
        /// <summary>
        /// AddConnector
        /// </summary>
        /// <param name="diagram"></param>
        /// <param name="eElement"></param>
        /// <param name="strFullOpName"></param>
        /// <param name="strEvent"></param>
        /// <param name="iSupplierID"></param>
        /// <param name="iSeqNo"></param>
        private void AddConnector(EA.Diagram diagram, EA.Element eElement, string strFullOpName, string strEvent, int iSupplierID, int iSeqNo, string strNotes)
        {
            string strLogInfo = "Connector for operation: " + strFullOpName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Connector eConnector = null;

            //for (short i = 0; i < eElement.Connectors.Count; i++)
            //{
            //    Application.DoEvents();

            //    eConnector = eElement.Connectors.GetAt(i);

            //    if (eConnector.Name == strFullOpName)
            //    {
            //        break;
            //    }
            //    else
            //    {
            //        eConnector = null;
            //    }
            //}

            if (eConnector == null)
            {
                eConnector       = eElement.Connectors.AddNew(strFullOpName, "Sequence");
                eConnector.Notes = strNotes;

                eConnector.SequenceNo       = iSeqNo;
                eConnector.SupplierID       = iSupplierID;
                eConnector.TransitionAction = "Call";
                eConnector.TransitionEvent  = "Synchronus";
                eConnector.TransitionGuard  = "params=;paramsDlg=param1;";
                eConnector.Update();

                eConnector.StartPointY = eConnector.StartPointY + 1;
                eConnector.Update();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strEvent, "sequence");
            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            eDiagramLink.Update();

            diagram.Update();
        }
Esempio n. 17
0
        public override void doEaGuiStuff()
        {
            EA.Element realelement = StoryPatternElement.getRealElement();
            realelement.StereotypeEx = TGGModelingMain.TggRuleStereotype;
            realelement.Update();

            if (realelement.Diagrams.Count > 0)
            {
                EA.Diagram ruleDiagram = (realelement.Diagrams.GetAt(0) as EA.Diagram);
                ruleDiagram.Name = realelement.Name;
                ruleDiagram.Update();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// creates an empty story diagram related to the given Method
        /// </summary>
        /// <param name="method"></param>
        /// <param name="repository"></param>
        /// <param name="currentDiagram"></param> The currently open diagram. An anchor will be added to this diagram.
        public static void createStoryDiagram(SQLMethod method, EA.Repository repository, EA.Diagram currentDiagram)
        {
            EA.Element    containingEClass = repository.GetElementByID(method.ParentID);
            SQLRepository sqlRepository    = new SQLRepository(repository, false);

            EA.Element sdmContainer = (EA.Element)(containingEClass.Elements.AddNew(method.Name, Main.EAClassType));
            sdmContainer.ParentID = containingEClass.ElementID;



            EA.Diagram sdmDiagram = (EA.Diagram)(sdmContainer.Diagrams.AddNew(method.Name + " Story Diagram", SdmDiagramMetatype[0]));
            sdmDiagram.ParentID      = sdmContainer.ElementID;
            sdmDiagram.ExtendedStyle = "HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=9;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=0;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=1;FormName=;";
            sdmDiagram.StyleEx       = sdmDiagram.StyleEx + "HideConnStereotype=0;";
            repository.SaveDiagram(sdmDiagram.DiagramID);
            sdmDiagram.Update();
            EA.Element startNode = (EA.Element)sdmContainer.Elements.AddNew(" Start", Main.EAStateNodeType);
            startNode.Subtype  = Main.EAStartNodeSubtype;
            startNode.ParentID = sdmContainer.ElementID;

            startNode.Name = SDMUtil.computeStartNodeName(sqlRepository.GetMethodByID(method.MethodID), sqlRepository.GetElementByID(containingEClass.ElementID));

            startNode.Update();
            EA.DiagramObject startNodeDiagramObject = (EA.DiagramObject)sdmDiagram.DiagramObjects.AddNew("l=50;r=70;t=50;b=70;", Main.EAStateNodeType);
            startNodeDiagramObject.ElementID = startNode.ElementID;
            startNodeDiagramObject.Update();


            method.getRealMethod().Update();
            sdmContainer.Update();

            Navigator.addAnchorEntry(sdmDiagram.DiagramID, currentDiagram.DiagramID);

            String objectStyleString = "StateNodeLBL=CX=437:CY=13:OX=-9:OY=-18:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;DUID=2B547EF9;LBL=CX=437:CY=13:OX=-6:OY=-17:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;";

            repository.Execute("UPDATE t_diagramobjects SET ObjectStyle = '" + objectStyleString + "' WHERE Object_ID = " + startNodeDiagramObject.ElementID);

            repository.OpenDiagram(sdmDiagram.DiagramID);

            sdmContainer.Elements.Refresh();

            setAnchorElementTags(sqlRepository, currentDiagram, sqlRepository.GetElementByID(sdmContainer.ElementID));
            Activity activity = new Activity(sqlRepository.GetElementByID(sdmContainer.ElementID), sqlRepository);

            activity.OwningOperation = new ECOREModeling.ECOREExportWrapper.EOperation(sqlRepository.GetMethodByID(method.MethodID), sqlRepository);
            activity.saveTreeToEATaggedValue(true);

            StartNode startNodeObject = new StartNode(sqlRepository, sqlRepository.GetElementByID(startNode.ElementID));

            startNodeObject.saveTreeToEATaggedValue(true);
        }
Esempio n. 19
0
        /// <summary>
        /// Set Diagram styles in PDATA and StyleEx. It simply updates the parameters in both field.
        ///
        /// HideQuals=1 HideQualifiers:
        /// OpParams=2  Show full Operation Parameter
        /// ScalePI=1   Scale to fit page
        /// Theme=:119  Set the diagram theme and the used features of the theme (here 119, see StyleEx of t_diagram)
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="dia"></param>
        /// <param name="par">par[0] contains the values as a semicolon/comma separated types</param>
        /// <param name="par">par[1] contains the possible diagram types</param>
        public static void SetDiagramStyle(EA.Repository rep, EA.Diagram dia, string[] par)
        {
            // Make '; as delimiter for types
            string styles  = par[0].Replace(",", ";");
            string dStyles = par[1].Replace(",", ";");

            string[] styleEx          = styles.Split(';');
            string   diaStyle         = dia.StyleEx;
            string   diaExtendedStyle = dia.ExtendedStyle.Trim();

            if (!DiagramIsToChange(dia, dStyles))
            {
                return;
            }

            // no distinguishing between StyleEx and ExtendedStayle, may cause of trouble
            if (dia.StyleEx == "")
            {
                diaStyle = dStyles + ";";
            }
            if (dia.ExtendedStyle == "")
            {
                diaExtendedStyle = dStyles + ";";
            }

            Regex rx = new Regex(@"([^=]*)=.*");

            rep.SaveDiagram(dia.DiagramID);
            foreach (string style in styleEx)
            {
                if (style.Trim() == "")
                {
                    continue;
                }
                Match match = rx.Match(style.Trim());
                if (!match.Success)
                {
                    continue;
                }
                string patternFind = $@"{match.Groups[1].Value}=[^;]*;";
                diaStyle         = Regex.Replace(diaStyle, patternFind, $@"{style};");
                diaExtendedStyle = Regex.Replace(diaExtendedStyle, patternFind, $@"{style};");
            }
            // delete spaces to avoid sql exception (string to long)
            dia.ExtendedStyle = diaExtendedStyle.Replace(";   ", ";").Replace(";  ", ";").Replace("; ", ";").Trim();
            dia.StyleEx       = diaStyle.Replace(";   ", ";").Replace(";  ", ";").Replace("; ", ";").Trim();
            dia.Update();
            rep.ReloadDiagram(dia.DiagramID);
        }
 public override void doRuleQuickFix(SQLPackage eaPackage, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage)
 {
     if (errorMessage == "TGG Package must contain a TGG diagram")
     {
         EA.Package pkg        = EAUtil.sqlEAObjectToOriginalObject(repository, eaPackage) as EA.Package;
         EA.Diagram newDiagram = pkg.Diagrams.AddNew(eaPackage.Name, TGGModelingMain.TggSchemaDiagramMetatype[0]) as EA.Diagram;
         newDiagram.Update();
     }
     else if (errorMessage == "Ecore Package must contain an Ecore diagram")
     {
         EA.Package pkg        = EAUtil.sqlEAObjectToOriginalObject(repository, eaPackage) as EA.Package;
         EA.Diagram newDiagram = pkg.Diagrams.AddNew(eaPackage.Name, ECOREModelingMain.EcoreDiagramMetatype[0]) as EA.Diagram;
         newDiagram.Update();
     }
 }
        private static bool CreateDefaultElementsForActivity(EA.Repository rep, EA.Diagram dia, EA.Element act)
        {
            // check if init and final node are available
            bool init  = false;
            bool final = false;

            foreach (EA.Element node in act.Elements)
            {
                if (node.Type == "StateNode" & node.Subtype == 100)
                {
                    init = true;
                }
                if (node.Type == "StateNode" & node.Subtype == 101)
                {
                    final = true;
                }
            }
            if (!init)
            {
                EA.Element initNode = (EA.Element)act.Elements.AddNew("", "StateNode");
                initNode.Subtype = 100;
                initNode.Update();
                if (dia != null)
                {
                    EA.DiagramObject initDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew("l=295;r=315;t=125;b=135;", "");
                    initDiaNode.ElementID = initNode.ElementID;
                    initDiaNode.Update();
                }
            }
            if (!final)
            {
                EA.Element finalNode = (EA.Element)act.Elements.AddNew("", "StateNode");
                finalNode.Subtype = 101;
                finalNode.Update();
                if (dia != null)
                {
                    EA.DiagramObject finalDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew("l=285;r=305;t=745;b=765;", "");
                    finalDiaNode.ElementID = finalNode.ElementID;
                    finalDiaNode.Update();
                }
            }
            act.Elements.Refresh();
            dia.DiagramObjects.Refresh();
            dia.Update();
            rep.ReloadDiagram(dia.DiagramID);

            return(true);
        }
Esempio n. 22
0
        private int AddUCToUCDiagram(EA.Package eaPackage, EA.Diagram diagram, int iUCElementID, int iUCClassElementID, int iVertPos)
        {
            int iTopOffset         = 10;
            int iHeightOneStep     = 200;
            int iSpaceBetweenSteps = 20;

            int iL = 300;
            int iR = 400;
            int iT = iTopOffset + (iHeightOneStep * iVertPos) + iSpaceBetweenSteps;
            int iB = iTopOffset + (iHeightOneStep * (iVertPos + 1));

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.DiagramObject diagramObj = diagram.DiagramObjects.AddNew(strPos, "");
            if (diagramObj == null)
            {
                //EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(1);
            }

            diagramObj.ElementID = iUCElementID;
            diagramObj.Update();

            iL = 700;
            iR = 800;
            iT = iTopOffset + (iHeightOneStep * iVertPos) + iSpaceBetweenSteps;
            iB = iTopOffset + (iHeightOneStep * (iVertPos + 1));

            strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.DiagramObject diagramObj2 = diagram.DiagramObjects.AddNew(strPos, "");
            if (diagramObj2 == null)
            {
                //EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(1);
            }

            diagramObj2.ElementID = iUCClassElementID;
            diagramObj2.Update();


            diagram.DiagramObjects.Refresh();
            eaPackage.Diagrams.Refresh();
            diagram.Update();

            return(0);
        }
Esempio n. 23
0
        ///
        /// Validate all object run state keys correspond to classifier attributes
        ///
        //static public void validateDiagram(EA.Repository Repository,EA.Diagram diagram)
        //{
        //    IList<string> messages = diagramValidation(Repository,diagram);

        //    logger.log("**ValidationResults**");
        //    if(messages!=null)
        //    {
        //        foreach (string m in messages)
        //        {
        //            logger.log(m);
        //        }
        //    }
        //}

        //static public IList<string> diagramValidation(EA.Repository Repository, EA.Diagram diagram,IList<EA.Element> diagramElements)
        //{
        //    JSchema jschema = null;
        //    JObject json = null;
        //    try
        //    {
        //        //logger.log("Validate Sample");
        //        json = (JObject)sampleToJObject(Repository, diagram, diagramElements)["json"];

        //        //logger.log("JObject formed");

        //        EA.Package samplePkg = Repository.GetPackageByID(diagram.PackageID);
        //        EA.Package samplesPackage = Repository.GetPackageByID(samplePkg.ParentID);
        //        EA.Package apiPackage = Repository.GetPackageByID(samplesPackage.ParentID);

        //        EA.Package schemaPackage = null;

        //        foreach (EA.Package p in apiPackage.Packages)
        //        {
        //            if (p!=null && p.Name.Equals(RoundTripAddInClass.API_PACKAGE_SCHEMAS))
        //            {
        //                schemaPackage = p;
        //            }
        //        }
        //        if (schemaPackage == null)
        //        {
        //            throw new Exception("No Schema package found");
        //        }

        //        EA.Diagram schemaDiagram = null;
        //        foreach (EA.Diagram d in schemaPackage.Diagrams)
        //        {
        //            if (d.Stereotype != null && d.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SCHEMADIAGRAM))
        //            {
        //                schemaDiagram = d;
        //            }
        //        }



        //        jschema = SchemaManager.schemaToJsonSchema(Repository, schemaDiagram,diagramElements).Value;
        //    }
        //    catch (ModelValidationException ex)
        //    {
        //        return ex.errors.messages;
        //    }

        //    IList<string> messages;

        //    if (!json.IsValid(jschema, out messages))
        //    {
        //        logger.log("Sample is not valid:");
        //        return messages;
        //    }
        //    else{
        //        logger.log("Sample is Valid!");
        //        return null;
        //    }

        //}


        public static void syncHierarchy(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache)
        {
            logger.log("Sync Hierarchy");

            RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache);
            //IList<EA.Element> diagramElements = diagramCache.elementsList;

            IList <EA.Element> samples = MetaDataManager.diagramSamples(Repository, diagramCache.elementsList);

            EA.Element container             = container = MetaDataManager.findContainer(Repository, diagram, diagramCache, RoundTripAddInClass.EA_STEREOTYPE_HIERARCHY);
            EA.Element containerClassifierEl = diagramCache.elementIDHash[container.ClassfierID];
            string     containerName         = container.Name;
            string     containerClassifier   = containerClassifierEl.Name;

            Hashtable ht = new Hashtable();

            MetaDataManager.extractDiagramMetaData(ht, container);

            EA.Package samplePkg = Repository.GetPackageByID(diagram.PackageID);

            string sourcecontrolPackage = (string)ht[RoundTripAddInClass.PROJECT];


            if (fileManager != null)
            {
                fileManager.initializeAPI(sourcecontrolPackage);
                fileManager.setDataName(RoundTripAddInClass.HIERARCHY_PATH);
                fileManager.setup(RoundTripAddInClass.RAML_0_8);
                if (!fileManager.populationExists(container.Name, containerClassifier, RoundTripAddInClass.HIERARCHY_PATH, container.Name))
                {
                    MessageBox.Show("No file exists at:" + fileManager.exportPath(container.Name, containerClassifier, RoundTripAddInClass.HIERARCHY_PATH, container.Name));
                    return;
                }
                else
                {
                    string fullpath = fileManager.exportPath(containerName, containerClassifier, RoundTripAddInClass.HIERARCHY_PATH, container.Name);
                    JArray jo       = JArray.Parse(File.ReadAllText(fullpath));
                    sync_hierarchy(Repository, diagram, container, jo, samplePkg, diagramCache);
                    samplePkg.Update();
                    diagram.DiagramLinks.Refresh();
                    if (!diagram.Update())
                    {
                        logger.log(diagram.GetLastError());
                    }
                }
            }
        }
 public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType)
 {
     EA.Diagram dia = rep.GetDiagramByGuid(GUID);
     if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0)
     {
         dia.Notes = _Description;
     }
     if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0)
     {
         dia.Name = _Name;
     }
     if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0)
     {
         dia.StereotypeEx = _Stereotype;
     }
     _isUpdated = true;
     dia.Update();
 }
Esempio n. 25
0
        public static void deleteDiagramObject(EA.Repository repository, EA.Diagram actDiagram, EA.Element actElement)
        {
            short i = 0;

            repository.SaveDiagram(actDiagram.DiagramID);
            foreach (EA.DiagramObject actDiagObject in actDiagram.DiagramObjects)
            {
                if (actDiagObject.ElementID == actElement.ElementID)
                {
                    actDiagram.DiagramObjects.Delete(i);
                    actDiagram.DiagramObjects.Refresh();
                    actDiagram.Update();
                    repository.ReloadDiagram(actDiagram.DiagramID);
                    break;
                }
                i++;
            }
        }
Esempio n. 26
0
        public override void doEaGuiStuff()
        {
            base.doEaGuiStuff();
            EA.Element realElement = SdmContainer.getRealElement();
            if (realElement.Diagrams.Count > 0)
            {
                EA.Diagram sdmDiagram = realElement.Diagrams.GetAt(0) as EA.Diagram;
                String     test       = sdmDiagram.ExtendedStyle;
                sdmDiagram.ExtendedStyle = "HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=2;PPgs.cy=2;PSize=9;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=0;HideAtts=1;HideOps=1;HideStereo=1;HideEStereo=1;FormName=;";
                sdmDiagram.StyleEx       = sdmDiagram.StyleEx + "HideConnStereotype=0;";
                sdmDiagram.Update();
            }
            realElement.StereotypeEx = SDMModelingMain.SdmContainerStereotype;
            realElement.Name         = EAUtil.getMethodSignature(OwningOperation.EaMethod);
            realElement.Update();

            EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realElement, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName, OwningOperation.EaMethod.MethodGUID);
        }
Esempio n. 27
0
 public static void setAllVerboseTags(Boolean toSet, SQLRepository repository, EA.Diagram currentDiagram)
 {
     EA.Diagram diagram = currentDiagram;
     if (diagram == null)
     {
         diagram = repository.GetTreeSelectedObject() as EA.Diagram;
     }
     repository.SaveDiagram(diagram.DiagramID);
     foreach (EA.DiagramObject diagObj in diagram.DiagramObjects)
     {
         SQLElement correspondingElement = repository.GetElementByID(diagObj.ElementID);
         if (correspondingElement.Stereotype == SDMModelingMain.ObjectVariableStereotype ||
             correspondingElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype ||
             correspondingElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
         {
             EAEcoreAddin.Util.EAUtil.setTaggedValue(repository, correspondingElement.getRealElement(), Main.MoflonVerboseTaggedValueName, toSet.ToString());
         }
     }
     foreach (EA.DiagramLink diagLink in diagram.DiagramLinks)
     {
         SQLConnector link = repository.GetConnectorByID(diagLink.ConnectorID);
         if (link.Stereotype == SDMModelingMain.LinkVariableStereotype ||
             link.Stereotype == TGGModelingMain.TggLinkVariableStereotype)
         {
             EAEcoreAddin.Util.EAUtil.setTaggedValue(repository, link.getRealConnector(), Main.MoflonVerboseTaggedValueName, toSet.ToString());
         }
     }
     if (toSet)
     {
         diagram.Notes = diagram.Notes.Replace("Moflon::Verbose=false", "Moflon::Verbose=true");
     }
     else
     {
         diagram.Notes = diagram.Notes.Replace("Moflon::Verbose=true", "Moflon::Verbose=false");
     }
     if (!diagram.Notes.Contains("Moflon::Verbose"))
     {
         diagram.Notes += "Moflon::Verbose=true";
     }
     diagram.Update();
     repository.ReloadDiagram(diagram.DiagramID);
 }
        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();
            }
        }
Esempio n. 29
0
        private ExecResult <Boolean> Test1()
        {
            ExecResult <Boolean> result = new ExecResult <bool>();

            try
            {
                // Открываем и чистим тестовую диаграмму
                EA.Diagram testDiagram = Context.EARepository.GetDiagramByGuid("{0093407F-0187-42a8-93DC-B97E8FA79EED}");
                if (test1Flag == 0)
                {
                    while (testDiagram.DiagramObjects.Count > 0)
                    {
                        testDiagram.DiagramObjects.DeleteAt(0, true);
                    }
                    testDiagram.Update();
                    testDiagram.DiagramObjects.Refresh();
                    Context.EARepository.ReloadDiagram(testDiagram.DiagramID);
                }

                Context.EARepository.OpenDiagram(testDiagram.DiagramID);
                Context.EARepository.ActivateDiagram(testDiagram.DiagramID);
                Context.CurrentDiagram = testDiagram;

                // Выделяем элемент
                EA.Element element = Context.EARepository.GetElementByGuid("{83142BDB-7EE4-48e7-B788-0011E0E2E343}");
                Context.EARepository.ShowInProjectView(element);

                // Запускаем формирование иерархии элементов диаграммы
                var putDeploymentHierarchyResult = Context.Designer.PutParentHierarchyOnDiagram();
                OutExecResult(putDeploymentHierarchyResult);


                test1Flag = 1;
            }
            catch (Exception ex)
            {
                result.setException(ex);
            }

            return(result);
        }
Esempio n. 30
0
        public void importTGGPackageModel(MocaNode tggPackageNode)
        {
            EA.Package rootPackage = MainImport.getInstance().EcoreImport.findOrCreateRoot(tggPackageNode);

            EA.Package modelPackage = MainImport.getInstance().EcoreImport.getOrCreatePackage(sqlRep.GetPackageByID(rootPackage.PackageID), tggPackageNode);

            TGG tggPkg = new TGG(sqlRep, sqlRep.GetPackageByID(modelPackage.PackageID));

            tggPkg.deserializeFromMocaTree(tggPackageNode);

            MainImport.getInstance().MocaTaggableElements.Add(tggPkg);
            MainImport.getInstance().OldGuidToNewGuid.Add(tggPkg.Guid, modelPackage.PackageGUID);
            MainImport.getInstance().importedPackages.Add(modelPackage);

            if (modelPackage.Diagrams.Count == 0)
            {
                EA.Diagram diag = modelPackage.Diagrams.AddNew(modelPackage.Name, TGGModelingMain.TggSchemaDiagramMetatype[0]) as EA.Diagram;
                diag.Update();
                MainImport.getInstance().DiagramsToBeFilled.Add(diag);
            }
            MainImport.getInstance().EcoreImport.importEPackageFeatures(tggPackageNode, sqlRep.GetPackageByID(modelPackage.PackageID));
            importTGGFeatures(tggPackageNode, sqlRep.GetPackageByID(modelPackage.PackageID));
        }