// ReSharper disable once UnusedMember.Global
        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();
        }
        /// <summary>
        /// Set Diagram styles:
        /// HideQuals=1 HideQualifiers:
        /// OpParams=2  Show full Operation Parameter
        /// ScalePI=1   Scale to fit page
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="dia"></param>
        /// <param name="par">par[0] contains the values as a semicolon separated list</param>
        // ReSharper disable once UnusedMember.Global
        public static void SetDiagramStyle(EA.Repository rep, EA.Diagram dia, string[] par)
        {
            string[] styleEx          = par[0].Split(';');
            string   diaStyle         = dia.StyleEx;
            string   diaExtendedStyle = dia.ExtendedStyle.Trim();

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

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

            rep.SaveDiagram(dia.DiagramID);
            foreach (string style in styleEx)
            {
                Match  match       = rx.Match(style);
                string patternFind = $@"{match.Groups[1].Value}=[^;]*;";
                diaStyle         = Regex.Replace(diaStyle, patternFind, $@"{style};");
                diaExtendedStyle = Regex.Replace(diaExtendedStyle, patternFind, $@"{style};");
            }
            dia.ExtendedStyle = diaExtendedStyle;
            dia.StyleEx       = diaStyle;
            dia.Update();
            rep.ReloadDiagram(dia.DiagramID);
        }
        private static readonly bool ActivityIsSimple = true; // Create Activity from function in the simple form

        // ReSharper disable once UnusedMethodReturnValue.Local
        private static bool CreateDefaultElementsForActivity(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);
        }
Exemple #4
0
        public void DrawDiagram(int parentDiagramID, int lifeCycleDiagramID)
        {
            EAAPI.Element parentElement    = eaRepo.GetElementByID(parentDiagramID);
            EAAPI.Diagram lifeCycleDiagram = eaRepo.GetDiagramByID(lifeCycleDiagramID);
            EAAPI.Package parentPackage    = eaRepo.GetPackageByID(lifeCycleDiagram.PackageID);

            // convert to Dictionary so it is easier to lookup.
            Dictionary <String, EAAPI.Element> elements = ConvertEAElementsToDictionary(parentPackage.Elements);

            AddOrUpdateElements(parentPackage, parentElement, lifeCycleDiagram, ref elements);

            AddOrUpdateElementsOnDiagram(parentElement, lifeCycleDiagram, ref elements);

            FixDiagramObjectsSequence(lifeCycleDiagram, elements);

            lifeCycleDiagram.Update();
        }
Exemple #5
0
        /// <summary>
        /// Create an Activity diagram beneath selected Activity.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="act"></param>
        /// <returns></returns>

        public static Diagram CreateActivityCompositeDiagram(Repository rep, EA.Element act)
        {
            // create activity diagram beneath Activity
            EA.Diagram actDia = (Diagram)act.Diagrams.AddNew(act.Name, "Activity");
            // update diagram properties
            actDia.ShowDetails = 0; // hide details
            // scale page to din A4

            if (actDia.StyleEx.Length > 0)
            {
                actDia.StyleEx = actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1"); // hide qualifier
            }
            else
            {
                actDia.StyleEx = "HideQuals=1;";
            }
            // Hide Qualifier
            if (actDia.ExtendedStyle.Length > 0)
            {
                actDia.ExtendedStyle = actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1");
            }
            else
            {
                actDia.ExtendedStyle = "ScalePI=1;";
            }
            actDia.Update();
            act.Diagrams.Refresh();

            // put the activity on the diagram
            HoUtil.AddSequenceNumber(rep, actDia);
            EA.DiagramObject actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", "");
            actObj.ElementID = act.ElementID;
            actObj.Update();
            actDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForActivity(rep, actDia, act);
            act.Elements.Refresh();
            actDia.DiagramObjects.Refresh();
            return(actDia);
        }
Exemple #6
0
        static public EAFactory createPopulation(EAMetaModel meta)
        {
            EAFactory factory = new EAFactory();

            meta.setupPopulationPackage();

            EA.Package package = EARepository.currentPackage;
            EA.Diagram diagram = EARepository.currentDiagram;

            EAFactory populationIndicator = factory.setupClient("populationIndicator", RoundTripAddInClass.EA_TYPE_OBJECT, RoundTripAddInClass.EA_STEREOTYPE_POPULATION, meta.META_SERVER.ElementID, null);


            EAFactory populationMember = factory.setupClient("populationMember", RoundTripAddInClass.EA_TYPE_OBJECT, null, meta.META_SERVER.ElementID, new string[] { "Name", "Name1", "version", "1" });

            //Object o = package.Diagrams.AddNew("Population-Sample", "Object");
            //EA.Diagram newdia = (EA.Diagram)o;
            EA.Diagram newdia = diagram;

            EARepository.currentPackage.Diagrams.Refresh();
            newdia.Stereotype = RoundTripAddInClass.EA_STEREOTYPE_SAMPLEDIAGRAM;
            newdia.Update();
            EARepository.currentPackage.Update();

            //logger.log("Added diagram:" + newdia.DiagramID);


            //Object o2 = diagram.DiagramObjects.AddNew("Indicator", "");
            //EA.DiagramObject diaObj2 = (EA.DiagramObject)o2;

            //diagram.Update();
            //diaObj2.ElementID = populationIndicator.clientElement.ElementID;
            //diaObj.Update();

            //Object o3 = diagram.DiagramObjects.AddNew("Item", "");
            //EA.DiagramObject diaObj3 = (EA.DiagramObject)o3;
            //diagram.Update();
            //diaObj3.ElementID = populationMember.clientElement.ElementID;

            return(factory);
        }
