public void EA_OnRunConnectorRule(EA.Repository repository, string ruleID, long connectorID) { RepositoryChanged(repository); RunRule(ruleID, () => { return(entityWrapper.Val.Wrap(repository.GetConnectorByID((int)connectorID))); }); }
internal bool EA_OnPreDeleteConnector(EA.Repository Repository, EA.EventProperties Info) { if (!initialConnectionAvailable) { return(true); } EA.Connector connector = Repository.GetConnectorByID(int.Parse((string)Info.Get(0).Value)); DeleteElementChange change = new DeleteElementChange(); change.elementType = ElementType.CONNECTOR; change.internalID = connector.ConnectorGUID; change.name = connector.Name; return(sendObject(change)); //return sendEvent(Repository, Info); }
private void CleanUpTransitionTable() { foreach (Row roi in m_Data.GetTransitionTable().GetRows()) { if ((roi.GetNextActivity().GetElementType() != ElementType.Activity) && (roi.GetNextActivity().GetElementType() != ElementType.Decision)) { Log.Info("dirtyActivity=" + roi.GetNextActivity().GetName() + " elementType=" + roi.GetNextActivity().GetElementType()); EA.Connector dirtyConnector = m_DiagramOfInterest.GetConnectorByID(roi.GetID()); EA.Element dirtyActivity = m_DiagramOfInterest.GetElementByID(dirtyConnector.SupplierID); Activity correctNextActivity = new Activity(); bool isCleanedUp = false; foreach (EA.Connector c in dirtyActivity.Connectors) { EA.Element possibleActivity = m_DiagramOfInterest.GetElementByID(c.SupplierID); if (possibleActivity.Name == "ActivityFinal") { correctNextActivity = new Activity(possibleActivity.Name, EnumUtil.ParseEnum <ElementType>(possibleActivity.Type, ElementType.Unknown), possibleActivity.ElementID); isCleanedUp = true; } else { foreach (Row r in m_Data.GetTransitionTable().GetRows()) { if (possibleActivity.Name == r.GetCurrentActivity().GetName() && (r.GetCurrentActivity().GetElementType() == ElementType.StateNode || r.GetCurrentActivity().GetElementType() == ElementType.Activity)) { correctNextActivity = new Activity(possibleActivity.Name, EnumUtil.ParseEnum <ElementType>(possibleActivity.Type, ElementType.Unknown), possibleActivity.ElementID); isCleanedUp = true; } } } } if (isCleanedUp) { roi.SetNextActivity(correctNextActivity); roi.SetAction(correctNextActivity.GetName()); } else { m_Data.GetTransitionTable().GetRows().Remove(roi); } } } }
public bool EA_OnPostNewConnector(EA.Repository Repository, EA.EventProperties Info) { preventCascade = true; SQLRepository sqlRepository = new SQLRepository(Repository, false); EA.Connector connector = Repository.GetConnectorByID(int.Parse((string)Info.Get(0).Value)); EA.Diagram currentDiagram = sqlRepository.GetCurrentDiagram(); sqlRepository.SaveDiagram(currentDiagram.DiagramID); bool modifiedBySDMModeling = sdmModeling.EA_OnPostNewConnector(sqlRepository, connector, currentDiagram); bool modifiedByTGGModeling = tggModeling.EA_OnPostNewConnector(sqlRepository, connector, currentDiagram); bool modifiedByECoreModeling = ecoreModeling.EA_OnPostNewConnector(sqlRepository, connector, currentDiagram); incrementalUpdateAdapter.EA_OnPostNewConnector(Repository, Info); preventCascade = false; return(modifiedBySDMModeling || modifiedByTGGModeling || modifiedByECoreModeling); }
/// <summary> /// EA_OnPostNewConnector notifies Add-Ins that a new ///connector has been created on a diagram.It enables Add-Ins ///to modify the connector upon creation. /// ///This event occurs after a user has dragged a new ///connector from the Toolbox or Resources window onto a ///diagram.The notification is provided immediately after the ///connector is added to the model. /// </summary> /// <param name="Repository">An EA.Repository object representing the currently open Enterprise Architect model.</param> /// <param name="EventProperties">Contains the following EventProperty objects for the new connector: /// ConnectorID: Along value corresponding to Connector. ConnectorID</param> /// <returns>Return True if the connector has been updated during this notification. Return False otherwise.</returns> public bool EA_OnPostNewConnector(EA.Repository Repository, EA.EventProperties EventProperties) { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { try { EA.Connector conn = Repository.GetConnectorByID(int.Parse(EventProperties.Get("ConnectorID").Value)); if (goatAddinMainViewModel.EditAssociationCommand.CanExecute(conn)) { goatAddinMainViewModel.EditAssociationCommand.Execute(conn); return(goatAddinMainViewModel.EditAssociationCommand.Result); } } catch (Exception e) { MessageBox.Show(e.Message); } } return(false); }
public static Object sqlEAObjectToOriginalObject(SQLRepository sqlRepository, Object sqlEAObject) { EA.Repository repository = sqlRepository.GetOriginalRepository(); Object realObject = sqlEAObject; if (sqlEAObject is SQLElement) { realObject = repository.GetElementByGuid((sqlEAObject as SQLElement).ElementGUID); if (realObject == null) { throw new COMException("Can't find matching ID"); } else { realObject = repository.GetElementByID((sqlEAObject as SQLElement).ElementID); } } else if (sqlEAObject is SQLConnector) { realObject = repository.GetConnectorByID((sqlEAObject as SQLConnector).ConnectorID); } else if (sqlEAObject is SQLMethod) { realObject = repository.GetMethodByID((sqlEAObject as SQLMethod).MethodID); } else if (sqlEAObject is SQLAttribute) { realObject = repository.GetAttributeByID((sqlEAObject as SQLAttribute).AttributeID); } else if (sqlEAObject is SQLPackage) { realObject = repository.GetPackageByID((sqlEAObject as SQLPackage).PackageID); } else if (sqlEAObject is SQLDiagram) { realObject = repository.GetDiagramByID((sqlEAObject as SQLDiagram).DiagramID); } return(realObject); }
public static void fillTGGSchemaDiagram(EA.Repository repository, EA.Package tggPackage, EA.Diagram tggDiagram) { int i = 2; int j = 1; List <int> validIds = new List <int>(); List <int> addedIds = new List <int>(); foreach (EA.Element element in tggPackage.Elements) { EA.DiagramObject diagramObject = tggDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject; diagramObject.ElementID = element.ElementID; diagramObject.left = i * 300; diagramObject.right = diagramObject.left + 250; diagramObject.top = j * -200; diagramObject.bottom = diagramObject.top - 100; diagramObject.Update(); validIds.Add(element.ElementID); addedIds.Add(element.ElementID); int z = i - 1; foreach (EA.Connector con in element.Connectors) { EA.Element otherEnd = null; if (con.ClientID == element.ElementID) { otherEnd = repository.GetElementByID(con.SupplierID); } else { otherEnd = repository.GetElementByID(con.ClientID); } if (otherEnd.Stereotype == ECOREModeling.ECOREModelingMain.EClassStereotype) { if (!addedIds.Contains(otherEnd.ElementID)) { diagramObject = tggDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject; diagramObject.left = z * 300; diagramObject.right = diagramObject.left + 200; diagramObject.top = j * -200; diagramObject.bottom = diagramObject.top - 100; diagramObject.ElementID = otherEnd.ElementID; diagramObject.Update(); addedIds.Add(otherEnd.ElementID); } z = z + 2; } } j++; } tggDiagram.DiagramObjects.Refresh(); tggDiagram.DiagramLinks.Refresh(); repository.ReloadDiagram(tggDiagram.DiagramID); repository.Execute("UPDATE t_diagramlinks SET Hidden = true WHERE DiagramID = " + tggDiagram.DiagramID); foreach (EA.DiagramLink links in tggDiagram.DiagramLinks) { EA.Connector con = repository.GetConnectorByID(links.ConnectorID); if (!validIds.Contains(con.ClientID) && !validIds.Contains(con.SupplierID)) { links.IsHidden = true; links.Update(); } } }