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");
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 3
0
 private void copyDiagramObjects(int leftMax, int topMax, EA.Diagram newSdmDiagram, EA.Element selectedElement)
 {
     //copy storypattern diagramObjects
     foreach (EA.Element ov in selectedElement.Elements)
     {
         EA.DiagramObject oldOVDiagramObject = getDiagramObject(ov.ElementID);
         if (oldOVDiagramObject != null)
         {
             copyDiagramObject(leftMax, topMax, newSdmDiagram, oldOVDiagramObject, ov, 1);
             EAUtil.deleteDiagramObject(repository, oldSDMDiagram, ov);
         }
     }
 }
Ejemplo n.º 4
0
        private void appendNewMethodAndSdm()
        {
            repository.SaveDiagram(oldSDMDiagram.DiagramID);


            EA.Element eClass = getContainingClass();
            this.newMethod = eClass.Methods.AddNew(textBoxNewSDM.Text, "void") as EA.Method;
            newMethod.Update();

            SDMModelingMain.createStoryDiagram(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository.GetOriginalRepository(), oldSDMDiagram);
            newSdmContainer = sqlRepository.GetOriginalRepository().GetElementByID(sqlRepository.GetCurrentDiagram().ParentID);
            EA.Diagram newSdmDiagram = newSdmContainer.Diagrams.GetAt(0) as EA.Diagram;
            EA.Element newStartNode  = findNewStartNode(newSdmContainer);
            createExtractedSDMStatementNode();

            int leftMax = 10000000;
            int topMax  = -100000;

            computeLeftAndTopMin(ref leftMax, ref topMax);

            //copy elements
            foreach (EA.Element selectedElement in this.selectedActivityNodes)
            {
                selectedElement.ParentID = newSdmContainer.ElementID;
                EA.DiagramObject newPatternDiagramObject = null;
                copyDiagramObjects(leftMax - 100, topMax + 100, newSdmDiagram, selectedElement);
                EA.DiagramObject selectedDiagramObject = getDiagramObject(selectedElement.ElementID);
                if (selectedDiagramObject != null)
                {
                    newPatternDiagramObject = copyDiagramObject(leftMax - 100, topMax + 100, newSdmDiagram, selectedDiagramObject, selectedElement, 2);
                    EAUtil.deleteDiagramObject(repository, oldSDMDiagram, selectedElement);
                }

                //deleteUnselectedConnectors(selectedElement);
                selectedElement.Update();

                arrangeUnselectedConnectors(newSdmContainer, newSdmDiagram, newStartNode, selectedElement, newPatternDiagramObject.bottom, newPatternDiagramObject.left);
            }



            repository.ReloadDiagram(newSdmDiagram.DiagramID);
            repository.ReloadDiagram(oldSDMDiagram.DiagramID);
            repository.OpenDiagram(oldSDMDiagram.DiagramID);
        }
        private void extractStoryPattern()
        {
            Dictionary <EA.DiagramObject, EA.Element> diagramObjectsToElement = new Dictionary <EA.DiagramObject, EA.Element>();

            EA.Diagram newDiagram = null;
            //create new diagram if necessary
            if (activityTabsForm.ActivityNode.ActivityNodeEAElement.Diagrams.Count == 0)
            {
                newDiagram = (EA.Diagram)activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement().Diagrams.AddNew(activityTabsForm.ActivityNode.ActivityNodeEAElement.Name, SDMModelingMain.SdmDiagramMetatype[0]);
            }
            //or choose already existing diagram
            else
            {
                newDiagram      = (activityTabsForm.ActivityNode.ActivityNodeEAElement.Diagrams.GetAt(0) as SQLDiagram).getRealDiagram();
                newDiagram.Name = activityTabsForm.ActivityNode.ActivityNodeEAElement.Name;
                newDiagram.Update();
            }
            newDiagram.ParentID = activityTabsForm.ActivityNode.ActivityNodeEAElement.ElementID;
            repository.SaveDiagram(newDiagram.DiagramID);
            newDiagram.Update();

            int leftMin = int.MaxValue;
            int topMax  = int.MinValue;

            //compute the minimal left value and the maximal top value of all object variables contained by current StoryNode
            foreach (SQLElement actElement in activityTabsForm.ActivityNode.ActivityNodeEAElement.Elements)
            {
                EA.DiagramObject actDiagObj = EAEcoreAddin.Util.EAUtil.findDiagramObject(repository, actElement.getRealElement(), currentSdmDiagram);
                if (actDiagObj != null)
                {
                    if (leftMin > actDiagObj.left)
                    {
                        leftMin = actDiagObj.left;
                    }
                    if (topMax < actDiagObj.top)
                    {
                        topMax = actDiagObj.top;
                    }
                    diagramObjectsToElement.Add(actDiagObj, actElement.getRealElement());
                }
            }
            //compute the difference for the new diagram objects so they are pinned on the left top corner
            int differenceLeftRight = leftMin - 40;

            if (differenceLeftRight < 0)
            {
                differenceLeftRight = 40;
            }
            int differenceTopBottom = topMax + 40;

            if (differenceTopBottom > 0)
            {
                differenceTopBottom = -40;
            }

            //delete all old diagramobjects and create new ones on the extracted diagram-
            foreach (EA.DiagramObject oldDiagramObject in diagramObjectsToElement.Keys)
            {
                EA.Element element = diagramObjectsToElement[oldDiagramObject];
                EAUtil.deleteDiagramObject(repository.GetOriginalRepository(), currentSdmDiagram, element);

                EA.DiagramObject newDiaObj = (EA.DiagramObject)newDiagram.DiagramObjects.AddNew("", element.Type);
                newDiaObj.left      = oldDiagramObject.left - differenceLeftRight;
                newDiaObj.right     = oldDiagramObject.right - differenceLeftRight;
                newDiaObj.top       = oldDiagramObject.top - differenceTopBottom;
                newDiaObj.bottom    = oldDiagramObject.bottom - differenceTopBottom;
                newDiaObj.ElementID = element.ElementID;
                newDiaObj.Update();
            }

            activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement().Update();
            repository.SaveDiagram(currentSdmDiagram.DiagramID);
            repository.ReloadDiagram(currentSdmDiagram.DiagramID);
            repository.ReloadDiagram(newDiagram.DiagramID);
            buttonEvacuate.Text = "Embed Story Pattern";

            Navigator.addAnchorEntry(newDiagram.DiagramID, currentSdmDiagram.DiagramID);

            repository.OpenDiagram(newDiagram.DiagramID);

            SDMModelingMain.setAnchorElementTags(repository, currentSdmDiagram, activityTabsForm.ActivityNode.ActivityNodeEAElement);

            this.ParentForm.Close();
            EAEcoreAddin.Util.EAUtil.setTaggedValue(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement(), Main.MoflonExtractedStoryPatternTaggedValueName, "true");
        }