/// <summary> /// Get list of package ids as comma separated list /// </summary> /// <param name="rep"></param> /// <param name="branch"></param> /// <param name="id"></param> /// <returns></returns> public static string GetBranch (EA.Repository rep, string branch, int id) { if (id > 0) { // add current package id if (branch == "") branch = id.ToString(); else branch = branch + ", " + id; EA.Package pkg = rep.GetPackageByID(id); foreach (EA.Package p in pkg.Packages) { int pkgId = p.PackageID; string s = pkgId.ToString(); branch = GetBranch(rep, branch, pkgId); } } return branch; }
//-------------------------------------------------------------------------------- // createActivityForOperation //-------------------------------------------------------------------------------- // Create an Activity Diagram for the operation public static bool CreateActivityForOperation(EA.Repository rep, EA.Method m, int treePos=100) { // get class EA.Element elClass = rep.GetElementByID(m.ParentID); EA.Package pkgSrc = rep.GetPackageByID(elClass.PackageID); // create a package with the name of the operation var pkgTrg = (EA.Package)pkgSrc.Packages.AddNew(m.Name, ""); pkgTrg.TreePos = treePos; pkgTrg.Update(); pkgSrc.Packages.Refresh(); EA.Element frame = null; // frame beneath package if (ActivityIsSimple == false) { // create Class Activity Diagram in target package var pkgActDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Activity"); pkgActDia.Update(); pkgTrg.Diagrams.Refresh(); // add frame in Activity diagram var frmObj = (EA.DiagramObject)pkgActDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", ""); frame = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram"); frame.Update(); frmObj.ElementID = frame.ElementID; //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; frmObj.Update(); pkgTrg.Elements.Refresh(); pkgActDia.DiagramObjects.Refresh(); } // create activity with the name of the operation var act = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Activity"); if (ActivityIsSimple == false) { act.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!"; } act.StereotypeEx = m.StereotypeEx; act.Update(); pkgTrg.Elements.Refresh(); // create activity diagram beneath Activity var actDia = (EA.Diagram)act.Diagrams.AddNew(m.Name, "Activity"); // update diagram properties actDia.ShowDetails = 0; // hide details // scale page to din A4 actDia.StyleEx = actDia.StyleEx.Length > 0 ? actDia.StyleEx.Replace("HideQuals=0", "HideQuals=1") : "HideQuals=1;"; // Hide Qualifier actDia.ExtendedStyle = actDia.ExtendedStyle.Length > 0 ? actDia.ExtendedStyle.Replace("ScalePI=0", "ScalePI=1") : "ScalePI=1;"; actDia.Update(); act.Diagrams.Refresh(); // put the activity on the diagram Util.AddSequenceNumber(rep, actDia); var actObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=30;r=780;t=30;b=1120", ""); actObj.ElementID = act.ElementID; actObj.Sequence = 1; actObj.Update(); Util.SetSequenceNumber(rep, actDia, actObj, "1"); actDia.DiagramObjects.Refresh(); // add default nodes (init/final) CreateDefaultElementsForActivity(rep, actDia, act); if (ActivityIsSimple == false) { // Add Heading to diagram Util.AddSequenceNumber(rep, actDia); var noteObj = (EA.DiagramObject)actDia.DiagramObjects.AddNew("l=40;r=700;t=25;b=50", ""); var note = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text"); note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType; note.Update(); noteObj.ElementID = note.ElementID; noteObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; noteObj.Sequence = 1; noteObj.Update(); Util.SetSequenceNumber(rep, actDia, noteObj, "1"); } pkgTrg.Elements.Refresh(); actDia.DiagramObjects.Refresh(); // Link Operation to activity Util.SetBehaviorForOperation(rep, m, act); // Set show behavior Util.SetShowBehaviorInDiagram(rep, m); // add parameters to activity UpdateParameterFromOperation(rep, act, m); int pos = 0; foreach (EA.Element actPar in act.EmbeddedElements) { if (! actPar.Type.Equals("ActivityParameter")) continue; Util.VisualizePortForDiagramobject(pos, actDia, actObj, actPar, null); pos = pos + 1; } if (ActivityIsSimple == false) { // link Overview frame to diagram Util.SetFrameLinksToDiagram(rep, frame, actDia); frame.Update(); } // select operation rep.ShowInProjectView(m); return true; }
public Boolean EA_OnPostNewPackage(EA.Repository repository, EA.EventProperties info) { EA.Package package = repository.GetPackageByID(IDcollect(repository, info)); MessageBox.Show("NEW PACKAGE CREATED"); return true; }
private void DoRule12(EA.Repository Repository, EA.Attribute Attribute) { if (Attribute.Stereotype == "XisEntityAttribute") { if (string.IsNullOrEmpty(Attribute.Type)) { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule12), EA.EnumMVErrorType.mvError, GetRuleStr(rule12)); isValid = false; } else { bool primitive = false; switch (Attribute.Type.ToLower()) { case "int": case "integer": case "double": case "float": case "long": case "short": case "char": case "string": case "bool": case "boolean": case "byte": case "date": case "time": case "image": case "url": primitive = true; break; default: break; } if (!primitive) { EA.Package package = Repository.GetPackageByID(Repository.GetElementByID(Attribute.ParentID).PackageID); EA.Element el = null; bool exists = false; for (short i = 0; i < package.Elements.Count; i++) { el = package.Elements.GetAt(i); if (el.Name == Attribute.Type && (el.Stereotype == "XisEntity" || el.Stereotype == "XisEnumeration")) { exists = true; break; } } if (!exists) { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule12), EA.EnumMVErrorType.mvError, GetRuleStr(rule12)); isValid = false; } } } } }
private void DoRule87(EA.Repository Repository, EA.Method method) { if (method.Stereotype == "XisAction") { string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value; if (type == "Navigate") { string navigation = M2MTransformer.GetMethodTag(method.TaggedValues, "navigation").Value; if (!string.IsNullOrEmpty(navigation)) { EA.Package model = Repository.GetPackageByID(Repository.GetElementByID(method.ParentID).PackageID); EA.Package interaction = null; if (model.StereotypeEx == "InteractionSpace View") { interaction = model; } if (interaction != null) { EA.Element el = null; bool exists = false; for (short i = 0; i < interaction.Elements.Count; i++) { el = interaction.Elements.GetAt(i); if (el.Type == "Class" && el.Stereotype == "XisInteractionSpace" && el.Name == navigation) { exists = true; break; } } if (!exists) { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87)); isValid = false; } } else { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87)); isValid = false; } } else { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule87), EA.EnumMVErrorType.mvError, GetRuleStr(rule87)); isValid = false; } } } }
public static void insertCDE(EA.Repository m_Repository, QueryServiceControl.QueryServiceManager.dataelement de, EAUtil.INSERT_XSD_TYPE xsdType) { try { string id = de.names.id; string name = de.names.preferred; string definition = QueryServiceControl.QueryServiceControl.getDefinition(de.definition); EA.Package package = m_Repository.GetPackageByID(m_Repository.GetCurrentDiagram().PackageID); EA.Element o = (EA.Element)package.Elements.AddNew(name.Replace(" ", "_"), "Class"); o.Notes = definition + " (ID: " + id + ")"; EAUtil.addTaggedValue("CDERef", id, o); EAUtil.addTaggedValue("preferred name", name, o); if (package.StereotypeEx == "XSDschema") { if (xsdType == EAUtil.INSERT_XSD_TYPE.TOP_LEVEL_ELEMENT) { o.Stereotype = "XSDtopLevelElement"; } else if (xsdType == EAUtil.INSERT_XSD_TYPE.TOP_LEVEL_ATTRIBUTE) { o.Stereotype = "XSDtopLevelAttribute"; } } if (de.values != null && de.values.Item is QueryServiceControl.QueryServiceManager.nonenumerated) { string dataType = (de.values.Item as QueryServiceControl.QueryServiceManager.nonenumerated).datatype; if (dataType.StartsWith("xs:"))// || dataType.StartsWith("xsd:")) { //o.Genlinks = "Parent=" + dataType.Substring(dataType.IndexOf(":") + 1) + ";"; string simpleTypeClassName = name.Replace(" ", "_") + "_Type"; EA.Element simpleTypeClass = (EA.Element)package.Elements.AddNew(simpleTypeClassName, "Class"); simpleTypeClass.Stereotype = "XSDsimpleType"; simpleTypeClass.Genlinks = "Parent=" + dataType.Substring(dataType.IndexOf(":") + 1) + ";"; simpleTypeClass.Update(); simpleTypeClass.Refresh(); EA.DiagramObject simpleTypeDiag = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", "")); simpleTypeDiag.ElementID = simpleTypeClass.ElementID; simpleTypeDiag.Update(); EA.Connector simpleTypeConnector = (EA.Connector)o.Connectors.AddNew("", "Generalization"); simpleTypeConnector.SupplierID = simpleTypeDiag.ElementID; simpleTypeConnector.Update(); o.Connectors.Refresh(); } else { o.Genlinks = "Parent=" + dataType + ";"; } } else if (de.values != null && de.values.Item is QueryServiceControl.QueryServiceManager.enumerated) { string enumClassName = "Enum_" + name.Replace(" ", "_"); EA.Element enumClass = (EA.Element)package.Elements.AddNew(enumClassName, "Class"); enumClass.Stereotype = "enumeration"; enumClass.Genlinks = "Parent=string;"; QueryServiceControl.QueryServiceManager.enumerated en = de.values.Item as QueryServiceControl.QueryServiceManager.enumerated; foreach (QueryServiceControl.QueryServiceManager.validvalue vv in en.validvalue) { EA.Attribute at = (EA.Attribute)enumClass.Attributes.AddNew("", ""); at.Stereotype = "enum"; at.Name = vv.code; at.Notes = QueryServiceControl.QueryServiceControl.getMeaning(vv.meaning); at.Update(); } enumClass.Attributes.Refresh(); EA.DiagramObject enumDiag = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", "")); enumDiag.ElementID = enumClass.ElementID; enumDiag.Update(); EA.Connector enumConnector = (EA.Connector)o.Connectors.AddNew("", "Generalization"); enumConnector.SupplierID = enumDiag.ElementID; enumConnector.Update(); o.Connectors.Refresh(); enumClass.Update(); enumClass.Refresh(); } //attr.Update(); //o.Attributes.Refresh(); o.Update(); o.Refresh(); EA.DiagramObject diagram = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", "")); diagram.ElementID = o.ElementID; diagram.Update(); m_Repository.ReloadDiagram(diagram.DiagramID); //this.Close(); } catch (Exception exp) { MessageBox.Show("Please make sure you have an active diagram openned." + "\n" + exp.Message + "\n" + exp.StackTrace, "No active diagram currently selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// method sends all data about model /// </summary> /// <param name="sendingDataWindow">window for data sending</param> /// <param name="repository">EA repository</param> public void sendDataAboutModel(SendingDataWindow sendingDataWindow, EA.Repository repository) { try { using (WebClient webClient = new WebClient()) { using (var stream = webClient.OpenRead(Utils.serviceAddress)) { stream.Close(); this.sendingDataWindow = sendingDataWindow; ChangeService.newEvent.Set(); changeModelGUID(repository); modelTraverse.sendDataAboutModel(repository); ScenarioChange propertyChange = new ScenarioChange(); propertyChange.modelGUID = repository.GetPackageByID(1).PackageGUID; propertyChange.elementType = 777; modelTraverse.saveCreate(propertyChange, repository); user = getLoggedUser(); modelInformation = new ModelInformation(); modelInformation.modelGUID = repository.GetPackageByID(1).PackageGUID; modelInformation.token = user.token; timer = new System.Timers.Timer(); timer.Elapsed += new System.Timers.ElapsedEventHandler(checkLastCreate); timer.Interval = 5000; timer.Start(); } } } catch (Exception e) { MessageBox.Show("Server is unavailable. Check your internet connection."); } }
public void newversion(EA.Repository Repository) { Form3 form = new Form3(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packversionid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packversion in pack0.Packages) { if (packversion.Name == "Version") packversionid = packversion.PackageID; } if (packversionid == 0) { EA.Collection collec = pack0.Packages; EA.Package packversion = collec.AddNew("Version", "Package"); packversion.Update(); collec.Refresh(); pack0.Update(); packversionid = packversion.PackageID; } EA.Collection newversion = Repository.GetPackageByID(packversionid).Elements; EA.Element version = newversion.AddNew("Version" + form.number.Text, "Class"); EA.Collection newversionattributes = version.Attributes; EA.Attribute att = newversionattributes.AddNew("number", "char"); att.Default = form.number.Text; att.Pos = 1; att.Update(); att = newversionattributes.AddNew("date", "char"); att.Default = form.Date.Text; att.Pos = 2; att.Update(); att = newversionattributes.AddNew("author", "char"); att.Default = form.author.Text; att.Pos = 3; att.Update(); att = newversionattributes.AddNew("changes", "char"); att.Default = form.Changes.Text; att.Pos = 4; att.Update(); att = newversionattributes.AddNew("status", "char"); att.Default = form.Status.Text; att.Pos = 5; att.Update(); newversionattributes.Refresh(); version.Update(); newversion.Refresh(); Repository.RefreshModelView(packversionid); } this.encours = true; }
public void newterm(EA.Repository Repository) { Form4 form = new Form4(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packtermid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packterm in pack0.Packages) { if (packterm.Name == "Terms") packtermid = packterm.PackageID; } if (packtermid == 0) { EA.Collection collec = pack0.Packages; EA.Package packterm = collec.AddNew("Terms", "Package"); packterm.Update(); collec.Refresh(); pack0.Update(); packtermid = packterm.PackageID; } EA.Collection newterm = Repository.GetPackageByID(packtermid).Elements; EA.Element term = newterm.AddNew(form.Term.Text, "Class"); EA.Collection newtermattributes = term.Attributes; EA.Attribute att = newtermattributes.AddNew("term", "char"); att.Default = form.Term.Text; att.Pos = 1; att.Update(); att = newtermattributes.AddNew("definition", "char"); att.Default = form.Definition.Text; att.Pos = 2; att.Update(); newtermattributes.Refresh(); term.Update(); newterm.Refresh(); Repository.RefreshModelView(packtermid); } this.encours = true; }
public void ping(string GUID, EA.Repository repository) { if (!active.ContainsKey(GUID)) { return; } foreach (RuleEntry ruleEntry in active[GUID]) { ruleEntry.actions++; DefectReport defectReport = new DefectReport(); defectReport.modelGUID = repository.GetPackageByID(1).PackageGUID; defectReport.ruleGUID = ruleEntry.GUID; defectReport.ruleName = ruleEntry.name; defectReport.actionsBeforeCorrection = ruleEntry.actions; defectReportService.saveReport(defectReport); } }
public void newscenario(EA.Repository Repository) { Form10 form = new Form10(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packscenarioid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packscenario in pack0.Packages) { if (packscenario.Name == "Scenarios") packscenarioid = packscenario.PackageID; } EA.Collection newscenario = Repository.GetPackageByID(packscenarioid).Elements; EA.Element scenario = newscenario.AddNew(form.Name.Text, "Use Case"); scenario.Stereotype = "Scenario"; scenario.Update(); EA.Collection newscenarios = scenario.Scenarios; EA.Scenario sc = newscenarios.AddNew(form.Name.Text, "Basic Path"); sc.Update(); newscenarios.Refresh(); newscenario.Refresh(); Repository.OpenElementPropertyDlg(scenario.ElementID); } this.encours = true; }
/// <summary> /// method deletes package /// </summary> /// <param name="Repository">EA repository</param> /// <param name="packageGUID">GUID of package that should be deleted</param> public void deletePackage(EA.Repository Repository, string packageGUID) { EA.Package packageToDelete = (EA.Package)Repository.GetPackageByGuid(packageGUID); string name = packageToDelete.Name; EA.Package parentPackage = (EA.Package)Repository.GetPackageByID(packageToDelete.ParentID); for (short i = 0; i < parentPackage.Packages.Count; i++) { EA.Package actualPackage = (EA.Package)parentPackage.Packages.GetAt(i); if (actualPackage.PackageGUID == packageGUID) { parentPackage.Packages.DeleteAt(i, false); break; } } parentPackage.Packages.Refresh(); BPAddIn.synchronizationWindow.addToList("Deletion of package '" + name + "' from package '" + parentPackage.Name + "'"); }
/// <summary> /// method deletes element /// </summary> /// <param name="Repository">EA repository</param> /// <param name="elementGUID">GUID of element that should be deleted</param> /// <param name="elementType">type of element that should be deleted</param> public void deleteElement(EA.Repository Repository, string elementGUID, int elementType) { EA.Element elementToDelete = (EA.Element)Repository.GetElementByGuid(elementGUID); string name = elementToDelete.Name; int packageID = elementToDelete.PackageID; int parentID = elementToDelete.ParentID; EA.Collection elements; if (elementToDelete.ParentID == 0) { elements = (EA.Collection)Repository.GetPackageByID(elementToDelete.PackageID).Elements; } else { elements = (EA.Collection)Repository.GetElementByID(elementToDelete.ParentID).Elements; } for (short i = 0; i < elements.Count; i++) { EA.Element actualElement = (EA.Element)elements.GetAt(i); if (actualElement.ElementGUID == elementGUID) { elements.DeleteAt(i, false); break; } } elements.Refresh(); BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name + "' (Previous location of element: " + itemTypes.getLocationOfItem(Repository, packageID, parentID)); }
/// <summary> /// method deletes diagram /// </summary> /// <param name="Repository">EA repository</param> /// <param name="diagramGUID">GUID of diagram that should be deleted</param> /// <param name="elementType">type of diagram that should be deleted</param> public void deleteDiagram(EA.Repository Repository, string diagramGUID, int elementType) { EA.Diagram diagramToDelete = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID); string name = diagramToDelete.Name; int packageID = diagramToDelete.PackageID; int parentID = diagramToDelete.ParentID; EA.Collection diagrams; if (diagramToDelete.ParentID == 0) { diagrams = (EA.Collection)Repository.GetPackageByID(diagramToDelete.PackageID).Diagrams; } else { diagrams = (EA.Collection)Repository.GetElementByID(diagramToDelete.ParentID).Diagrams; } for (short i = 0; i < diagrams.Count; i++) { EA.Diagram actualDiagram = (EA.Diagram)diagrams.GetAt(i); if (actualDiagram.DiagramGUID == diagramGUID) { diagrams.DeleteAt(i, false); break; } } diagrams.Refresh(); BPAddIn.synchronizationWindow.addToList("Deletion of " + itemTypes.getElementTypeInEnglish(elementType) + " '" + name + "' (Previous location of diagram: " + itemTypes.getLocationOfItem(Repository, packageID, parentID)); }
public string getLocationOfItem(EA.Repository repository, int packageID, int parentID) { EA.Package parentPackage = (EA.Package)repository.GetPackageByID(packageID); if (parentID == 0) { return " package '" + parentPackage.Name + "')"; } else { EA.Element parentElement = (EA.Element)repository.GetElementByID(parentID); return " element '" + parentElement.Name + "' in package '" + parentPackage.Name + "')"; } }
public void newKPI(EA.Repository Repository) { Form5 form = new Form5(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packkpiid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packkpi in pack0.Packages) { if (packkpi.Name == "KPI") packkpiid = packkpi.PackageID; } if (packkpiid == 0) { EA.Collection collec = pack0.Packages; EA.Package packkpi = collec.AddNew("KPI", "Package"); packkpi.Update(); collec.Refresh(); pack0.Update(); packkpiid = packkpi.PackageID; } EA.Collection newkpi = Repository.GetPackageByID(packkpiid).Elements; EA.Element kpi = newkpi.AddNew("KPI_" + form.ID.Text, "Class"); EA.Collection newkpiattributes = kpi.Attributes; EA.Attribute att = newkpiattributes.AddNew("id", "char"); att.Default = form.ID.Text; att.Pos = 1; att.Update(); att = newkpiattributes.AddNew("name", "char"); att.Default = form.Name.Text; att.Pos = 2; att.Update(); att = newkpiattributes.AddNew("description", "char"); att.Default = form.Description.Text; att.Pos = 3; att.Update(); att = newkpiattributes.AddNew("reference", "char"); att.Default = form.Reference.Text; att.Pos = 4; att.Update(); newkpiattributes.Refresh(); kpi.Update(); newkpi.Refresh(); Repository.RefreshModelView(packkpiid); } this.encours = true; }
//deprecated public static void insertCDE(EA.Repository m_Repository, XElement node, EAUtil.INSERT_XSD_TYPE xsdType) { try { string id = node.Element(rs + "names").Element(rs + "id").Value; string name = node.Element(rs + "names").Element(rs + "preferred").Value; string definition = node.Element(rs + "definition").Value; if (definition == null || definition.Length == 0) { definition = "(No definition supplied)"; } else { //Handle special caDSR format definition = definition.Trim().Replace(">", ">").Replace("<", "<").Replace("<![CDATA[", "").Replace("]]>", ""); if (definition.Contains("<def-source>")) { XElement e = XElement.Parse("<def>" + definition + "</def>"); definition = e.Element("def-definition").Value + "\n(Source: " + e.Element("def-source").Value + ")"; } } EA.Package package = m_Repository.GetPackageByID(m_Repository.GetCurrentDiagram().PackageID); EA.Element o = (EA.Element)package.Elements.AddNew(name.Replace(" ", "_"), "Class"); o.Notes = definition + " (ID: " + id + ")"; EAUtil.addTaggedValue("CDERef", id, o); EAUtil.addTaggedValue("preferred name", name, o); if (package.StereotypeEx == "XSDschema") { if (xsdType == EAUtil.INSERT_XSD_TYPE.TOP_LEVEL_ELEMENT) { o.Stereotype = "XSDtopLevelElement"; } else if (xsdType == EAUtil.INSERT_XSD_TYPE.TOP_LEVEL_ATTRIBUTE) { o.Stereotype = "XSDtopLevelAttribute"; } } if (node.Element(rs + "values").Element(rs + "non-enumerated") != null) { string dataType = node.Element(rs + "values").Element(rs + "non-enumerated").Element(rs + "data-type").Value; if (dataType.StartsWith("xs:"))// || dataType.StartsWith("xsd:")) { //o.Genlinks = "Parent=" + dataType.Substring(dataType.IndexOf(":") + 1) + ";"; string simpleTypeClassName = name.Replace(" ", "_") + "_Type"; EA.Element simpleTypeClass = (EA.Element)package.Elements.AddNew(simpleTypeClassName, "Class"); simpleTypeClass.Stereotype = "XSDsimpleType"; simpleTypeClass.Genlinks = "Parent=" + dataType.Substring(dataType.IndexOf(":") + 1) + ";"; simpleTypeClass.Update(); simpleTypeClass.Refresh(); EA.DiagramObject simpleTypeDiag = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", "")); simpleTypeDiag.ElementID = simpleTypeClass.ElementID; simpleTypeDiag.Update(); EA.Connector simpleTypeConnector = (EA.Connector)o.Connectors.AddNew("", "Generalization"); simpleTypeConnector.SupplierID = simpleTypeDiag.ElementID; simpleTypeConnector.Update(); o.Connectors.Refresh(); } else { o.Genlinks = "Parent=" + dataType + ";"; } } else if (node.Element(rs + "values").Element(rs + "enumerated") != null) { string enumClassName = "Enum_" + name.Replace(" ", "_"); EA.Element enumClass = (EA.Element)package.Elements.AddNew(enumClassName, "Class"); enumClass.Stereotype = "enumeration"; enumClass.Genlinks = "Parent=string;"; foreach (XElement n in node.Element(rs + "values").Element(rs + "enumerated").Elements(rs + "valid-value")) { EA.Attribute at = (EA.Attribute)enumClass.Attributes.AddNew("", ""); at.Stereotype = "enum"; at.Name = n.Element(rs + "code").Value; at.Notes = n.Element(rs + "meaning").Value; at.Update(); } enumClass.Attributes.Refresh(); EA.DiagramObject enumDiag = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", "")); enumDiag.ElementID = enumClass.ElementID; enumDiag.Update(); EA.Connector enumConnector = (EA.Connector)o.Connectors.AddNew("", "Generalization"); enumConnector.SupplierID = enumDiag.ElementID; enumConnector.Update(); o.Connectors.Refresh(); enumClass.Update(); enumClass.Refresh(); } //attr.Update(); //o.Attributes.Refresh(); o.Update(); o.Refresh(); EA.DiagramObject diagram = (EA.DiagramObject)(m_Repository.GetCurrentDiagram().DiagramObjects.AddNew("", "")); diagram.ElementID = o.ElementID; diagram.Update(); m_Repository.ReloadDiagram(diagram.DiagramID); //this.Close(); } catch (Exception exp) { MessageBox.Show("Please make sure you have an active diagram openned." + "\n" + exp.Message + "\n" + exp.StackTrace, "No active diagram currently selected", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void model(EA.Repository Repository, string packagename) { this.encours = false; int packageid = 0; int actorsid = 0; int ucid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { if (package.Name == "Use Case Model") packageid = package.PackageID; } if (packageid != 0) { pack0 = Repository.GetPackageByID(packageid); EA.Collection collec = pack0.Packages; EA.Package pack = collec.AddNew(packagename, "otPackage"); pack.Name = packagename; pack.ParentID = packageid; pack.Update(); pack.Update(); packageid = pack.PackageID; } foreach (EA.Package pack1 in pack0.Packages) { if (pack1.Name == "Actors") { actorsid = pack1.PackageID; } if (pack1.Name == "Primary Use Cases") { ucid = pack1.PackageID; } } if (actorsid != 0) { EA.Package pack1 = Repository.GetPackageByID(actorsid); EA.Collection actors = pack1.Elements; foreach (EA.Element actor in actors) { if (actor.Name == "User") { actors.Delete(0); actor.Update(); } } actors.Refresh(); pack1.ParentID = packageid; pack1.Update(); } if (ucid != 0) { EA.Package pack1 = Repository.GetPackageByID(ucid); EA.Collection usecases = pack1.Elements; short i = 0; short j = 0; foreach (EA.Diagram diag in pack1.Diagrams) { if (diag.Name == "Primary Use Cases") { diag.Name = "Scenarios"; diag.Update(); } } foreach (EA.Element usecase in usecases) { EA.Collection ucelements = usecase.Elements; foreach (EA.Element ucel in ucelements) { ucelements.Delete(j); //ucel.Update(); j++; } usecases.Delete(i); // usecase.Update(); i++; } usecases.Refresh(); pack1.ParentID = packageid; pack1.Name = "Scenarios"; pack1.Update(); Form9 form = new Form9(packagename); form.ShowDialog(); if (form.confirm == 1) { EA.Package pack = Repository.GetPackageByID(packageid); EA.Collection collec = pack.Elements; EA.Element uc = collec.AddNew(packagename, "Use Case"); uc.Notes = form.Complete.Text; EA.Collection uctag = uc.TaggedValues; EA.TaggedValue tag = uctag.AddNew("Short description", ""); tag.Notes = form.Short.Text; tag = uctag.AddNew("UCId", ""); tag.Value = form.Short.Text; tag.Update(); tag = uctag.AddNew("Area/Domain/Zone", ""); tag.Value = form.ADZ.Text; tag.Update(); tag = uctag.AddNew("Objective(s)", ""); tag.Value = form.Objectives.Text; tag.Update(); tag = uctag.AddNew("Scope", ""); tag.Value = form.Scope.Text; tag.Update(); tag = uctag.AddNew("Related UC", ""); tag.Value = form.RelatedUC.Text; tag.Update(); uctag.Refresh(); uc.Update(); collec.Refresh(); } } this.encours = true; }
/// <summary> /// method executes synchronization process /// </summary> /// <param name="repository">EA repository</param> public void executeSynchronization(EA.Repository repository) { User user = getLoggedUser(); using (WebClient webClient = new WebClient()) { this.user = user; string result = "", result2 = "", result3 = ""; ModelInformation synchronizationData = new ModelInformation(); synchronizationData.token = user.token; EA.Package package = (EA.Package)repository.GetPackageByID(1); synchronizationData.modelGUID = package.PackageGUID; string data = user.token; BPAddIn.changesAllowed = false; webClient.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8"; result = webClient.UploadString(Utils.serviceAddress + "/synchronization/getNumber", user.token); int number = Convert.ToInt32(result); if (BPAddIn.synchronizationWindow == null) { BPAddIn.synchronizationWindow = repository.AddWindow("Synchronization", "BPAddIn.SynchronizationPackage.SynchronizationWindow") as SynchronizationWindow; } repository.ShowAddinWindow("Synchronization"); BPAddIn.synchronizationWindow.removeList(); DateTime localDate = DateTime.Now; var culture = new CultureInfo("de-DE"); BPAddIn.synchronizationWindow.addToList(localDate.ToString(culture)); if (number == 0) { BPAddIn.synchronizationWindow.addToList("No modifications."); BPAddIn.changesAllowed = true; return; } while (true) { try { data = user.token; webClient.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8"; result2 = webClient.UploadString(Utils.serviceAddress + "/synchronization/changes", data); ModelChange modelChange = JsonConvert.DeserializeObject<ModelChange>(result2, new JsonItemConverter()); if (modelChange == null) { data = user.token; continue; } if (modelChange is PropertyChange) { PropertyChange propertyChange = (PropertyChange)modelChange; if (propertyChange.timestamp == "-1") { repository.ShowAddinWindow("Synchronization"); repository.RefreshModelView(1); break; } } if (modelChange is ItemCreation) { ItemCreation itemCreation = (ItemCreation)modelChange; //addition NewCorrespondenceNode newCorrNode = new NewCorrespondenceNode(); newCorrNode.firstUsername = user.username; newCorrNode.firstItemGUID = synchronization.handleSynchronizationAdditions(itemCreation, repository); newCorrNode.secondUsername = itemCreation.userName; newCorrNode.secondItemGUID = itemCreation.itemGUID; data = EncodeNonAsciiCharacters(newCorrNode.serialize()); webClient.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8"; result3 = webClient.UploadString(Utils.serviceAddress + "/corrModel/createNode", data); } else if (modelChange is PropertyChange) { PropertyChange propertyChange = (PropertyChange)modelChange; if (propertyChange.elementDeleted == 0) { synchronization.handleSynchronizationChanges(propertyChange, repository); //change } else { synchronization.handleSynchronizationDeletions(propertyChange, repository); //deletion } } else if (modelChange is StepChange) //scenarios { StepChange scenarioChange = (StepChange)modelChange; if (scenarioChange.status == 1) //addition { NewCorrespondenceNode newCorrNode = new NewCorrespondenceNode(); newCorrNode.firstUsername = user.username; newCorrNode.firstItemGUID = synchronization.handleScenarioAddition(scenarioChange, repository); newCorrNode.secondUsername = scenarioChange.userName; newCorrNode.secondItemGUID = scenarioChange.scenarioGUID; data = EncodeNonAsciiCharacters(newCorrNode.serialize()); webClient.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8"; result3 = webClient.UploadString(Utils.serviceAddress + "/corrModel/createNode", data); } else if (scenarioChange.status == 2 || scenarioChange.status == 0) //change or deletion { synchronization.handleScenarioChange(scenarioChange, repository); } } } catch (Exception e) { continue; } } } }
public void newcustominfo(EA.Repository Repository) { Form6 form = new Form6(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packcustomid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packcustom in pack0.Packages) { if (packcustom.Name == "Custom Informations") packcustomid = packcustom.PackageID; } if (packcustomid == 0) { EA.Collection collec = pack0.Packages; EA.Package packcustom = collec.AddNew("Custom Informations", "Package"); packcustom.Update(); collec.Refresh(); pack0.Update(); packcustomid = packcustom.PackageID; } EA.Collection newcustom = Repository.GetPackageByID(packcustomid).Elements; EA.Element custom = newcustom.AddNew(form.Key.Text, "Class"); EA.Collection newcustomattributes = custom.Attributes; EA.Attribute att = newcustomattributes.AddNew("key", "char"); att.Default = form.Key.Text; att.Pos = 1; att.Update(); att = newcustomattributes.AddNew("value", "char"); att.Default = form.Value.Text; att.Pos = 2; att.Update(); att = newcustomattributes.AddNew("refers", "char"); att.Default = form.Refers.Text; att.Pos = 3; att.Update(); newcustomattributes.Refresh(); custom.Update(); newcustom.Refresh(); Repository.RefreshModelView(packcustomid); } this.encours = true; }
/// <summary> /// method shows window that informs user about current situation of his synchronization process /// </summary> /// <param name="repository">EA repository</param> public void showCorrectWindow(EA.Repository repository) { User user = getLoggedUser(); if (user == null) { MessageBox.Show("First you must log in and join your colleague to team."); return; } using (WebClient webClient = new WebClient()) { this.user = user; string result = "", result2 = "", result3 = ""; ModelInformation synchronizationData = new ModelInformation(); synchronizationData.token = user.token; EA.Package package = (EA.Package)repository.GetPackageByID(1); synchronizationData.modelGUID = package.PackageGUID; string data = user.token; try { webClient.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8"; data = EncodeNonAsciiCharacters(synchronizationData.serialize()); result = webClient.UploadString(Utils.serviceAddress + "/synchronization", data); BPAddIn.syncProgressWindow = new SynchronizationProgressWindow(repository); BPAddIn.syncProgressWindow.ShowDialog(); } catch (WebException e) { var response = e.Response as HttpWebResponse; int code = (int)response.StatusCode; if (code == 401) { MessageBox.Show("Please, log in once again."); } else if (code == 400) { MessageBox.Show("Currently, you are not a member of any team. First, join your colleague to team."); } else if (code == 405) { MessageBox.Show("Synchronization of this model in your team is not allowed."); } else if (code == 403) { MessageBox.Show("Your colleague in team has not sent data about model yet."); } else if (code == 404) { DialogResult resultWindow = MessageBox.Show("Do you want to synchronise currently opened model? Change of synchronized model in team project is not possible.", "Choice of model for synchronization", MessageBoxButtons.YesNo); if (resultWindow == DialogResult.Yes) { SendingDataWindow sendingDataWindow = new SendingDataWindow(repository); sendingDataWindow.ShowDialog(); } } else if (code == 406) { MessageBox.Show("Your colleague has not joined your team yet."); } } catch (Exception ex) { MessageBox.Show("Unexpected error has occured."); } } }
public void newreference(EA.Repository Repository) { Form8 form = new Form8(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packreferenceid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packreference in pack0.Packages) { if (packreference.Name == "References") packreferenceid = packreference.PackageID; } if (packreferenceid == 0) { EA.Collection collec = pack0.Packages; EA.Package packreference = collec.AddNew("References", "Package"); packreference.Update(); collec.Refresh(); pack0.Update(); packreferenceid = packreference.PackageID; } EA.Collection newreference = Repository.GetPackageByID(packreferenceid).Elements; EA.Element reference = newreference.AddNew("Reference_" + form.No.Text, "Class"); EA.Collection newreferenceattributes = reference.Attributes; EA.Attribute att = newreferenceattributes.AddNew("no", "char"); att.Default = form.No.Text; att.Pos = 1; att.Update(); att = newreferenceattributes.AddNew("type", "char"); att.Default = form.Type.Text; att.Pos = 2; att.Update(); att = newreferenceattributes.AddNew("reference", "char"); att.Default = form.Reference.Text; att.Pos = 3; att.Update(); att = newreferenceattributes.AddNew("status", "char"); att.Default = form.Status.Text; att.Pos = 4; att.Update(); att = newreferenceattributes.AddNew("impact", "char"); att.Default = form.Impact.Text; att.Pos = 5; att.Update(); att = newreferenceattributes.AddNew("originator", "char"); att.Default = form.Originator.Text; att.Pos = 6; att.Update(); att = newreferenceattributes.AddNew("link", "char"); att.Default = form.Link.Text; att.Pos = 7; att.Update(); newreferenceattributes.Refresh(); reference.Update(); newreference.Refresh(); Repository.RefreshModelView(packreferenceid); } this.encours = true; }
private void DoRule86(EA.Repository Repository, EA.Method method) { if (method.Stereotype == "XisAction") { string type = M2MTransformer.GetMethodTag(method.TaggedValues, "type").Value; if (type == "WebService") { if (method.Name.Contains('.')) { string[] serviceName = method.Name.Split('.'); if (serviceName.Length == 2) { EA.Package model = Repository.GetPackageByID(Repository.GetElementByID(method.ParentID).PackageID); EA.Package package = null; EA.Package architectural = null; for (short i = 0; i < model.Packages.Count; i++) { package = model.Packages.GetAt(i); if (package.StereotypeEx == "Architectural View") { architectural = package; break; } } if (architectural != null) { EA.Element el = null; EA.Element service = null; for (short i = 0; i < architectural.Elements.Count; i++) { el = architectural.Elements.GetAt(i); if (el.Type == "Interface" && (el.Stereotype == "XisInternalService" || el.Stereotype == "XisRemoteService") && el.Name == serviceName[0]) { service = el; break; } } if (service != null && service.Methods.Count > 0) { EA.Method m = null; bool hasMethod = false; for (short i = 0; i < service.Methods.Count; i++) { m = service.Methods.GetAt(i); if (m.Stereotype == "XisServiceMethod" && m.Name == serviceName[1]) { hasMethod = true; break; } } if (hasMethod) { if (m.Parameters.Count == method.Parameters.Count) { EA.Parameter p1 = null; EA.Parameter p2 = null; for (short i = 0; i < m.Parameters.Count; i++) { p1 = m.Parameters.GetAt(i); p2 = method.Parameters.GetAt(i); if (p1.Name == p2.Name) { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule86), EA.EnumMVErrorType.mvError, GetRuleStr(rule86)); isValid = false; break; } } } else { EA.Project Project = Repository.GetProjectInterface(); Project.PublishResult(LookupMap(rule86), EA.EnumMVErrorType.mvError, GetRuleStr(rule86)); isValid = false; } } } } } } } } }
public void newinfo(EA.Repository Repository) { Form7 form = new Form7(); form.ShowDialog(); if (form.confirm == 1) { this.encours = false; int packageid = 0; int packinfoid = 0; EA.Package pack0 = Repository.Models.GetAt(0); foreach (EA.Package package in pack0.Packages) { foreach (EA.Package pack in package.Packages) { packageid = pack.PackageID; } } pack0 = Repository.GetPackageByID(packageid); foreach (EA.Package packinfo in pack0.Packages) { if (packinfo.Name == "Informations exchanged") packinfoid = packinfo.PackageID; } if (packinfoid == 0) { EA.Collection collec = pack0.Packages; EA.Package packinfo = collec.AddNew("Informations exchanged", "Package"); packinfo.Update(); collec.Refresh(); pack0.Update(); packinfoid = packinfo.PackageID; } EA.Collection newinfo = Repository.GetPackageByID(packinfoid).Elements; EA.Element info = newinfo.AddNew(form.ID.Text, "Class"); EA.Collection newinfoattributes = info.Attributes; EA.Attribute att = newinfoattributes.AddNew("id", "char"); att.Default = form.ID.Text; att.Pos = 1; att.Update(); att = newinfoattributes.AddNew("name", "char"); att.Default = form.Name.Text; att.Pos = 2; att.Update(); att = newinfoattributes.AddNew("description", "char"); att.Default = form.Description.Text; att.Pos = 3; att.Update(); newinfoattributes.Refresh(); info.Update(); newinfo.Refresh(); Repository.RefreshModelView(packinfoid); } this.encours = true; }
public void RunPackageRule(EA.Repository Repository, string sRuleID, long PackageID) { EA.Package Package = Repository.GetPackageByID((int)PackageID); if (Package != null) { switch (LookupMapEx(sRuleID)) { case rule01: DoRule01_to_04(Repository, Package); break; case rule18: DoRule18(Repository, Package); break; case rule32: DoRule32(Repository, Package); break; case rule106: DoRule106(Repository, Package); break; case rule107: DoRule107(Repository, Package); break; case rule108: DoRule108(Repository, Package); break; case rule109: DoRule109(Repository, Package); break; case rule110: DoRule110(Repository, Package); break; case rule111: DoRule111(Repository, Package); break; default: break; } } }
/// <summary> /// method adds a new diagram object into diagram /// </summary> /// <param name="Repository">EA repository</param> /// <param name="elementGUID">GUID of element</param> /// <param name="diagramGUID">GUID of diagram</param> /// <param name="coordinates">coordinates of new diagram object</param> public void addDiagramObject(EA.Repository Repository, string elementGUID, string diagramGUID, string coordinates) { int left, right, top, bottom; string[] coordinate; string str; string[] parts = coordinates.Split(';'); str = parts[0]; coordinate = str.Split('='); left = Convert.ToInt32(coordinate[1]); str = parts[1]; coordinate = str.Split('='); right = Convert.ToInt32(coordinate[1]); str = parts[2]; coordinate = str.Split('='); top = Convert.ToInt32(coordinate[1]); str = parts[3]; coordinate = str.Split('='); bottom = Convert.ToInt32(coordinate[1]); EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID); for (short i = 0; i < diagram.DiagramObjects.Count; i++) { EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i); EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID); if (diagramObj.left <= left && diagramObj.right >= right && diagramObj.top >= top && diagramObj.bottom <= bottom) { diagramObj.Sequence += 1; diagramObj.Update(); } } diagram.DiagramObjects.Refresh(); EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID); EA.DiagramObject displayElement = (EA.DiagramObject)diagram.DiagramObjects.AddNew(coordinates, ""); displayElement.ElementID = element.ElementID; displayElement.Sequence = 1; displayElement.Update(); diagram.DiagramObjects.Refresh(); EA.Package parentPackage = (EA.Package)Repository.GetPackageByID(diagram.PackageID); if (diagram.ParentID == 0) { BPAddIn.synchronizationWindow.addToList("Addition of element '" + element.Name + "' to diagram '" + diagram.Name + "' (Location of diagram: package '" + parentPackage.Name + "')"); } else { EA.Element parentElement = (EA.Element)Repository.GetElementByID(diagram.ParentID); BPAddIn.synchronizationWindow.addToList("Addition of element '" + element.Name + "' to diagram '" + diagram.Name + "' (Location of diagram: element '" + parentElement.Name + "' in package '" + parentPackage.Name + "')"); } }
/// <summary> /// method moves diagram object of element in diagram /// </summary> /// <param name="Repository">EA repository</param> /// <param name="elementGUID">GUID of element which diagram object that should be moved belongs to</param> /// <param name="diagramGUID">GUID of diagram</param> /// <param name="coordinates">new coordinates of diagram object that should be moved</param> public void moveElementInDiagram(EA.Repository Repository, string elementGUID, string diagramGUID, string coordinates) { EA.Element element = (EA.Element)Repository.GetElementByGuid(elementGUID); EA.Diagram diagram = (EA.Diagram)Repository.GetDiagramByGuid(diagramGUID); int left, right, top, bottom, pocet = 0; Wrapper.Diagram diagramWrapper = new Wrapper.Diagram(model, diagram); Wrapper.ElementWrapper elWrapper = new Wrapper.ElementWrapper(model, element); EA.DiagramObject diagramObject = diagramWrapper.getdiagramObjectForElement(elWrapper); string[] coordinate; string str; string[] parts = coordinates.Split(';'); str = parts[0]; coordinate = str.Split('='); diagramObject.left = Convert.ToInt32(coordinate[1]); left = Convert.ToInt32(coordinate[1]); str = parts[1]; coordinate = str.Split('='); diagramObject.right = Convert.ToInt32(coordinate[1]); right = Convert.ToInt32(coordinate[1]); str = parts[2]; coordinate = str.Split('='); diagramObject.top = Convert.ToInt32(coordinate[1]); top = Convert.ToInt32(coordinate[1]); str = parts[3]; coordinate = str.Split('='); diagramObject.bottom = Convert.ToInt32(coordinate[1]); bottom = Convert.ToInt32(coordinate[1]); for (short i = 0; i < diagram.DiagramObjects.Count; i++) { EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i); EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID); if (diagramObj.left >= left && diagramObj.right <= right && diagramObj.top <= top && diagramObj.bottom >= bottom) { if (diagramObj.ElementID != diagramObject.ElementID) { pocet++; } } } diagramObject.Sequence = 1 + pocet; diagramObject.Update(); for (short i = 0; i < diagram.DiagramObjects.Count; i++) { EA.DiagramObject diagramObj = (EA.DiagramObject)diagram.DiagramObjects.GetAt(i); EA.Element el = (EA.Element)Repository.GetElementByID(diagramObj.ElementID); if (diagramObj.left <= left && diagramObj.right >= right && diagramObj.top >= top && diagramObj.bottom <= bottom) { if (diagramObj.ElementID != diagramObject.ElementID) { diagramObj.Sequence += 1; diagramObj.Update(); } } } int parentID = diagram.ParentID; EA.Package package = (EA.Package)Repository.GetPackageByID(diagram.PackageID); if (parentID == 0) { BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" + diagram.Name + "' (Location of diagram: package '" + package.Name + "')"); } else { EA.Element parent = (EA.Element)Repository.GetElementByID(parentID); BPAddIn.synchronizationWindow.addToList("Change of coordinates of element '" + element.Name + "' in diagram '" + diagram.Name + "' (Location of diagram: element '" + parent.Name + "' in package '" + package.Name + "')"); } diagram.DiagramObjects.Refresh(); }
public static EA.Package GetFirstControlledPackage(EA.Repository rep, EA.Package pkg) { if (pkg.IsControlled) return pkg; var pkgId = pkg.ParentID; if (pkgId == 0) return null; pkg = GetFirstControlledPackage(rep, rep.GetPackageByID(pkgId)); return pkg; }
//Возвращает ID пакета, вход - упорядоченный массив из наименований пакетов (путь к искомому пакету) public static int getPackageId(String[] list, EA.Repository r) { EA.Package package = r.GetPackageByID(1); //root package bool flag; //Найден ли очередной пакет for (short i = 1; i < list.Length; i++) { flag = false; for (short j = 0; j < package.Packages.Count; j++) { if (package.Packages.GetAt(j).Name == list[i]) { package = package.Packages.GetAt(j); flag = true; break; } } if (!flag) throw new ReportException(packageNotFound, 1, r, 1); } return package.PackageID; }
public static bool CreateInteractionForOperation(EA.Repository rep, EA.Method m) { // get class EA.Element elClass = rep.GetElementByID(m.ParentID); EA.Package pkgSrc = rep.GetPackageByID(elClass.PackageID); // create a package with the name of the operation var pkgTrg = (EA.Package)pkgSrc.Packages.AddNew(m.Name, ""); pkgTrg.Update(); pkgSrc.Packages.Refresh(); // create Class Sequence Diagram in target package var pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Sequence"); pkgSeqDia.Update(); pkgTrg.Diagrams.Refresh(); // add frame in Sequence diagram var frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", ""); var frm = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram"); frm.Update(); frmObj.ElementID = frm.ElementID; //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; frmObj.Update(); pkgTrg.Elements.Refresh(); pkgSeqDia.DiagramObjects.Refresh(); // create Interaction with the name of the operation var seq = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Interaction"); seq.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!"; seq.Update(); pkgTrg.Elements.Refresh(); // create sequence diagram beneath Interaction var seqDia = (EA.Diagram)seq.Diagrams.AddNew(m.Name, "Sequence"); seqDia.Update(); seq.Diagrams.Refresh(); // create instance from class beneath Interaction var obj = (EA.Element)seq.Elements.AddNew("", "Object"); seq.Elements.Refresh(); obj.ClassfierID = elClass.ElementID; obj.Update(); // add node object to Sequence Diagram var node = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=100;r=180;t=50;b=70", ""); node.ElementID = obj.ElementID; node.Update(); // Add Heading to diagram var noteObj = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", ""); var note = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text"); note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType; note.Update(); noteObj.ElementID = note.ElementID; noteObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; noteObj.Update(); pkgTrg.Elements.Refresh(); seqDia.DiagramObjects.Refresh(); // Link Operation to activity Util.SetBehaviorForOperation(rep, m, seq); // Set show behavior Util.SetShowBehaviorInDiagram(rep, m); Util.SetFrameLinksToDiagram(rep, frm, seqDia); // link Overview frame to diagram frm.Update(); //rep.ReloadDiagram(actDia.DiagramID); return true; }