Example #1
0
        private void btnOKClick(object sender, EventArgs e)
        {
            DialogClosed = true;
            Boolean valid = false;

            valid  = ovPropertiesControl.btnOK_Click();
            valid &= ovConstraintControl.handleCloseAction();
            if (valid)
            {
                forceClose = true;
                if (objectVariable.BindingState == BindingState.BOUND)
                {
                    objectVariable.BindingExpression = ovBindingProvider.getExpression();
                }
                else
                {
                    objectVariable.BindingExpression = null;
                }
                objectVariable.saveTreeToEATaggedValue(true);
                Close();

                objectVariable.loadTreeFromTaggedValue();
                objectVariable.saveTreeToEATaggedValue(true);
            }
        }
        private void createThisObject()
        {
            EA.DiagramObject activityDiagramObject = EAEcoreAddin.Util.EAUtil.findDiagramObject(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement(), currentSdmDiagram);
            SQLElement       sdmContainer          = repository.GetElementByID(activityTabsForm.ActivityNode.ActivityNodeEAElement.ParentID);
            SQLElement       containingEClass      = repository.GetElementByID(sdmContainer.ParentID);

            String b = "";
            String r = "";
            String l = "";
            String t = "";

            //compute the coordinates of the new diagramObject according to the StoryNode
            if (evacuated == Main.FalseValue)
            {
                b = "" + (activityDiagramObject.bottom + 20);
                r = "" + (activityDiagramObject.left + 110);
                l = "" + (activityDiagramObject.left + 20);
                t = "" + (activityDiagramObject.bottom + 70);
            }
            //compute the coordinates of the new diagramObject with static values
            else if (evacuated == Main.TrueValue)
            {
                b = "" + 60;
                r = "" + 100;
                l = "" + 10;
                t = "" + 10;
            }
            //create a new EA.Element which represents our new this ObjectVariable
            EA.Element obj = (EA.Element)activityTabsForm.ActivityNode.ActivityNodeEAElement.getRealElement().Elements.AddNew("this", Main.EAObjectType);
            obj.Name         = "this";
            obj.ParentID     = activityTabsForm.ActivityNode.ActivityNodeEAElement.ElementID;
            obj.ClassifierID = containingEClass.ElementID;
            obj.Update();

            //set the default values for the xml representation of the objectVariable
            ObjectVariable objectVariable = new ObjectVariable(repository.GetElementByID(obj.ElementID), repository);

            objectVariable.BindingState     = BindingState.BOUND;
            objectVariable.BindingSemantics = BindingSemantics.MANDATORY;
            objectVariable.BindingOperator  = BindingOperator.CHECK_ONLY;
            objectVariable.saveTreeToEATaggedValue(true);


            //create new diagramObject with the computed coordinates
            EA.DiagramObject diaObj = (EA.DiagramObject)currentSdmDiagram.DiagramObjects.AddNew("l=" + l + ";r=" + r + ";t=" + t + ";b=" + b, Main.EAObjectType);
            diaObj.ElementID = obj.ElementID;
            diaObj.Update();

            //this is required since EA 10.
            if (activityDiagramObject != null)
            {
                activityDiagramObject.Sequence = int.MaxValue;
                activityDiagramObject.Update();
            }
            repository.ReloadDiagram(currentSdmDiagram.DiagramID);
        }
Example #3
0
        private EA.Element createThisOv(EA.Element thisActivity)
        {
            EA.Element thisObject = thisActivity.Elements.AddNew("this", "Object") as EA.Element;
            thisObject.ClassifierID = this.oldSDMContainer.ParentID;
            thisObject.Update();
            ObjectVariable ov = new ObjectVariable(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository);

            ov.BindingState = BindingState.BOUND;
            ov.saveTreeToEATaggedValue(true);
            return(thisObject);
        }
