/// <summary>
 /// Get element from Context element. Possible inputs are: Attribute, Operation, Element, Package
 /// </summary>
 /// <param name="rep"></param>
 /// <returns></returns>
 public static EA.Element GetElementFromContextObject(EA.Repository rep)  {
     EA.Element el = null;
     EA.ObjectType objectType = rep.GetContextItemType();
     switch (objectType)
     {
         case ObjectType.otAttribute:
             var a = (EA.Attribute)rep.GetContextObject();
             el = rep.GetElementByID(a.ParentID);
             break;
         case ObjectType.otMethod:
             var m = (Method)rep.GetContextObject();
             el = rep.GetElementByID(m.ParentID);
             break;
         case ObjectType.otElement:
             el = (EA.Element)rep.GetContextObject();
             break;
         case ObjectType.otPackage:
             EA.Package pkg  = rep.GetContextObject();
             el = rep.GetElementByGuid(pkg.PackageGUID);
             break;
         case ObjectType.otNone:
             EA.Diagram dia = rep.GetCurrentDiagram();
             if (dia?.SelectedObjects.Count == 1)
             {
                 var objSelected = (EA.DiagramObject)dia.SelectedObjects.GetAt(0);
                 el = rep.GetElementByID(objSelected.ElementID);
             }
             break;
         default:
             MessageBox.Show(@"No Element, Attribute, Operation, Package selected");
             break;
      }
     return el;
 }
        /// <summary>
        /// method changes scope of attribute
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="attributeGUID">GUID of changed attribute</param>
        /// <param name="scope">new scope of changed attribute</param>
        /// <param name="oldScope">previous scope of changed attribute</param>
        public void changeAttributeVisibility(EA.Repository Repository, string attributeGUID, string scope, string oldScope)
        {
            EA.Attribute attribute = (EA.Attribute)Repository.GetAttributeByGuid(attributeGUID);
            attribute.Visibility = scope;
            attribute.Update();

            EA.Element element = (EA.Element)Repository.GetElementByID(attribute.ParentID);

            BPAddIn.synchronizationWindow.addToList("Change of scope of attribute '" +
               attribute.Name + "' - previous scope: '" + oldScope + "', current scope: '" + scope +
               "' (Attribute of element '" + element.Name + "', location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));
        }
        /// <summary>
        /// method deletes connector
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="connectorGUID">GUID of connector that should be deleted</param>
        /// <param name="diagramGUID">GUID of diagram</param>
        /// <param name="elementType">type of connector that should be deleted</param>
        public void deleteConnector(EA.Repository Repository, string connectorGUID, string diagramGUID, int elementType)
        {
            EA.Connector connector = (EA.Connector)Repository.GetConnectorByGuid(connectorGUID);
            string name = connector.Name;
            EA.Element srcElement = (EA.Element)Repository.GetElementByID(connector.ClientID);
            EA.Element targetElement = (EA.Element)Repository.GetElementByID(connector.SupplierID);

            for (short i = 0; i < srcElement.Connectors.Count; i++)
            {
                EA.Connector conn = (EA.Connector)srcElement.Connectors.GetAt(i);
                if (conn.ConnectorGUID == connectorGUID)
                {
                    srcElement.Connectors.DeleteAt(i, false);
                    break;
                }
            }
            srcElement.Connectors.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '"
                + name + "' between element '" + srcElement.Name +
                "' and element '" + targetElement.Name + "'");
        }
        //---------------------------------------------------------------------------------------------
        // updateActionParameter(EA.Repository rep, EA.Element actionPin)
        //---------------------------------------------------------------------------------------------
        public static bool UpdateActionPinParameter(EA.Repository rep, EA.Element action)
        {
            foreach (EA.Element actionPin in action.EmbeddedElements)
            {
                // pin target for the return type of the action
                if (actionPin.Name == "target")
                {
                    //// return type
                    //Int32 parTypeID = Util.getTypeID(rep, m.ReturnType);
                    //if (parTypeID != 0)
                    //{
                    //    //pin.Name = par.
                    //    pin.ClassfierID = parTypeID;
                    //    EA.Element el = rep.GetElementByID(parTypeID);
                    //    pin.Update(); // do it before update table
                    //    Util.setElementPDATA1(rep, pin, el.ElementGUID);// set PDATA1

                    //}
                }
                else
                {
                    // get type of synchronized parameter
                    // if parameter isn't synchronized it will not work
                    string type = Util.GetParameterType(rep, actionPin.ElementGUID);
                    if (type == "")
                    {
                        string txt = "No type is available for action:'" + action.Name + "'";
                        rep.WriteOutput("ifm_addin", txt, 0);
                    }
                    else
                    {
                        Int32 parTypeId = Util.GetTypeId(rep, type);
                        if (parTypeId != 0)
                        {
                            //pin.Name = par.
                            EA.Element el = rep.GetElementByID(parTypeId);
                            Util.SetElementPdata1(rep, actionPin, el.ElementGUID);// PDATA1 setzen
                        }
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// method deletes attribute from element
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="attributeGUID">GUID of attribute that should be deleted</param>
        public void deleteAttribute(EA.Repository Repository, string attributeGUID)
        {
            EA.Attribute attribute = (EA.Attribute)Repository.GetAttributeByGuid(attributeGUID);
            string name = attribute.Name;
            EA.Element element = (EA.Element)Repository.GetElementByID(attribute.ParentID);

            for (short i = 0; i < element.Attributes.Count; i++)
            {
                EA.Attribute actualAttribute = (EA.Attribute)element.Attributes.GetAt(i);
                if (actualAttribute.AttributeGUID == attributeGUID)
                {
                    element.Attributes.DeleteAt(i, false);
                    break;
                }
            }
            element.Attributes.Refresh();

            BPAddIn.synchronizationWindow.addToList("Deletion of attribute '" + name + "' from element '" + element.Name
                + "' (Location of element: " + itemTypes.getLocationOfItem(Repository, element.PackageID, element.ParentID));
        }
예제 #6
0
        /// <summary>
        /// Selected items in the project browser are processed differently than selected elements
        /// in the visible diagram. This helper will grab the currently selected project browser item first.
        /// If it doesn't find it, it will return the currently selected diagram item.
        /// </summary>
        /// <param name="repository">The currently open EA repository</param>
        /// <returns>The element currently selected in either the project browser or diagram</returns>
        public static EA.Element GetCurrentElement(EA.Repository repository)
        {
            EA.Element result = null;

            EA.Collection elements = repository.GetTreeSelectedElements();

            if (elements.Count > 0)
            {
                result = elements.GetAt(0);
            }
            else
            {
                EA.Diagram diagram = repository.GetCurrentDiagram();
                if (diagram != null)
                {
                    EA.DiagramObject s = diagram.SelectedObjects.GetAt(0);
                    result = repository.GetElementByID(s.ElementID);
                }
            }

            return result;
        }
예제 #7
0
        private void DoRule09(EA.Repository Repository, EA.Connector Connector)
        {
            EA.Project Project = Repository.GetProjectInterface();
            EA.Element client = Repository.GetElementByID(Connector.ClientID);
            EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);

            if (Connector.Stereotype == "XisEntityInheritance"
                && (client.Stereotype != "XisEntity" || supplier.Stereotype != "XisEntity"))
            {
                Project.PublishResult(LookupMap(rule09), EA.EnumMVErrorType.mvError, GetRuleStr(rule09));
                isValid = false;
            }
        }
예제 #8
0
        private void DoRule89_to_93(EA.Repository Repository, EA.Element Element, string stereotype)
        {
            if (Element.Type == "Class" && Element.Stereotype == stereotype)
            {
                string entityName = M2MTransformer.GetTaggedValue(Element.TaggedValues, "entityName").Value;

                if (!string.IsNullOrEmpty(entityName))
                {
                    EA.Element space = null;
                    EA.Element el = null;
                    EA.Connector conn = null;
                    EA.Connector assoc = null;
                    bool publishResult = false;
                    int parentID = Element.ParentID;

                    while (parentID > 0)
                    {
                        el = Repository.GetElementByID(parentID);

                        if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace")
                        {
                            space = el;
                            break;
                        }
                        parentID = el.ParentID;
                    }

                    if (space == null && stereotype == "XisMenu")
                    {
                        EA.Element end = null;

                        for (short i = 0; i < Element.Connectors.Count; i++)
                        {
                            conn = Element.Connectors.GetAt(i);

                            if (conn.ClientID != Element.ElementID)
                            {
                                end = Repository.GetElementByID(conn.ClientID);
                            }
                            else
                            {
                                end = Repository.GetElementByID(conn.SupplierID);
                            }

                            if (conn.Stereotype == "XisIS-MenuAssociation")
                            {
                                if (end.Stereotype == "XisInteractionSpace")
                                {
                                    space = end;
                                    break;
                                }
                                else
                                {
                                    parentID = end.ParentID;

                                    while (parentID > 0)
                                    {
                                        el = Repository.GetElementByID(parentID);

                                        if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace")
                                        {
                                            space = el;
                                            break;
                                        }
                                        parentID = el.ParentID;
                                    }
                                }
                            }
                        }
                    }

                    if (space != null)
                    {
                        for (short i = 0; i < space.Connectors.Count; i++)
                        {
                            conn = space.Connectors.GetAt(i);

                            if (conn.Stereotype == "XisIS-BEAssociation")
                            {
                                assoc = conn;
                                break;
                            }
                        }

                        if (assoc != null)
                        {
                            EA.Element be = Repository.GetElementByID(assoc.SupplierID);
                            bool hasEntity = false;

                            if (be.Stereotype == "XisBusinessEntity" && be.Connectors.Count > 0)
                            {
                                EA.Element entity = null;

                                for (short i = 0; i < be.Connectors.Count; i++)
                                {
                                    conn = be.Connectors.GetAt(i);

                                    if (conn.Stereotype == "XisBE-EntityMasterAssociation"
                                        || conn.Stereotype == "XisBE-EntityDetailAssociation"
                                        || conn.Stereotype == "XisBE-EntityReferenceAssociation")
                                    {
                                        entity = Repository.GetElementByID(conn.SupplierID);

                                        if (entity.Type == "Class" && entity.Stereotype == "XisEntity"
                                            && entity.Name == entityName)
                                        {
                                            hasEntity = true;
                                            break;
                                        }
                                    }
                                }

                                if (!hasEntity)
                                {
                                    publishResult = true;
                                }
                            }
                            else
                            {
                                publishResult = true;
                            }
                        }
                        else
                        {
                            publishResult = true;
                        }
                    }
                    else
                    {
                        publishResult = true;
                    }

                    if (publishResult)
                    {
                        EA.Project Project = Repository.GetProjectInterface();

                        switch (stereotype)
                        {
                            case "XisForm":
                                Project.PublishResult(LookupMap(rule89), EA.EnumMVErrorType.mvError, GetRuleStr(rule89));
                                isValid = false;
                                break;
                            case "XisList":
                                Project.PublishResult(LookupMap(rule90), EA.EnumMVErrorType.mvError, GetRuleStr(rule90));
                                isValid = false;
                                break;
                            case "XisListGroup":
                                Project.PublishResult(LookupMap(rule91), EA.EnumMVErrorType.mvError, GetRuleStr(rule91));
                                isValid = false;
                                break;
                            case "XisVisibilityBoundary":
                                Project.PublishResult(LookupMap(rule92), EA.EnumMVErrorType.mvError, GetRuleStr(rule92));
                                isValid = false;
                                break;
                            case "XisMenu":
                                Project.PublishResult(LookupMap(rule93), EA.EnumMVErrorType.mvError, GetRuleStr(rule93));
                                isValid = false;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
예제 #9
0
        private void DoRule96_97(EA.Repository Repository, EA.Element Element, string filter)
        {
            if (Element.Type == "Class" && Element.Stereotype == "XisList")
            {
                string domainRef = M2MTransformer.GetTaggedValue(Element.TaggedValues, filter).Value;

                if (!string.IsNullOrEmpty(domainRef) && domainRef.Contains('.'))
                {
                    bool publishResult = false;
                    string[] values = domainRef.Split('.');

                    if (values.Length == 2)
                    {
                        EA.Element space = null;
                        EA.Element el = null;
                        EA.Connector conn = null;
                        EA.Connector assoc = null;
                        int parentID = Element.ParentID;

                        while (parentID > 0)
                        {
                            el = Repository.GetElementByID(parentID);

                            if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace")
                            {
                                space = el;
                                break;
                            }
                            parentID = el.ParentID;
                        }

                        if (space != null)
                        {
                            for (short i = 0; i < space.Connectors.Count; i++)
                            {
                                conn = space.Connectors.GetAt(i);

                                if (conn.Stereotype == "XisIS-BEAssociation")
                                {
                                    assoc = conn;
                                    break;
                                }
                            }

                            if (assoc != null)
                            {
                                EA.Element be = Repository.GetElementByID(assoc.SupplierID);
                                bool hasEntity = false;

                                if (be.Stereotype == "XisBusinessEntity" && be.Connectors.Count > 0)
                                {
                                    EA.Element entity = null;

                                    for (short i = 0; i < be.Connectors.Count; i++)
                                    {
                                        conn = be.Connectors.GetAt(i);

                                        if (conn.Stereotype == "XisBE-EntityMasterAssociation"
                                            || conn.Stereotype == "XisBE-EntityDetailAssociation"
                                            || conn.Stereotype == "XisBE-EntityReferenceAssociation")
                                        {
                                            entity = Repository.GetElementByID(conn.SupplierID);

                                            if (entity.Type == "Class" && entity.Stereotype == "XisEntity"
                                                && entity.Name == values[0])
                                            {
                                                hasEntity = true;
                                                break;
                                            }
                                        }
                                    }

                                    if (hasEntity && entity.Attributes.Count > 0)
                                    {
                                        bool attrExists = false;
                                        EA.Attribute attr = null;

                                        for (short i = 0; i < entity.Attributes.Count; i++)
                                        {
                                            attr = entity.Attributes.GetAt(i);

                                            if (attr.Stereotype == "XisEntityAttribute" && attr.Name == values[1])
                                            {
                                                attrExists = true;
                                                break;
                                            }
                                        }

                                        if (!attrExists)
                                        {
                                            publishResult = true;
                                        }
                                    }
                                    else
                                    {
                                        publishResult = true;
                                    }
                                }
                                else
                                {
                                    publishResult = true;
                                }
                            }
                            else
                            {
                                publishResult = true;
                            }
                        }
                        else
                        {
                            publishResult = true;
                        }
                    }
                    else
                    {
                        publishResult = true;
                    }

                    if (publishResult)
                    {
                        EA.Project Project = Repository.GetProjectInterface();

                        switch (filter)
                        {
                            case "searchBy":
                                Project.PublishResult(LookupMap(rule96), EA.EnumMVErrorType.mvError, GetRuleStr(rule96));
                                isValid = false;
                                break;
                            case "orderBy":
                                Project.PublishResult(LookupMap(rule97), EA.EnumMVErrorType.mvError, GetRuleStr(rule97));
                                isValid = false;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
        private void DoRule87(EA.Repository Repository, EA.Method method)
        {
            if (method.Stereotype == "XisAction")
            {
                string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value;

                if (type == "Navigate")
                {
                    string navigation = M2MTransformer.GetMethodTag(method.TaggedValues, "navigation").Value;

                    if (!string.IsNullOrEmpty(navigation))
                    {
                        EA.Package model = Repository.GetPackageByID(Repository.GetElementByID(method.ParentID).PackageID);
                        EA.Package interaction = null;

                        if (model.StereotypeEx == "InteractionSpace View")
                        {
                            interaction = model;
                        }

                        if (interaction != null)
                        {
                            EA.Element el = null;
                            bool exists = false;

                            for (short i = 0; i < interaction.Elements.Count; i++)
                            {
                                el = interaction.Elements.GetAt(i);

                                if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace" && el.Name == navigation)
                                {
                                    exists = true;
                                    break;
                                }
                            }

                            if (!exists)
                            {
                                EA.Project Project = Repository.GetProjectInterface();
                                Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
                                isValid = false;
                            }
                        }
                        else
                        {
                            EA.Project Project = Repository.GetProjectInterface();
                            Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
                            isValid = false;
                        }
                    }
                    else
                    {
                        EA.Project Project = Repository.GetProjectInterface();
                        Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87));
                        isValid = false;
                    }
                }
            }
        }
예제 #12
0
파일: MyAddin.cs 프로젝트: jotab/add_in
 private Boolean EA_OnPostNewDiagramObject(EA.Repository repository, EA.EventProperties info)
 {
     outputTabActive(repository);
     MessageBox.Show("NEW OBJECT CREATED");
     EA.Element element = repository.GetElementByID(IDcollect(repository, info));
     return true;
 }
예제 #13
0
        private void DoRule13(EA.Repository Repository, EA.Element Element)
        {
            if (Element.Type == "Class" && Element.Stereotype == "XisBusinessEntity")
            {
                if (Element.Connectors.Count > 0)
                {
                    bool hasAssociation = false;
                    EA.Connector conn = null;
                    EA.Element supplier = null;

                    for (short i = 0; i < Element.Connectors.Count; i++)
                    {
                        conn = Element.Connectors.GetAt(i);
                        supplier = Repository.GetElementByID(conn.SupplierID);

                        if ((conn.Stereotype == "XisBE-EntityMasterAssociation"
                            || conn.Stereotype == "XisBE-EntityDetailAssociation"
                            || conn.Stereotype == "XisBE-EntityReferenceAssociation")
                            && supplier.Stereotype == "XisEntity")
                        {
                            hasAssociation = true;
                            break;
                        }
                    }

                    if (!hasAssociation)
                    {
                        EA.Project Project = Repository.GetProjectInterface();
                        Project.PublishResult(LookupMap(rule13), EA.EnumMVErrorType.mvError, GetRuleStr(rule13));
                        isValid = false;
                    }
                }
                else
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule13), EA.EnumMVErrorType.mvError, GetRuleStr(rule13));
                    isValid = false;
                }
            }
        }
예제 #14
0
        private void DoRule39(EA.Repository Repository, EA.Connector Connector)
        {
            if (Connector.Stereotype == "XisWidget-GestureAssociation")
            {
                EA.Element client = Repository.GetElementByID(Connector.ClientID);
                EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);

                if (supplier.Stereotype != "XisGesture" ||
                    (client.Stereotype != "XisLabel" && client.Stereotype != "XisTextBox" && client.Stereotype != "XisCheckBox"
                     && client.Stereotype != "Button" && client.Stereotype != "Link" && client.Stereotype != "XisImage"
                     && client.Stereotype != "XisDatePicker" && client.Stereotype != "XisTimePicker" && client.Stereotype != "XisDropdown"
                     && client.Stereotype != "XisListItem" && client.Stereotype != "XisMenuItem"))
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule39), EA.EnumMVErrorType.mvError, GetRuleStr(rule39));
                    isValid = false;
                }
            }
        }
예제 #15
0
        private void DoRule50(EA.Repository Repository, EA.Element Element)
        {
            if (Element.Type == "Class" && Element.Stereotype == "XisMenu")
            {
                EA.TaggedValue menuType = M2MTransformer.GetTaggedValue(Element.TaggedValues, "type");

                if (menuType != null && menuType.Value == "OptionsMenu")
                {
                    if (Element.ParentID > 0)
                    {
                        EA.Element parent = Repository.GetElementByID(Element.ParentID);

                        if (parent.Stereotype != "XisInteractionSpace")
                        {
                            if (parent.Stereotype == "XisVisibilityBoundary" && parent.ParentID > 0)
                            {
                                parent = Repository.GetElementByID(parent.ParentID);

                                if (parent.Stereotype != "XisInteractionSpace")
                                {
                                    EA.Project Project = Repository.GetProjectInterface();
                                    Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
                                    isValid = false;
                                }
                            }
                            else
                            {
                                EA.Project Project = Repository.GetProjectInterface();
                                Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
                                isValid = false;
                            }
                        }
                    }
                    else if (Element.Connectors.Count > 0)
                    {
                        EA.Connector conn = null;
                        EA.Element end = null;

                        for (short i = 0; i < Element.Connectors.Count; i++)
                        {
                            conn = Element.Connectors.GetAt(i);

                            if (conn.ClientID != Element.ElementID)
                            {
                                end = Repository.GetElementByID(conn.ClientID);
                            }
                            else
                            {
                                end = Repository.GetElementByID(conn.SupplierID);
                            }

                            if ((conn.Stereotype == "XisIS-MenuAssociation" && end.Stereotype != "XisInteractionSpace")
                                || (conn.Stereotype != "XisIS-MenuAssociation" && end.Stereotype == "XisInteractionSpace"))
                            {
                                EA.Project Project = Repository.GetProjectInterface();
                                Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
                                isValid = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        EA.Project Project = Repository.GetProjectInterface();
                        Project.PublishResult(LookupMap(rule50), EA.EnumMVErrorType.mvError, GetRuleStr(rule50));
                        isValid = false;
                    }
                }
            }
        }
예제 #16
0
        private void DoRule25(EA.Repository Repository, EA.Connector Connector)
        {
            if (Connector.Stereotype == "XisMobileApp-ServiceAssociation")
            {
                EA.Element client = Repository.GetElementByID(Connector.ClientID);
                EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);

                if (client.Stereotype != "XisMobileApp"
                    || (supplier.Stereotype != "XisInternalService" && supplier.Stereotype != "XisRemoteService"))
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule25), EA.EnumMVErrorType.mvError, GetRuleStr(rule25));
                    isValid = false;
                }
            }
        }
예제 #17
0
        private void DoRule37(EA.Repository Repository, EA.Connector Connector)
        {
            if (Connector.Stereotype == "XisIS-DialogAssociation")
            {
                EA.Element client = Repository.GetElementByID(Connector.ClientID);
                EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);

                if (client.Stereotype != "XisInteractionSpace" || supplier.Stereotype != "XisDialog")
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule37), EA.EnumMVErrorType.mvError, GetRuleStr(rule37));
                    isValid = false;
                }
            }
        }
