private void buttonToggleMceVis_Click(object sender, EventArgs e) { checkFunctions(); if (activateSDMVerboseButton) { EA.Diagram currentDiagram = repository.GetCurrentDiagram(); if (currentDiagram.Notes.Contains("Moflon::MceVisualization=true")) { SDMUtil.setAllMceVisTags(false, repository, currentDiagram); currentDiagram.Notes = currentDiagram.Notes.Replace("Moflon::MceVisualization=true", "Moflon::MceVisualization=false"); } else if (currentDiagram.Notes.Contains("Moflon::MceVisualization=false")) { SDMUtil.setAllMceVisTags(true, repository, currentDiagram); currentDiagram.Notes = currentDiagram.Notes.Replace("Moflon::MceVisualization=false", "Moflon::MceVisualization=true"); } else { SDMUtil.setAllMceVisTags(false, repository, currentDiagram); currentDiagram.Notes = currentDiagram.Notes += "Moflon::MceVisualization=false"; } currentDiagram.Update(); repository.ReloadDiagram(currentDiagram.DiagramID); } else { MessageBox.Show("To use this function open a SDM Diagram"); } }
public override void expressionFromXmlElement(System.Xml.XmlElement parameterExpressionElement) { base.expressionFromXmlElement(parameterExpressionElement); XmlAttribute parameterAttribute = XmlUtil.getXMLAttributeWithName(parameterExpressionElement, "parameter"); XmlAttribute parameterGUIDAttribute = XmlUtil.getXMLAttributeWithName(parameterExpressionElement, "parameterGUID"); this.ParameterName = SDMUtil.extractNameFromURIString(parameterAttribute.InnerXml); this.ParameterGUID = parameterGUIDAttribute.InnerXml; }
internal void fillSDMDiagram(EA.Diagram diagram) { EA.Element parentElement = repository.GetElementByID(diagram.ParentID); if (parentElement.Stereotype == SDMModelingMain.SdmContainerStereotype) { SDMUtil.fillSDMActivityNodeDiagram(repository, diagram, parentElement); } else if (parentElement.Stereotype == SDMModelingMain.StoryNodeStereotype) { SDMUtil.fillAllStoryNodeDiagrams(sqlRep, diagram, parentElement); } }
public override void expressionFromXmlElement(XmlElement attributeValueExpressionElement) { XmlAttribute attributeAttr = XmlUtil.getXMLAttributeWithName(attributeValueExpressionElement, "attribute"); XmlAttribute ovAttr = XmlUtil.getXMLAttributeWithName(attributeValueExpressionElement, "object"); XmlAttribute ovNameAttr = XmlUtil.getXMLAttributeWithName(attributeValueExpressionElement, "objectName"); XmlAttribute attributeGuidAttr = XmlUtil.getXMLAttributeWithName(attributeValueExpressionElement, "attributeGUID"); this.AttributeName = SDMUtil.extractNameFromURIString(attributeAttr.InnerXml); this.ObjectVariableGUID = ovAttr.InnerXml; this.ObjectVariableName = ovNameAttr.InnerXml; this.AttributeGUID = getGuidOfAttributeByURIString(attributeAttr.InnerXml); }
private void addPossibleNamesToComboBox() { List <ObjectVariable> listOfOvs = new List <ObjectVariable>(); List <EParameter> listOfParameters = new List <EParameter>(); if (objectVariable is TGGObjectVariable) { TGGRule tggRule = objectVariable.StoryPattern as TGGRule; listOfOvs = SDMUtil.getTGGObjectVariablesInTggRule(tggRule, repository); } else if (objectVariable is ObjectVariable) { Activity activity = objectVariable.StoryPattern.ParentStoryNode.OwningActivity; listOfOvs = SDMUtil.getSDMObjectVariablesInActivity(activity, repository); try { foreach (EParameter eParameter in objectVariable.StoryPattern.ParentStoryNode.OwningActivity.OwningOperation.EParameters) { listOfParameters.Add(eParameter); } } catch { } } ObjectVariable ovToDelete = null; foreach (ObjectVariable ov in listOfOvs) { if (ov.Name == this.objectVariable.ObjectVariableEA.Name) { ovToDelete = ov; } } listOfOvs.Remove(ovToDelete); InternalList.AddRange(listOfOvs); InternalList.AddRange(listOfParameters); foreach (Object possibleObject in InternalList) { if (possibleObject is ObjectVariable) { this.Items.Add((possibleObject as ObjectVariable).Name); } else if (possibleObject is EParameter) { this.Items.Add((possibleObject as EParameter).Name); } } }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (SDMUtil.isActivityNodeMetatype(eaElement.Stereotype)) { SQLElement aNodeParent = repository.GetElementByID(eaElement.ParentID); if (aNodeParent.Stereotype != SDMModelingMain.SdmContainerStereotype) { results.Add("ActivityNode must be child of SDM Activity element"); } } return(results); }
private void buttonSDMVerbose_Click(object sender, EventArgs e) { EA.Diagram currentDiagram = repository.GetCurrentDiagram(); if (currentDiagram.Notes == "Moflon::Verbose=true") { SDMUtil.setAllVerboseTags(false, repository, currentDiagram); } else if (currentDiagram.Notes == "Moflon::Verbose=false") { SDMUtil.setAllVerboseTags(true, repository, currentDiagram); } else { SDMUtil.setAllVerboseTags(true, repository, currentDiagram); } }
public override void doRuleQuickFix(SQLConnector eaConnector, SQLRepository repository, int i, String errorMessage) { LinkVariable lv = new LinkVariable(eaConnector, repository); lv.loadTreeFromTaggedValue(); if (errorMessage == "The rolename(s) of the LinkVariable differs from the related EReference") { if (i == 0) { SQLConnector referencedReference = SDMUtil.getRelatedEReference(lv); if (referencedReference != null) { EA.Diagram currentDiagram = repository.GetCurrentDiagram(); lv.linkDialogueEntry.clientRoleName = referencedReference.ClientEnd.Role; lv.linkDialogueEntry.supplierRoleName = referencedReference.SupplierEnd.Role; lv.saveTreeToEATaggedValue(true); if (currentDiagram != null) { repository.SaveDiagram(currentDiagram.DiagramID); repository.ReloadDiagram(currentDiagram.DiagramID); } } } } else { if (i == 0) { if (eaConnector.Stereotype == SDMModelingMain.LinkVariableStereotype) { lv = new LinkVariable(eaConnector, repository); } else if (eaConnector.Stereotype == TGGModelingMain.TggLinkVariableStereotype) { lv = new TGGLinkVariable(eaConnector, repository); } LinkVariablePropertiesForm lvForm = new LinkVariablePropertiesForm(lv, repository, true); } } }
private void toggleDiagramVerboseStatus(EA.Diagram currentDiagram) { if (currentDiagram != null) { if (currentDiagram.Notes.Contains("Moflon::Verbose=true")) { SDMUtil.setAllVerboseTags(false, repository, currentDiagram); } else if (currentDiagram.Notes.Contains("Moflon::Verbose=false")) { SDMUtil.setAllVerboseTags(true, repository, currentDiagram); } else { SDMUtil.setAllVerboseTags(true, repository, currentDiagram); } } }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaElement.Stereotype == ECOREModelingMain.EClassStereotype) { EClass eclass = new EClass(eaElement, repository); eclass.loadTreeFromTaggedValue(); if (eclass.Name != eaElement.Name) { results.Add("EClass name is not equal to name of the saved EClass fragment"); } if (eclass.Guid != eaElement.ElementGUID) { results.Add("EClass GUID is not equal to saved fragment GUID"); } } else if (eaElement.Stereotype == SDMModelingMain.StartNodeStereotype || eaElement.Stereotype == SDMModelingMain.StopNodeStereotype || eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype || eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype) { ActivityNode aNode = SDMUtil.createCorrectActivityNode(repository, eaElement); if (aNode == null) { return(new List <string>()); } aNode.loadTreeFromTaggedValue(); if (aNode.EaGuid != eaElement.ElementGUID) { results.Add("ActivityNode GUID is not equal to saved fragment GUID"); } if (eaElement.Stereotype != SDMModelingMain.StopNodeStereotype && aNode.Name != eaElement.Name && eaElement.Stereotype != SDMModelingMain.StartNodeStereotype) { results.Add("ActivityNode name is not equal to name of the saved fragment"); } } return(results); }
public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage) { if (i == 0) { if (eaElement.Stereotype == ECOREModelingMain.EClassStereotype) { EClass eclass = new EClass(eaElement, repository); eclass.saveTreeToEATaggedValue(true); } else if (eaElement.Stereotype == SDMModelingMain.StartNodeStereotype || eaElement.Stereotype == SDMModelingMain.StopNodeStereotype || eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype || eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype) { ActivityNode aNode = SDMUtil.createCorrectActivityNode(repository, eaElement); aNode.loadTreeFromTaggedValue(); aNode.saveTreeToEATaggedValue(true); } } }
public override void doEaGuiStuff() { base.doEaGuiStuff(); EA.Element sdmContainer = ActivityNodeEAElement.getRealElement(); if (sdmContainer.Stereotype == SDMModelingMain.SdmContainerStereotype) { try { SQLMethod associatedMethod = Repository.GetMethodByGuid(EAUtil.findTaggedValue(ActivityNodeEAElement, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value); SQLElement containingEClass = Repository.GetElementByID(associatedMethod.ParentID); ActivityNodeEAElement.getRealElement().Name = SDMUtil.computeStartNodeName(associatedMethod, containingEClass); } catch (Exception) { } } sdmContainer.StereotypeEx = SDMModelingMain.StartNodeStereotype; sdmContainer.Update(); }
public override void doEaGuiStuff() { base.doEaGuiStuff(); //compute real ea object to perfom updates EA.Element realElement = sqlElement.getRealElement(); //taggedvalues for shapescript EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realElement, ObjectVariable.BindingSemanticsTaggedValueName, this.BindingSemantics.ToString().ToLower()); EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realElement, ObjectVariable.BindingOperatorTaggedValueName, this.BindingOperator.ToString().ToLower()); EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realElement, ObjectVariable.BindingStateTaggedValueName, this.BindingState.ToString().ToLower()); EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realElement, ObjectVariable.RunStateTaggedValueName, (Constraints.Count > 0 || AttributeAssignments.Count > 0).ToString()); if (NacIndex == -1) { EAUtil.deleteTaggedValue(realElement, NacIndexTaggedValueName); } else { EAUtil.setTaggedValue(Repository, realElement, NacIndexTaggedValueName, NacIndex.ToString()); } realElement.Name = this.Name; realElement.StereotypeEx = SDMModelingMain.ObjectVariableStereotype; if (this.Classifier != null) { realElement.ClassifierID = this.Classifier.EaElement.ElementID; } realElement.Notes = ""; String bindingExprText = SDMUtil.setOvMethodCallExpressionGui(this); EAEcoreAddin.Util.EAUtil.setTaggedValue(Repository, realElement, "bindingOutput", bindingExprText); autoSetDiagramObjectSize(bindingExprText); realElement.Update(); }
private void buttonToMethodCallExpression_Click(object sender, EventArgs e) { Object selectedSource = expressionProvider.getSelectedSecond(); if (selectedSource is SDMExpressionHelper.SecondObject) { SDMExpressionHelper.SecondObject secondObject = selectedSource as SDMExpressionHelper.SecondObject; if (secondObject.eaObject is SQLMethod) { SQLMethod selectedOperation = secondObject.eaObject as SQLMethod; if (selectedOperation != null) { SQLMethod method = repository.GetMethodByID(selectedOperation.MethodID); EA.Diagram currentDiagram = repository.GetCurrentDiagram(); int sdmDiagramId = SDMUtil.getSDMDiagramID(repository, method); if (sdmDiagramId != SDMUtil.UNKNOWN_SDM_DIAGRAM_ID) { Navigator.addAnchorEntry(sdmDiagramId, currentDiagram.DiagramID); repository.OpenDiagram(sdmDiagramId); this.ParentForm.Close(); } else { CreateSDMDialog.CreateSDMDialog createSdmDialog = new CreateSDMDialog.CreateSDMDialog(); if (createSdmDialog.ShowDialog() == DialogResult.OK) { SDMModelingMain.createStoryDiagram(method, repository.eaRepository, currentDiagram); this.ParentForm.Close(); } } } } } }
public override void deserializeFromMocaTree(Serialization.MocaTree.MocaNode actNode) { this.Constraints.Clear(); this.AttributeAssignments.Clear(); this.BindingSemantics = SDMUtil.computeBindingSemantics(actNode.getAttributeOrCreate(ObjectVariable.BindingSemanticsTaggedValueName).Value.ToUpper()); this.BindingOperator = SDMUtil.computeBindingOperator(actNode.getAttributeOrCreate(ObjectVariable.BindingOperatorTaggedValueName).Value.ToUpper()); if (actNode.getAttributeOrCreate(NacIndexTaggedValueName).Value != "") { NacIndex = int.Parse(actNode.getAttributeOrCreate(NacIndexTaggedValueName).Value); } this.BindingState = SDMUtil.computeBindingState(actNode.getAttributeOrCreate(ObjectVariable.BindingStateTaggedValueName).Value.ToUpper()); this.Guid = actNode.getAttributeOrCreate(Main.GuidStringName).Value; this.TypeGuid = actNode.getAttributeOrCreate("typeGuid").Value; MocaNode assignmentsNode = actNode.getChildNodeWithName("attributeAssignments"); MocaNode constraintsNode = actNode.getChildNodeWithName("constraints"); MocaNode bindingExpressionNode = actNode.getChildNodeWithName("bindingExpression"); if (bindingExpressionNode != null) { this.BindingExpression = Expression.createExpression(bindingExpressionNode.getAttributeOrCreate("type").Value, Repository); this.BindingExpression.deserializeFromMocaTree(bindingExpressionNode); } foreach (MocaNode constraints in constraintsNode.Children) { Constraint constraint = new Constraint(Repository); constraint.deserializeFromMocaTree(constraints); this.Constraints.Add(constraint); } foreach (MocaNode assignments in assignmentsNode.Children) { AttributeAssignment atAs = new AttributeAssignment(Repository); atAs.deserializeFromMocaTree(assignments); this.AttributeAssignments.Add(atAs); } }
private void buttonSDMVerbose_Click(object sender, EventArgs e) { checkFunctions(); if (activateSDMVerboseButton) { EA.Diagram currentDiagram = repository.GetCurrentDiagram(); if (currentDiagram.Notes.Contains("Moflon::Verbose=true")) { SDMUtil.setAllVerboseTags(false, repository, currentDiagram); } else if (currentDiagram.Notes.Contains("Moflon::Verbose=false")) { SDMUtil.setAllVerboseTags(true, repository, currentDiagram); } else { SDMUtil.setAllVerboseTags(true, repository, currentDiagram); } } else { MessageBox.Show("To use this function open a SDM Diagram"); } }
private void addPossibleNamesToComboBox() { List <ObjectVariable> listOfOvs = new List <ObjectVariable>(); List <MocaSerializableElement> existingNames = new List <MocaSerializableElement>(); if (objectVariable is TGGObjectVariable) { TGGRule tggRule = objectVariable.StoryPattern as TGGRule; listOfOvs = SDMUtil.getTGGObjectVariablesInTggRule(tggRule, repository); } else if (objectVariable is ObjectVariable) { Activity activity = objectVariable.StoryPattern.ParentStoryNode.OwningActivity; listOfOvs = SDMUtil.getSDMObjectVariablesInActivity(activity, repository); try { foreach (EParameter eParameter in objectVariable.StoryPattern.ParentStoryNode.OwningActivity.OwningOperation.EParameters) { if (eParameter.EaParameter.ClassifierID != "0" && eParameter.EaParameter.ClassifierID != "") { existingNames.Add(eParameter); } } } catch { } } foreach (ObjectVariable ov in listOfOvs) { existingNames.Add(ov); } existingNames.Sort(new SDMExportWrapperComparator()); foreach (Object possibleObject in existingNames) { if (possibleObject is MocaSerializableElement) { MocaSerializableElement entry = possibleObject as MocaSerializableElement; if (!this.Items.Contains(entry.Name)) { this.Items.Add((possibleObject as MocaSerializableElement).Name); InternalList.Add(possibleObject); } } } /* * * ObjectVariable ovToDelete = null; * foreach (ObjectVariable ov in listOfOvs) * { * if (ov.Name == this.objectVariable.ObjectVariableEA.Name) * ovToDelete = ov; * } * listOfOvs.Remove(ovToDelete); * InternalList.AddRange(listOfOvs); * InternalList.AddRange(listOfParameters); * * foreach (Object possibleObject in InternalList) * { * if (possibleObject is ObjectVariable) * { * this.Items.Add((possibleObject as ObjectVariable).Name); * } * else if (possibleObject is EParameter) * { * this.Items.Add((possibleObject as EParameter).Name); * } * } */ }
private void buttonJump_Click(object sender, EventArgs e) { EA.Diagram currentDiagram = repository.GetCurrentDiagram(); Boolean handled = false; if (currentDiagram != null && currentDiagram.SelectedObjects.Count == 1) { EA.DiagramObject selectedDiagramObject = currentDiagram.SelectedObjects.GetAt(0) as EA.DiagramObject; SQLElement selectedElement = repository.GetElementByID(selectedDiagramObject.ElementID); EA.Diagram calledDiagram = null; Expression callExpression = null; if (selectedElement.Stereotype == SDMModelingMain.StatementNodeStereotype) { StatementNode statementNode = new StatementNode(repository, selectedElement); statementNode.loadTreeFromTaggedValue(); callExpression = statementNode.StatementExpression; } else if (selectedElement.Stereotype == SDMModelingMain.ObjectVariableStereotype) { ObjectVariable ov = new ObjectVariable(selectedElement, repository); ov.loadTreeFromTaggedValue(); callExpression = ov.BindingExpression; } else if (selectedElement.Stereotype == SDMModelingMain.StopNodeStereotype) { StopNode stopNode = new StopNode(repository, selectedElement); stopNode.loadTreeFromTaggedValue(); callExpression = stopNode.ReturnValue; } if (callExpression is MethodCallExpression) { MethodCallExpression mcE = callExpression as MethodCallExpression; SQLMethod calledMethod = repository.GetMethodByGuid(mcE.MethodGuid); if (calledMethod != null) { int sdmDiagramId = SDMUtil.getSDMDiagramID(repository, calledMethod); if (sdmDiagramId != SDMUtil.UNKNOWN_SDM_DIAGRAM_ID) { calledDiagram = repository.GetOriginalRepository().GetDiagramByID(sdmDiagramId); } } } if (calledDiagram != null) { Navigator.addAnchorEntry(calledDiagram.DiagramID, currentDiagram.DiagramID); repository.OpenDiagram(calledDiagram.DiagramID); handled = true; } } if (!handled) { if (currentDiagram != null) { Navigator.jumpToAnchorSuccessor(repository.GetOriginalRepository(), currentDiagram.DiagramID); } } }
public override List <String> doRule(SQLConnector eaConnector, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (eaConnector.Stereotype == SDMModelingMain.LinkVariableStereotype || eaConnector.Stereotype == TGGModelingMain.TggLinkVariableStereotype) { LinkVariable lv = new LinkVariable(eaConnector, repository); lv.loadTreeFromTaggedValue(); SQLConnector referencedReference = SDMUtil.getRelatedEReference(lv); //try to get the related EReference //related EReference cant be found if (referencedReference == null) { results.Add("There is no related EReference"); } //rolename of linkVariable not existing in the referenced EReference if (eaConnector.SupplierEnd.Role != "" && referencedReference != null) { if (!((eaConnector.SupplierEnd.Role == referencedReference.ClientEnd.Role || eaConnector.SupplierEnd.Role == referencedReference.SupplierEnd.Role) && (eaConnector.ClientEnd.Role == referencedReference.ClientEnd.Role || eaConnector.ClientEnd.Role == referencedReference.SupplierEnd.Role))) { results.Add("The rolename(s) of the LinkVariable differs from the related EReference"); } } //for unidirectional EReferences the supplierEnd.Role of the linkvariable must be the "value" rolename if (eaConnector.ClientEnd.Role != "" && eaConnector.SupplierEnd.Role == "") { results.Add("The rolename(s) of the LinkVariable differs from the related EReference"); } //checks if the related reference is connecting the correct EClasses if (referencedReference != null) { try { SQLElement lvSource = repository.GetElementByID(eaConnector.ClientID); SQLElement lvTarget = repository.GetElementByID(eaConnector.SupplierID); SQLElement sourceClassifier = EAUtil.getClassifierElement(repository, lvSource.ClassifierID); SQLElement targetClassifier = EAUtil.getClassifierElement(repository, lvTarget.ClassifierID); SQLElement refRefClient = repository.GetElementByID(referencedReference.ClientID); SQLElement refRefSupplier = repository.GetElementByID(referencedReference.SupplierID); if (sourceClassifier != null && targetClassifier != null) { List <SQLElement> sourceBases = EAUtil.getBaseClasses(sourceClassifier); List <SQLElement> targetBases = EAUtil.getBaseClasses(targetClassifier); Boolean valid = false; foreach (SQLElement sourceBase in sourceBases) { foreach (SQLElement targetBase in targetBases) { if (((referencedReference.ClientID == sourceBase.ElementID || referencedReference.ClientID == targetBase.ElementID) && (referencedReference.SupplierID == sourceBase.ElementID || referencedReference.SupplierID == targetBase.ElementID))) { valid = true; } } } //maybe there is a direct connectio to EObject if (!valid) { if (refRefClient.Name == "EObject" && (eaConnector.SupplierEnd.Role == referencedReference.SupplierEnd.Role || eaConnector.SupplierEnd.Role == referencedReference.ClientEnd.Role) || refRefSupplier.Name == "EObject" && (eaConnector.SupplierEnd.Role == referencedReference.SupplierEnd.Role || eaConnector.SupplierEnd.Role == referencedReference.ClientEnd.Role)) { valid = true; } } if (!valid) { results.Add("The related EReference doesn't connect EClasses from the same type hiearchy as the LinkVariable"); } } } catch { results.Add("Error during computing of related EReference. Please update your LinkVariable manually"); } } } return(results); }