private void onTggOvDoubleClicked(SQLRepository sqlRepository, EA.Element doubleClickedElement)
        {
            TGGObjectVariable tggObjectVariable = new TGGObjectVariable(sqlRepository.GetElementByID(doubleClickedElement.ElementID), sqlRepository);

            this.ObjectVariableDialog = new OvDialog(sqlRepository, tggObjectVariable);
            ObjectVariableDialog.ShowDialog();
        }
示例#2
0
 public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage)
 {
     if (i == 0)
     {
         ObjectVariable ov       = ObjectVariable.createCorrectOvType(eaElement, repository);
         OvDialog       ovDialog = new OvDialog(repository, ov);
         ovDialog.ShowDialog();
     }
 }
 public override void doRuleQuickFix(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository, int i, String errorMessage)
 {
     if (i == 0)
     {
         EA.Element realElement = eaElement.getRealElement();
         SQLElement classifier  = repository.GetElementByID(eaElement.ClassifierID);
         realElement.Name = classifier.Name.Substring(0, 1).ToLower() + classifier.Name.Substring(1, classifier.Name.Length - 1);
         realElement.Update();
     }
     else if (i == 1)
     {
         ObjectVariable ov       = ObjectVariable.createCorrectOvType(eaElement, repository);
         OvDialog       ovDialog = new OvDialog(repository, ov);
         ovDialog.ShowDialog();
     }
 }
        /// <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);
        }
        /// <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 bool EA_OnPostNewElement(SQLRepository sqlRepository, EA.Element newElement, EA.Diagram currentDiagram)
        {
            EA.Repository repository = sqlRepository.GetOriginalRepository();

            try
            {
                //a correspondence is created as an instance of CorrespondenceType
                //Therefore its stereotype is at first time "CorrespondenceType"
                //but we want to change it to "Correspondence"

                if (TGGModelingMain.TggRuleDiagramMetatype.Contains(currentDiagram.MetaType))
                {
                    sqlRepository.SuppressEADialogs = true;

                    if (newElement.Type == Main.EAObjectType)
                    {
                        TGGObjectVariable tggOv = null;

                        //drag & drop is used
                        if (newElement.ClassifierID != 0)
                        {
                            SQLElement classifier = sqlRepository.GetElementByID(newElement.ClassifierID);
                            if (classifier.Stereotype == ECOREModelingMain.EClassStereotype)
                            {
                                tggOv                     = new TGGObjectVariable(sqlRepository.GetElementByID(newElement.ElementID), sqlRepository);
                                tggOv.Name                = classifier.Name.ToLower().Substring(0, 1) + classifier.Name.Substring(1, classifier.Name.Length - 1);
                                tggOv.BindingOperator     = BindingOperator.CREATE;
                                this.ObjectVariableDialog = new OvDialog(sqlRepository, tggOv);
                                ObjectVariableDialog.ShowDialog();
                            }
                            else if (classifier.Stereotype == TGGModelingMain.TggCorrespondenceTypeStereotype)
                            {
                                tggOv                     = new TGGCorrespondence(sqlRepository.GetElementByID(newElement.ElementID), sqlRepository);
                                tggOv.Name                = classifier.Name.ToLower().Substring(0, 1) + classifier.Name.Substring(1, classifier.Name.Length - 1);
                                tggOv.BindingOperator     = BindingOperator.CREATE;
                                this.ObjectVariableDialog = new OvDialog(sqlRepository, tggOv);
                                ObjectVariableDialog.ShowDialog();
                            }
                        }
                        else
                        {
                            //toolbox is used
                            if (newElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype)
                            {
                                tggOv = new TGGObjectVariable(sqlRepository.GetElementByID(newElement.ElementID), sqlRepository);
                                this.ObjectVariableDialog = new OvDialog(sqlRepository, tggOv);
                                ObjectVariableDialog.ShowDialog();
                            }
                            else if (newElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
                            {
                                tggOv = new TGGCorrespondence(sqlRepository.GetElementByID(newElement.ElementID), sqlRepository);
                                this.ObjectVariableDialog = new OvDialog(sqlRepository, tggOv);
                                this.ObjectVariableDialog.ShowDialog();
                            }
                            else if (newElement.Stereotype == SDMModelingMain.CSPInstanceStereotype)
                            {
                                TGG tggPackage = new TGG(sqlRepository, EAUtil.getOutermostPackage(newElement, sqlRepository));
                                tggPackage.loadTreeFromTaggedValue();

                                CSPInstanceDialog cspInstanceDialog = new CSPInstanceDialog(sqlRepository, sqlRepository.GetElementByID(newElement.ElementID), new TGGCSPController(tggPackage));
                                cspInstanceDialog.ShowDialog();
                            }
                        }
                    }
                }
                else if (TGGModelingMain.TggRulesDiagramMetatype.Contains(currentDiagram.MetaType))
                {
                    sqlRepository.SuppressEADialogs = true;
                    if (newElement.Type == Main.EAClassType && (newElement.Stereotype == TGGModelingMain.TggRuleStereotype))
                    {
                        newElement = EAUtil.sqlEAObjectToOriginalObject(sqlRepository, newElement) as EA.Element;

                        EA.Diagram ruleDiagram = newElement.Diagrams.AddNew(newElement.Name, TGGModelingMain.TggRuleDiagramMetatype[0]) as EA.Diagram;
                        ruleDiagram.Update();

                        EA_OnNotifyContextItemModified(sqlRepository.GetOriginalRepository(), newElement.ElementGUID, EA.ObjectType.otElement);
                    }
                }
                else if (TGGModelingMain.TggPatternsDiagramMetatype.Contains(currentDiagram.MetaType))
                {
                    sqlRepository.SuppressEADialogs = true;
                }
            }
            catch
            {
            }
            return(true);
        }