예제 #18
0
        private void DoRule22(EA.Repository Repository, EA.Connector Connector)
        {
            if (Connector.Stereotype == "XisServiceUC-BEAssociation")
            {
                EA.Element client = Repository.GetElementByID(Connector.ClientID);
                EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);

                if (client.Stereotype != "XisServiceUseCase" || supplier.Stereotype != "XisBusinessEntity")
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule22), EA.EnumMVErrorType.mvError, GetRuleStr(rule22));
                    isValid = false;
                }
            }
        }
예제 #19
0
        private void DoRule20(EA.Repository Repository, EA.Element Element)
        {
            if (Element.Stereotype == "XisServiceUseCase")
            {
                EA.Project Project = Repository.GetProjectInterface();

                if (Element.Connectors.Count > 0)
                {
                    EA.Connector conn = null;
                    EA.Element supplier = null;

                    for (short i = 0; i < Element.Connectors.Count; i++)
                    {
                        conn = Element.Connectors.GetAt(i);
                        supplier = Repository.GetElementByID(conn.SupplierID);

                        if ((conn.Stereotype != "XisServiceUC-BEAssociation" && supplier.Stereotype == "XisBusinessEntity")
                            || (conn.Stereotype != "XisServiceUC-ProviderAssociation"
                            && (supplier.Stereotype == "XisInternalProvider" || supplier.Stereotype == "XisServer"
                                || supplier.Stereotype == "XisClientMobileApp"
                            )))
                        {
                            Project.PublishResult(LookupMap(rule19), EA.EnumMVErrorType.mvError, GetRuleStr(rule19));
                            isValid = false;
                        }
                    }
                }
                else
                {
                    Project.PublishResult(LookupMap(rule20), EA.EnumMVErrorType.mvError, GetRuleStr(rule20));
                    isValid = false;
                }
            }
        }
