Ejemplo n.º 1
0
 /// <summary>
 /// GUIDを指定してEA上の属性オブジェクトを取得する
 /// </summary>
 /// <param name="attributeGuid">検索対象属性のGUID</param>
 /// <returns>合致するGUIDでヒットした属性オブジェクト。ヒットしなかったらnull</returns>
 private static EA.Attribute getAttributeByGuid(string attributeGuid)
 {
     EA.Repository repo    = ProjectSetting.getVO().eaRepo;
     EA.Attribute  attrObj = (EA.Attribute)repo.GetAttributeByGuid(attributeGuid);
     if (attrObj != null)
     {
         return(attrObj);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 2
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.º 3
0
        /// <summary>
        /// EAのAttributeを上書きもしくは追加する
        /// </summary>
        internal static void updateEaAttributeObject(ElementVO myElement, AttributeVO selectedAttribute)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;
            EA.Element    elem = null;
            int           tmp  = -1;

            // EAのAPIを使って属性をGUIDより検索
            EA.Attribute attrObj = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid);

            // 取得できなかったら(該当するGUIDの属性が存在しなかったら)
            if (attrObj == null)
            {
                // この属性を持っているはずの要素をGUIDより検索
                elem = (EA.Element)repo.GetElementByGuid(myElement.guid);
                if (elem == null)
                {
                    return;
                }
                attrObj = (EA.Attribute)elem.Attributes.AddNew(selectedAttribute.name, selectedAttribute.eaType);
            }

            // 更新前後で更新ログ出力
            writeUpdateLogAttribute(attrObj, false);

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

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

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

            attrObj.Update();
            //						elem.Update();

            // 更新前後で更新ログ出力
            writeUpdateLogAttribute(attrObj, true);
        }
Ejemplo n.º 4
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にアタッチしていないため、反映できません");
            }
        }