private int AddConnector(EA.Diagram diagram, EA.Element eaElSource, EA.Element eaElDest, string strText, string strControlType, string strPath = "")
        {
            string strLogInfo = "Connector for operation: " + strText;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Connector eConnector = eaElSource.Connectors.AddNew(strText, strControlType);
            if (eConnector == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            // eConnector.Notes = strNotes;
            eConnector.SupplierID = eaElDest.ElementID;
            eConnector.Width      = 2;
            eConnector.Update();

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strText, strControlType);
            if (eDiagramLink == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(0);
            }

            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            if (strPath != "")
            {
                eDiagramLink.Path = strPath;
            }
            eDiagramLink.Update();

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(0);
        }
Exemplo n.º 2
0
        private static void linkToParent(EA.Repository Repository, EA.Diagram diagram, EA.Element sample, EA.Element parent)
        {
            foreach (EA.Connector con in sample.Connectors)
            {
                logger.log("Connector:" + con.SupplierEnd.Role);
                EA.Element related = null;

                if (sample.ElementID == con.ClientID && parent.ElementID == con.SupplierID)
                {
                    logger.log("Found parent link");
                    return;
                }
                else if (sample.ElementID == con.SupplierID && parent.ElementID == con.ClientID)
                {
                    logger.log("Found parent link");
                    return;
                }
            }

            logger.log("No  parent link found");
            EA.Connector link = sample.Connectors.AddNew("", "Association");
            link.SupplierID = parent.ElementID;
            link.Update();

            EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
            dl.ConnectorID = link.ConnectorID;
            sample.Connectors.Refresh();
            dl.Update();
        }
Exemplo n.º 3
0
        private static void sync_relationship(EA.Repository Repository, EA.Diagram diagram, String connectorGuid, EA.Element source, EA.Element target, JObject jo, EA.Package pkg)
        {
            if (checkRelationship(Repository, connectorGuid, source, target))
            {
                //logger.log("Relationship exists:"+source.Name+":"+target.Name);
            }
            else
            {
                logger.log("Adding Relationship:" + source.Name + ":" + target.Name);

                //Add relationship  logger.log("No  parent link found");
                EA.Connector link = source.Connectors.AddNew("", "Association");
                link.SupplierID = target.ElementID;
                link.Update();
                source.Update();
                target.Update();

                EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
                dl.ConnectorID = link.ConnectorID;
                dl.Update();

                source.Connectors.Refresh();
                target.Connectors.Refresh();
            }
        }
Exemplo n.º 4
0
        private void mergeDiagrams(EA.Repository repository, EA.Package package)
        {
            Dictionary <int, EA.DiagramObject> dobjects = new Dictionary <int, EA.DiagramObject>();
            Dictionary <int, EA.DiagramLink>   dlinks   = new Dictionary <int, EA.DiagramLink>();

            foreach (EA.Diagram diagram in package.Diagrams)
            {
                foreach (EA.DiagramObject dobject in diagram.DiagramObjects)
                {
                    dobjects[dobject.ElementID] = dobject;
                }
                foreach (EA.DiagramLink dlink in diagram.DiagramLinks)
                {
                    dlinks[dlink.ConnectorID] = dlink;
                }
            }

            EA.Diagram mdiagram = (EA.Diagram)package.Diagrams.AddNew(string.Format("{0} (Merged)", package.Name), "Custom");
            mdiagram.Update();

            // copy objects
            int       left    = 10;
            int       top     = 10;
            const int width   = 100;
            const int height  = 80;
            const int padding = 10;

            foreach (EA.DiagramObject dobject in dobjects.Values)
            {
                EA.Element element = repository.GetElementByID(dobject.ElementID);
                if ("Boundary".Equals(element.Type))
                {
                    continue;
                }

                string dimensions = string.Format("l={0};r={1};t={2};b={3};", left, left + width, top, top + height);
                left += padding + width;
                EA.DiagramObject mobject = (EA.DiagramObject)mdiagram.DiagramObjects.AddNew(dimensions, "");
                mobject.ElementID = element.ElementID;
                mobject.Update();

                if (left == 1000)
                {
                    left = 10;
                    top += height;
                }
            }
            mdiagram.Update();

            // copy links (o.a. NoteLinks)
            foreach (EA.DiagramLink dlink in dlinks.Values)
            {
                EA.DiagramLink mlink = (EA.DiagramLink)mdiagram.DiagramLinks.AddNew("", "");
                mlink.ConnectorID = dlink.ConnectorID;
                mlink.Update();
            }

            package.Update();
            repository.OpenDiagram(mdiagram.DiagramID);
        }
        public static EA.DiagramLink CreateDiagramLink(EA.Connector connector)
        {
            EA.DiagramLink diagramLink = CurrentDiagram.DiagramLinks.AddNew("", "");
            diagramLink.ConnectorID = connector.ConnectorID;
            diagramLink.Update();

            return(diagramLink);
        }
