Exemple #1
0
        private SpecificationBase ParseSpecification(bool showVerbolMsg)
        {
            if (CurrentEditorTabItem == null || this.CurrentEditorTabItem.Text.Trim() == "")
            {
                if (showVerbolMsg)
                {
                    MessageBox.Show(Resources.Please_input_a_model_first_, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(null);
            }

            DisableAllControls();
            SpecificationBase spec = null;

            try
            {
                //clear the error list
                if (!ErrorListWindow.IsDisposed)
                {
                    ErrorListWindow.Clear();
                }

                CurrentModule = new ModuleFacade();
                spec          = CurrentModule.ParseSpecification(this.CurrentEditorTabItem.Text, "",
                                                                 CurrentEditorTabItem.FileName);

                if (spec != null)
                {
                    CurrentEditorTabItem.Specification = spec;

                    if (spec.Errors.Count > 0)
                    {
                        string key = "";
                        foreach (KeyValuePair <string, ParsingException> pair in spec.Errors)
                        {
                            key = pair.Key;
                            break;
                        }
                        ParsingException parsingException = spec.Errors[key];
                        spec.Errors.Remove(key);
                        throw parsingException;
                    }

                    if (showVerbolMsg)
                    {
                        this.StatusLabel_Status.Text = Resources.Grammar_Checked;

                        MenuButton_OutputPanel.Checked = true;
                        Output_Window.TextBox.Text     = spec.GetSpecification() + "\r\n" + Output_Window.TextBox.Text;
                        Output_Window.Show(DockContainer);

                        if (spec.Warnings.Count > 0)
                        {
                            this.MenuButton_ErrorList.Checked = true;
                            ErrorListWindow.AddWarnings(spec.Warnings);

                            //ErrorListWindow.Show(DockContainer);
                            ShowErrorMessage();
                        }
                    }


                    EnableAllControls();

                    return(spec);
                }
                else
                {
                    EnableAllControls();

                    return(null);
                }
            }
            catch (ParsingException ex)
            {
                EnableAllControls();

                if (showVerbolMsg)
                {
                    if (spec != null)
                    {
                        ErrorListWindow.AddWarnings(spec.Warnings);
                        ErrorListWindow.AddErrors(spec.Errors);
                        //MenuButton_ErrorList.Checked = true;
                    }


                    CurrentEditorTabItem.HandleParsingException(ex);
                    ErrorListWindow.InsertError(ex);
                    MenuButton_ErrorList.Checked = true;

                    if (ex.Line > 0)
                    {
                        MessageBox.Show(Resources.Parsing_error_at_line_ + ex.Line + Resources._column_ + ex.CharPositionInLine + ": " + ex.Text + "\nFile:" + ex.DisplayFileName + "\n" + ex.Message, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        MenuButton_OutputPanel.Checked  = true;
                        this.Output_Window.TextBox.Text = Resources.Parsing_error_at_line_ + ex.Line + Resources._column_ + ex.CharPositionInLine + ": " + ex.Text + "\nFile:" + ex.DisplayFileName + "\n" + ex.Message + "\r\n\r\n" + this.Output_Window.TextBox.Text; //"\n" + ex.StackTrace +
                    }
                    else
                    {
                        MessageBox.Show(Resources.Parsing_error__ + ex.Message, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        MenuButton_OutputPanel.Checked  = true;
                        this.Output_Window.TextBox.Text = Resources.Parsing_error__ + ex.Message + "\r\n\r\n" + this.Output_Window.TextBox.Text; //"\n" + ex.StackTrace +
                    }
                    ShowErrorMessage();
                }
            }
            catch (Exception ex)
            {
                EnableAllControls();
                if (showVerbolMsg)
                {
                    MessageBox.Show(Resources.Parsing_error__ + ex.Message, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MenuButton_OutputPanel.Checked  = true;
                    this.Output_Window.TextBox.Text = Resources.Parsing_error__ + ex.Message + "\n" + ex.StackTrace + "\r\n\r\n" + this.Output_Window.TextBox.Text;
                }
            }

            return(null);
        }