Exemplo n.º 1
0
        private void loadCSPConstraints(MocaNode actNode)
        {
            MocaNode constraintsNode = actNode.getChildNodeWithName(ConstraintsChildNodeName);

            if (constraintsNode != null)
            {
                Constraints.Clear();
                foreach (MocaNode constraintNode in actNode.getChildNodeWithName(ConstraintsChildNodeName).Children)
                {
                    if (constraintNode.Name == DeclarationsChildNodeName)
                    {
                        foreach (MocaNode constraintNodeReal in constraintNode.Children)
                        {
                            CSPConstraint newConstr = new CSPConstraint();
                            newConstr.deserializeFromMocaTree(constraintNodeReal);
                            this.Constraints.Add(newConstr);
                        }
                    }
                    else if (constraintNode.Name == ConstraintInstancesChildNodeName)
                    {
                    }
                    else
                    {
                        CSPConstraint newConstr = new CSPConstraint();
                        newConstr.deserializeFromMocaTree(constraintNode);
                        this.Constraints.Add(newConstr);
                    }
                }
            }
            CSPUtil.addDefaultConstraints(Constraints);
            this.Constraints.Sort(new CSPConstraintComparer());
            CSPUtil.recomputeConstraintIndizes(Constraints);
        }
Exemplo n.º 2
0
        private void buttonImportCSP_Click(object sender, EventArgs e)
        {
            checkForFunctions();
            if (activateExportImportCSPButton)
            {
                String pathToWrite = Path.GetDirectoryName(repository.ConnectionString);

                OpenFileDialog dialog = new OpenFileDialog();
                dialog.AddExtension     = true;
                dialog.DefaultExt       = "txt";
                dialog.InitialDirectory = pathToWrite;
                dialog.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                dialog.FileName         = "csptemp.txt";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    TGG tggPackage = new TGG(repository, repository.GetTreeSelectedPackage());
                    tggPackage.loadTreeFromTaggedValue();

                    String   fileContent = File.ReadAllText(dialog.FileName);
                    MocaNode dummyParent = MocaTreeUtil.mocaNodeFromXmlString(fileContent);
                    foreach (MocaNode cspNode in dummyParent.Children)
                    {
                        CSPConstraint constraint = new CSPConstraint();
                        constraint.deserializeFromMocaTree(cspNode);
                        Boolean alreadyIn = false;
                        foreach (CSPConstraint existingCSP in tggPackage.Constraints)
                        {
                            if (existingCSP.Name == constraint.Name)
                            {
                                alreadyIn = true;
                                break;
                            }
                        }

                        if (!alreadyIn)
                        {
                            tggPackage.Constraints.Add(constraint);
                        }
                    }

                    tggPackage.saveTreeToEATaggedValue(false);
                }
            }
        }