Esempio n. 1
0
        public override void Execute(object parameter)
        {
            if (Current.ActiveDiagram != null && Current.ActiveDiagram.Schema is PSMSchema)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter           = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Multiselect      = false;

                String fileToCheck = null;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    fileToCheck = openFileDialog.FileName;

                    PushDownAutomat  pda = new PushDownAutomat();
                    ValidationResult validationResult = null;
                    try
                    {
                        pda.inicialize((PSMSchema)Current.ActiveDiagram.Schema, fileToCheck);
                    }
                    catch (System.Xml.XmlException e)
                    {
                        validationResult = new ValidationResult(false, e.Message);
                    }
                    if (validationResult == null)
                    {
                        validationResult = pda.processTree();
                    }
                    ExolutioMessageBox.Show("Validation", "Validation Result", validationResult.Message);
                }
            }
        }
Esempio n. 2
0
        public override void Execute(object parameter)
        {
            String validationResults = "";

            System.Collections.Generic.IList <DiagramView> diagrams = Current.MainWindow.DiagramTabManager.GetOpenedDiagramViews();
            foreach (DiagramView diagram in diagrams)
            {
                if (diagram.Diagram.Schema is PSMSchema)
                {
                    string coreFileName = ((PSMSchema)diagram.Diagram.Schema).PSMSchemaClass.Name;

                    System.IO.DirectoryInfo dirInfo   = diagram.Diagram.Project.ProjectFile.Directory;
                    System.IO.FileInfo[]    fileNames = dirInfo.GetFiles("*.xml");
                    foreach (System.IO.FileInfo file in fileNames)
                    {
                        bool startsWith  = file.Name.StartsWith(coreFileName);
                        bool followedByO = coreFileName.Length < file.Name.Length && file.Name.Substring(coreFileName.Length).StartsWith("O");
                        bool followedByF = coreFileName.Length < file.Name.Length && file.Name.Substring(coreFileName.Length).StartsWith("F");
                        if (startsWith && (followedByO || followedByF))
                        {
                            PushDownAutomat  pda = new PushDownAutomat();
                            ValidationResult validationResult = null;
                            bool             validate         = true;
                            try
                            {
                                pda.inicialize((PSMSchema)diagram.Diagram.Schema, file.FullName);
                            }
                            catch (System.Xml.XmlException e)
                            {
                                validationResult = new ValidationResult(false, e.Message);
                            }
                            catch (Exception e) {
                                validationResults += "Soubor " + file.Name + " neodpovida modelu " + coreFileName + ". Nastala chyba: " + e.Message + System.Environment.NewLine;
                                validate           = false;
                            }
                            if (validate)
                            {
                                if (validationResult == null)
                                {
                                    validationResult = pda.processTree();
                                }
                                if ((!validationResult.Successful && file.Name.Substring(coreFileName.Length).StartsWith("O")) || validationResult.Successful && file.Name.Substring(coreFileName.Length).StartsWith("F"))
                                {
                                    validationResults += "Soubor " + file.Name + " neodpovida modelu " + coreFileName + "." + System.Environment.NewLine;
                                }
                            }
                        }
                    }
                }
            }

            ExolutioMessageBox.Show("Validation", "Validation Result", validationResults);
        }