コード例 #1
0
ファイル: EAUtil.cs プロジェクト: NCIP/cagrid-grid-incubation
        public static void annotateWithCDE(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.dataelement de)
        {
            object item;
            const string CDEREF = "CDERef";
            const string PREFNAME = "preferred name";

            try
            {
                string id = de.names.id;
                string name = de.names.preferred;

                EA.ObjectType type = m_Repository.GetTreeSelectedItem(out item);
                if (type != EA.ObjectType.otAttribute)
                {
                    MessageBox.Show("No class attribute has been selected in the Project Browser", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                EA.Attribute attr = (EA.Attribute)item;

                //string txt = "Container["+attr.Container;
                //txt += "]\nContainment["+attr.Containment;
                //txt += "]\nDefault["+attr.Default;
                //txt += "]\nParentID["+attr.ParentID;
                //txt += "]\nPos["+attr.Pos;
                //txt += "]\nStereotype["+attr.Stereotype;
                //txt += "]\nStereotypeEx["+attr.StereotypeEx;
                //txt += "]\nStyle["+attr.Style;
                //txt += "]\nStyleEx["+attr.StyleEx;
                //txt += "]\n";
                //MessageBox.Show(txt);

                EA.Collection tvs = attr.TaggedValues;

                if (tagExists(attr.TaggedValues, CDEREF))
                {
                    //DialogResult dg = MessageBox.Show(
                    //    el.Name + " already has a " + CDEREF + " annotation. Replace?",
                    //    "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    //if (dg == DialogResult.Cancel)
                    //    return;
                    MessageBox.Show(attr.Name + " already has a " + CDEREF + " annotation. Please remove and try again.");
                    return;
                }

                if (tagExists(attr.TaggedValues, PREFNAME))
                {
                    MessageBox.Show(attr.Name + " already has a " + PREFNAME + " annotation. Please remove and try again.");
                    return;
                }

                EAUtil.addTaggedValue(CDEREF, id, attr);
                EAUtil.addTaggedValue(PREFNAME, name, attr);

                //
                // All done, just display a successful message window
                //
                string attrName = "";
                EA.Element pel = m_Repository.GetElementByID(attr.ParentID);
                if (pel != null && pel.Name != null && pel.Name.Length > 0)
                    attrName = pel.Name + ".";
                attrName += attr.Name;

                MessageBox.Show("Attribute [" + attrName + "] successfully annotated with:\n\n"
                    + CDEREF + " =>   " + id + "\n"
                    + PREFNAME + " =>   " + name + "\n",
                    "Success",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
            catch(Exception exp)
            {
                MessageBox.Show("Error annotating with CDE. " + exp.Message);
            }
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: NCIP/cagrid-grid-incubation
        /*
        private void ShowElementDetails(EA.Repository repository)
        {
            if (!SelectedElement(repository))
            {
                MessageBox.Show("No element selected");
            }

            object item;
            EA.ObjectType t = repository.GetTreeSelectedItem(out item);
            EA.Diagram r = (EA.Diagram)item;
            string s = "Author: " + r.Author + "\n";
            s += "CreatedDate: " + r.CreatedDate + "\n";
            s += "DiagramGUID: " + r.DiagramGUID + "\n";
            s += "ExtendedStyle: " + r.ExtendedStyle + "\n";
            s += "MetaType: " + r.MetaType + "\n";
            s += "Name: " + r.Name + "\n";
            s += "Notes: " + r.Notes + "\n";
            s += "ObjectType: " + r.ObjectType.ToString() + "\n";
            s += "Orientation: " + r.Orientation + "\n";
            s += "Stereotype: " + r.Stereotype + "\n";
            s += "StereotypeEx: " + r.StereotypeEx + "\n";
            s += "StyleEx: " + r.StyleEx + "\n";
            s += "Swimlanes: " + r.Swimlanes + "\n";
            s += "Type: " + r.Type + "\n";
            s += "Version: " + r.Version + "\n";
            MessageBox.Show(s);

            EA.DiagramObject dObj = (EA.DiagramObject)r.SelectedObjects.GetAt(0);
            EA.Element el = repository.GetElementByID(dObj.ElementID);

            s = "Abstract: " + el.Abstract + "\n";
            s += "ActionFlags: " + el.ActionFlags + "\n";
            s += "Alias: " + el.Alias + "\n";
            s += "Author: " + el.Author + "\n";
            s += "ClassifierName: " + el.ClassifierName + "\n";
            s += "ClassifierType: " + el.ClassifierType + "\n";
            s += "Complexity: " + el.Complexity + "\n";
            s += "Difficulty: " + el.Difficulty + "\n";
            s += "ElementGUID: " + el.ElementGUID + "\n";
            s += "EventFlags: " + el.EventFlags + "\n";
            s += "ExtensionPoints: " + el.ExtensionPoints + "\n";
            s += "Genfile: " + el.Genfile + "\n";
            s += "Genlinks: " + el.Genlinks + "\n";
            s += "Gentype: " + el.Gentype + "\n";
            s += "MetaType: " + el.MetaType + "\n";
            s += "Multiplicity: " + el.Multiplicity + "\n";
            s += "Name: " + el.Name + "\n";
            s += "Notes: " + el.Notes + "\n";
            s += "Phase: " + el.Phase + "\n";
            s += "Priority: " + el.Priority + "\n";
            s += "Status: " + el.Status + "\n";
            s += "Stereotype: " + el.Stereotype + "\n";
            s += "StereotypeEx: " + el.StereotypeEx + "\n";
            s += "StyleEx: " + el.StyleEx + "\n";
            s += "Tag: " + el.Tag + "\n";
            s += "Type: " + el.Type + "\n";
            s += "Version: " + el.Version + "\n";
            s += "Visibility: " + el.Visibility + "\n";
            MessageBox.Show(s);
        }
        */
        private bool SelectedElement(EA.Repository repository)
        {
            try
            {
                object item;
                EA.ObjectType t = repository.GetTreeSelectedItem(out item);
                EA.Diagram r = (EA.Diagram)item;
                if (r.SelectedObjects.Count != 1)
                {
                    return false;
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
コード例 #3
0
ファイル: EAUtil.cs プロジェクト: NCIP/cagrid-grid-incubation
        public static void insertConceptRef(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.concept concept)
        {
            try
            {
                string id = concept.names.id;
                if (id.StartsWith("http:"))
                {
                    id = id.Substring(id.IndexOf("#") + 1);
                }
                else
                {
                    id = id.Substring(id.LastIndexOf("-") + 1);
                }

                object item;
                EA.ObjectType t = m_Repository.GetTreeSelectedItem(out item);

                if (t.ToString() == "otDiagram")
                {
                    MessageBox.Show("Please select an package or element in the Project Browser.");
                }
                else if (t.ToString() == "otElement")
                {
                    EA.Element el = (EA.Element)item;
                    string note = el.Notes;
                    if (note.Contains("ConceptRefs: ["))
                    {
                        if (!note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", "").Contains(id))
                        {
                            el.Notes = note.Substring(0, note.IndexOf("ConceptRefs: [") + 14) + note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", ", " + id + "])");
                        }
                    }
                    else
                    {
                        el.Notes += " (ConceptRefs: [" + id + "])";
                    }
                    el.Update();
                    el.Refresh();
                    MessageBox.Show("Concept reference, " + id + ", inserted to selected element.");
                }
                else if (t.ToString() == "otPackage")
                {
                    EA.Package pkg = (EA.Package)item;
                    string note = pkg.Notes;
                    if (note.Contains("ConceptRefs: ["))
                    {
                        if (!note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", "").Contains(id))
                        {
                            pkg.Notes = note.Substring(0, note.IndexOf("ConceptRefs: [") + 14) + note.Substring(note.IndexOf("ConceptRefs: [") + 14).Replace("])", ", " + id + "])");
                        }
                    }
                    else
                    {
                        pkg.Notes += " (ConceptRefs: [" + id + "])";
                    }
                    pkg.Update();
                    MessageBox.Show("Concept reference, " + id + ", inserted to selected package.");
                }
                else
                {
                    MessageBox.Show("Please select a valid element (class, package) for the concept reference to be inserted into.");
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("Error inserting concept reference. " + exp.Message);
            }
        }
コード例 #4
0
 private static bool IsModelOrPackageSelected(EA.Repository repository)
 {
     if (IsProjectOpen(repository))
     {
         object item;
         EA.ObjectType objectType = repository.GetTreeSelectedItem(out item);
         return (objectType == EA.ObjectType.otModel ||
                 objectType == EA.ObjectType.otPackage);
     } else {
         return false;
     }
 }