Esempio n. 1
0
        public void bttEdit_Click(object sender, EventArgs e)
        {
            int    selectedIndex = listboxEntries.SelectedIndex;
            String assignmentConstraintString = "";

            if (selectedIndex != -1)
            {
                //attributeAssignment
                if (radioSet.Checked && cmbAttributes.Text != "")
                {
                    SQLAttribute        leftAttribute   = this.leftAttributes[cmbAttributes.SelectedIndex] as SQLAttribute;
                    AttributeAssignment attAssignment   = new AttributeAssignment(repository, objectVariable, leftAttribute);
                    Expression          rightExpression = ConstraintExpressionProvider.getExpression();
                    if (rightExpression != null)
                    {
                        attAssignment.ValueExpression = rightExpression;
                        this.assignmentsAndConstraints.RemoveAt(selectedIndex);
                        this.assignmentsAndConstraints.Insert(selectedIndex, attAssignment);
                        assignmentConstraintString = attAssignment.ToString();
                    }
                }


                //constraint
                else if (!radioSet.Checked && cmbAttributes.Text != "")
                {
                    SQLAttribute leftAttribute = this.leftAttributes[cmbAttributes.SelectedIndex];
                    EAEcoreAddin.Modeling.SDMModeling.SDMExportWrapper.patterns.Constraint constraint = new EAEcoreAddin.Modeling.SDMModeling.SDMExportWrapper.patterns.Constraint(repository);

                    ComparisonExpression compExp           = new ComparisonExpression(repository);
                    ComparingOperator    comparingOperator = ComparingOperator.EQUAL;
                    if (radioEqual.Checked)
                    {
                        comparingOperator = ComparingOperator.EQUAL;
                    }
                    else if (radioGreater.Checked)
                    {
                        comparingOperator = ComparingOperator.GREATER;
                    }
                    else if (radioLess.Checked)
                    {
                        comparingOperator = ComparingOperator.LESS;
                    }
                    else if (radioLessEqual.Checked)
                    {
                        comparingOperator = ComparingOperator.LESS_OR_EQUAL;
                    }
                    else if (radioNotEqual.Checked)
                    {
                        comparingOperator = ComparingOperator.UNEQUAL;
                    }
                    else if (radioGreaterEqual.Checked)
                    {
                        comparingOperator = ComparingOperator.GREATER_OR_EQUAL;
                    }
                    compExp.Operator       = comparingOperator;
                    compExp.LeftExpression = new AttributeValueExpression(repository, leftAttribute, objectVariable.sqlElement);
                    Expression rightExpression = ConstraintExpressionProvider.getExpression();
                    if (rightExpression != null)
                    {
                        compExp.RightExpression         = rightExpression;
                        constraint.ConstraintExpression = compExp;
                        this.assignmentsAndConstraints.RemoveAt(selectedIndex);
                        this.assignmentsAndConstraints.Insert(selectedIndex, constraint);
                        assignmentConstraintString = constraint.ToString();
                    }
                }
                internalAssignmentConstraintListToOVLists();
                addAssignmentsAndConstraintsToListboxNew();

                listboxEntries.SelectedItem = assignmentConstraintString;
            }
            this.expressionControl.setInformationLossPossible(false);
        }
Esempio n. 2
0
        private void bttAdd_Click(object sender, EventArgs e)
        {
            String assignmentConstraintString = "";

            //attributeAssignment
            if (radioSet.Checked && cmbAttributes.Text != "")
            {
                SQLAttribute        leftAttribute   = this.leftAttributes[cmbAttributes.SelectedIndex] as SQLAttribute;
                AttributeAssignment attAssignment   = new AttributeAssignment(repository, this.objectVariable, leftAttribute);
                Expression          rightExpression = ConstraintExpressionProvider.getExpression();
                if (rightExpression != null)
                {
                    attAssignment.ValueExpression = rightExpression;
                    this.objectVariable.AttributeAssignments.Add(attAssignment);
                    String assignmentString = attAssignment.ToString();
                    listboxEntries.Items.Add(assignmentString);

                    assignmentConstraintString = assignmentString;
                }
            }

            //constraint
            else if (!radioSet.Checked && cmbAttributes.Text != "")
            {
                SQLAttribute leftAttribute = this.leftAttributes[cmbAttributes.SelectedIndex];
                EAEcoreAddin.Modeling.SDMModeling.SDMExportWrapper.patterns.Constraint constraint = new EAEcoreAddin.Modeling.SDMModeling.SDMExportWrapper.patterns.Constraint(repository);

                ComparisonExpression compExp           = new ComparisonExpression(repository);
                ComparingOperator    comparingOperator = ComparingOperator.EQUAL;
                if (radioEqual.Checked)
                {
                    comparingOperator = ComparingOperator.EQUAL;
                }
                else if (radioGreater.Checked)
                {
                    comparingOperator = ComparingOperator.GREATER;
                }
                else if (radioLess.Checked)
                {
                    comparingOperator = ComparingOperator.LESS;
                }
                else if (radioLessEqual.Checked)
                {
                    comparingOperator = ComparingOperator.LESS_OR_EQUAL;
                }
                else if (radioNotEqual.Checked)
                {
                    comparingOperator = ComparingOperator.UNEQUAL;
                }
                else if (radioGreaterEqual.Checked)
                {
                    comparingOperator = ComparingOperator.GREATER_OR_EQUAL;
                }
                compExp.Operator = comparingOperator;

                compExp.LeftExpression = new AttributeValueExpression(repository, leftAttribute, objectVariable.sqlElement);
                Expression rightExpression = ConstraintExpressionProvider.getExpression();
                if (rightExpression != null)
                {
                    compExp.RightExpression         = rightExpression;
                    constraint.ConstraintExpression = compExp;
                    this.objectVariable.Constraints.Add(constraint);
                    String constraintString = constraint.ToString();
                    listboxEntries.Items.Add(constraintString);

                    assignmentConstraintString = constraintString;
                }
            }
            addAssignmentsAndConstraintsToListboxNew();

            if (assignmentConstraintString != "")
            {
                listboxEntries.SelectedItem = assignmentConstraintString;
                //listBoxSelectedIndexChangedNew(null, null);
            }
            this.expressionControl.setInformationLossPossible(false);
        }