Exemplo n.º 1
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);
        }
Exemplo n.º 2
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にアタッチしていないため、反映できません");
            }
        }