Exemplo n.º 6
0
        private void addTGGLinkVariableCopyToRule(EA.Connector connectorToBeCopied)
        {
            EA.Element newSource = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.ClientID]];
            EA.Element newTarget = newElementIdToNewElement[oldElementIdToNewElementId[connectorToBeCopied.SupplierID]];

            EA.Connector newConnector = newSource.Connectors.AddNew("", connectorToBeCopied.Type) as EA.Connector;
            newConnector.Stereotype       = TGGModelingMain.TggLinkVariableStereotype;
            newConnector.ClientEnd.Role   = connectorToBeCopied.ClientEnd.Role;
            newConnector.SupplierEnd.Role = connectorToBeCopied.SupplierEnd.Role;
            newConnector.SupplierID       = newTarget.ElementID;
            newConnector.ClientID         = newSource.ElementID;
            newConnector.Update();
            if (connectorToBeCopied.Stereotype == TGGModelingMain.TggLinkVariableStereotype)
            {
                foreach (EA.ConnectorTag tag in connectorToBeCopied.TaggedValues)
                {
                    EA.ConnectorTag newTag = newConnector.TaggedValues.AddNew(tag.Name, "") as EA.ConnectorTag;
                    if (!checkBoxExactCopy.Checked)
                    {
                        newTag.Value = tag.Value.Replace("create", "check_only");
                        newTag.Notes = tag.Notes.Replace("\"bindingOperator\" value=\"create", "\"bindingOperator\" value=\"check_only");
                    }
                    else
                    {
                        newTag.Value = tag.Value;
                        newTag.Notes = tag.Notes;
                    }
                    newTag.Update();
                }
            }
            EA.DiagramLink newDiagramLink = newRuleDiagram.DiagramLinks.AddNew("", newConnector.Type) as EA.DiagramLink;
            newDiagramLink.ConnectorID = newConnector.ConnectorID;
            newDiagramLink.Update();
            if (connectorToBeCopied.Stereotype != TGGModelingMain.TggLinkVariableStereotype)
            {
                LinkDialogueEntry linkEntry = new LinkDialogueEntry();
                linkEntry.direction = LinkDialogueEntryDirection.RIGHT;
                linkEntry.CorrespondingConnectorGuid = connectorToBeCopied.ConnectorGUID;
                if (newConnector.ClientEnd.Role != "")
                {
                    linkEntry.supplierRoleName = newConnector.ClientEnd.Role;
                }
                else if (newConnector.SupplierEnd.Role != "")
                {
                    linkEntry.supplierRoleName = newConnector.SupplierEnd.Role;
                }
                TGGLinkVariable tggLv = new TGGLinkVariable(repository.GetConnectorByID(newConnector.ConnectorID), repository);
                tggLv.linkDialogueEntry = linkEntry;
                if (!checkBoxExactCopy.Checked)
                {
                    tggLv.BindingOperator = SDMModeling.SDMExportWrapper.patterns.BindingOperator.CREATE;
                }
                tggLv.saveTreeToEATaggedValue(true);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Update Diagram Link
 /// </summary>
 private void Update()
 {
     try
     {
         _link.Update();
     }
     catch (Exception e)
     {
         MessageBox.Show($"Style is possibly to long for DB field\r\n\r\n{e}", "Cant write Diagram Styles!");
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Включает/выключает показ коннекторов указанного типа на диаграмме
        /// </summary>
        /// <param name="linkType"></param>
        /// <param name="visibility"></param>
        public void SetConnectorVisibility(LinkType linkType, bool visibility = true)
        {
            // проходимся по элементам диаграммы
            foreach (EA.DiagramObject diagramObject in CurrentDiagram.DiagramObjects)
            {
                // Получаем элемент
                EA.Element diagramElement = EARepository.GetElementByID(diagramObject.ElementID);

                // Получаем коннекторы элемента
                foreach (EA.Connector connector in diagramElement.Connectors)
                {
                    // Получаем тип коннектора
                    try
                    {
                        LinkType curLinkType = LTHelper.GetConnectorType(connector);
                        if (linkType != curLinkType)
                        {
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.OutA("Не удалось определить тип коннектора " + ex.StackTrace, new EA.Connector[] { connector });
                        continue;
                    }

                    // проверяем, что коннектор может быть потенциально показан на диаграмме, т.е, что оба его элемента на диаграмме
                    EA.Element       secondElement   = EARepository.GetElementByID((connector.ClientID == diagramElement.ElementID) ? connector.SupplierID : connector.ClientID);
                    EA.DiagramObject secondElementDA = CurrentDiagram.GetDiagramObjectByID(secondElement.ElementID, "");
                    if (secondElementDA == null)
                    {
                        continue;
                    }

                    // Теперь смотрим на настройки видимости коннектора
                    if (LibraryHelper.IsLibrary(connector))
                    {
                        LinkType connectorlinkType = LTHelper.GetConnectorType(connector);
                        if (linkType == connectorlinkType)
                        {
                            EA.DiagramLink connectorLink = DiagramLinkHelper.GetDLForConnector(connector);
                            if (connectorLink == null)
                            {
                                connectorLink = DiagramLinkHelper.CreateDiagramLink(connector);
                                connectorLink.Update();
                            }

                            DiagramLinkHelper.SetDiagramLinkVisibility(connectorLink, visibility);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// AddConnector
        /// </summary>
        /// <param name="diagram"></param>
        /// <param name="eElement"></param>
        /// <param name="strFullOpName"></param>
        /// <param name="strEvent"></param>
        /// <param name="iSupplierID"></param>
        /// <param name="iSeqNo"></param>
        private void AddConnector(EA.Diagram diagram, EA.Element eElement, string strFullOpName, string strEvent, int iSupplierID, int iSeqNo, string strNotes)
        {
            string strLogInfo = "Connector for operation: " + strFullOpName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Connector eConnector = null;

            //for (short i = 0; i < eElement.Connectors.Count; i++)
            //{
            //    Application.DoEvents();

            //    eConnector = eElement.Connectors.GetAt(i);

            //    if (eConnector.Name == strFullOpName)
            //    {
            //        break;
            //    }
            //    else
            //    {
            //        eConnector = null;
            //    }
            //}

            if (eConnector == null)
            {
                eConnector       = eElement.Connectors.AddNew(strFullOpName, "Sequence");
                eConnector.Notes = strNotes;

                eConnector.SequenceNo       = iSeqNo;
                eConnector.SupplierID       = iSupplierID;
                eConnector.TransitionAction = "Call";
                eConnector.TransitionEvent  = "Synchronus";
                eConnector.TransitionGuard  = "params=;paramsDlg=param1;";
                eConnector.Update();

                eConnector.StartPointY = eConnector.StartPointY + 1;
                eConnector.Update();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }

            EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strEvent, "sequence");
            eDiagramLink.ConnectorID = eConnector.ConnectorID;
            eDiagramLink.Update();

            diagram.Update();
        }
Exemplo n.º 10
0
        private static void sync_relationship(EA.Repository Repository, EA.Diagram diagram, EA.Element source, EA.Element target, JObject jo, EA.Package pkg)
        {
            logger.log("Adding Relationship:");

            //Add relationship  logger.log("No  parent link found");
            EA.Connector link = source.Connectors.AddNew("", "Association");
            link.SupplierID = target.ElementID;
            link.Update();
            source.Update();
            target.Update();

            EA.DiagramLink dl = diagram.DiagramLinks.AddNew("", "");
            dl.ConnectorID = link.ConnectorID;
            dl.Update();

            source.Connectors.Refresh();
            target.Connectors.Refresh();
        }
Exemplo n.º 11
0
        private EA.Connector createNewConnection(Dictionary <SQLElement, EA.DiagramObject> elementsToDiagramObjects, EA.Diagram currentDiagram, String objectName, String attributeName)
        {
            foreach (SQLElement diagramElement in elementsToDiagramObjects.Keys)
            {
                if (diagramElement.Name == objectName)
                {
                    EA.Connector connector = constraintElement.getRealElement().Connectors.AddNew(attributeName, Main.EADependencyType) as EA.Connector;
                    connector.SupplierID   = diagramElement.ElementID;
                    connector.StereotypeEx = "ConstraintLink";
                    connector.Update();

                    EA.DiagramLink diagramLink = currentDiagram.DiagramLinks.AddNew("", Main.EADependencyType) as EA.DiagramLink;
                    diagramLink.ConnectorID = connector.ConnectorID;
                    diagramLink.Update();
                    return(connector);
                }
            }
            return(null);
        }
Exemplo n.º 12
0
        public static void ApplyStyleToDL(EA.DiagramLink diagramLink, SetLinkStyle setLinkStyle)
        {
            if (setLinkStyle.DoSetLinkStyle)
            {
                if (setLinkStyle.SetLineWidth)
                {
                    diagramLink.LineWidth = setLinkStyle.LineWidth;
                }

                if (setLinkStyle.SetColor)
                {
                    diagramLink.LineColor = (setLinkStyle.Color.B * 256 + setLinkStyle.Color.G) * 256 + setLinkStyle.Color.R;
                }

                if (setLinkStyle.SetLineStyle)
                {
                    diagramLink.LineStyle = setLinkStyle.LineStyle;
                }
            }

            diagramLink.Update();
        }
Exemplo n.º 13
0
 public static void SetDiagramLinkVisibility(EA.DiagramLink diagramLink, bool visibility)
 {
     diagramLink.IsHidden = !visibility;
     diagramLink.Update();
 }