Ejemplo n.º 1
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Creates a new dictionary
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title           = "Create new dictionary. Select dictionary file location";
            openFileDialog.Filter          = "EFS Files (*.efs)|*.efs";
            openFileDialog.CheckFileExists = false;
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string filePath = openFileDialog.FileName;

                DataDictionary.Dictionary dictionary = new DataDictionary.Dictionary();
                dictionary.FilePath = filePath;
                dictionary.Name     = Path.GetFileNameWithoutExtension(filePath);
                EFSSystem.AddDictionary(dictionary);
                RefreshModel();

                // Open a data dictionary window if none is yet present
                bool found = false;
                foreach (IBaseForm form in SubWindows)
                {
                    if (form is DataDictionaryView.Window)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    AddChildWindow(new DataDictionaryView.Window(dictionary));
                }
            }
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------
        ///    IMPORT SPEC OPERATIONS
        /// ------------------------------------------------------

        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataDictionary.Dictionary dictionary = GetActiveDictionary();
            if (dictionary != null)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title  = "Open original specification file";
                openFileDialog.Filter = "RTF Files (*.rtf)|*.rtf|All Files (*.*)|*.*";
                if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    string OriginalFileName = openFileDialog.FileName;
                    openFileDialog.Title  = "Open new specification file";
                    openFileDialog.Filter = "RTF Files (*.rtf)|*.rtf|All Files (*.*)|*.*";
                    if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        string NewFileName = openFileDialog.FileName;

                        string baseFileName = createBaseFileName(OriginalFileName, NewFileName);

                        /// Perform the importation
                        Importers.RtfDeltaImporter.Importer importer = new Importers.RtfDeltaImporter.Importer(OriginalFileName, NewFileName, dictionary.Specifications);
                        ProgressDialog dialog = new ProgressDialog("Opening file", importer);
                        dialog.ShowDialog();

                        /// Creates the report based on the importation result
                        Reports.Importer.DeltaImportReportHandler reportHandler = new Reports.Importer.DeltaImportReportHandler(dictionary, importer.NewDocument, baseFileName);
                        dialog = new ProgressDialog("Opening file", reportHandler);
                        dialog.ShowDialog();

                        RefreshModel();
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void showSpecificationViewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataDictionary.Dictionary dictionary = GetActiveDictionary();
     if (dictionary != null)
     {
         AddChildWindow(new SpecificationView.Window(dictionary));
     }
 }
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="dictionary"></param>
        public VersionSelector(Dictionary dictionary)
        {
            InitializeComponent();
            Dictionary = dictionary;
            RefreshModel();

            dataGridView.DoubleClick += dataGridView_DoubleClick;
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Handles the change of a dictionary on the file system
        /// </summary>
        /// <param name="dictionary"></param>
        private static void HandleInstanceDictionaryChangesOnFileSystem(Dictionary dictionary)
        {
            OpenFileOperation openFile = new OpenFileOperation(dictionary.FilePath, EfsSystem.Instance, false, true);
            openFile.ExecuteUsingProgressDialog("Refreshing dictionary " +
                                                Path.GetFileNameWithoutExtension(dictionary.FilePath), false);

            RefreshModel.Execute();
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary"></param>
 public SpecIssuesReportHandler(Dictionary dictionary)
     : base(dictionary)
 {
     createFileName("SpecificationIssuesReport");
     AddSpecIssues = false;
     AddDesignChoices = false;
     AddInformationNeeded = false;
     AddComments = false;
 }
Ejemplo n.º 7
0
 private void testsCoverageToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataDictionary.Dictionary dictionary = GetActiveDictionary();
     if (dictionary != null)
     {
         Report.TestReport aReport = new Report.TestReport(dictionary);
         aReport.ShowDialog(this);
     }
 }
Ejemplo n.º 8
0
 private void generateDataDictionaryReportToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DataDictionary.Dictionary dictionary = GetActiveDictionary();
     if (dictionary != null)
     {
         Report.ModelReport aReport = new Report.ModelReport(dictionary);
         aReport.ShowDialog(this);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor: creates a report for the dictionary
 /// </summary>
 /// <param name="aDictionary"></param>
 public TestReport(DataDictionary.Dictionary aDictionary)
 {
     InitializeComponent();
     EFSSystem                = aDictionary.EFSSystem;
     reportHandler            = new TestsCoverageReportHandler(aDictionary);
     reportHandler.Dictionary = aDictionary;
     InitializeCheckBoxes(1);
     TxtB_Path.Text = reportHandler.FileName;
 }
Ejemplo n.º 10
0
        public StandardValuesCollection GetValues(Dictionary dictionary)
        {
            FinderRepository.INSTANCE.ClearCache();

            List<string> retVal = new List<string>();
            OverallNameSpaceFinder.INSTANCE.findAllValueNames("", dictionary, false, retVal);
            retVal.Sort();

            return new StandardValuesCollection(retVal);
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="dictionary"></param>
        public FindingsReportHandler(Dictionary dictionary)
            : base(dictionary)
        {
            createFileName("FindingsReport");
            addQuestions = false;
            addComments = false;
            addBugs = false;

            addReviewed = true;
            addNotReviewed = true;
        }
 /// <summary>
 /// Creates a table for design choices
 /// </summary>
 /// <param name="aDictionary">The model</param>
 /// <returns></returns>
 private void GenerateDesignChoices(Dictionary aDictionary)
 {
     AddSubParagraph("Design choices");
     foreach (DataDictionary.Specification.Paragraph paragraph in aDictionary.Specifications.DesignChoices)
     {
         AddSubParagraph("Design choice " + paragraph.FullId);
         AddTable(new string[] { "Design choice " + paragraph.FullId }, new int[] { 30, 100 });
         AddRow(paragraph.Text);
         CloseSubParagraph();
     }
     CloseSubParagraph();
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary"></param>
 public SpecCoverageReportHandler(Dictionary dictionary)
     : base(dictionary)
 {
     createFileName("SpecificationCoverageReport");
     AddSpecification = false;
     ShowFullSpecification = false;
     AddCoveredParagraphs = false;
     ShowAssociatedReqRelated = false;
     AddNonCoveredParagraphs = false;
     AddReqRelated = false;
     ShowAssociatedParagraphs = false;
 }
Ejemplo n.º 14
0
        private void FindOrCreateUpdate(object sender, EventArgs args)
        {
            Dictionary dictionary = GetPatchDictionary();

            if (dictionary != null)
            {
                Paragraph paragraphUpdate = dictionary.FindByFullName(Item.FullName) as Paragraph;
                if (paragraphUpdate == null)
                {
                    // If the element does not already exist in the patch, add a copy to it
                    paragraphUpdate = Item.CreateParagraphUpdate(dictionary);
                }
                // Navigate to the element, whether it was created or not
                EfsSystem.Instance.Context.SelectElement(paragraphUpdate, this, Context.SelectionCriteria.DoubleClick);
            }
        }
        public ErtmsAcademyReport(Dictionary dictionary)
        {
            InitializeComponent();
            _reportHandler = new ERTMSAcademyReportHandler(dictionary);
            TxtB_Path.Text = _reportHandler.FileName;

            _usersAndLogin.Add("James", "*****@*****.**");
            _usersAndLogin.Add("Moritz", "*****@*****.**");
            _usersAndLogin.Add("Luis", "*****@*****.**");
            _usersAndLogin.Add("Laurent", "*****@*****.**");
            _usersAndLogin.Add("Svitlana", "*****@*****.**");

            List<string> userNames = new List<string>();
            userNames.AddRange(_usersAndLogin.Keys);
            userNames.Sort();
            Cbb_UserNames.DataSource = userNames;
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     Provides the dictionary on which operation should be performed
        /// </summary>
        /// <returns></returns>
        public Dictionary GetPatchDictionary()
        {
            Dictionary retVal = null;

            MainWindow mainWindow = GuiUtils.MdiWindow;
            EfsSystem  efsSystem  = mainWindow.EfsSystem;

            if (efsSystem != null)
            {
                ModelElement modelElement = Item as ModelElement;
                if (modelElement != null)
                {
                    int updates = 0;
                    foreach (Dictionary dict in efsSystem.Dictionaries)
                    {
                        if (modelElement.Dictionary.IsUpdatedBy(dict))
                        {
                            // Set retVal to the update in case it is the only one for the base dictionary
                            retVal = dict;
                            updates++;
                        }
                    }

                    if (updates == 0)
                    {
                        MessageBox.Show("No updates loaded for the current dictionary.");
                    }

                    if (updates > 1)
                    {
                        // if there are 0 or 1 possible updates, it will already have the correct value
                        // if there are more, choose the update from a list of possibilities
                        DictionarySelector.DictionarySelector dictionarySelector =
                            new DictionarySelector.DictionarySelector(FilterOptions.Updates, modelElement.Dictionary);
                        dictionarySelector.ShowDictionaries(mainWindow);

                        if (dictionarySelector.Selected != null)
                        {
                            retVal = dictionarySelector.Selected;
                        }
                    }
                }
            }

            return(retVal);
        }
Ejemplo n.º 17
0
        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataDictionary.Dictionary activeDictionary = GetActiveDictionary();

            if (activeDictionary != null)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Title  = "Saving EFS file " + activeDictionary.Name;
                saveFileDialog.Filter = "EFS files (*.efs)|*.efs|All Files (*.*)|*.*";
                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    activeDictionary.FilePath = saveFileDialog.FileName;
                    SaveOperation  saveOperation = new SaveOperation(this, activeDictionary);
                    ProgressDialog dialog        = new ProgressDialog("Saving file " + activeDictionary.FilePath, saveOperation);
                    dialog.ShowDialog();
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     Creates the interfaces of the the EFS model
        /// </summary>
        /// <param name="args"></param>
        /// <returns>the error code of the program</returns>
        private static int Main(string[] args)
        {
            int retVal = 0;

            try
            {
                Console.Out.WriteLine("EFS Interfaces");

                // Load the dictionaries provided as parameters
                EfsSystem efsSystem = EfsSystem.Instance;
                Util.PleaseLockFiles = false;
                foreach (string arg in args)
                {
                    Console.Out.WriteLine("Loading dictionary " + arg);

                    Dictionary dictionary = Util.Load(efsSystem, new Util.LoadParams(arg)
                    {
                        LockFiles       = false,
                        Errors          = null,
                        UpdateGuid      = false,
                        ConvertObsolete = false
                    });
                    if (dictionary == null)
                    {
                        Console.Out.WriteLine("Cannot load dictionary " + arg);
                        return(-1);
                    }
                }

                TextWriter      writer  = new StreamWriter("Interface.out");
                VariableVisitor visitor = new VariableVisitor(writer);
                foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries)
                {
                    visitor.visit(dictionary, true);
                }
            }
            finally
            {
                Util.UnlockAllFiles();
            }

            return(retVal);
        }
Ejemplo n.º 19
0
        protected override ModelElement FindOrCreateUpdate()
        {
            ModelElement retVal = null;

            Dictionary dictionary = GetPatchDictionary();

            if (dictionary != null)
            {
                retVal = dictionary.FindByFullName(Item.FullName) as ModelElement;
                if (retVal == null)
                {
                    // If the element does not already exist in the patch, add a copy to it
                    retVal = Item.CreateVariableUpdate(dictionary);
                }
                // Navigate to the element, whether it was created or not
                EfsSystem.Instance.Context.SelectElement(retVal, this, Context.SelectionCriteria.DoubleClick);
            }

            return(retVal);
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="dictionary"></param>
        public DictionaryWatcher(EfsSystem system, Dictionary dictionary)
        {
            System = system;
            Dictionary = dictionary;
            LastChange = DateTime.Now;
            DeltaTime = new TimeSpan(0, 0, 2);

            CriticalRegion = new Mutex(false, "Critical region");

            if (dictionary.FilePath != null)
            {
                if (dictionary.countNameSpaces() > 0)
                {
                    string path = Path.GetDirectoryName(dictionary.FilePath) + Path.DirectorySeparatorChar +
                                  Path.GetFileNameWithoutExtension(dictionary.FilePath);
                    path = Path.GetFullPath(path);
                    Directory.CreateDirectory(path);
                    Watcher = new FileSystemWatcher(path, "*.*")
                    {
                        IncludeSubdirectories = true,
                        NotifyFilter = NotifyFilters.LastWrite
                    };
                }
                else
                {
                    string path = Path.GetDirectoryName(dictionary.FilePath);
                    string fileName = Path.GetFileName(dictionary.FilePath);
                    Watcher = new FileSystemWatcher(path, fileName)
                    {
                        IncludeSubdirectories = false,
                        NotifyFilter = NotifyFilters.LastWrite
                    };
                }

                Watcher.Changed += Watcher_Changed;
                Watcher.Created += Watcher_Changed;
                Watcher.Deleted += Watcher_Changed;

                StartWatching();
            }
        }
Ejemplo n.º 21
0
        private void importFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataDictionary.Dictionary dictionary = GetActiveDictionary();
            if (dictionary != null)
            {
                FolderBrowserDialog selectFolderDialog = new FolderBrowserDialog();
                if (selectFolderDialog.ShowDialog(this) == DialogResult.OK)
                {
                    ImportTestDataBaseHandler importTestDataBaseHandler = new ImportTestDataBaseHandler(selectFolderDialog.SelectedPath, dictionary, ImportTestDataBaseHandler.Mode.Directory);
                    ProgressDialog            dialog = new ProgressDialog("Import database directory", importTestDataBaseHandler);
                    dialog.ShowDialog();

                    // Updates the test tree view data
                    if (TestWindow != null)
                    {
                        TestWindow.TreeView.RefreshModel();
                        Refresh();
                    }
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Finds or creates an udate for the current element.
        /// </summary>
        /// <returns></returns>
        protected override ModelElement FindOrCreateUpdate()
        {
            ModelElement retVal = null;

            Dictionary dictionary = GetPatchDictionary();

            if (dictionary != null)
            {
                retVal = dictionary.FindByFullName(Item.FullName) as ModelElement;
                if (retVal == null)
                {
                    // If the element does not already exist in the patch, add a copy of the function to it
                    // Get the enclosing namespace (by splitting the fullname and asking a recursive function to provide or make it)
                    retVal = Item.CreateRangeUpdate(dictionary);
                }
                // Navigate to the element, whether it was created or not
                EfsSystem.Instance.Context.SelectElement(retVal, this, Context.SelectionCriteria.DoubleClick);
            }

            return(retVal);
        }
 public ModelReportHandler(Dictionary aDictionary)
     : base(aDictionary)
 {
     createFileName("ModelReport");
     AddRanges = false;
     AddRangesDetails = false;
     AddEnumerations = false;
     AddEnumerationsDetails = false;
     AddStructures = false;
     AddStructuresDetails = false;
     AddCollections = false;
     AddCollectionsDetails = false;
     AddFunctions = false;
     AddFunctionsDetails = false;
     AddProcedures = false;
     AddProceduresDetails = false;
     AddVariables = false;
     AddVariablesDetails = false;
     AddRules = false;
     AddRulesDetails = false;
     ImplementedOnly = true;
 }
Ejemplo n.º 24
0
        private void importDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataDictionary.Dictionary dictionary = GetActiveDictionary();
            if (dictionary != null)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title  = "Open test sequence database";
                openFileDialog.Filter = "Access Files (*.mdb)|*.mdb";
                if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    ImportTestDataBaseHandler importTestDataBaseHandler = new ImportTestDataBaseHandler(openFileDialog.FileName, dictionary, ImportTestDataBaseHandler.Mode.File);
                    ProgressDialog            dialog = new ProgressDialog("Import database", importTestDataBaseHandler);
                    dialog.ShowDialog();

                    // Updates the test tree view data
                    if (TestWindow != null)
                    {
                        TestWindow.TreeView.RefreshModel();
                        Refresh();
                    }
                }
            }
        }
        /// <summary>
        /// Provides the set of covered requirements by the model
        /// </summary>
        /// <param name="aDictionary">The model</param>
        /// <param name="covered">Indicates if we need compute covered or non covered requirements</param>
        /// <returns></returns>
        public static HashSet<DataDictionary.Specification.Paragraph> CoveredRequirements(Dictionary aDictionary, bool covered)
        {
            HashSet<DataDictionary.Specification.Paragraph> retVal = new HashSet<DataDictionary.Specification.Paragraph>();

            ICollection<DataDictionary.Specification.Paragraph> applicableParagraphs = aDictionary.Specifications.ApplicableParagraphs;
            Dictionary<DataDictionary.Specification.Paragraph, List<ReqRef>> paragraphsReqRefDictionary = aDictionary.ParagraphsReqRefs;
            foreach (DataDictionary.Specification.Paragraph paragraph in applicableParagraphs)
            {
                bool implemented = paragraph.getImplementationStatus() == DataDictionary.Generated.acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented;
                if (implemented)
                {
                    if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                    {
                        List<ReqRef> implementations = paragraphsReqRefDictionary[paragraph];
                        for (int i = 0; i < implementations.Count; i++)
                        {
                            // the implementation may be also a ReqRef
                            if (implementations[i].Enclosing is ReqRelated)
                            {
                                ReqRelated reqRelated = implementations[i].Enclosing as ReqRelated;
                                // Do not consider tests
                                if (Utils.EnclosingFinder<DataDictionary.Tests.Frame>.find(reqRelated) == null)
                                {
                                    implemented = implemented && reqRelated.ImplementationCompleted;
                                }
                            }
                        }
                    }
                }
                if (implemented == covered)
                {
                    retVal.Add(paragraph);
                }
            }
            return retVal;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Provides the dictionary on which operation should be performed
        /// </summary>
        /// <returns></returns>
        public DataDictionary.Dictionary GetActiveDictionary()
        {
            DataDictionary.Dictionary retVal = null;

            if (EFSSystem != null)
            {
                if (EFSSystem.Dictionaries.Count == 1)
                {
                    retVal = EFSSystem.Dictionaries[0];
                }
                else
                {
                    DictionarySelector.DictionarySelector dictionarySelector = new DictionarySelector.DictionarySelector(EFSSystem);
                    dictionarySelector.ShowDialog(this);

                    if (dictionarySelector.Selected != null)
                    {
                        retVal = dictionarySelector.Selected;
                    }
                }
            }

            return(retVal);
        }
Ejemplo n.º 27
0
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title  = "Open ERTMS Formal Spec file";
            openFileDialog.Filter = "EFS Files (*.efs)|*.efs|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    OpenFileOperation openFileOperation = new OpenFileOperation(openFileDialog.FileName, EFSSystem);
                    ProgressDialog    dialog            = new ProgressDialog("Opening file", openFileOperation);
                    dialog.ShowDialog();

                    // Open the windows
                    if (openFileOperation.Dictionary != null)
                    {
                        DataDictionary.Dictionary dictionary = openFileOperation.Dictionary;
                        DataDictionary.Generated.ControllersManager.NamableController.DesactivateNotification();

                        // Only open the specification window if specifications are available in the opened file
                        if (dictionary.Specifications != null && dictionary.Specifications.AllParagraphs.Count > 0)
                        {
                            AddChildWindow(new SpecificationView.Window(dictionary));
                        }

                        // Only open the model view window if model elements are available in the opened file
                        if (dictionary.NameSpaces.Count > 0)
                        {
                            AddChildWindow(new DataDictionaryView.Window(dictionary));
                        }

                        // Only shold the tests window if tests are defined in the opened file
                        if (dictionary.Tests.Count > 0)
                        {
                            IBaseForm testWindow = TestWindow;
                            if (testWindow == null)
                            {
                                AddChildWindow(new TestRunnerView.Window(EFSSystem));
                            }
                            else
                            {
                                testWindow.RefreshModel();
                            }
                        }

                        // Only open the shortcuts window if there are some shortcuts defined
                        if (dictionary.ShortcutsDictionary != null)
                        {
                            IBaseForm shortcutsWindow = ShortcutsWindow;
                            if (shortcutsWindow == null)
                            {
                                if (dictionary != null)
                                {
                                    Shortcuts.Window newWindow = new Shortcuts.Window(dictionary.ShortcutsDictionary);
                                    newWindow.Location = new System.Drawing.Point(Width - newWindow.Width - 20, 0);
                                    AddChildWindow(newWindow);
                                }
                            }
                            else
                            {
                                shortcutsWindow.RefreshModel();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot open file, please see log file (GUI.Log) for more information", "Cannot open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                finally
                {
                    DataDictionary.Generated.ControllersManager.NamableController.ActivateNotification();
                }

                Refresh();
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Performs the job as a background task
 /// </summary>
 /// <param name="arg"></param>
 public override void ExecuteWork()
 {
     Dictionary = DataDictionary.Util.load(FileName, System);
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="aDictionary"></param>
 /// <param name="importResult"></param>
 public DeltaImportReportHandler(Dictionary aDictionary, Document importResult, string baseFileName)
     : base(aDictionary)
 {
     createFileName(baseFileName);
     ImportResult = importResult;
 }
Ejemplo n.º 30
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary"></param>
 public Window(Dictionary dictionary)
 {
     InitializeComponent();
     Dictionary = dictionary;
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary"></param>
 public FunctionalAnalysisReport(Dictionary dictionary)
 {
     InitializeComponent();
     reportHandler = new FunctionalAnalysisReportHandler(dictionary);
     TxtB_Path.Text = reportHandler.FileName;
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary">The dictionary to use to create the report</param>
 public ERTMSAcademyReportHandler(Dictionary dictionary)
     : base(dictionary)
 {
     createFileName("ERTMSAcademyReport");
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary">The dictionary to be compared</param>
 /// <param name="commit">The commit to compare with</param>
 public CompareWithRepositoryOperation(Dictionary dictionary, Commit commit)
     : base(dictionary)
 {
     Commit = commit;
 }
Ejemplo n.º 34
0
        // For each element in this report, have a Create method that does the paragraphing stuff and a
        // Generate method, that involves loops and stuff
        /// <summary>
        ///     Provides the first-level paragraph under a chapter with the provided name
        /// </summary>
        /// <param name="aSectionName"></param>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        private Paragraph getSection(string aSectionName, Dictionary dictionary)
        {
            Paragraph retVal = new Paragraph();
            foreach (Specification specification in dictionary.Specifications)
            {
                foreach (Chapter chapter in specification.Chapters)
                {
                    foreach (Paragraph paragraph in chapter.Paragraphs)
                    {
                        if (paragraph.ExpressionText == aSectionName)
                        {
                            retVal = paragraph;
                        }
                    }
                }
            }

            return retVal;
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="dictionary"></param>
 public ImportTestDataBaseHandler(string fileName, Dictionary dictionary, Mode mode)
 {
     FileName   = fileName;
     Dictionary = dictionary;
     ImportMode = mode;
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Creates the picture associated to this graph
        /// </summary>
        /// <param name="name"></param>
        /// <returns>the corresponding bitmap</returns>
        public Bitmap Display()
        {
            Bitmap retVal = null;

            SpeedDistanceCurvePlotter display = new SpeedDistanceCurvePlotter();
            String name = null;

            /// Computes the expected end to display
            double expectedEndX = 0;
            Dictionary<Function, Graph> graphs = new Dictionary<Function, Graph>();
            foreach (Function function in Functions)
            {
                InterpretationContext context = new InterpretationContext(function);
                if (function.FormalParameters.Count == 1)
                {
                    Parameter parameter = (Parameter)function.FormalParameters[0];
                    Graph graph = function.createGraph(context, parameter);
                    if (graph != null)
                    {
                        expectedEndX = Math.Max(expectedEndX, graph.ExpectedEndX());
                        graphs.Add(function, graph);
                    }
                }
            }

            double expectedEndY = 0;
            Dictionary<Function, Surface> surfaces = new Dictionary<Function, Surface>();
            foreach (Function function in Functions)
            {
                InterpretationContext context = new InterpretationContext(function);
                if (function.FormalParameters.Count == 2)
                {
                    Surface surface = function.createSurface(context);
                    if (surface != null)
                    {
                        expectedEndX = Math.Max(expectedEndX, surface.ExpectedEndX());
                        expectedEndY = Math.Max(expectedEndY, surface.ExpectedEndY());
                        surfaces.Add(function, surface);
                    }
                }
            }

            // Don't display surfaces that are too big
            if (setMaximumYValueCheckBox.Checked)
            {
                try
                {
                    int maxY = Int32.Parse(maximumYValueTextBox.Text);
                    expectedEndY = Math.Min(expectedEndY, maxY);
                }
                catch (Exception)
                {
                }
            }
            expectedEndY = Math.Min(600, expectedEndY);

            int i = 0;
            /// Creates the graphs
            foreach (KeyValuePair<Function, Graph> pair in graphs)
            {
                Function function = pair.Key;
                Graph graph = pair.Value;

                if (graph != null)
                {
                    if (graph.IsFlat())
                    {
                        FlatSpeedDistanceCurve curve = graph.FlatSpeedDistanceCurve(expectedEndX);
                        display.AddCurve(curve, function.FullName, COLORS[i % COLORS.Length]);
                    }
                    else
                    {
                        QuadraticSpeedDistanceCurve curve = graph.QuadraticSpeedDistanceCurve(expectedEndX);
                        display.AddCurve(curve, function.FullName, COLORS[i % COLORS.Length]);
                    }

                    if (name == null)
                    {
                        name = function.Name;
                    }
                }
                i += 1;
            }

            /// Creates the surfaces
            foreach (KeyValuePair<Function, Surface> pair in surfaces)
            {
                Function function = pair.Key;
                Surface surface = pair.Value;

                if (surface != null)
                {
                    AccelerationSpeedDistanceSurface curve = surface.createAccelerationSpeedDistanceSurface(expectedEndX, expectedEndY);
                    display.AddCurve(curve, function.FullName);
                    if (name == null)
                    {
                        name = function.Name;
                    }
                }
            }

            if (name != null)
            {
                display.GnuPlot_Home_Path = Path.GetDirectoryName(Application.ExecutablePath) + "\\gnuplot\\bin";
                string outputDir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\ERTMSFormalSpecs";
                System.IO.Directory.CreateDirectory(outputDir);
                display.Output_Path = outputDir;
                display.Base_Name = "EFSPicture_" + name;
                display.ImageWidth = 1200;
                display.ImageHeight = 600;
                display.EraseTemporaryFiles = false;
                display.ShowColouredSegments = false;

                if (setMinimumValueCheckBox.Checked)
                {
                    try
                    {
                        double val = double.Parse(minimumValueTextBox.Text);
                        display.Min_X = new SiDistance(val, SiDistance_SubUnits.Meter);
                    }
                    catch (Exception)
                    {
                    }
                }

                if (setMaximumValueCheckBox.Checked)
                {
                    try
                    {
                        double val = double.Parse(maximumValueTextBox.Text);
                        display.Max_X = new SiDistance(val, SiDistance_SubUnits.Meter);
                    }
                    catch (Exception)
                    {
                    }
                }

                if (display.Plot())
                {
                    // Sometimes, a handle is still open on the corresponding file which forbids opening the stream on it
                    // Wait a bit until the handle is no more open
                    System.IO.FileStream stream = null;

                    System.DateTime start = System.DateTime.Now;
                    while (stream == null && System.DateTime.Now - start < new TimeSpan(0, 0, 5))
                    {
                        try
                        {
                            stream = new System.IO.FileStream(display.ImageFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                        }
                        catch (Exception)
                        {
                            System.Threading.Thread.Sleep(100);
                        }
                    }

                    if (stream != null)
                    {
                        try
                        {
                            retVal = new Bitmap(stream);
                        }
                        catch (Exception)
                        {
                        }
                        finally
                        {
                            stream.Close();
                            // System.IO.File.Delete(display.ImageFileName);
                        }
                    }
                }
            }

            return retVal;
        }
        /// <summary>
        /// Generates a table with specification coverage statistics
        /// </summary>
        /// <param name="aDictionary">The model</param>
        /// <param name="coveredParagraphs">Number and percentage of covered paragraphs</param>
        /// <param name="nonCoveredParagraphs">Number and percentage of non covered paragraphs</param>
        /// <param name="applicableParagraphs">Number of applicable paragraphs</param>
        /// <param name="allParagraphs">Total number of paragraphs</param>
        /// <returns></returns>
        private void GenerateStatistics(Dictionary aDictionary, bool coveredParagraphs, bool nonCoveredParagraphs, bool applicableParagraphs, bool allParagraphs)
        {
            AddTable(new string[] { "Statistics" }, new int[] { 70, 70 });
            if (allParagraphs)
            {
                AddRow("Total number of paragraphs", aDictionary.Specifications.AllParagraphs.Count.ToString());
            }
            if (applicableParagraphs)
            {
                AddRow("Number of applicable paragraphs", aDictionary.Specifications.ApplicableParagraphs.Count.ToString());
            }

            double applicableParagraphsCount = aDictionary.Specifications.ApplicableParagraphs.Count;
            double coveredParagraphsCount = CoveredRequirements(aDictionary, true).Count;
            double coveredPercentage = (coveredParagraphsCount / applicableParagraphsCount) * 100;
            double nonCoveredParagraphsCount = applicableParagraphsCount - coveredParagraphsCount;
            double nonCoveredPercentage = 100 - coveredPercentage;

            if (coveredParagraphs)
            {
                AddRow("Number of covered requirements", String.Format("{0} ({1:0.##}%)", coveredParagraphsCount, coveredPercentage));
            }
            if (nonCoveredParagraphs)
            {
                AddRow("Number of non covered requirements", String.Format("{0} ({1:0.##}%)", nonCoveredParagraphsCount, nonCoveredPercentage));
            }
        }
 /// <summary>
 /// Creates a table resuming all requirements of the specification
 /// </summary>
 /// <param name="aDictionary">The model</param>
 /// <returns></returns>
 private void CreateSpecificationTable(Dictionary aDictionary)
 {
     AddTable(new string[] { "Model information" }, new int[] { 40, 40, 30, 30 });
     AddTableHeader("Requirement", "Target", "Type", "Implementation status");
     foreach (DataDictionary.Specification.Paragraph paragraph in aDictionary.Specifications.AllParagraphs)
     {
         AddRow(paragraph.FullId, paragraph.getScope_AsString(), paragraph.getType_AsString(), paragraph.getImplementationStatus_AsString());
     }
 }
        /// <summary>
        /// Creates a table for a given set of paragraphs
        /// </summary>
        /// <param name="title">Title of the table</param>
        /// <param name="paragraphs">The paragraphs to display</param>
        /// <param name="showAssociatedImplementations">Indicates if we need to show the model elements implementing the paragraphs</param>
        /// <returns></returns>
        private void CreateImplementedParagraphsTable(HashSet<DataDictionary.Specification.Paragraph> paragraphs, Dictionary dictionary)
        {
            Dictionary<DataDictionary.Specification.Paragraph, List<ReqRef>> paragraphsReqRefDictionary = dictionary.ParagraphsReqRefs;
            foreach (DataDictionary.Specification.Paragraph paragraph in paragraphs)
            {
                Cell previousCell = null;

                if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                {
                    AddSubParagraph("Requirement " + paragraph.FullId);
                    AddTable(new string[] { "Requirement " + paragraph.FullId }, new int[] { 40, 60, 40 });
                    AddRow(paragraph.Text);

                    foreach (ReqRef reqRef in paragraph.Implementations)
                    {
                        string fullName = null;
                        string comment = null;

                        ReqRelated reqRelated = reqRef.Enclosing as ReqRelated;
                        if (reqRelated != null)
                        {
                            fullName = reqRelated.FullName;
                            comment = reqRelated.Comment;
                        }
                        else
                        {
                            DataDictionary.Specification.Paragraph par = reqRef.Enclosing as DataDictionary.Specification.Paragraph;
                            if (par != null)
                            {
                                fullName = paragraph.FullName;
                                comment = paragraph.Comment;
                            }
                        }

                        if (fullName != null && comment != null)
                        {
                            if (previousCell == null)
                            {
                                AddRow("Associated implementation", fullName, comment);
                                previousCell = lastRow.Cells[0];
                            }
                            else
                            {
                                AddRow("", fullName, comment);
                                previousCell.MergeDown += 1;
                            }
                        }
                    }
                    CloseSubParagraph();
                }
            }
        }
Ejemplo n.º 40
0
 /// <summary>
 /// Constructor used to save a single dictionary
 /// </summary>
 /// <param name="mainWindow"></param>
 /// <param name="dictionary"></param>
 public SaveOperation(MainWindow mainWindow, DataDictionary.Dictionary dictionary)
 {
     MainWindow = mainWindow;
     Dictionary = dictionary;
     System     = Dictionary.EFSSystem;
 }
Ejemplo n.º 41
0
        /// <summary>
        ///     Builds a dictionary of sequences containing a given test case, from the implementations of a paragraph
        /// </summary>
        /// <param name="paragraph"></param>
        /// <returns></returns>
        private Dictionary<string, string[]> findSteps(Paragraph paragraph)
        {
            Dictionary<string, string[]> retVal = new Dictionary<string, string[]>();

            foreach (ReqRef reference in paragraph.Implementations)
            {
                Step step = reference.Model as Step;
                if (step != null)
                {
                    if (retVal.ContainsKey(step.TestCase.Name))
                    {
                        string steps = retVal[step.TestCase.Name][0];
                        string sequences = retVal[step.TestCase.Name][1];

                        // Only add the subsequence if it is not already in the string
                        if (sequences.IndexOf(step.SubSequence.Name) == -1)
                        {
                            sequences = sequences + "\n" + step.SubSequence.Name;
                            steps = steps + "\n" + stepNumber(step);
                        }
                        else
                        {
                            int line = getLine(sequences, step.SubSequence.Name);
                            if (!stepPresent(line, step, steps))
                            {
                                steps = steps.Insert(stepIndex(line, steps), ", " + stepNumber(step));
                            }
                        }

                        retVal[step.TestCase.Name][0] = steps;
                        retVal[step.TestCase.Name][1] = sequences;
                    }
                    else
                    {
                        retVal[step.TestCase.Name] = new string[] {stepNumber(step), step.SubSequence.Name};
                    }
                }
            }

            return retVal;
        }
Ejemplo n.º 42
0
 /// <summary>
 ///     Creates a table for the questions
 /// </summary>
 /// <param name="aDictionary"></param>
 public void GenerateQuestions(Dictionary aDictionary)
 {
     AddSubParagraph("");
     Paragraph questions = getSection("Questions", aDictionary);
     foreach (Paragraph subparagraph in questions.SubParagraphs)
     {
         addEntry(subparagraph, "Question");
     }
     CloseSubParagraph();
 }
Ejemplo n.º 43
0
        /// <summary>
        ///     Displays the graph
        /// </summary>
        /// <returns></returns>
        public void Display()
        {
            Util.DontNotify(() =>
            {
                GraphVisualiser.Reset();
                String name = null;

                // Computes the expected end to display
                double expectedEndX = 0;
                Dictionary<Function, Graph> graphs = new Dictionary<Function, Graph>();
                foreach (Function function in Functions)
                {
                    InterpretationContext context = new InterpretationContext(function);
                    if (function.FormalParameters.Count == 1)
                    {
                        Parameter parameter = (Parameter) function.FormalParameters[0];
                        Graph graph = function.CreateGraph(context, parameter, null);
                        if (graph != null)
                        {
                            expectedEndX = Math.Max(expectedEndX, graph.ExpectedEndX());
                            graphs.Add(function, graph);
                        }
                    }
                }

                double expectedEndY = 0;
                Dictionary<Function, Surface> surfaces = new Dictionary<Function, Surface>();
                foreach (Function function in Functions)
                {
                    InterpretationContext context = new InterpretationContext(function);
                    if (function.FormalParameters.Count == 2)
                    {
                        Surface surface = function.CreateSurface(context, null);
                        if (surface != null)
                        {
                            expectedEndX = Math.Max(expectedEndX, surface.ExpectedEndX());
                            expectedEndY = Math.Max(expectedEndY, surface.ExpectedEndY());
                            surfaces.Add(function, surface);
                        }
                    }
                }

                try
                {
                    int maxX = Int32.Parse(Tb_MaxX.Text);
                    expectedEndX = Math.Min(expectedEndX, maxX);
                }
                catch (Exception)
                {
                }

                // Creates the graphs
                foreach (KeyValuePair<Function, Graph> pair in graphs)
                {
                    Function function = pair.Key;
                    Graph graph = pair.Value;

                    if (graph != null)
                    {
                        EfsProfileFunction efsProfileFunction = new EfsProfileFunction(graph);
                        GraphVisualiser.AddGraph(new EfsProfileFunctionGraph(GraphVisualiser, efsProfileFunction,
                            function.FullName));

                        if (name == null)
                        {
                            name = function.Name;
                        }
                    }
                }

                // Creates the surfaces
                foreach (KeyValuePair<Function, Surface> pair in surfaces)
                {
                    Function function = pair.Key;
                    Surface surface = pair.Value;

                    if (surface != null)
                    {
                        EfsSurfaceFunction efsSurfaceFunction = new EfsSurfaceFunction(surface);
                        GraphVisualiser.AddGraph(new EfsSurfaceFunctionGraph(GraphVisualiser, efsSurfaceFunction,
                            function.FullName));
                        if (name == null)
                        {
                            name = function.Name;
                        }
                    }
                }

                if (name != null)
                {
                    try
                    {
                        double val = double.Parse(Tb_MinX.Text);
                        GraphVisualiser.SetMinX(val);
                    }
                    catch (Exception)
                    {
                    }

                    try
                    {
                        double val = double.Parse(Tb_MaxX.Text);
                        GraphVisualiser.SetMaxX(val);
                    }
                    catch (Exception)
                    {
                    }

                    if (Cb_AutoYSize.Checked)
                    {
                        GraphVisualiser.SetMaxY(double.NaN);
                    }
                    else
                    {
                        double height;
                        if (double.TryParse(Tb_MaxY.Text, out height))
                        {
                            GraphVisualiser.SetMaxY(height);
                        }
                        else
                        {
                            GraphVisualiser.SetMaxY(double.NaN);
                        }
                    }
                    GraphVisualiser.DrawGraphs(expectedEndX);
                }
            });
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary">The dictionary holding the S76 issues and S76 test sequences</param>
 public Subseet76ReportHandler(Dictionary dictionary)
     : base(dictionary)
 {
     CreateFileName("FindingsReport");
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary">The dictionary to compare with</param>
 /// <param name="filePath">The path to the file to compare with</param>
 public CompareWithFileOperation(Dictionary dictionary, string filePath)
 {
     Dictionary = dictionary;
     OtherFilePath = filePath;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public ReportHandler(Dictionary dictionary)
 {
     Name = "Report";
     createFileName("Report");
     Dictionary = dictionary;
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary">The dictionary on which the operation should be performed</param>
 protected BaseCompareWithRepositoryOperation(Dictionary dictionary)
 {
     Dictionary = dictionary;
 }
 /// <summary>
 ///     Creates a table for specification issues
 /// </summary>
 /// <param name="aDictionary">The model</param>
 /// <returns></returns>
 private void GenerateSpecIssues(Dictionary aDictionary)
 {
     AddSubParagraph("Specification issues");
     foreach (Paragraph paragraph in aDictionary.SpecIssues)
     {
         AddSubParagraph("Issue on " + paragraph.FullId);
         AddTable(new string[] {"Issue on " + paragraph.FullId}, new int[] {30, 100});
         AddRow("Description", paragraph.Text);
         AddRow("Comment", paragraph.Comment);
         CloseSubParagraph();
     }
     CloseSubParagraph();
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="dictionary"></param>
 public CloseDictionary(Dictionary dictionary)
 {
     Dictionary = dictionary;
 }
Ejemplo n.º 50
0
 /// <summary>
 ///     Provides a comparator for sort method
 /// </summary>
 /// <param name="x">First dictionary</param>
 /// <param name="y">Second discionary</param>
 /// <returns></returns>
 private static int compare(Dictionary x, Dictionary y)
 {
     int retVal = 0; // x = y
     if (String.Compare(x.Name, y.Name) < 0) // x < y
     {
         retVal = -1;
     }
     else if (String.Compare(x.Name, y.Name) > 0) // x > y
     {
         retVal = 1;
     }
     return retVal;
 }