private void FunctionItemInit(string name, string returnType, bool isStatic, List <ParameterItem> par, InterfaceItem interfaceItem, EA.Method method)
        {
            _name          = name;
            _parameterList = par;
            _returnType    = returnType;
            _isStatic      = isStatic;

            _interface = interfaceItem;
            _module    = null;
            _op        = method;
        }
        public bool GetMethod(out EA.Method method)
        {
            method = null;
            int methodId;

            if (GetEAObjectId(MethodID, out methodId))
            {
                method = repository.GetMethodByID(methodId);
                return(method != null);
            }
            return(false);
        }
Ejemplo n.º 3
0
 private EA.Method getMethodByGuid(string methodGuid)
 {
     EA.Repository repo   = ProjectSetting.getVO().eaRepo;
     EA.Method     mthObj = (EA.Method)repo.GetMethodByGuid(methodGuid);
     if (mthObj != null)
     {
         return(mthObj);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mth"></param>
        /// <param name="afterUpdateFlag"></param>
        private static void writeUpdateLogMethod(EA.Method mth, bool afterUpdateFlag)
        {
            try
            {
                StreamWriter sw = new StreamWriter(@"C:\DesignHistory\DiffViewerUpdate.log", true);


                if (afterUpdateFlag)
                {
                    sw.WriteLine("■操作の書き込みが完了しました(ID={0}, GUID={1})。", mth.MethodID, mth.MethodGUID);
                }
                else
                {
                    sw.WriteLine("〇操作の更新前情報を表示します(ID={0}, GUID={1})。", mth.MethodID, mth.MethodGUID);
                }

                sw.WriteLine("  MethodID =" + mth.MethodID);
                sw.WriteLine("  MethodGUID =" + mth.MethodGUID);
                sw.WriteLine("  Name =" + mth.Name);
                sw.WriteLine("  Alias =" + mth.Alias);
                sw.WriteLine("  StereotypeEx =" + mth.StereotypeEx);
                sw.WriteLine("  Notes =" + mth.Notes);
                sw.WriteLine("  Behavior =" + mth.Behavior);
                sw.WriteLine("  Abstract =" + mth.Abstract);
                sw.WriteLine("  ClassifierID =" + mth.ClassifierID);
                sw.WriteLine("  Code =" + mth.Code);
                sw.WriteLine("  Concurrency =" + mth.Concurrency);
                sw.WriteLine("  IsConst =" + mth.IsConst);
                sw.WriteLine("  IsLeaf =" + mth.IsLeaf);
                sw.WriteLine("  IsPure =" + mth.IsPure);
                sw.WriteLine("  IsQuery =" + mth.IsQuery);
                sw.WriteLine("  IsRoot =" + mth.IsRoot);
                sw.WriteLine("  IsStatic =" + mth.IsStatic);
                sw.WriteLine("  Pos =" + mth.Pos);
                sw.WriteLine("  ReturnIsArray =" + mth.ReturnIsArray);
                sw.WriteLine("  ReturnType =" + mth.ReturnType);
                sw.WriteLine("  StateFlags =" + mth.StateFlags);
                sw.WriteLine("  StyleEx =" + mth.StyleEx);
                sw.WriteLine("  Throws =" + mth.Throws);
                sw.WriteLine("  Visibility =" + mth.Visibility);

                sw.WriteLine("");

                sw.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 5
0
        void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            if (repo != null)
            {
                // 選択された属性に対する更新処理
                if (selectedAttribute != null)
                {
                    EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
                    if (attr != null)
                    {
                        repo.ShowInProjectView(attr);
                    }
                    else
                    {
                        // 属性がGUIDで空振りしたら要素GUIDで再検索
                        EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                        if (elem != null)
                        {
                            repo.ShowInProjectView(elem);
                        }
                    }
                }

                // 選択された操作に対する更新処理
                if (selectedMethod != null)
                {
                    EA.Method mth = (EA.Method)repo.GetMethodByGuid(selectedMethod.guid);
                    if (mth != null)
                    {
                        repo.ShowInProjectView(mth);
                    }
                    else
                    {
                        // 操作がGUIDで空振りしたら要素GUIDで再検索
                        EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                        if (elem != null)
                        {
                            repo.ShowInProjectView(elem);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("EAにアタッチしていないため、選択できません");
            }
        }
Ejemplo n.º 6
0
        private int ZmielElement(Element jaElem)
        {
            int wynik = 0;

            //ZmielElement(rodzicPckg,jaElem
            foreach (Element e in jaElem.Elements)
            {
                wynik += ZmielElement(e);
            }
            //mielenie
            //daj wszystkie konektory
            foreach (Connector c in jaElem.Connectors)
            {
                ////dla kazdego konektora typu information flow daj source
                if (c.Type != "InformationFlow")
                {
                    continue;
                }
                ////dla kazdego konektora daj destination
                Element elSource      = Repo.GetElementByID(c.ClientID);
                Element elDestination = Repo.GetElementByID(c.SupplierID);
                //patrz tylko na te ktorych realizatorem jest jaElem
                if (jaElem.ElementID == elDestination.ElementID)
                {
                    //wez interfejs lub go dodaj
                    Element interf = EAUtils.dodajElement(ref jaElem, "Interfejs " + jaElem.Name, "", "Interface");

                    ////do interfejsu dodaj operację (nazwa to fid, notatka to notatka, parametr to nazwa systemu target)
                    EA.Method m = EAUtils.dodajOperacje(ref interf, c.Name, c.Notes);
                    try{
                        m.Parameters.AddNew(elSource.Name, "");
                        m.Update();
                        m.Parameters.Refresh();
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "( " + System.Reflection.MethodBase.GetCurrentMethod().Attributes.ToString() + ") #" + exc.Message);
                    }
                    ////utworz relacje use z source do interfejs
                    Connector conUse = EAUtils.dodajRelacje(elSource, interf, "Usage", "", "");
                    ////utworz relacje realize z destination do interfejs
                    Connector conReal = EAUtils.dodajRelacje(elSource, interf, "Realisation", "", "");

                    wynik++;
                }
            }
            return(wynik);
        }
        /// <summary>
        /// Get Tagged Value with 'Name'. If TV not exists return "".
        /// </summary>
        /// <param name="method"></param>
        /// <param name="name"></param>
        /// <param name="caseSensitive"></param>
        /// <returns></returns>
        public static string GetTaggedValue(EA.Method method, string name, bool caseSensitive = true)
        {
            foreach (EA.MethodTag taggedValue in method.TaggedValues)
            {
                if (caseSensitive)
                {
                    if (taggedValue.Name == name)
                    {
                        return(GetTaggedValue(taggedValue));
                    }
                }
                else
                {
                    if (taggedValue.Name.ToLower() == name.ToLower())
                    {
                        return(GetTaggedValue(taggedValue));
                    }
                }
            }

            return("");
        }
Ejemplo n.º 8
0
        /// <summary>
        ///  Create/Update an Activity Diagram for the operation
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="m"></param>
        /// <param name="treePos">If a new package is created the new tree position to show the package in the correct order</param>
        /// <returns></returns>
        public static bool CreateActivityForOperation(EA.Repository rep, EA.Method m, int treePos = 100)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            EA.Package pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // Check if update behavior, behavior exists
            string behaviorGuid = m.Behavior;

            // Check if update Activity or Create a new one
            if (behaviorGuid.StartsWith("{") && behaviorGuid.EndsWith("}"))
            {
                //behaviorGuid = behaviorGuid.Substring(1, behaviorGuid.Length-2);
                EA.Element actForUpdate = rep.GetElementByGuid(behaviorGuid);
                if (actForUpdate == null)
                {
                    var res = MessageBox.Show($@"Can't update Activity for Operation, invalid link to Activity found

Behavior GUID =GUID of expected Activity:
{behaviorGuid}

Unable to find Activity for this GUID",
                                              @"Invalid link to Activity found, Create a new one?",
                                              MessageBoxButtons.OKCancel);
                    if (res != DialogResult.OK)
                    {
                        return(false);
                    }
                    CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass);
                }
                else
                {
                    UpdateParameterFromOperation(rep, actForUpdate, m); // update parameters from Operation for Activity
                }
                return(true);
            }
            CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass);
            return(true);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// GUIDを指定してEA上のメソッドオブジェクトを取得する
 /// </summary>
 /// <param name="methodGuid">検索対象メソッドのGUID</param>
 /// <returns>合致するGUIDでヒットしたメソッドオブジェクト。ヒットしなかったらnull</returns>
 private static EA.Method getMethodByGuid(string methodGuid)
 {
     EA.Repository repo   = ProjectSetting.getVO().eaRepo;
     EA.Method     mthObj = (EA.Method)repo.GetMethodByGuid(methodGuid);
     return(mthObj);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// EAのMethod(t_operator)を上書きもしくは追加する
        /// </summary>
        internal static void updateEaMethodObject(ElementVO myElement, MethodVO selectedMethod)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            EA.Element    elem = null;

            // EA.Repository の GetMethodByGuid を呼んでEA上の該当メソッドオブジェクトを取得する
            EA.Method mthObj = getMethodByGuid(selectedMethod.guid);

            if (mthObj == null)
            {
                elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                if (elem == null)
                {
                    return;
                }

                mthObj = (EA.Method)elem.Methods.AddNew(selectedMethod.name, selectedMethod.returnType);
            }

            writeUpdateLogMethod(mthObj, false);

            mthObj.Name         = selectedMethod.name;
            mthObj.MethodGUID   = selectedMethod.guid;
            mthObj.Alias        = selectedMethod.alias;
            mthObj.StereotypeEx = selectedMethod.stereoType;
            mthObj.Notes        = selectedMethod.notes;
            mthObj.Behavior     = selectedMethod.behavior;

            mthObj.Abstract     = selectedMethod.isAbstract;
            mthObj.ClassifierID = selectedMethod.classifierID;
            mthObj.Code         = selectedMethod.code;
            mthObj.Concurrency  = selectedMethod.concurrency;
            mthObj.IsConst      = selectedMethod.isConst;
            mthObj.IsLeaf       = selectedMethod.isLeaf;
            mthObj.IsPure       = selectedMethod.isPure;
            mthObj.IsQuery      = selectedMethod.isQuery;
            mthObj.IsRoot       = selectedMethod.isRoot;
            mthObj.IsStatic     = selectedMethod.isStatic;
            // mth.IsSynchronized = selectedMethod;
            mthObj.Pos           = selectedMethod.pos;
            mthObj.ReturnIsArray = selectedMethod.returnIsArray;
            mthObj.ReturnType    = selectedMethod.returnType;
            mthObj.StateFlags    = selectedMethod.stateFlags;
            mthObj.StyleEx       = selectedMethod.styleEx;
            mthObj.Throws        = selectedMethod.throws;
            mthObj.Visibility    = selectedMethod.visibility;
            mthObj.Update();

            // 既にパラメータが設定されている場合は一旦削除
            for (short i = 0; i < mthObj.Parameters.Count; i++)
            {
                mthObj.Parameters.Delete(i);
            }

            // XMLから読み込まれたパラメータの値を設定する
            foreach (ParameterVO prm in selectedMethod.parameters)
            {
                EA.Parameter paramObj = (EA.Parameter)mthObj.Parameters.AddNew(prm.name, prm.eaType);
                paramObj.Alias         = prm.alias;
                paramObj.ClassifierID  = prm.classifierID;
                paramObj.Default       = prm.defaultValue;
                paramObj.IsConst       = prm.isConst;
                paramObj.Kind          = prm.kind;
                paramObj.Name          = prm.name;
                paramObj.Notes         = prm.notes;
                paramObj.ParameterGUID = prm.guid;
                paramObj.Position      = prm.pos;
                paramObj.StereotypeEx  = prm.stereoType;
                // paramObj.Style = prm.Style ;
                // paramObj.StyleEx = prm.StyleEx ;
                paramObj.Type = prm.eaType;
                paramObj.Update();
            }

            mthObj.Update();

            writeUpdateLogMethod(mthObj, true);
        }
 public FunctionItem(string name, string returnType, bool isStatic, List <ParameterItem> par, InterfaceItem interfaceItem, EA.Method method)
 {
     FunctionItemInit(name, returnType, isStatic, par, interfaceItem, method);
 }
        public static MethodVO getMethodFromEAObject(EA.Method eaMethodObj)
        {
            MethodVO mthvo = new MethodVO();

            mthvo.name  = excludeSpecialChar(eaMethodObj.Name);
            mthvo.alias = excludeSpecialChar(eaMethodObj.Alias);
            if (eaMethodObj.StereotypeEx != null && !"".Equals(eaMethodObj.StereotypeEx))
            {
                mthvo.stereoType = eaMethodObj.StereotypeEx;
            }
            else
            {
                mthvo.stereoType = null;
            }

            mthvo.guid          = eaMethodObj.MethodGUID;
            mthvo.pos           = eaMethodObj.Pos;
            mthvo.classifierID  = eaMethodObj.ClassifierID;
            mthvo.isConst       = eaMethodObj.IsConst;
            mthvo.isLeaf        = eaMethodObj.IsLeaf;
            mthvo.isPure        = eaMethodObj.IsPure;
            mthvo.isQuery       = eaMethodObj.IsQuery;
            mthvo.isRoot        = eaMethodObj.IsRoot;
            mthvo.returnIsArray = eaMethodObj.ReturnIsArray;
            mthvo.stateFlags    = eaMethodObj.StateFlags;
            mthvo.behavior      = eaMethodObj.Behavior;
            mthvo.notes         = eaMethodObj.Notes;
            mthvo.returnType    = excludeSpecialChar(eaMethodObj.ReturnType);
            mthvo.visibility    = excludeSpecialChar(eaMethodObj.Visibility);

            List <ParameterVO> outParamList = new List <ParameterVO>();

            foreach (EA.Parameter eaParamObj in eaMethodObj.Parameters)
            {
                ParameterVO prm = new ParameterVO();
                prm.name         = excludeSpecialChar(eaParamObj.Name);
                prm.alias        = excludeSpecialChar(eaParamObj.Alias);
                prm.eaType       = excludeSpecialChar(eaParamObj.Type);
                prm.stereoType   = excludeSpecialChar(eaParamObj.StereotypeEx);
                prm.guid         = eaParamObj.ParameterGUID;
                prm.pos          = eaParamObj.Position;
                prm.classifierID = eaParamObj.ClassifierID;
                prm.defaultValue = excludeSpecialChar(eaParamObj.Default);
                prm.isConst      = eaParamObj.IsConst;
                prm.kind         = eaParamObj.Kind;
                prm.styleEx      = excludeSpecialChar(eaParamObj.StyleEx);
                prm.notes        = eaParamObj.Notes;
                prm.objectType   = "25";
                outParamList.Add(prm);
            }
            mthvo.parameters = outParamList;

            List <TaggedValueVO> outTagList = new List <TaggedValueVO>();

            foreach (EA.MethodTag mtag in eaMethodObj.TaggedValues)
            {
                outTagList.Add(getMethodTagFromEAObject(mtag));
            }
            mthvo.taggedValues = outTagList;

            return(mthvo);
        }
Ejemplo n.º 13
0
        void ReflectToEAToolStripMenuItemClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            EA.Element    elem = null;
            int           tmp  = -1;

            if (repo != null)
            {
                // 選択された属性に対する更新処理
                if (selectedAttribute != null)
                {
                    //メッセージボックスを表示する
                    DialogResult result = MessageBox.Show("EAのリポジトリの属性を上書き、もしくは追加します。よろしいですか?",
                                                          "質問",
                                                          MessageBoxButtons.YesNoCancel,
                                                          MessageBoxIcon.Exclamation,
                                                          MessageBoxDefaultButton.Button1);

                    //何が選択されたか調べる
                    if (result == DialogResult.Yes)
                    {
                        EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);
                        if (attr == null)
                        {
                            elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                            if (elem == null)
                            {
                                return;
                            }
                            attr = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, "String");
                        }

                        attr.Name          = selectedAttribute.name;
                        attr.AttributeGUID = selectedAttribute.guid;
                        attr.Alias         = selectedAttribute.alias;
                        attr.StereotypeEx  = selectedAttribute.stereoType;
                        attr.Notes         = selectedAttribute.notes;

                        attr.AllowDuplicates = selectedAttribute.allowDuplicates;
                        if ("".Equals(selectedAttribute.classifierID) || !Int32.TryParse(selectedAttribute.classifierID, out tmp))
                        {
                            selectedAttribute.classifierID = "0";
                        }
                        else
                        {
                            attr.ClassifierID = tmp;
                        }
//						attr.ClassifierID =  Int32.Parse( selectedAttribute.classifierID );

                        attr.Container    = selectedAttribute.container;
                        attr.Containment  = selectedAttribute.containment;
                        attr.Default      = selectedAttribute.defaultValue;
                        attr.IsCollection = selectedAttribute.isCollection;
                        attr.IsConst      = selectedAttribute.isConst;
                        attr.IsDerived    = selectedAttribute.isDerived;
                        // attr.IsID = selectedAttribute.;
                        attr.IsOrdered  = selectedAttribute.isOrdered;
                        attr.IsStatic   = selectedAttribute.isStatic;
                        attr.Length     = selectedAttribute.length.ToString();
                        attr.LowerBound = selectedAttribute.lowerBound.ToString();
                        attr.Precision  = selectedAttribute.precision.ToString();
                        // attr.RedefinedProperty = selectedAttribute.;
                        attr.Scale = selectedAttribute.scale.ToString();
                        // attr.Stereotype = ;
                        // attr.Style = selectedAttribute.;
                        // attr.SubsettedProperty = selectedAttribute.;
                        // attr.StyleEx = selectedAttribute.;
                        attr.Type       = selectedAttribute.eaType;
                        attr.UpperBound = selectedAttribute.upperBound.ToString();
                        attr.Visibility = selectedAttribute.visibility;

                        attr.Update();
//						elem.Update();
                    }
                    else
                    {
                        return;
                    }
                }


                // 選択された操作に対する更新処理
                if (selectedMethod != null)
                {
                    //メッセージボックスを表示する
                    DialogResult result = MessageBox.Show("EAのリポジトリの操作を上書き、もしくは追加します。よろしいですか?",
                                                          "質問",
                                                          MessageBoxButtons.YesNoCancel,
                                                          MessageBoxIcon.Exclamation,
                                                          MessageBoxDefaultButton.Button1);

                    //何が選択されたか調べる
                    if (result == DialogResult.Yes)
                    {
                        EA.Method mth = getMethodByGuid(selectedMethod.guid);

                        if (mth == null)
                        {
                            elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                            if (elem == null)
                            {
                                return;
                            }

                            mth = (EA.Method)elem.Methods.AddNew(selectedMethod.name, selectedMethod.returnType);
                        }

                        mth.Name         = selectedMethod.name;
                        mth.MethodGUID   = selectedMethod.guid;
                        mth.Alias        = selectedMethod.alias;
                        mth.StereotypeEx = selectedMethod.stereoType;
                        mth.Notes        = selectedMethod.notes;
                        mth.Behavior     = selectedMethod.behavior;

                        mth.Abstract     = selectedMethod.isAbstract;
                        mth.ClassifierID = selectedMethod.classifierID;
                        mth.Code         = selectedMethod.code;
                        mth.Concurrency  = selectedMethod.concurrency;
                        mth.IsConst      = selectedMethod.isConst;
                        mth.IsLeaf       = selectedMethod.isLeaf;
                        mth.IsPure       = selectedMethod.isPure;
                        mth.IsQuery      = selectedMethod.isQuery;
                        mth.IsRoot       = selectedMethod.isRoot;
                        mth.IsStatic     = selectedMethod.isStatic;
                        // mth.IsSynchronized = selectedMethod.s isSynchronized;
                        mth.Pos           = selectedMethod.pos;
                        mth.ReturnIsArray = selectedMethod.returnIsArray;
                        mth.ReturnType    = selectedMethod.returnType;
                        mth.StateFlags    = selectedMethod.stateFlags;
                        // mth.StyleEx = selectedMethod.StyleEx;
                        mth.Throws     = selectedMethod.throws;
                        mth.Visibility = selectedMethod.visibility;
                        mth.Update();

                        // 既にパラメータが設定されている場合は一旦削除
                        for (short i = 0; i < mth.Parameters.Count; i++)
                        {
                            mth.Parameters.Delete(i);
                        }

                        // XMLから読み込まれたパラメータの値を設定する
                        foreach (ParameterVO prm in selectedMethod.parameters)
                        {
                            EA.Parameter paramObj = (EA.Parameter)mth.Parameters.AddNew(prm.name, prm.eaType);
                            paramObj.Alias         = prm.alias;
                            paramObj.ClassifierID  = prm.classifierID;
                            paramObj.Default       = prm.defaultValue;
                            paramObj.IsConst       = prm.isConst;
                            paramObj.Kind          = prm.kind;
                            paramObj.Name          = prm.name;
                            paramObj.Notes         = prm.notes;
                            paramObj.ParameterGUID = prm.guid;
                            paramObj.Position      = prm.pos;
                            paramObj.StereotypeEx  = prm.stereoType;
                            // paramObj.Style = prm.Style ;
                            // paramObj.StyleEx = prm.StyleEx ;
                            paramObj.Type = prm.eaType;
                            paramObj.Update();
                        }

//						elem.Update();
                    }
                    else
                    {
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("EAにアタッチしていないため、反映できません");
            }
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        //-----------------------------------------------------------------------------------------
        // 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);
        }