Example #4
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BindingSemantics bindingSemantics = BindingSemantics.MANDATORY;
            BindingOperator  bindingOperator  = BindingOperator.CHECK_ONLY;

            if (radioButtonMandatory.Checked)
            {
                bindingSemantics = BindingSemantics.MANDATORY;
            }
            else if (radioButtonNegative.Checked)
            {
                bindingSemantics = BindingSemantics.NEGATIVE;
            }
            if (radioButtonDestroy.Checked)
            {
                bindingOperator = BindingOperator.DESTROY;
            }
            else if (radioButtonCreate.Checked)
            {
                bindingOperator = BindingOperator.CREATE;
            }
            else if (radioButtonCheckOnly.Checked)
            {
                bindingOperator = BindingOperator.CHECK_ONLY;
            }


            foreach (EA.Element selectedOv in this.selectedObjectVariables)
            {
                ObjectVariable currentOV = ObjectVariable.createCorrectOvType(repository.GetElementByID(selectedOv.ElementID), repository);
                currentOV.loadTreeFromTaggedValue();

                currentOV.BindingSemantics = bindingSemantics;
                currentOV.BindingOperator  = bindingOperator;

                if (bindingOperator == BindingOperator.CHECK_ONLY)
                {
                    TGGModelingUtil.assignmentsToConstraints(currentOV, repository);
                }
                else if (bindingOperator == BindingOperator.CREATE)
                {
                    TGGModelingUtil.constraintsToAssignments(currentOV, repository);
                }

                currentOV.saveTreeToEATaggedValue(true);
            }

            if (checkBoxLinksToo.Checked)
            {
                foreach (EA.Connector selectedLink in this.selectedLinkVariables)
                {
                    LinkVariable lv = null;
                    if (selectedLink.Stereotype == SDMModelingMain.LinkVariableStereotype)
                    {
                        lv = new LinkVariable(repository.GetConnectorByID(selectedLink.ConnectorID), repository);
                    }
                    else if (selectedLink.Stereotype == TGGModelingMain.TggLinkVariableStereotype)
                    {
                        lv = new TGGLinkVariable(repository.GetConnectorByID(selectedLink.ConnectorID), repository);
                    }

                    lv.loadTreeFromTaggedValue();
                    lv.BindingOperator  = bindingOperator;
                    lv.BindingSemantics = bindingSemantics;

                    lv.saveTreeToEATaggedValue(true);
                }
            }
            repository.ReloadDiagram(repository.GetCurrentDiagram().DiagramID);
            Close();
        }
Example #5
0
        private void createExtractedSDMStatementNode()
        {
            Boolean thisPatternCreated = false;

            int leftMax = 0;
            int topMax  = -100000;

            computeLeftAndTopMax(ref leftMax, ref topMax);


            EA.Element thisObject = searchThisObject();
            //only create a statementNode if there exists a this object on the sdm
            //otherwise create new story node with an this variable

            if (thisObject == null)
            {
                thisOvPattern = createStoryPattern("this Activity");

                thisObject = createThisOv(thisOvPattern);

                createDiagramObject(leftMax + 50, topMax - 20, 50, 100, thisObject);

                createDiagramObject(leftMax, topMax, 100, 200, thisOvPattern);

                thisPatternCreated = true;

                leftMax += 300;
            }

            //create new story node with objectvariable bound to new sdm.
            if (checkBoxBoundOv.Checked)
            {
                EA.Element boundOvPattern = createStoryPattern("Bound new SDM");
                EA.Element boundObject2   = createThisOv(boundOvPattern);
                SQLElement boundObject    = sqlRepository.GetElementByID(boundObject2.ElementID);


                createDiagramObject(leftMax + 20, topMax - 20, 50, 100, boundObject2);
                createDiagramObject(leftMax, topMax, 100, 200, boundOvPattern);

                ObjectVariable ov = new ObjectVariable(boundObject, sqlRepository);
                ov.loadTreeFromTaggedValue();

                ov.BindingState = BindingState.BOUND;

                MethodCallExpression mcExp = new MethodCallExpression(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository);

                ObjectVariableExpression ovExp = new ObjectVariableExpression(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository);
                mcExp.Target         = ovExp;
                ov.BindingExpression = mcExp;
                ov.Classifier        = ovClassifiersComboBox1.Classifiers[ovClassifiersComboBox1.SelectedIndex];

                ov.saveTreeToEATaggedValue(true);

                sdmCallPattern = boundOvPattern;

                EA.Method sdmMethod = repository.GetMethodByGuid(EAUtil.findTaggedValue(sqlRepository.GetElementByID(newSdmContainer.ElementID), SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value);
                sdmMethod.ClassifierID = "" + ov.Classifier.EaElement.ElementID;
                sdmMethod.ReturnType   = ov.Classifier.EaElement.Name;
                sdmMethod.Update();
            }
            //instead create statement node construct
            else
            {
                EA.Element           statementActivity = createStoryPattern("Call extracted method");
                StatementNode        statementNode     = new StatementNode(sqlRepository, sqlRepository.GetElementByID(statementActivity.ElementID));
                MethodCallExpression mcExp             = new MethodCallExpression(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository);

                ObjectVariableExpression ovExp = new ObjectVariableExpression(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository);
                mcExp.Target = ovExp;
                statementNode.StatementExpression = mcExp;
                statementActivity.Notes           = thisObject.Name + "." + newMethod.Name + "()";
                EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, statementActivity, "activityType", "call");
                EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, statementActivity, "evacuated", "false");
                statementActivity.Update();

                createDiagramObject(leftMax, topMax, 200, 200, statementActivity);
                statementNode.saveTreeToEATaggedValue(true);

                sdmCallPattern = statementActivity;
            }

            if (thisPatternCreated)
            {
                //create edge between this pattern and statement pattern
                EA.Connector acEdge = thisOvPattern.Connectors.AddNew("", Main.EAControlFlowType) as EA.Connector;
                acEdge.SupplierID = sdmCallPattern.ElementID;
                acEdge.Update();
                ActivityEdge edge = new ActivityEdge(sqlRepository, sqlRepository.GetConnectorByID(acEdge.ConnectorID));
                edge.saveTreeToEATaggedValue(true);
            }
        }