private void buttonModify_Click(object sender, EventArgs e)
        {
            if (listBoxConstraints.SelectedIndex != -1)
            {
                int selectedIndex = listBoxConstraints.SelectedIndex;


                CSPInstanceEntry currentEntry = constraintInstance.createdEntries[selectedIndex];

                currentEntry.constraintName = controller.getConstraints()[comboBoxConstraints.SelectedIndex].Name;
                currentEntry.typedInExpressions.Clear();
                foreach (Expression typedExpression in CSPConstraintDataGridView1.getTypedExpressions())
                {
                    currentEntry.typedInExpressions.Add(typedExpression);
                }

                if (constraintInstance.createdEntries.Count <= selectedIndex)
                {
                    constraintInstance.createdEntries.Insert(selectedIndex, currentEntry);
                }

                constraintInstance.createdEntries[selectedIndex] = currentEntry;

                listBoxConstraints.Items.RemoveAt(selectedIndex);
                listBoxConstraints.Items.Insert(selectedIndex, computeConstraintString(currentEntry));
                listBoxConstraints.SelectedIndex = selectedIndex;
            }
        }
        private void listBoxConstraints_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxConstraints.SelectedIndex != -1)
            {
                if (constraintInstance.createdEntries.Count == listBoxConstraints.Items.Count)
                {
                    CSPInstanceEntry currentEntry = constraintInstance.createdEntries[listBoxConstraints.SelectedIndex];
                    int constraintIndex           = 0;
                    foreach (CSPConstraint constraint in controller.getConstraints())
                    {
                        if (constraint.Name == currentEntry.constraintName)
                        {
                            break;
                        }
                        constraintIndex++;
                    }

                    if (comboBoxConstraints.Items.Count > constraintIndex)
                    {
                        this.comboBoxConstraints.SelectedIndex = constraintIndex;
                        int i = 0;
                        CSPConstraintDataGridView1.resetTypedExpressions();
                        foreach (Expression currentExpression in currentEntry.typedInExpressions)
                        {
                            CSPConstraintDataGridView1.addTypedExpression(currentExpression);
                            CSPConstraintDataGridView1.setCellValue(currentExpression.ToString(), i);
                            i++;
                        }
                    }
                }
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (!this.CSPConstraintDataGridView1.getTypedInValues().Contains(""))
            {
                CSPInstanceEntry currentEntry = new CSPInstanceEntry(repository);
                foreach (Expression expr in CSPConstraintDataGridView1.getTypedExpressions())
                {
                    currentEntry.typedInExpressions.Add(expr);
                }

                currentEntry.constraintName = controller.getConstraints()[comboBoxConstraints.SelectedIndex].Name;
                constraintInstance.createdEntries.Add(currentEntry);

                this.listBoxConstraints.Items.Add(computeConstraintString(currentEntry));
                listBoxConstraints.SelectedIndex = listBoxConstraints.Items.Count - 1;
            }
        }
        private String computeConstraintString(CSPInstanceEntry currentEntry)
        {
            if (currentEntry != null)
            {
                return(currentEntry.ToString());
            }


            String constraintString = comboBoxConstraints.Text + "(";

            foreach (String typedInValue in this.CSPConstraintDataGridView1.getTypedInValues())
            {
                constraintString += typedInValue + ",";
            }
            constraintString = constraintString.Remove(constraintString.Length - 1, 1);
            constraintString = constraintString + ")";
            return(constraintString);
        }