/// <summary> /// Removes a decision from the table and diagram /// </summary> /// <param name="decision">The element to be removed</param> private void RemoveDecisionFromDiagram(IEAElement decision) { IEARepository repository = EAFacade.EA.Repository; string diagramGuid = _controller.Model.DiagramGUID; IEADiagram diagram = repository.GetDiagramByGuid(diagramGuid); //Remove the TaggedValue of the decision decision.RemoveTaggedValue(EATaggedValueKeys.IsDecisionElement, diagramGuid); //Delete the element if it is not used in the diagram/table anymore if (!ElementExistsInDiagram(decision, diagramGuid)) { diagram.RemoveElement(decision); } }
/// <summary> /// Removes a force/concern from the table and diagram (if necessary). Diagram should be update afterwards /// </summary> /// <param name="rowIndex">The element to be removed</param> private void RemoveForceFromDiagram(int rowIndex) { //Get the GUIDs from the diagram, force and concern string diagramGuid = _controller.Model.DiagramGUID; string forceGuid = _forcesTable.Rows[rowIndex].Cells[ForcesTableContext.ForceGUIDColumnIndex].Value.ToString(); string concernGuid = _forcesTable.Rows[rowIndex].Cells[ForcesTableContext.ConcernGUIDColumnIndex].Value.ToString(); //Get the diagram, force and concern objects IEARepository repository = EAMain.Repository; IEADiagram diagram = repository.GetDiagramByGuid(diagramGuid); IEAElement force = repository.GetElementByGUID(forceGuid); IEAElement concern = repository.GetElementByGUID(concernGuid); foreach ( IEAConnector connector in force.FindConnectors(concern, EAConstants.RelationClassifiedBy, EAConstants.ForcesConnectorType)) { if (connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector, diagramGuid)) { connector.RemoveTaggedValue(EATaggedValueKeys.IsForceConnector, diagramGuid); if (!connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector)) { force.RemoveConnector(connector); concern.RemoveConnector(connector); } break; } } //Remove the TaggedValue of the force and concern force.RemoveTaggedValue(EATaggedValueKeys.IsForceElement, diagramGuid); concern.RemoveTaggedValue(EATaggedValueKeys.IsConcernElement, diagramGuid); //Delete the element if it is not used in the diagram/table anymore if (!ElementExistsInDiagram(force, diagramGuid)) { diagram.RemoveElement(force); } if (!ElementExistsInDiagram(concern, diagramGuid)) { diagram.RemoveElement(concern); } }