public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); SQLElement clientClass = repository.GetElementByID(eaConnector.ClientID); if (clientClass.Stereotype == ECOREModelingMain.EClassStereotype && eaConnector.Type == ECOREModelingMain.EReferenceConnectorType) { SQLConnector con = eaConnector; SQLElement supplierClass = repository.GetElementByID(con.SupplierID); EReference eReference = new EReference(con, repository); eReference.loadTreeFromTaggedValue(); if ((con.ClientEnd.Navigable == "Navigable" && eReference.ClientEnd.typeGUID != clientClass.ElementGUID) || (con.SupplierEnd.Navigable == "Navigable" && eReference.SupplierEnd.typeGUID != supplierClass.ElementGUID)) { results.Add("Moca fragment of EReference is invalid and must be refreshed"); } } return(results); }
/// <summary> /// Checks if the new created Element is an SDM related Element. /// Opens the custom User Dialogues or sets default values if it is necessary. /// </summary> /// <param name="sqlRep"></param> /// <param name="Info"></param> /// <returns>if newElement is still valid</returns> public bool EA_OnPostNewElement(SQLRepository sqlRep, EA.Element newElement, EA.Diagram currentDiagram) { if (SdmDiagramMetatype.Contains(currentDiagram.MetaType)) { sqlRep.SuppressEADialogs = true; if (newElement.Stereotype == SDMModelingMain.ObjectVariableQuickCreateStereotype) { newElement.Stereotype = SDMModelingMain.ObjectVariableStereotype; ObjectVariable ov = new ObjectVariable(sqlRep.GetElementByID(newElement.ElementID), sqlRep); OvDialog objectVariableDialogue = new OvDialog(sqlRep, ov); List <SQLElement> validEClassesTemp = new List <SQLElement>(); List <EClass> validEClasses = new List <EClass>(); SQLElement sourceObjectVariable = sqlRep.GetElementByGuid(Main.lastContextItemGUID); SQLElement classifier = sqlRep.GetElementByID(sourceObjectVariable.ClassifierID); foreach (SQLElement baseclass in EAUtil.getBaseClasses(classifier)) { foreach (SQLConnector connector in baseclass.Connectors) { if (connector.Type == ECOREModelingMain.EReferenceConnectorType) { EReference eRef = new EReference(connector, sqlRep); eRef.loadTreeFromTaggedValue(); SQLElement otherEnd = null; if (connector.ClientID == baseclass.ElementID && eRef.SupplierEnd.Navigable) { otherEnd = sqlRep.GetElementByID(connector.SupplierID); } else if (connector.SupplierID == baseclass.ElementID && eRef.ClientEnd.Navigable) { otherEnd = sqlRep.GetElementByID(connector.ClientID); } if (otherEnd != null && otherEnd.Stereotype == ECOREModelingMain.EClassStereotype) { validEClassesTemp.Add(otherEnd); } } } } objectVariableDialogue.ovPropertiesControl.comboTypes.clearClassifiers(); foreach (SQLElement tempClassifier in validEClassesTemp) { objectVariableDialogue.ovPropertiesControl.comboTypes.addClassifier(new EClass(tempClassifier, sqlRep)); } objectVariableDialogue.ovPropertiesControl.comboTypes.printClassifiers(); objectVariableDialogue.ShowDialog(); } else if (newElement.Stereotype == SDMModelingMain.ObjectVariableStereotype || (newElement.Type == Main.EAObjectType && newElement.Stereotype == "")) { Boolean dragAndDropUsed = newElement.ClassifierID != 0; if (dragAndDropUsed && !classifierIsValid(sqlRep, newElement)) { Main.addToDeleteGUIDQueue(newElement.ElementGUID); return(false); } EA.DiagramObject diagObj = EAEcoreAddin.Util.EAUtil.findDiagramObject(sqlRep, newElement, currentDiagram); foreach (EA.DiagramObject diagObjs in currentDiagram.DiagramObjects) { if (diagObj.left > (diagObjs.left - 45) && diagObj.right < (diagObjs.right + 45) && diagObj.top < (diagObjs.top + 30) && diagObj.bottom > (diagObjs.bottom - 30)) { if (newElement.ElementID != diagObjs.ElementID) { EA.Element realElement = sqlRep.GetOriginalRepository().GetElementByID(newElement.ElementID); realElement.ParentID = diagObjs.ElementID; realElement.Update(); break; } } } //recompute newElement because of drag and drop changes to the element if (dragAndDropUsed) { newElement = sqlRep.GetOriginalRepository().GetElementByID(newElement.ElementID); } newElement.Stereotype = SDMModelingMain.ObjectVariableStereotype; ObjectVariable ov = new ObjectVariable(sqlRep.GetElementByID(newElement.ElementID), sqlRep); OvDialog objectVariableDialogue = new OvDialog(sqlRep, ov); objectVariableDialogue.ShowDialog(); } else if (newElement.Stereotype == SDMModelingMain.StoryNodeStereotype) { //save initial data for storyNode EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRep, newElement, Main.MoflonExtractedStoryPatternTaggedValueName, "false"); StoryNode storyNode = new StoryNode(sqlRep, sqlRep.GetElementByID(newElement.ElementID)); storyNode.ForEach = false; storyNode.saveTreeToEATaggedValue(true); } else if (newElement.Stereotype == SDMModelingMain.StopNodeStereotype) { //save initial data for stopNode StopNode stopNode = new StopNode(sqlRep, sqlRep.GetElementByID(newElement.ElementID)); stopNode.saveTreeToEATaggedValue(true); } else if (newElement.Stereotype == SDMModelingMain.StartNodeStereotype) { //save initial data for startNode StartNode startNode = new StartNode(sqlRep, sqlRep.GetElementByID(newElement.ElementID)); startNode.saveTreeToEATaggedValue(false); } else if (newElement.Stereotype == SDMModelingMain.CSPInstanceStereotype) { EA.DiagramObject instanceObject = EAUtil.findDiagramObject(sqlRep, newElement, sqlRep.GetCurrentDiagram()); instanceObject.right = instanceObject.left + 225; instanceObject.bottom = instanceObject.top - 125; instanceObject.Update(); SDMCSPDialog sdmCspDialog = new SDMCSPDialog(sqlRep.GetElementByID(newElement.ElementID), sqlRep); sdmCspDialog.ShowDialog(); } } return(true); }