public void CloseDecisionDetailView(IDecision decision) { if (!_tabMap.ContainsKey(decision.GUID)) { return; } string tabName = _tabMap[decision.GUID]; IEARepository repository = EAMain.Repository; if (repository.IsTabOpen(tabName) > 0) { repository.RemoveTab(tabName); _tabMap.Remove(decision.GUID); } }
public override bool OnPreDeleteDiagram(IEAVolatileDiagram volatileDiagram) { IEARepository repository = EAMain.Repository; IEADiagram diagram = repository.GetDiagramByID(volatileDiagram.DiagramID); if (!diagram.IsForcesView()) { return(true); } if (_controllers.ContainsKey(diagram.GUID)) { if (repository.IsTabOpen(ForcesModel.CreateForcesTabName(diagram.Name)) > 0) { repository.RemoveTab(ForcesModel.CreateForcesTabName(diagram.Name)); } _controllers.Remove(diagram.GUID); } return(true); }
public override void OnNotifyContextItemModified(string guid, EANativeType type) { IEARepository repository = EAMain.Repository; IForcesController forcesController; switch (type) { // the diagram is modified when we remove an element or a connector from it case EANativeType.Diagram: IEADiagram diagram = repository.GetDiagramByGuid(guid); if (!diagram.IsForcesView()) { return; } // if the name of a diagram changed and the forces tab is open then close it to avoid conflicts if (repository.IsTabOpen(ForcesModel.CreateForcesTabName(diagram.Name)) <= 0) { if (!_controllers.ContainsKey(diagram.GUID)) { break; } forcesController = _controllers[diagram.GUID]; if (repository.IsTabOpen(forcesController.Model.Name) > 0) { repository.RemoveTab(forcesController.Model.Name); } break; } if (!_controllers.ContainsKey(diagram.GUID)) { break; } forcesController = _controllers[diagram.GUID]; forcesController.SetDiagramModel(diagram); break; case EANativeType.Element: IEAElement element = repository.GetElementByGUID(guid); foreach ( IEADiagram eaDiagram in element.GetDiagrams() .Where(eaDiagram => eaDiagram.IsForcesView()) .Where(eaDiagram => _controllers.ContainsKey(eaDiagram.GUID))) { forcesController = _controllers[eaDiagram.GUID]; // An element can be of multiple types: if (element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, eaDiagram.GUID)) { forcesController.UpdateDecision(element); } if (element.TaggedValueExists(EATaggedValueKeys.IsConcernElement, eaDiagram.GUID)) { forcesController.UpdateConcern(element); } if (element.TaggedValueExists(EATaggedValueKeys.IsForceElement, eaDiagram.GUID)) { forcesController.UpdateForce(element); } } break; } }