/// informed that the deletion of the Method will delete the SDM Diagram as well. /// </summary> /// <param name="Repository"></param> /// <param name="Info"></param> /// <returns></returns> public Boolean EA_OnPreDeleteMethod(EA.Repository Repository, EA.Method method) { EA.Method meth = method; EA.Element methParent = Repository.GetElementByID(meth.ParentID); EA.TaggedValue aTag = null; SQLRepository sqlRep = new SQLRepository(Repository, false); foreach (EA.Element actEle in methParent.Elements) { aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(actEle, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName); if (aTag != null) { if (aTag.Value.ToString() == meth.MethodGUID.ToString()) { Boolean delete = false; DeleteMethod deleteMethod = new DeleteMethod(delete); deleteMethod.StartPosition = FormStartPosition.CenterScreen; deleteMethod.ShowDialog(); delete = deleteMethod.setVal(); if (delete) { EAUtil.deleteElement(actEle, sqlRep); return(true); } return(false); } } } return(true); }
private static void deleteElementsInQueue(EA.Repository Repository) { while (DeleteQueue.Count > 0) { EAUtil.deleteElement(Repository.GetElementByGuid(DeleteQueue[0]), new SQLRepository(Repository, false)); DeleteQueue.RemoveAt(0); } }
private static void transformConstraintToCSPElement(SQLElement eaElement2, SQLWrapperClasses.SQLRepository sqlRep, EA.Repository repository) { EA.Element eaElement = EAUtil.sqlEAObjectToOriginalObject(sqlRep, eaElement2) as EA.Element; String result = repository.SQLQuery("select Diagram_ID from t_diagramobjects where Object_ID = " + eaElement.ElementID); string diagramId = EAUtil.getXMLNodeContentFromSQLQueryString(result, "Diagram_ID")[0]; if (diagramId != "") { EA.Diagram diagram = repository.GetDiagramByID(int.Parse(diagramId)); EA.DiagramObject oldDiagObject = EAUtil.findDiagramObject(sqlRep, eaElement, diagram); EA.Element ruleElement = repository.GetElementByID(diagram.ParentID); if (ruleElement.Stereotype == TGGModelingMain.TggRuleStereotype) { List <EA.Connector> outgoingCons = new List <EA.Connector>(); foreach (EA.Connector con in eaElement.Connectors) { if (con.Stereotype == "ConstraintLink" && con.ClientID == eaElement.ElementID) { outgoingCons.Add(con); } } EA.Element newCsp = ruleElement.Elements.AddNew("", Main.EAClassType) as EA.Element; newCsp.Notes = eaElement.Notes; newCsp.Stereotype = TGGModelingMain.CSPConstraintStereotype; newCsp.Update(); EA.TaggedValue oldTag = EAUtil.findTaggedValue(eaElement, Main.MoflonExportTreeTaggedValueName); if (oldTag != null) { EAUtil.setTaggedValueNotes(sqlRep, newCsp, oldTag.Name, oldTag.Notes); } EA.DiagramObject newDiagObject = diagram.DiagramObjects.AddNew("", Main.EAClassType) as EA.DiagramObject; newDiagObject.ElementID = newCsp.ElementID; newDiagObject.left = oldDiagObject.left; newDiagObject.right = oldDiagObject.right; newDiagObject.bottom = oldDiagObject.bottom; newDiagObject.top = oldDiagObject.top; newDiagObject.Update(); foreach (EA.Connector con in outgoingCons) { con.ClientID = newCsp.ElementID; con.Update(); } EAUtil.deleteDiagramObject(repository, diagram, eaElement); EAUtil.deleteElement(eaElement, sqlRep); } } }
public override void doRuleQuickFix(SQLElement eaElement, SQLRepository repository, int i, String errorMessage) { if (i == 0) { EAUtil.deleteElement(eaElement.getRealElement(), repository); } else if (i == 1) { EA.Diagram possibleDiagram = null; SQLElement parent = eaElement; SQLPackage parentPackage = null; while (possibleDiagram == null) { if (parent.ParentID != 0) { parent = repository.GetElementByID(parent.ParentID); if (parent.Diagrams.Count > 0) { possibleDiagram = parent.Diagrams.GetAt(0) as EA.Diagram; } } else { if (parentPackage == null) { parentPackage = repository.GetPackageByID(parent.PackageID); } else { parentPackage = repository.GetPackageByID(parentPackage.ParentID); } if (parentPackage.Diagrams.Count > 0) { possibleDiagram = parentPackage.Diagrams.GetAt(0) as EA.Diagram; } } } possibleDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, possibleDiagram) as EA.Diagram; EA.DiagramObject diagObject = possibleDiagram.DiagramObjects.AddNew("", eaElement.Type) as EA.DiagramObject; diagObject.left = 20; diagObject.right = 120; diagObject.top = -20; diagObject.bottom = -70; diagObject.ElementID = eaElement.ElementID; diagObject.Update(); repository.OpenDiagram(possibleDiagram.DiagramID); EAUtil.clearSelectedDiagramObjects(repository); possibleDiagram.SelectedObjects.AddNew(diagObject.ElementID.ToString(), ""); repository.ReloadDiagram(possibleDiagram.DiagramID); } }
private void buttonDeleteSdms_Click(object sender, EventArgs e) { ConfirmDeleteSDMs confirmDialog = new ConfirmDeleteSDMs(); if (confirmDialog.ShowDialog() == DialogResult.OK) { SQLPackage selectedPackage = repository.GetTreeSelectedPackage(); SQLPackage outermostPackage = EAUtil.getOutermostPackage(selectedPackage, repository); String sqlResult = repository.SQLQuery("SELECT * FROM t_object WHERE Stereotype = '" + SDMModelingMain.SdmContainerStereotype + "'"); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(sqlResult, "Row")) { if (row != "") { SQLElement element = new SQLElement(repository, row); if (EAUtil.getOutermostPackage(element, repository).PackageGUID == outermostPackage.PackageGUID) { EAUtil.deleteElement(element.getRealElement(), repository); } } } } }
private void buttonCancel_Click(object sender, EventArgs e) { EAUtil.deleteElement(this.corrObject.getRealElement(), this.sqlRepository); Close(); }