private void embedStoryPattern()
        {
            EA.Diagram evacuateDiagram = currentSdmDiagram;
            EA.Diagram embedDiagram    = null;
            activityTabsForm.ActivityNode.ActivityNodeEAElement.Diagrams.Refresh();
            SQLElement sdmContainer = repository.GetElementByID(activityTabsForm.ActivityNode.ActivityNodeEAElement.ParentID);

            repository.SaveDiagram(currentSdmDiagram.DiagramID);
            EA.DiagramObject activityDiagObj = null;
            foreach (SQLDiagram diagrams in sdmContainer.Diagrams)
            {
                if (activityDiagObj == null)
                {
                    activityDiagObj = EAUtil.findDiagramObject(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement(), diagrams.getRealDiagram());

                    embedDiagram = EAUtil.sqlEAObjectToOriginalObject(repository, diagrams) as EA.Diagram;
                }
            }
            try
            {
                int i = 30;
                foreach (SQLElement element in activityTabsForm.ActivityNode.ActivityNodeEAElement.Elements)
                {
                    if (element.Stereotype == SDMModelingMain.ObjectVariableStereotype)
                    {
                        EAUtil.deleteDiagramObject(repository.GetOriginalRepository(), evacuateDiagram, element.getRealElement());
                        int l = activityDiagObj.left + i;
                        int r = l + 90;
                        int t = activityDiagObj.top - i;
                        int b = t - 50;
                        EA.DiagramObject elementDiagObj = (EA.DiagramObject)embedDiagram.DiagramObjects.AddNew(

                            "l=" + l +
                            ";r=" + r +
                            ";t=" + t +
                            ";b=" + b, element.Type);

                        i += 60;
                        elementDiagObj.ElementID = element.ElementID;
                        elementDiagObj.Sequence  = activityDiagObj.Sequence + 1;
                        elementDiagObj.Update();
                    }
                }

                activityDiagObj.Sequence = int.MaxValue;
                activityDiagObj.Update();

                repository.ReloadDiagram(embedDiagram.DiagramID);

                EAEcoreAddin.Util.EAUtil.setTaggedValue(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, "false");
                buttonEvacuate.Text = "Extract Story Pattern";
                repository.OpenDiagram(embedDiagram.DiagramID);
                this.ParentForm.Close();
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("The associated Activity is not on any diagrams");
            }
        }
예제 #2
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);
                }
            }
        }
예제 #3
0
        /// <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);
        }