public static void CreateAndTraceTopic() { IEARepository repository = EAMain.Repository; if (repository.GetContextItemType() == EANativeType.Element) { var eaelement = repository.GetContextObject <IEAElement>(); if (eaelement != null && !EAMain.IsDecision(eaelement) && !EAMain.IsTopic(eaelement)) { string nameSuggestion = string.Format(Messages.NameSuggestionTopic, eaelement.Name); var createTopicView = new CreateTopicDialog(nameSuggestion); if (createTopicView.ShowDialog() == DialogResult.OK) { IEAPackage dvPackage = createTopicView.GetDecisionViewPackage(); IEAElement topic = dvPackage.CreateElement(createTopicView.GetName(), EAConstants.TopicStereoType, EAConstants.ActivityMetaType); topic.MetaType = EAConstants.TopicMetaType; topic.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate, DateTime.Now.ToString(CultureInfo.InvariantCulture)); eaelement.ConnectTo(topic, EAConstants.AbstractionMetaType, EAConstants.RelationTrace); topic.Update(); dvPackage.RefreshElements(); repository.RefreshModelView(dvPackage.ID); topic.ShowInProjectView(); } } } }
/// <summary> /// Add deicsion to the diagram and TaggedValue to the decision if it doesn't exist already /// </summary> /// <param name="element"></param> private void AddDecisionToDiagram(IEAElement element) { if (_listener != null) { _listener.OnDecisionSelected(element); return; } IEARepository repository = EAMain.Repository; string diagramGuid = _controller.Model.DiagramGUID; IEADiagram diagram = repository.GetDiagramByGuid(diagramGuid); diagram.AddElement(element); // Only add the TaggedValue once, because the element is already a decision if (!element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, diagramGuid)) { element.AddTaggedValue(EATaggedValueKeys.IsDecisionElement, diagramGuid); _closeWindow = true; } else { MessageBox.Show(string.Format(Messages.ForcesViewDecisionExists, element.Name), Messages.ForcesViewDecisionExistsTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private static MenuItem CreateTraceMenuItem(string uniqueName, IEAElement tracedElement) { var menuItem = new MenuItem(uniqueName); menuItem.Value = tracedElement; menuItem.ClickDelegate = delegate { IEADiagram[] diagrams = tracedElement.GetDiagrams(); if (diagrams.Count() == 1) { IEADiagram diagram = diagrams[0]; diagram.OpenAndSelectElement(tracedElement); } else if (diagrams.Count() >= 2) { var selectForm = new SelectDiagramDialog(diagrams); if (selectForm.ShowDialog() == DialogResult.OK) { IEADiagram diagram = selectForm.GetSelectedDiagram(); diagram.OpenAndSelectElement(tracedElement); } } tracedElement.ShowInProjectView(); }; return(menuItem); }
/******************************************************************************************** ** Invoke View Change methods ********************************************************************************************/ internal static void InvokeViewChange(string elementGUID, EANativeType eANativeType) { if (eANativeType == EANativeType.Diagram) { IEAElement element = EAMain.Repository.GetElementByGUID(elementGUID); IEADiagram[] diagrams = element.GetDiagrams(); if (diagrams.Length == 1) { IEADiagram diagram = diagrams[0]; diagram.OpenAndSelectElement(element); } else if (diagrams.Length >= 2) { var selectForm = new SelectDiagramDialog(diagrams); if (selectForm.ShowDialog() == DialogResult.OK) { IEADiagram diagram = selectForm.GetSelectedDiagram(); diagram.OpenAndSelectElement(element); } } } else if (eANativeType == EANativeType.Element) { Instance.OnContextItemDoubleClicked(elementGUID, eANativeType); } }
/// <summary> /// Remove the decision from the ForcesView /// </summary> /// <param name="element"></param> public void RemoveDecision(IEAElement element) { RemoveDecisionFromDiagram(element); IEARepository repository = EAFacade.EA.Repository; _controller.SetDiagramModel(repository.GetDiagramByGuid(_controller.Model.DiagramGUID)); }
public bool IsDecisionViewPackage() { IEAElement underlyingElement = EAElement.Wrap(_native.Element); string value = underlyingElement.GetTaggedValueByName(EATaggedValueKeys.DecisionViewPackage); return(value != null && value.Equals("true")); }
public Concern(string concernGUID) { IEAElement element = EAMain.Repository.GetElementByGUID(concernGUID); Name = element.Name; ConcernGUID = concernGUID; }
/// <summary> /// Add a new force for each concern if the combination not exists already /// </summary> /// <param name="force"></param> private void AddForceConcerns(IEAElement force) { IEARepository repository = EAFacade.EA.Repository; string diagramGuid = _controller.Model.DiagramGUID; IEADiagram diagram = repository.GetDiagramByGuid(diagramGuid); //Add the force for each selected concern foreach (var item in _lbConcern.SelectedItems) { var selectedItem = (KeyValuePair <string, string>)item; IEAElement concern = repository.GetElementByGUID(selectedItem.Key); diagram.AddElement(concern); IEAConnector connector = force.ConnectTo(concern, EAConstants.ForcesConnectorType, EAConstants.RelationClassifiedBy); if (!connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector, diagramGuid)) { // Add TaggedValue for new force and concern (having multiple TaggedValues of the same name/data is possible). // The amount of TaggedValues with the same name and data is the amount of forces/concerns in the table. force.AddTaggedValue(EATaggedValueKeys.IsForceElement, diagramGuid); concern.AddTaggedValue(EATaggedValueKeys.IsConcernElement, diagramGuid); // Add the diagramGuid as a TaggedValue (ConnectorTag) to the connector connector.AddTaggedValue(EATaggedValueKeys.IsForceConnector, diagramGuid); _closeWindow = true; } else //Force concern combination (connector) already exists { MessageBox.Show(string.Format(Messages.ForcesViewForceExists, force.Name, concern.Name), "Force already exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
/// <summary> /// Adds the forces and concerns that are selected in the TreeView and ListBox to the forces diagram /// </summary> public void AddForceToForcesDiagram() { TreeNode selectedNode = _tvForce.SelectedNode; // Cannot add force if no force or concern is selected if (selectedNode == null || _lbConcern.SelectedItems.Count < 1) { return; } IEARepository repository = EAFacade.EA.Repository; string diagramGuid = _controller.Model.DiagramGUID; IEADiagram diagram = repository.GetDiagramByGuid(diagramGuid); IEAElement force = repository.GetElementByGUID(selectedNode.ImageKey); // if (force.Type.Equals("Package")) return; // User cannot add packages as a force diagram.AddElement(force); //Will not be added if already exists AddForceConcerns(force); //Window does not have to be closed and no update needed if (!_closeWindow) { return; } _controller.SetDiagramModel(repository.GetDiagramByGuid(_controller.Model.DiagramGUID)); DialogResult = DialogResult.OK; }
public void ReloadDecisionDetailView(IDecision decision) { IEAElement refreshedDecision = EAMain.Repository.GetElementByGUID(decision.GUID); CloseDecisionDetailView(decision); OpenDecisionDetailView(Decision.Load(refreshedDecision)); }
/******************************************************************************************** ** EAMain Callbacks ********************************************************************************************/ /// <summary> /// This method is called when double clicking an element in the view pane. It opens the respective View. /// </summary> /// <param name="guid"> /// A string holding the GUID of the EAElement clicked by the user. /// </param> /// <param name="type"> /// The EANativeType of the element clicked by the user. /// </param> /// <returns></returns> public override bool OnContextItemDoubleClicked(string guid, EANativeType type) { // If the type is not an Element if (type != EANativeType.Element) { return(false); } // Get the element IEAElement element = EAMain.Repository.GetElementByGUID(guid); // If it is not a decision or a topic, leave! if (!(EAMain.IsDecision(element) || EAMain.IsTopic(element))) { return(false); } // Check if the tab is already open. if (EAMain.IsDecision(element)) { OpenDecisionDetailView(Decision.Load(element)); return(true); } if (EAMain.IsTopic(element)) { OpenTopicDetailView(Topic.Load(element)); return(true); } return(false); }
private void SaveStakeholders(IEAElement element) { IEARepository repository = EAMain.Repository; IEnumerable <string> deleted = element.GetConnectors().Where(connector => connector.IsAction() && connector.ClientId != element.ID) .Select(c => c.GUID) .Except(Stakeholders.Select(a => a.ConnectorGUID)); foreach (string connector in deleted) { element.RemoveConnector(repository.GetConnectorByGUID(connector)); } foreach (IStakeholderAction connector in Stakeholders) { if ("".Equals(connector.ConnectorGUID) || null == connector.ConnectorGUID && !connector.DoDelete) { var client = repository.GetElementByGUID(GUID); var supplier = repository.GetElementByGUID(connector.Stakeholder.GUID); supplier.ConnectTo(client, EAConstants.ActionMetaType, connector.Action); } else if (connector.ConnectorGUID != null && connector.DoDelete) { var supplier = repository.GetElementByGUID(connector.Stakeholder.GUID); var temp = EAMain.Repository.GetConnectorByGUID(connector.ConnectorGUID); supplier.RemoveConnector(temp); } } }
private void SaveRelations(IEAElement element) { IEARepository repository = EAMain.Repository; IEnumerable <string> deleted = element.FindConnectors(EAConstants.RelationMetaType, EAConstants.RelationDependsOn, EAConstants.RelationExcludedBy, EAConstants.RelationCausedBy, EAConstants.RelationReplaces) .Select(c => c.GUID) .Except(RelatedDecisions.Select(a => a.RelationGUID)); foreach (string connector in deleted) { element.RemoveConnector(repository.GetConnectorByGUID(connector)); } foreach (IDecisionRelation connector in RelatedDecisions) { if ("".Equals(connector.RelationGUID) || null == connector.RelationGUID) { IEAElement client = repository.GetElementByGUID(connector.Decision.GUID); IEAElement supplier = repository.GetElementByGUID(connector.RelatedDecision.GUID); client.ConnectTo(supplier, EAConstants.RelationMetaType, connector.Type); } } }
/// <summary> /// Loads information from EAelement and converts them into domain model. /// </summary> /// <param name="element"></param> private void LoadDecisionDataFromElement(IEAElement element, bool loadTopic) { if (element == null) { throw new Exception(); } RemoveAllChangeListener(); GUID = element.GUID; ID = element.ID; Name = element.Name; State = element.StereotypeList; Modified = element.Modified; Author = element.Author; Rationale = LoadRationale(element); //Topic change not yet possible. if (loadTopic) { Topic = LoadTopic(element); } LoadAlternatives(element); LoadRelations(element); LoadHistory(element); LoadForces(element); LoadTraces(element); LoadStakeholder(element); Changed = false; AddAllChangeListener(); }
private void SaveTraces(IEAElement element) { //first need to identify those tracelinks that were removed and those that were added // currently traces do not support update and can only be added or removed IEAElement[] existingTraces = element.GetTracedElements().ToArray(); // existing.except(traces) traces that have been deleted IEnumerable <string> removedTraces = existingTraces.Select(e => e.GUID).Except(Traces.Select(t => t.TracedElementGUID)); // traces.except(existing) traces that were added IEnumerable <string> addedTraces = Traces.Select(t => t.TracedElementGUID).Except(existingTraces.Select(e => e.GUID)); //in order to remove tracelink i need to find the correct connection that connect this and the linked element. foreach (string removedTrace in removedTraces) { IEAConnector connector = element.GetConnectors().FirstOrDefault(c => (c.GetSupplier().GUID.Equals(removedTrace) || c.GetClient().GUID.Equals(removedTrace)) && c.Stereotype.Equals(EAConstants.RelationTrace) && c.Type.Equals(EAConstants.AbstractionMetaType)); if (null != connector) { element.RemoveConnector(connector); } } foreach (string addedTrace in addedTraces) { IEAElement suppliedElement = EAMain.Repository.GetElementByGUID(addedTrace); element.ConnectTo(suppliedElement, EAConstants.AbstractionMetaType, EAConstants.RelationTrace); } }
public override void EA_OnRunElementRule(Repository repository, string ruleId, Element element) { EAMain.UpdateRepository(repository); IEAElement wrappedElement = EAMain.WrapElement(element); _modelValidator.ValidateElementUsingRuleID(repository, ruleId, wrappedElement); }
/// <summary> /// Open selected element in diagram and select in project browser /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { var grid = (DataGridView)sender; string guid = null; DataGridViewRow row = grid.Rows[e.RowIndex]; // ReSharper disable CanBeReplacedWithTryCastAndCheckForNull if (row.DataBoundItem is IDecisionRelation) { var link = (IDecisionRelation)row.DataBoundItem; DetailViewHandler.Instance.OpenDecisionDetailView(link.RelatedDecision); } else { if (row.DataBoundItem is IStakeholderAction) { var stakeholderAction = (IStakeholderAction)row.DataBoundItem; guid = stakeholderAction.Stakeholder.GUID; } else if (row.DataBoundItem is ITraceLink) { var link = (ITraceLink)row.DataBoundItem; guid = link.TracedElementGUID; } if (guid != null && !"".Equals(guid)) { IEAElement element = EAMain.Repository.GetElementByGUID(guid); element.ShowInDiagrams(); } } // ReSharper restore CanBeReplacedWithTryCastAndCheckForNull }
private void add_Click(object sender, EventArgs e) { TreeNode node = treeAllDecisions.SelectedNode; string guid = node.ImageKey; switch (EAUtilities.IdentifyGUIDType(guid)) { case EANativeType.Package: case EANativeType.Model: IEAPackage package = EAMain.Repository.GetPackageByGUID(guid); foreach (IEAElement d in package.GetAllDecisions()) { if (!Decisions.Contains(d)) { Decisions.Add(d); listSelectedDecisions.Items.Add(d); node.Checked = true; } } break; case EANativeType.Element: IEAElement decision = EAMain.Repository.GetElementByGUID(guid); if (!Decisions.Contains(decision)) { Decisions.Add(decision); listSelectedDecisions.Items.Add(decision); node.Checked = true; } break; } UpdateButtonStates(); }
public IEAConnector ConnectTo(IEAElement suppliedElement, String type, String stereotype, bool allowMultiple) { //check if two elements are already connected with this connector if (!allowMultiple) { IList <IEAConnector> connectors = FindConnectors(suppliedElement, stereotype, type); if (connectors.Count > 0) { return(connectors.FirstOrDefault()); } } Connector connector = _native.Connectors.AddNew("", type); connector.Stereotype = stereotype; connector.SupplierID = suppliedElement.ID; connector.Update(); _native.Connectors.Refresh(); _native.Update(); ((EAElement)suppliedElement)._native.Connectors.Refresh(); suppliedElement.Update(); return(EAConnector.Wrap(connector)); }
public void EA_WrapElement_elementTest() { Element element = _e.GetDecisionPackageElement(); IEAElement e = EAMain.WrapElement(element); Assert.IsTrue(element.ElementID == e.ID); }
/// <summary> /// Loads Rationale from LinkedDocument /// </summary> /// <param name="element"></param> private string LoadDescription(IEAElement element) { var rtf = new RichTextBox { Rtf = element.GetLinkedDocument() }; return(rtf.Text); }
public void EA_WrapElement_eventPropertiesTest() { IEADiagramObject obj = _e.GetForcesDiagramObject(); EventProperties properties = EAEventPropertiesHelper.GetInstance("", "", "", 0, 0, 0, obj.ElementID, 0); IEAElement e = EAMain.WrapElement(properties); Assert.IsTrue(obj.ElementID == e.ID); }
private IEAConnector GetForceConcernConnector(IEAElement forceElement) { return((from x in forceElement.GetConnectors() where x.GetSupplier().GUID.Equals(Concern.ConcernGUID) && x.TaggedValueExists(EAConstants.ConcernUID) && x.GetTaggedValueByName(EAConstants.ConcernUID).Equals(Concern.UID) select x).FirstOrDefault()); }
public bool Equals(IEAElement element) { if (element == null) { return(false); } return(_native.ElementGUID == element.GUID); }
private void LoadFiles(IEAElement element) { Files = new BindingList <DAFile>(element.Files.Select(x => new DAFile(x)).ToList()) { RaiseListChangedEvents = true }; Files.ListChanged += ListMemberChanged; }
public bool Contains(IEAElement element) { EARepository repository = EARepository.Instance; return ((from DiagramObject diagramObject in _native.DiagramObjects select repository.GetElementByID(diagramObject.ElementID)).Any( diagramElement => diagramElement.GUID == element.GUID)); }
public void Delete(IEAElement forceElement) { var connector = GetConnector(forceElement); if (connector != null) { forceElement.RemoveConnector(connector); } }
public override void FillContent() { SetPlaceholder(NewSlidePart, "{title}", _forces.DiagramName); Table tbl = NewSlidePart.Slide.Descendants <Table>().First(); TableGrid tableGrid = tbl.TableGrid; for (int i = 0; i != _forces.GetDecisions().Length; i++) { var gc = new GridColumn { Width = 1234000L }; tableGrid.AppendChild(gc); } // insert the concern header and the decisions names TableRow decRow = tbl.Descendants <TableRow>().First(); foreach ( TableCell decCell in _forces.GetDecisions() .Select(decision => CreateTextCell(decision.Name))) { decRow.AppendChild(decCell); } foreach (var concernsPerForce in _forces.GetConcernsPerForce()) { IEAElement force = concernsPerForce.Key; List <IEAElement> concerns = concernsPerForce.Value; foreach (IEAElement concern in concerns) { var forceRow = new TableRow { Height = 370840L }; forceRow.AppendChild(CreateTextCell(force.Name)); forceRow.AppendChild(CreateTextCell(concern.Name)); // insert ratings foreach (Rating rating in _forces.GetRatings()) { if (rating.ForceGUID != force.GUID || rating.ConcernGUID != concern.GUID) { continue; } if (_forces.GetDecisions().Any(decision => rating.DecisionGUID == decision.GUID)) { forceRow.AppendChild(CreateTextCell(rating.Value)); } } tbl.AppendChild(forceRow); } } }
public override void FillContent() { var relatedDecisions = new StringBuilder(); var alternativeDecisions = new StringBuilder(); foreach (IDecisionRelation relation in _decision.RelatedDecisions) { relatedDecisions.AppendLine(relation.Decision.GUID.Equals(_decision.GUID) ? "<<this>> " + _decision.Name + " - " + relation.Type + " - " + relation.RelatedDecision.Name : "" + relation.Decision.Name + " - " + relation.Type + " - <<this>> " + _decision.Name); } // Related Decisions foreach (IDecisionRelation alternatives in _decision.Alternatives) { alternativeDecisions.AppendLine(alternatives.Decision.GUID.Equals(_decision.GUID) ? "<<this>> " + _decision.Name + " - " + alternatives.Type + " - " + alternatives.RelatedDecision.Name : "" + alternatives.Decision.Name + " - " + alternatives.Type + " - <<this>> " + _decision.Name); } // Related Forces var relatedForces = new StringBuilder(); IEnumerable <IForceEvaluation> forces = _decision.Forces; foreach (ForceEvaluation rating in forces) { IEAElement force = EAMain.Repository.GetElementByGUID(rating.Force.ForceGUID); EAMain.Repository.GetElementByGUID(rating.Concern.ConcernGUID); relatedForces.AppendLine(force.Name + " - " + force.Notes); } //Traces Componenets var traces = new StringBuilder(); foreach (ITraceLink element in _decision.Traces) { string trace = element.TracedElementName; traces.AppendLine(trace); } SetPlaceholder(NewSlidePart, Placeholder.Name, _decision.Name); SetPlaceholder(NewSlidePart, Placeholder.State, _decision.State); SetPlaceholder(NewSlidePart, Placeholder.Topic, _decision.HasTopic() ? _decision.Topic.Name : ""); SetPlaceholder(NewSlidePart, Placeholder.Issue, ""); SetPlaceholder(NewSlidePart, Placeholder.DecisionText, ""); SetPlaceholder(NewSlidePart, Placeholder.Arguments, _decision.Rationale); SetPlaceholder(NewSlidePart, Placeholder.Alternatives, alternativeDecisions.ToString()); SetPlaceholder(NewSlidePart, Placeholder.RelatedDecisions, relatedDecisions.ToString()); SetPlaceholder(NewSlidePart, Placeholder.RelatedForces, relatedForces.ToString()); SetPlaceholder(NewSlidePart, Placeholder.Traces, traces.ToString()); }
/// <summary> /// Update the concern's name /// </summary> /// <param name="element"></param> public void UpdateConcern(IEAElement element) { foreach ( DataGridViewRow row in _forcesTable.Rows.Cast <DataGridViewRow>() .Where(row => row.Cells[ForcesTableContext.ConcernGUIDColumnIndex].Value.ToString().Equals(element.GUID))) { row.Cells[ForcesTableContext.ConcernColumnIndex].Value = element.Name; } }