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);
        }
Exemple #2
0
        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();
                            }
                        }
                    }
                }
            }
        }