예제 #20
0
        private void DoRule16(EA.Repository Repository, EA.Connector Connector)
        {
            EA.Element client = Repository.GetElementByID(Connector.ClientID);
            EA.Element supplier = Repository.GetElementByID(Connector.SupplierID);

            if (Connector.Stereotype == "XisBE-EntityReferenceAssociation"
                && (client.Stereotype != "XisBusinessEntity" || supplier.Stereotype != "XisEntity"))
            {
                EA.Project Project = Repository.GetProjectInterface();
                Project.PublishResult(LookupMap(rule16), EA.EnumMVErrorType.mvError, GetRuleStr(rule16));
                isValid = false;
            }
        }
예제 #21
0
파일: MyAddin.cs 프로젝트: jotab/add_in
 public Boolean EA_OnPostNewElement(EA.Repository repository, EA.EventProperties info)
 {
     EA.Element element = repository.GetElementByID(IDcollect(repository, info));
     MessageBox.Show("NEW ELEMENT CREATED");
     return true;
 }
예제 #22
0
파일: MyAddin.cs 프로젝트: jotab/add_in
 private void restoreClientElementApeearance(EA.Repository repository, EventProperties info)
 {
     EA.Connector connector = repository.GetConnectorByID(IDcollect(repository, info));
     Element client = repository.GetElementByID(connector.ClientID);
     Element supplier = repository.GetElementByID(connector.SupplierID);
     client.SetAppearance(1, 0, 0);
     client.Update();
 }
