/// <summary> /// List all diagram elements. /// </summary> /// <param name="args[2]">guid of the diagram</param> /// <param name="args"></param> /// <returns></returns> public bool ListDiagramElements(string[] args) { // guid passed, use the selected diagram if (args.Length > 2 && args[2].StartsWith("{")) { EA.Diagram dia = (EA.Diagram)_repository.GetDiagramByGuid(args[2].Trim()); if (dia != null) { foreach (EA.DiagramObject diaObj in dia.DiagramObjects) { EA.Element el = _repository.GetElementByID(diaObj.ElementID); if (el != null) { Print(el.Name); _repository.ShowInProjectView(el); } } } } else { Console.WriteLine("No Diagram guid passed"); MessageBox.Show("Diagram guid should be passed", "No Diagram guid passed"); return(false); } return(true); }
/// <summary> /// Returns the information of a diagram /// </summary> /// <param name="diagramId"></param> public Diagram GetDiagramByGuid(string guid) { // TODO: validate guid EA.Diagram eadiagram = repo.GetDiagramByGuid(guid); Diagram diag = new Diagram(); SerializeDiagram(diag, eadiagram); return(diag); }
private void ShowInBrowser(EaHistoryListEntry entry) { string guid = entry.Guid; switch (entry.EaObjectTypeName) { case "Diagram": EA.Diagram dia = (EA.Diagram)_repository.GetDiagramByGuid(guid); _repository.ShowInProjectView(dia); break; case "Element": EA.Element el = (EA.Element)_repository.GetDiagramByGuid(guid); _repository.ShowInProjectView(el); break; case "Package": EA.Package pkg = _repository.GetPackageByGuid(guid); _repository.ShowInProjectView(pkg); break; } }
public override void save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType) { EA.Diagram dia = rep.GetDiagramByGuid(GUID); if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0) { dia.Notes = _Description; } if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0) { dia.Name = _Name; } if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0) { dia.StereotypeEx = _Stereotype; } _isUpdated = true; dia.Update(); }
/// <summary> /// Extension Method EA.Repository to get: /// - EA Object /// - EA.ObjectType /// from Object Type in Table and GUID /// </summary> /// <param name="rep"></param> /// <param name="sqlObjectType"></param> /// <param name="guid"></param> /// <param name="objectType"></param> /// <returns></returns> public static object GetEaObject(this EA.Repository rep, string sqlObjectType, string guid, out EA.ObjectType objectType) { objectType = EA.ObjectType.otNone; // eaObjectType found in dictionary if (EaObjectTypes.TryGetValue(sqlObjectType, out EA.ObjectType eaObjectType)) { switch (eaObjectType) { case EA.ObjectType.otElement: objectType = eaObjectType; return(rep.GetElementByGuid(guid)); case EA.ObjectType.otDiagram: objectType = eaObjectType; return((object)rep.GetDiagramByGuid(guid)); case EA.ObjectType.otPackage: objectType = eaObjectType; return(rep.GetPackageByGuid(guid)); case EA.ObjectType.otAttribute: objectType = eaObjectType; return(rep.GetAttributeByGuid(guid)); case EA.ObjectType.otMethod: objectType = eaObjectType; return(rep.GetMethodByGuid(guid)); case EA.ObjectType.otConnector: objectType = eaObjectType; return(rep.GetConnectorByGuid(guid)); default: break; } } else { // by SQL string where = $"where ea_guid = '{ guid}'"; string sql = $"select 'OBJECT' as object_type from t_object {where} UNION " + $"select 'DIAGRAM' from t_diagram {where} "; XElement x = XElement.Parse(rep.SQLQuery(sql)); var oType = (from t in x.Descendants("object_type") select t).FirstOrDefault(); if (oType == null) { MessageBox.Show($"GUID:'{guid}'", @"GUID not found, Break!!!!"); return(null); } string type = oType.Value; switch (type) { case "OBJECT": objectType = EA.ObjectType.otElement; return(rep.GetElementByGuid(guid)); case "DIAGRAM": objectType = EA.ObjectType.otDiagram; return(rep.GetDiagramByGuid(guid)); default: MessageBox.Show($"GUID searched in object, diagram:'{guid}'", @"GUID not found in Repository, Break!!!!"); return(null); } } return(null); }
public FindAndReplaceItemDiagram(EA.Repository rep, string GUID) : base(rep, GUID) { this._dia = rep.GetDiagramByGuid(GUID); this.load(rep); }
/// <summary> /// Defines what happens if the user doubleclicks on SDM related Elements. /// </summary> /// <param name="repository"></param> /// <param name="GUID"></param> /// <param name="ot"></param> /// <returns>True if the EA Dialogs should not be openend. False if the standard EA Dialogs should be opened. /// </returns> public bool EA_OnContextItemDoubleClicked(EA.Repository repository, String GUID, EA.ObjectType ot) { SQLRepository sqlRepository = new SQLRepository(repository, false); EA.Diagram actDiag = repository.GetCurrentDiagram(); SQLMethod meth = sqlRepository.GetMethodByGuid(GUID); SQLElement elem = sqlRepository.GetElementByGuid(GUID); SQLConnector con = sqlRepository.GetConnectorByGuid(GUID); if (actDiag != null) { if (ECOREModelingMain.EcoreDiagramMetatype.Contains(actDiag.MetaType) && ot == EA.ObjectType.otMethod) { SQLElement methParent; SQLElement container; if (!openSelectedMethodSDM(actDiag, meth, sqlRepository, out methParent, out container)) { if (methParent.Stereotype == ECOREModelingMain.EClassStereotype) { CreateSDMDialog createSdmDialog = new CreateSDMDialog(); if (createSdmDialog.ShowDialog() == DialogResult.OK) { createStoryDiagram(meth, repository, actDiag); } return(true); } } else { return(true); } } else if (SdmDiagramMetatype.Contains(actDiag.MetaType)) { repository.SaveDiagram(actDiag.DiagramID); if (elem != null) { if (elem.Stereotype == SDMModelingMain.ObjectVariableStereotype) { ObjectVariable ov = new ObjectVariable(elem, sqlRepository); OvDialog objectVariableDialogue = new OvDialog(sqlRepository, ov); objectVariableDialogue.ShowDialog(); return(true); } else if (elem.Stereotype == SDMModelingMain.StoryNodeStereotype || elem.Stereotype == SDMModelingMain.StatementNodeStereotype) { SQLTaggedValue extractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, Main.MoflonExtractedStoryPatternTaggedValueName); if (extractedTag == null) { SQLTaggedValue oldExtractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, "evacuated"); if (oldExtractedTag != null) { EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, elem.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, oldExtractedTag.Value); } else { EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, elem.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, "false"); } extractedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(elem, Main.MoflonExtractedStoryPatternTaggedValueName); } if (extractedTag != null && extractedTag.Value == Main.TrueValue) { SQLDiagram diagram = (SQLDiagram)elem.Diagrams.GetAt(0); Navigator.addAnchorEntry(diagram.DiagramID, actDiag.DiagramID); repository.OpenDiagram(diagram.DiagramID); } else { if (elem.Stereotype == SDMModelingMain.StoryNodeStereotype) { ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(new StoryNode(sqlRepository, elem), sqlRepository); } else if (elem.Stereotype == SDMModelingMain.StatementNodeStereotype) { ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(new StatementNode(sqlRepository, elem), sqlRepository); } } return(true); } else if (elem.Stereotype == SDMModelingMain.StopNodeStereotype) { StopNode stopNode = new StopNode(sqlRepository, elem); StopNodeForm sNodeForm = new StopNodeForm(stopNode, sqlRepository); return(true); } else if (elem.Stereotype == TGGModelingMain.CSPConstraintStereotype) { SDMCSPDialog sdmCspDialog = new SDMCSPDialog(elem, sqlRepository); sdmCspDialog.ShowDialog(); return(true); } } if (con != null) { if (con.Stereotype == SDMModelingMain.LinkVariableStereotype) { LinkVariablePropertiesForm linkVariableDialogue = new LinkVariablePropertiesForm(new LinkVariable(con, sqlRepository), sqlRepository, true); return(true); } else if (con.Type == Main.EAControlFlowType) { ActivityEdge activityEdge = new ActivityEdge(sqlRepository, con); ActivityEdgePropertiesForm activityEdgeDialog = new ActivityEdgePropertiesForm(activityEdge, repository); return(true); } else if (con.Stereotype == SDMModelingMain.BindingExpressionLinkStereotype) { SQLElement targetElement = sqlRepository.GetElementByID(con.SupplierID); ObjectVariable ov = new ObjectVariable(targetElement, sqlRepository); OvDialog ovDialog = new OvDialog(sqlRepository, ov); ovDialog.showTab(2); ovDialog.ShowDialog(); return(true); } } if (ot == EA.ObjectType.otDiagram) { EA.Diagram diag = (EA.Diagram)repository.GetDiagramByGuid(GUID); EA.Element activity = null; SQLTaggedValue evacuatedTag = null; if (diag.ParentID != 0) { activity = repository.GetElementByID(diag.ParentID); evacuatedTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sqlRepository.GetElementByID(activity.ElementID), Main.MoflonExtractedStoryPatternTaggedValueName); } if (evacuatedTag != null && evacuatedTag.Value == Main.TrueValue) { StoryNode activityNode = new StoryNode(sqlRepository, sqlRepository.GetElementByID(activity.ElementID)); ActivityNodeTabsForm activityNodeDialog = new ActivityNodeTabsForm(activityNode, sqlRepository); return(true); } } //sqlRepository.ReloadDiagram(actDiag.DiagramID); } else if (TGGModelingMain.TggRulesDiagramMetatype.Contains(actDiag.MetaType) && ot == EA.ObjectType.otMethod) { EA.TaggedValue aTag = null; EA.Element methParent = repository.GetElementByID(meth.ParentID); EA.Element container = null; foreach (EA.Element sdmContainer in methParent.Elements) { if (sdmContainer.Stereotype == SDMModelingMain.SdmContainerStereotype) { aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(sdmContainer, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName); if (aTag.Value == meth.MethodGUID.ToString()) { container = sdmContainer; break; } } } EA.Diagram sdmDiagg = null; if (container != null) { foreach (EA.Diagram sdmDiag in container.Diagrams) { sdmDiagg = sdmDiag; repository.OpenDiagram(sdmDiag.DiagramID); return(true); } } if (sdmDiagg == null && container == null) // no SDM Diagram exists { if (methParent.Stereotype == TGGModelingMain.TggRuleStereotype) { createStoryDiagram(meth, repository, actDiag); return(true); } } } } return(false); }
public FindAndReplaceItemDiagram(EA.Repository rep, string guid) : base(rep, guid) { _dia = (EA.Diagram)rep.GetDiagramByGuid(guid); Load(rep); }
public ActionResult OSLC_SmallPreview() { //Get the URL that was posted. var fullURL = this.Url.Action(); string url = fullURL.ToString(); //parse the URL var VallueArray = url.Split('/'); //Clean emptycells string[] CleanURL = VallueArray.Where(x => !string.IsNullOrEmpty(x)).ToArray(); //store the current working repository EA.Repository m_Repository = new EA.Repository(); //I don't know what this is about but it can cause trouble if not caught if (CleanURL.Count() > 2) { if (CleanURL[1] == "__browserLink") { return(View()); } } string ThingOfInterest = CleanURL[CleanURL.Count() - 2]; string ActionOfInterest = CleanURL[CleanURL.Count() - 1]; m_Repository = getEA_Repos(CleanURL[1]); string[] UrlArray = ThingOfInterest.Split('|'); string TOI_Name = UrlArray[0]; string TOI_Type = UrlArray[1]; string TOI_GUID = UrlArray[2]; List <string> ListOfElementsTypes = new List <string>(); List <string> ListOfElementsNames = new List <string>(); List <string> ListOfElementAuthor = new List <string>(); List <string> ListOfElementSteroType = new List <string>(); List <string> ListOfElementNotes = new List <string>(); EA.Diagram DiagramToShow = (EA.Diagram)m_Repository.GetDiagramByGuid(TOI_GUID); ViewBag.DiagramName = DiagramToShow.Name; for (short iDO = 0; iDO < DiagramToShow.DiagramObjects.Count; iDO++) { EA.DiagramObject MyDO = (EA.DiagramObject)DiagramToShow.DiagramObjects.GetAt(iDO); int ID = m_Repository.GetElementByID(MyDO.ElementID).ElementID; EA.Element MyEle = (EA.Element)m_Repository.GetElementByID(ID); ListOfElementsNames.Add(MyEle.Name); ListOfElementsTypes.Add(MyEle.Type); ListOfElementAuthor.Add(MyEle.Author); ListOfElementSteroType.Add(MyEle.Stereotype); ListOfElementNotes.Add(MyEle.Notes); } ViewBag.ListOfElementsTypes = ListOfElementsTypes; ViewBag.ListOfElementsNames = ListOfElementsNames; ViewBag.ListOfElementAuthor = ListOfElementAuthor; ViewBag.ListOfElementSteroType = ListOfElementSteroType; ViewBag.ListOfElementNotes = ListOfElementNotes; return(View("EA_small_preview")); }