Exemple #7
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 values as a semicolon/comma separated properties</param>
        /// <param name="par">par[2] contains the possible diagram types</param>

        public static void SetDiagramStyleDeleteMe(Repository rep, EA.Diagram dia, string[] par)
        {
            // Make '; as delimiter for types
            string styles     = par[0].Replace(",", ";");
            string properties = par[1].Replace(",", ";");
            string dStyles    = par[2].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 + ";";
            }

            // find: Name=value
            Regex rx = new Regex(@"([^=]*)=(.*)");

            rep.SaveDiagram(dia.DiagramID);

            // update the ExtendedStyle, StyleEX with PDATA1, StyleEX
            // Steps of update:
            // 1. StyleEx, ExtendedStyleEx
            // 2. Properties which represents EA Properties
            // 3. Properties which are set by SQL
            // Don't change order, Update()
            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};");
                // advanced styles
                //SetAdvancedStyle(rep, dia, match.Groups[1].Value, match.Groups[2].Value);
                //var schowForeign0 = rep.GetStringsBySql($@"select ShowForeign from t_diagram where Diagram_ID = {dia.DiagramID}");
            }
            // 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();

            // update non SQL Diagram properties
            foreach (string property in properties.Split(';'))
            {
                if (property.Trim() == "")
                {
                    continue;
                }
                Match match = rx.Match(property.Trim());
                if (!match.Success)
                {
                    continue;
                }
                // advanced styles
                SetDiagramProperty(rep, dia, match.Groups[1].Value, match.Groups[2].Value, withSql: false);
            }
            dia.Update();

            // update SQL Diagram properties
            foreach (string property in properties.Split(';'))
            {
                if (property.Trim() == "")
                {
                    continue;
                }
                Match match = rx.Match(property.Trim());
                if (!match.Success)
                {
                    continue;
                }
                // advanced styles
                SetDiagramProperty(rep, dia, match.Groups[1].Value, match.Groups[2].Value, withSql: true);
            }
            rep.ReloadDiagram(dia.DiagramID);
        }
        /// <summary>
        /// Create Activity for operation
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="m"></param>
        /// <param name="treePos"></param>
        /// <param name="pkgSrc"></param>
        /// <param name="elClass"></param>
        private static void CreateActivityFromOperation(Repository rep, Method m, int treePos, EA.Package pkgSrc, EA.Element elClass)
        {
            // create a package with the name of the operation
            EA.Package pkgTrg = (EA.Package)pkgSrc.Packages.AddNew(m.Name, "");
            pkgTrg.TreePos = treePos;
            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            EA.Element frm = null; // frame beneath package
            if (ActivityIsSimple == false)
            {
                // create Class Activity Diagram in target package
                EA.Diagram pkgActDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Activity");
                pkgActDia.Update();
                pkgTrg.Diagrams.Refresh();
                // prevent information loss
                Util.SetDiagramStyleFitToPage(pkgActDia); // after save diagram!

                // add frame in Activity diagram
                EA.DiagramObject frmObj = (EA.DiagramObject)pkgActDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
                frm = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
                frm.Update();
                frmObj.ElementID = frm.ElementID;
                //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
                frmObj.Update();
                pkgTrg.Elements.Refresh();
                pkgActDia.DiagramObjects.Refresh();
            }

            // create activity with the name of the operation
            EA.Element act = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Activity");
            if (ActivityIsSimple == false)
            {
                act.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType +
                            ";\r\nDetails see Operation definition!!";
            }

            act.StereotypeEx = m.StereotypeEx;
            act.Update();
            pkgTrg.Elements.Refresh();

            // create activity diagram beneath Activity
            EA.Diagram actDia = (EA.Diagram)act.Diagrams.AddNew(m.Name, "Activity");
            // update diagram properties
            actDia.ShowDetails = 0; // hide details
            // scale page to din A4

            if (actDia.StyleEx.Length > 0)
            {
                actDia.StyleEx = actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1"); // hide qualifier
            }
            else
            {
                actDia.StyleEx = "HideQuals=1;";
            }

            // Hide Qualifier
            if (actDia.ExtendedStyle.Length > 0)
            {
                actDia.ExtendedStyle = actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1");
            }
            else
            {
                actDia.ExtendedStyle = "ScalePI=1;";
            }

            actDia.Update();
            act.Diagrams.Refresh();


            // put the activity on the diagram
            Util.AddSequenceNumber(rep, actDia);
            EA.DiagramObject actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", "");
            actObj.ElementID = act.ElementID;
            actObj.Sequence  = 1;
            actObj.Update();
            Util.SetSequenceNumber(rep, actDia, actObj, "1");
            actDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForActivity(rep, actDia, act);

            if (ActivityIsSimple == false)
            {
                // Add Heading to diagram
                Util.AddSequenceNumber(rep, actDia);
                EA.DiagramObject noteObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=40;r=700;t=25;b=50", "");
                EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

                note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
                note.Update();
                noteObj.ElementID = note.ElementID;
                noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
                noteObj.Sequence  = 1;
                noteObj.Update();
                Util.SetSequenceNumber(rep, actDia, noteObj, "1");
            }

            pkgTrg.Elements.Refresh();
            actDia.DiagramObjects.Refresh();


            // Link Operation to activity
            Util.SetBehaviorForOperation(rep, m, act);

            // Set show behavior
            Util.SetShowBehaviorInDiagram(rep, m);

            // add parameters to activity
            UpdateParameterFromOperation(rep, act, m);
            int pos = 0;

            foreach (EA.Element actPar in act.EmbeddedElements)
            {
                if (!actPar.Type.Equals("ActivityParameter"))
                {
                    continue;
                }
                Util.VisualizePortForDiagramobject(rep, pos, actDia, actObj, actPar, null);
                pos = pos + 1;
            }

            if (ActivityIsSimple == false)
            {
                // link Overview frame to diagram
                Util.SetFrameLinksToDiagram(rep, frm, actDia);
                frm.Update();
            }

            // select operation
            rep.ShowInProjectView(m);
        }
        public static bool CreateInteractionForOperation(EA.Repository rep, EA.Method m)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            Package    pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // create a package with the name of the operation
            Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");

            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            // create Class Sequence Diagram in target package
            EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Sequence");
            pkgSeqDia.Update();
            pkgTrg.Diagrams.Refresh();

            // add frame in Sequence diagram
            EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
            EA.Element       frm    = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
            frm.Update();
            frmObj.ElementID = frm.ElementID;
            //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            frmObj.Update();
            pkgTrg.Elements.Refresh();
            pkgSeqDia.DiagramObjects.Refresh();


            // create Interaction with the name of the operation
            EA.Element seq = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Interaction");
            seq.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
            seq.Update();
            pkgTrg.Elements.Refresh();

            // create sequence diagram beneath Interaction
            EA.Diagram seqDia = (EA.Diagram)seq.Diagrams.AddNew(m.Name, "Sequence");
            seqDia.Update();
            seq.Diagrams.Refresh();

            // create instance from class beneath Interaction
            EA.Element obj = (EA.Element)seq.Elements.AddNew("", "Object");
            seq.Elements.Refresh();
            obj.ClassfierID = elClass.ElementID;
            obj.Update();

            // add node object to Sequence Diagram
            EA.DiagramObject node = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=100;r=180;t=50;b=70", "");
            node.ElementID = obj.ElementID;
            node.Update();


            // Add Heading to diagram
            EA.DiagramObject noteObj = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", "");
            EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

            note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
            note.Update();
            noteObj.ElementID = note.ElementID;
            noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            noteObj.Update();
            pkgTrg.Elements.Refresh();
            seqDia.DiagramObjects.Refresh();


            // Link Operation to activity
            HoUtil.SetBehaviorForOperation(rep, m, seq);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);



            HoUtil.SetFrameLinksToDiagram(rep, frm, seqDia); // link Overview frame to diagram
            frm.Update();
            //rep.ReloadDiagram(actDia.DiagramID);


            return(true);
        }
        //-----------------------------------------------------------------------------------------
        // Create StateMachine for Operation
        //----------------------------------------------------------------------------------
        public static bool CreateStateMachineForOperation(EA.Repository rep, EA.Method m)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            EA.Package pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // create a package with the name of the operation
            EA.Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");
            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            // create Class StateMachine Diagram in target package
            EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Statechart");
            pkgSeqDia.Update();
            pkgTrg.Diagrams.Refresh();

            // add frame in StateMachine diagram
            EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
            EA.Element       frm    = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
            frm.Update();
            frmObj.ElementID = frm.ElementID;
            //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            frmObj.Update();
            pkgTrg.Elements.Refresh();
            pkgSeqDia.DiagramObjects.Refresh();


            // create StateMachine with the name of the operation
            EA.Element stateMachine = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "StateMachine");
            stateMachine.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
            stateMachine.Update();
            pkgTrg.Elements.Refresh();

            // create Statechart diagram beneath State Machine
            EA.Diagram chartDia = (EA.Diagram)stateMachine.Diagrams.AddNew(m.Name, "Statechart");
            chartDia.Update();
            stateMachine.Diagrams.Refresh();

            // put the state machine on the diagram
            EA.DiagramObject chartObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=50;r=600;t=100;b=800", "");
            chartObj.ElementID = stateMachine.ElementID;
            chartObj.Update();
            chartDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForStateDiagram(rep, chartDia, stateMachine);

            // Add Heading to diagram
            EA.DiagramObject noteObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", "");
            EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

            note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
            note.Update();
            noteObj.ElementID = note.ElementID;
            noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            noteObj.Update();
            pkgTrg.Elements.Refresh();
            chartDia.DiagramObjects.Refresh();


            // Link Operation to StateMachine
            HoUtil.SetBehaviorForOperation(rep, m, stateMachine);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);



            HoUtil.SetFrameLinksToDiagram(rep, frm, chartDia); // link Overview frame to diagram
            frm.Update();
            //rep.ReloadDiagram(actDia.DiagramID);


            return(true);
        }
        //------------------------------------------------------------------------------
        // Create default Elements for Statemachine
        //------------------------------------------------------------------------------
        //
        // init
        // state 'State1'
        // final
        // transition from init to 'State1'

        public static bool CreateDefaultElementsForStateDiagram(Repository rep, EA.Diagram dia, EA.Element stateChart)
        {
            // check if init and final node are available
            bool init  = false;
            bool final = false;

            foreach (EA.Element node in stateChart.Elements)
            {
                if (node.Type == "StateNode" & node.Subtype == 100)
                {
                    init = true;
                }
                if (node.Type == "StateNode" & node.Subtype == 101)
                {
                    final = true;
                }
            }
            EA.Element initNode = null;
            if (!init)
            {
                initNode          = (EA.Element)stateChart.Elements.AddNew("", "StateNode");
                initNode.Subtype  = 3;
                initNode.ParentID = stateChart.ElementID;
                initNode.Update();
                if (dia != null)
                {
                    HoUtil.AddSequenceNumber(rep, dia);
                    EA.DiagramObject initDiaNode =
                        (EA.DiagramObject)dia.DiagramObjects.AddNew("l=295;r=315;t=125;b=135;", "");
                    initDiaNode.Sequence  = 1;
                    initDiaNode.ElementID = initNode.ElementID;
                    initDiaNode.Update();
                    HoUtil.SetSequenceNumber(rep, dia, initDiaNode, "1");
                }
            }
            EA.Element finalNode = null;
            // create final node
            if (!final)
            {
                finalNode          = (EA.Element)stateChart.Elements.AddNew("", "StateNode");
                finalNode.Subtype  = 4;
                finalNode.ParentID = stateChart.ElementID;
                finalNode.Update();
                if (dia != null)
                {
                    HoUtil.AddSequenceNumber(rep, dia);
                    EA.DiagramObject finalDiaNode =
                        (EA.DiagramObject)dia.DiagramObjects.AddNew("l=285;r=305;t=745;b=765;", "");
                    finalDiaNode.Sequence  = 1;
                    finalDiaNode.ElementID = finalNode.ElementID;
                    finalDiaNode.Update();
                    HoUtil.SetSequenceNumber(rep, dia, finalDiaNode, "1");
                }
            }
            // create state node
            EA.Element stateNode = (EA.Element)stateChart.Elements.AddNew("", "State");
            stateNode.Subtype  = 0; // state
            stateNode.Name     = "State1";
            stateNode.ParentID = stateChart.ElementID;
            stateNode.Update();
            if (dia != null)
            {
                HoUtil.AddSequenceNumber(rep, dia);
                string           pos          = "l=300;r=400;t=-400;b=-470";
                EA.DiagramObject stateDiaNode = (EA.DiagramObject)dia.DiagramObjects.AddNew(pos, "");
                stateDiaNode.Sequence  = 1;
                stateDiaNode.ElementID = stateNode.ElementID;
                stateDiaNode.Update();
                HoUtil.SetSequenceNumber(rep, dia, stateDiaNode, "1");

                // draw a transition
                EA.Connector con = (EA.Connector)finalNode.Connectors.AddNew("", "StateFlow");
                con.SupplierID = stateNode.ElementID;
                con.ClientID   = initNode.ElementID;
                con.Update();
                finalNode.Connectors.Refresh();
                stateChart.Elements.Refresh();
                dia.DiagramObjects.Refresh();
                dia.Update();
                rep.ReloadDiagram(dia.DiagramID);
            }

            return(true);
        }