예제 #23
0
파일: MyAddin.cs 프로젝트: jotab/add_in
 public Boolean EA_OnPostNewGlossaryTerm(EA.Repository repository, EA.EventProperties info)
 {
     EA.Element element = repository.GetElementByID(IDcollect(repository, info));
     MessageBox.Show("NEW GLOSSARY TERM CREATED");
     return true;
 }
예제 #24
0
        /*
         * Returns a description of the reference relationship along with a decision on
         * whether the referenced element should appear as a member of the source element.
         *
         * Background on UML Associations:
         * http://www.uml-diagrams.org/association.html
         *
         * To appear as a member the relationship must:
         * - Be "Association", "Aggregation", or "Nesting"
         * - Be navigable to the referenced element
         * - Have (source) aggregation property of "shared" or "composite"
         * - We do not look at the TARGET role containment. It does not matter if it is
         *   value, reference, or unspecified
         *                                                                       referencedElem
         *    +-------------------+  sourceElemEnd       referencedElemEnd  +-----------------+
         *    |  sourceElementId  | ----------------------------------------| targetElementId |
         *    +-------------------+               conn                      +-----------------+
         *
         *                                 memberName (computed from relationship name)
         *
         * The funtion fills the output paramaters as follows:
         *
         * - includeInSourceElem. Set to TRUE if the target class should be included as
         *   a member of the source class. If it is set to FALSE the member will not appear and
         *   the explantion out parameter will be filled.
         *
         * - explanation. Contains the explanation of why tha target class is not included
         *   as a member of the source class. Filled if and only if includeInSourceElem = FALSE
         *   and explain = TRUE.
         *
         * - sourceElemEnd. The connectorId corresponding to the sourceElemId. Note that in the
         *   UMM model it could be either the SOURCE or TARGET connector. But this function
         *   normalized it so it it seen from the perspectibe of the sourceElemId.
         *
         * - referencedElemId. The ElementId of the element at the other side of the relationship
         *   from the point of view of the sourceElemId.
         *
         * - memberName. The name of the member that would be generated. This is filled even if
         *   the relationship does not cause a member to be generated, that way the member name
         *   can be used in the log messages.
         *
         * - referencedElem. The Element corresponding to the referencedElemId. If
         *   includeInSourceElem = TRUE, then the referenced element will be a valid element in
         *   the repository as this is checked as a condition for includeInSourceElem=TRUE.
         */
        private static void GenIDL_ReferenceDescriptor(
            EA.Repository repository, EA.Connector conn, int sourceElemId, bool explain,
            out EA.ConnectorEnd sourceElemEnd, out EA.ConnectorEnd referencedElemEnd,
            out int referencedElemId, out EA.Element referencedElem,
            out String memberName, out bool includeAsReference,
            out bool includeInSourceElem, out String explanation)
        {
            includeInSourceElem = false;
            explanation = null;
            memberName = null;
            includeAsReference = false;

            /* Normalize the relationship identofyign the source and target roles */
            if (sourceElemId == conn.ClientID)
            {
                sourceElemEnd = conn.ClientEnd;
                referencedElemEnd = conn.SupplierEnd;
                referencedElemId = conn.SupplierID;
            }
            else
            {
                sourceElemEnd = conn.SupplierEnd;
                referencedElemEnd = conn.ClientEnd;
                referencedElemId = conn.ClientID;
            }

            referencedElem = repository.GetElementByID(referencedElemId);
            if (referencedElem == null)
            {
                if (explain)
                {
                    explanation = "target element with ElementID = " + referencedElemId + " is not found in UML Repository";
                }
                return;
            }

            memberName = GenIDL_GetReferenceName(conn, referencedElemEnd, referencedElem);

            // Only consider "Aggregation", "Association", and "Nesting" relationships as reasons to include the
            // referenced element as a member
            string[] relevantConnectorTypes = new string[] { "Association", "Aggregation", "Nesting" };
            if (!relevantConnectorTypes.Contains(conn.Type))
            {
                if (explain)
                {
                    explanation = "association type is '" + conn.Type + "' instead of 'Association', 'Aggregation', or 'Nesting'";
                }
                return;
            }

            if (referencedElemEnd.IsNavigable == false)
            {
                if (explain)
                {
                    explanation = "target role Navigability property is false";
                }
                return;
            }

            if (sourceElemEnd.Aggregation == 0)
            {
                if (explain)
                {
                    explanation = "source role Aggegation property is 'none' instead of 'shared' or 'composite'";
                }
                return;
            }

            /*
            if (conn.Type.Equals("Association") && !referencedElemEnd.Containment.Equals("Value"))
            {
                if (explain)
                {
                    explanation = "target role containment type is '"  + referencedElemEnd.Containment + "' instead of 'Value'";
                }
                return;
            }
            */

            // Determine if the referenced element is "by value" or "by reference"
            // sourceElemEnd.Aggregation can be 0, 1, 2 for  none, shared, composite. See http://www.sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/connectorend.html

            // Note that we alredy know that sourceElemEnd.Aggregation != 0. Otherwise we are not generating the member
            if ((referencedElemEnd.Containment.Equals("Reference"))
                 || (referencedElemEnd.Containment.Equals("Unspecified") && sourceElemEnd.Aggregation == 1 ))
            {
                includeAsReference = true;
            }
            else // in this case either Containment.Equals("Reference") or sourceElemEnd.Aggregation == 2
            {
                includeAsReference = false;
            }

            includeInSourceElem = true;
            return;
        }
예제 #25
0
파일: MyAddin.cs 프로젝트: jotab/add_in
 ///////////////////////////////////
 //                 ---------     END EA METHODS     ---------
 private void paintClient(EA.Repository repository, EA.EventProperties info)
 {
     Connector connector = repository.GetConnectorByID(IDcollect(repository, info));
     Element client = repository.GetElementByID(connector.ClientID);
     Element supplier = repository.GetElementByID(connector.SupplierID);
     client.SetAppearance(1, BORDER, RED);
     client.Update();
 }
예제 #26
0
        private void DoRule12(EA.Repository Repository, EA.Attribute Attribute)
        {
            if (Attribute.Stereotype == "XisEntityAttribute")
            {
                if (string.IsNullOrEmpty(Attribute.Type))
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule12), EA.EnumMVErrorType.mvError, GetRuleStr(rule12));
                    isValid = false;
                }
                else
                {
                    bool primitive = false;
                    switch (Attribute.Type.ToLower())
                    {
                        case "int":
                        case "integer":
                        case "double":
                        case "float":
                        case "long":
                        case "short":
                        case "char":
                        case "string":
                        case "bool":
                        case "boolean":
                        case "byte":
                        case "date":
                        case "time":
                        case "image":
                        case "url":
                            primitive = true;
                            break;
                        default:
                            break;
                    }

                    if (!primitive)
                    {
                        EA.Package package = Repository.GetPackageByID(Repository.GetElementByID(Attribute.ParentID).PackageID);
                        EA.Element el = null;
                        bool exists = false;

                        for (short i = 0; i < package.Elements.Count; i++)
                        {
                            el = package.Elements.GetAt(i);

                            if (el.Name == Attribute.Type && (el.Stereotype == "XisEntity" || el.Stereotype == "XisEnumeration"))
                            {
                                exists = true;
                                break;
                            }
                        }

                        if (!exists)
                        {
                            EA.Project Project = Repository.GetProjectInterface();
                            Project.PublishResult(LookupMap(rule12), EA.EnumMVErrorType.mvError, GetRuleStr(rule12));
                            isValid = false;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// method moves diagram object of element in diagram
        /// </summary>
        /// <param name="Repository">EA repository</param>
        /// <param name="elementGUID">GUID of element which diagram object that should be moved belongs to</param>
        /// <param name="diagramGUID">GUID of diagram</param>
        /// <param name="coordinates">new coordinates of diagram object that should be moved</param>
        public void moveElementInDiagram(EA.Repository Repository, string elementGUID, string diagramGUID, string coordinates)
        {
            EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID);
            EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID);

            int left, right, top, bottom, pocet = 0;

            Wrapper.Diagram diagramWrapper = new Wrapper.Diagram(model, diagram);
            Wrapper.ElementWrapper elWrapper = new Wrapper.ElementWrapper(model, element);
            EA.DiagramObject diagramObject = diagramWrapper.getdiagramObjectForElement(elWrapper);

            string[] coordinate;
            string str;
            string[] parts = coordinates.Split(';');

            str = parts[0];
            coordinate = str.Split('=');
            diagramObject.left = Convert.ToInt32(coordinate[1]);
            left = Convert.ToInt32(coordinate[1]);

            str = parts[1];
            coordinate = str.Split('=');
            diagramObject.right = Convert.ToInt32(coordinate[1]);
            right = Convert.ToInt32(coordinate[1]);

            str = parts[2];
            coordinate = str.Split('=');
            diagramObject.top = Convert.ToInt32(coordinate[1]);
            top = Convert.ToInt32(coordinate[1]);

            str = parts[3];
            coordinate = str.Split('=');
            diagramObject.bottom = Convert.ToInt32(coordinate[1]);
            bottom = Convert.ToInt32(coordinate[1]);

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i);
                EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID);
                if (diagramObj.left >= left && diagramObj.right <= right && diagramObj.top <= top && diagramObj.bottom >= bottom)
                {
                    if (diagramObj.ElementID != diagramObject.ElementID)
                    {
                        pocet++;
                    }
                }
            }

            diagramObject.Sequence = 1 + pocet;
            diagramObject.Update();

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i);
                EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID);
                if (diagramObj.left <= left && diagramObj.right >= right && diagramObj.top >= top && diagramObj.bottom <= bottom)
                {
                    if (diagramObj.ElementID != diagramObject.ElementID)
                    {
                        diagramObj.Sequence += 1;
                        diagramObj.Update();
                    }
                }
            }

            int parentID = diagram.ParentID;
            EA.Package package = (EA.Package)Repository.GetPackageByID(diagram.PackageID);
            if (parentID == 0)
            {
                BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" +
                    diagram.Name + "' (Location of diagram: package '" + package.Name + "')");
            }
            else {
                EA.Element parent = (EA.Element)Repository.GetElementByID(parentID);
                BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" +
                    diagram.Name + "' (Location of diagram: element '" + parent.Name + "' in package '" + package.Name + "')");
            }

            diagram.DiagramObjects.Refresh();
        }
예제 #28
0
        private void DoRule79_to_83(EA.Repository Repository, EA.Method method, string crud)
        {
            if (method.Stereotype == "XisAction")
            {
                string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value;

                if (type == crud)
                {
                    EA.Element parent = Repository.GetElementByID(method.ParentID);
                    bool needsParam = false;
                    bool publishResult = false;

                    while (parent != null)
                    {
                        if (parent.Stereotype == "XisForm" || parent.Stereotype == "XisList"
                            || parent.Stereotype == "XisListGroup" || parent.Stereotype == "XisMenu")
                        {
                            break;
                        }
                        else if (parent.Stereotype == "XisInteractionSpace")
                        {
                            needsParam = true;
                            break;
                        }

                        if (parent.ParentID > 0)
                        {
                            try
                            {
                                parent = Repository.GetElementByID(parent.ParentID);
                            }
                            catch (Exception)
                            {
                                break;
                            }
                        }
                    }

                    if (needsParam)
                    {
                        if (method.Parameters.Count == 1)
                        {
                            EA.Parameter p = method.Parameters.GetAt(0);

                            if (parent.Connectors.Count > 0 && p.Name == "entityName" && !string.IsNullOrEmpty(p.Default))
                            {
                                EA.Connector conn = null;
                                EA.Connector assoc = null;

                                for (short i = 0; i < parent.Connectors.Count; i++)
                                {
                                    conn = parent.Connectors.GetAt(i);

                                    if (conn.Stereotype == "XisIS-BEAssociation")
                                    {
                                        assoc = conn;
                                        break;
                                    }
                                }

                                if (assoc != null)
                                {
                                    EA.Element be = Repository.GetElementByID(assoc.SupplierID);
                                    bool hasEntity = false;

                                    if (be.Stereotype == "XisBusinessEntity" && be.Connectors.Count > 0)
                                    {
                                        EA.Element entity = null;

                                        for (short i = 0; i < be.Connectors.Count; i++)
                                        {
                                            conn = be.Connectors.GetAt(i);

                                            if (conn.Stereotype == "XisBE-EntityMasterAssociation"
                                                || conn.Stereotype == "XisBE-EntityDetailAssociation"
                                                || conn.Stereotype == "XisBE-EntityReferenceAssociation")
                                            {
                                                entity = Repository.GetElementByID(conn.SupplierID);

                                                if (entity.Type == "Class" && entity.Stereotype == "XisEntity"
                                                    && entity.Name == p.Default)
                                                {
                                                    hasEntity = true;
                                                    break;
                                                }
                                            }
                                        }

                                        if (!hasEntity)
                                        {
                                            publishResult = true;
                                        }
                                    }
                                    else
                                    {
                                        publishResult = true;
                                    }
                                }
                                else
                                {
                                    publishResult = true;
                                }
                            }
                            else
                            {
                                publishResult = true;
                            }
                        }
                        else
                        {
                            publishResult = true;
                        }
                    }

                    if (publishResult)
                    {
                        EA.Project Project = Repository.GetProjectInterface();

                        switch (crud)
                        {
                            case "Create":
                                Project.PublishResult(LookupMap(rule79), EA.EnumMVErrorType.mvError, GetRuleStr(rule79));
                                isValid = false;
                                break;
                            case "Read":
                                Project.PublishResult(LookupMap(rule80), EA.EnumMVErrorType.mvError, GetRuleStr(rule80));
                                isValid = false;
                                break;
                            case "Update":
                                Project.PublishResult(LookupMap(rule81), EA.EnumMVErrorType.mvError, GetRuleStr(rule81));
                                isValid = false;
                                break;
                            case "Delete":
                                Project.PublishResult(LookupMap(rule82), EA.EnumMVErrorType.mvError, GetRuleStr(rule82));
                                isValid = false;
                                break;
                            case "DeleteAll":
                                Project.PublishResult(LookupMap(rule83), EA.EnumMVErrorType.mvError, GetRuleStr(rule83));
                                isValid = false;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
예제 #29
0
        private void DoRule76(EA.Repository Repository, EA.Method method)
        {
            if (method.Stereotype == "XisAction")
            {
                EA.Element element = Repository.GetElementByID(method.ParentID);

                if (element.Stereotype != "XisGesture" && element.Stereotype != "XisListItem"
                    && element.Stereotype != "XisButton" && element.Stereotype != "XisLink" && element.Stereotype != "XisMenuItem")
                {
                    EA.Project Project = Repository.GetProjectInterface();
                    Project.PublishResult(LookupMap(rule76), EA.EnumMVErrorType.mvError, GetRuleStr(rule76));
                    isValid = false;
                }
            }
        }
예제 #30
0
        private void DoRule86(EA.Repository Repository, EA.Method method)
        {
            if (method.Stereotype == "XisAction")
            {
                string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value;

                if (type == "WebService")
                {
                    if (method.Name.Contains('.'))
                    {
                        string[] serviceName = method.Name.Split('.');

                        if (serviceName.Length == 2)
                        {
                            EA.Package model = Repository.GetPackageByID(Repository.GetElementByID(method.ParentID).PackageID);
                            EA.Package package = null;
                            EA.Package architectural = null;

                            for (short i = 0; i < model.Packages.Count; i++)
                            {
                                package = model.Packages.GetAt(i);

                                if (package.StereotypeEx == "Architectural View")
                                {
                                    architectural = package;
                                    break;
                                }
                            }

                            if (architectural != null)
                            {
                                EA.Element el = null;
                                EA.Element service = null;

                                for (short i = 0; i < architectural.Elements.Count; i++)
                                {
                                    el = architectural.Elements.GetAt(i);

                                    if (el.Type == "Interface"
                                        && (el.Stereotype == "XisInternalService" || el.Stereotype == "XisRemoteService")
                                        && el.Name == serviceName[0])
                                    {
                                        service = el;
                                        break;
                                    }
                                }

                                if (service != null && service.Methods.Count > 0)
                                {
                                    EA.Method m = null;
                                    bool hasMethod = false;

                                    for (short i = 0; i < service.Methods.Count; i++)
                                    {
                                        m = service.Methods.GetAt(i);

                                        if (m.Stereotype == "XisServiceMethod" && m.Name == serviceName[1])
                                        {
                                            hasMethod = true;
                                            break;
                                        }
                                    }

                                    if (hasMethod)
                                    {
                                        if (m.Parameters.Count == method.Parameters.Count)
                                        {
                                            EA.Parameter p1 = null;
                                            EA.Parameter p2 = null;

                                            for (short i = 0; i < m.Parameters.Count; i++)
                                            {
                                                p1 = m.Parameters.GetAt(i);
                                                p2 = method.Parameters.GetAt(i);

                                                if (p1.Name == p2.Name)
                                                {
                                                    EA.Project Project = Repository.GetProjectInterface();
                                                    Project.PublishResult(LookupMap(rule86), EA.EnumMVErrorType.mvError, GetRuleStr(rule86));
                                                    isValid = false;
                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            EA.Project Project = Repository.GetProjectInterface();
                                            Project.PublishResult(LookupMap(rule86), EA.EnumMVErrorType.mvError, GetRuleStr(rule86));
                                            isValid = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }