Inheritance: SIL.FieldWorks.LexText.Controls.ParserTrace
Beispiel #1
0
        public void SetDlgInfo(Mediator mediator, IWfiWordform wordform, ParserListener parserListener)
        {
            m_mediator        = mediator;
            m_persistProvider = new PersistenceProvider(PersistProviderID, m_mediator.PropertyTable);
            m_persistProvider.RestoreWindowSettings(PersistProviderID, this);
            m_xampleTrace     = new XAmpleTrace(mediator);
            m_hermitCrabTrace = new HCTrace(mediator);
            m_cache           = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            m_parserListener  = parserListener;

            Text = m_cache.ProjectId.UiName + " - " + Text;
            SetRootSite();
            SetFontInfo();
            if (wordform == null)
            {
                GetLastWordUsed();
            }
            else
            {
                SetWordToUse(wordform.Form.VernacularDefaultWritingSystem.Text);
            }

            m_webPageInteractor = new WebPageInteractor(m_htmlControl, ParserTrace, m_mediator, m_wordformTextBox);
#if !__MonoCS__
            m_htmlControl.Browser.ObjectForScripting = m_webPageInteractor;
#endif

            // HermitCrab does not currently support selected tracing

            /*if (m_cache.LangProject.MorphologicalDataOA.ActiveParser == "HC")
             * {
             *      m_parserCanDoSelectMorphs = false;
             *      m_doSelectMorphsCheckBox.Enabled = false;
             * }
             */
            // No such thing as FwApp.App now: if(FwApp.App != null) // Could be null during testing
            if (m_mediator.HelpTopicProvider != null)             // trying this
            {
                m_helpProvider.HelpNamespace = m_mediator.HelpTopicProvider.HelpFile;
                m_helpProvider.SetHelpKeyword(this, m_mediator.HelpTopicProvider.GetHelpString(HelpTopicID));
                m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }

            if (m_parserListener.Connection != null)
            {
                m_parserListener.Connection.TryAWordDialogIsRunning = true;
                m_statusLabel.Text = GetString("ParserStatusPrefix") + ParserUIStrings.ksIdle_ + GetString("ParserStatusSuffix");
            }
            else
            {
                m_statusLabel.Text = ParserStoppedMessage();
            }
        }
Beispiel #2
0
        /// <summary>
        /// The real deal
        /// </summary>
        /// <param name="mediator"></param>
        public ParseWordDlg(Mediator mediator)
        {
            m_mediator                  = mediator;
            m_xampleTrace               = new XAmpleTrace(mediator);
            m_hermitCrabTrace           = new HCTrace(mediator);
            m_parserTrace               = m_xampleTrace; // we'll start with the default one; it can get changed by the user
            m_cache                     = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            m_sLastWordUsedPropertyName = m_cache.DatabaseName + "ParseWordDlg-lastWordToTry";
            m_sWhileTracingFile         = Path.Combine(TransformPath, "WhileTracing.htm");
            m_sXAmpleSelectFile         = Path.Combine(Path.GetTempPath(), m_cache.DatabaseName + "XAmpleSelectFile.txt");

            m_connectionTimer          = new System.Windows.Forms.Timer();
            m_connectionTimer.Interval = 250;             // use a quarter of a second
            m_connectionTimer.Tick    += new EventHandler(m_connectionTimer_Tick);

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.Text = m_cache.DatabaseName + " - " + this.Text;
            // order is important between SetInitialWord and SetRootSite
            SetRootSite();
            SetInitialWord();

            InitHtmlControl();

            SetStrings();

            // HermitCrab does not currently support selected tracing
            if (m_cache.LangProject.MorphologicalDataOA.ActiveParser == "HC")
            {
                m_fParserCanDoSelectMorphs = false;
                m_cbDoSelectMorphs.Enabled = false;
            }

            if (FwApp.App != null)            // Could be null during testing
            {
                this.helpProvider = new System.Windows.Forms.HelpProvider();
                this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
                this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
                this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
            }
        }
Beispiel #3
0
        private void CreateResultPage(XDocument result)
        {
            string sOutput;

            if (result == null)
            {
                // It's an error message.
                sOutput = Path.GetTempFileName();
                using (var writer = new StreamWriter(sOutput))
                {
                    writer.WriteLine("<!DOCTYPE html>");
                    writer.WriteLine("<body>");
                    writer.WriteLine(ParserUIStrings.ksDidNotParse);
                    writer.WriteLine("</body>");
                    writer.WriteLine("</html>");
                }
            }
            else
            {
                IParserTrace trace = null;
                switch (m_cache.LanguageProject.MorphologicalDataOA.ActiveParser)
                {
                case "XAmple":
                    trace = new XAmpleTrace(m_mediator);
                    m_webPageInteractor.WordGrammarDebugger = new XAmpleWordGrammarDebugger(m_mediator, result);
                    break;

                case "HC":
                    trace = new HCTrace(m_mediator);
                    m_webPageInteractor.WordGrammarDebugger = null;
                    break;
                }

                Debug.Assert(trace != null);

                sOutput = trace.CreateResultPage(result, DoTrace);
            }
            var uri = new Uri(sOutput);

            m_htmlControl.URL = uri.AbsoluteUri;
        }
Beispiel #4
0
		/// <summary>
		/// The real deal
		/// </summary>
		/// <param name="mediator"></param>
		public ParseWordDlg(Mediator mediator)
		{
			m_mediator = mediator;
			m_xampleTrace = new XAmpleTrace(mediator);
			m_hermitCrabTrace = new HCTrace(mediator);
			m_parserTrace = m_xampleTrace; // we'll start with the default one; it can get changed by the user
			m_cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
			m_sLastWordUsedPropertyName = m_cache.DatabaseName + "ParseWordDlg-lastWordToTry";
			m_sWhileTracingFile = Path.Combine(TransformPath, "WhileTracing.htm");
			m_sXAmpleSelectFile = Path.Combine(Path.GetTempPath(), m_cache.DatabaseName + "XAmpleSelectFile.txt");

			m_connectionTimer = new System.Windows.Forms.Timer();
			m_connectionTimer.Interval = 250; // use a quarter of a second
			m_connectionTimer.Tick += new EventHandler(m_connectionTimer_Tick);

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.Text = m_cache.DatabaseName + " - " + this.Text;
			// order is important between SetInitialWord and SetRootSite
			SetRootSite();
			SetInitialWord();

			InitHtmlControl();

			SetStrings();

			// HermitCrab does not currently support selected tracing
			if (m_cache.LangProject.MorphologicalDataOA.ActiveParser == "HC")
			{
				m_fParserCanDoSelectMorphs = false;
				m_cbDoSelectMorphs.Enabled = false;
			}

			if(FwApp.App != null) // Could be null during testing
			{
				this.helpProvider = new System.Windows.Forms.HelpProvider();
				this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
				this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
				this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
			}
		}
Beispiel #5
0
		private void CreateResultPage(XDocument result)
		{
			string sOutput;
			if (result == null)
			{
				// It's an error message.
				sOutput = Path.GetTempFileName();
				using (var writer = new StreamWriter(sOutput))
				{
					writer.WriteLine("<!DOCTYPE html>");
					writer.WriteLine("<body>");
					writer.WriteLine(ParserUIStrings.ksDidNotParse);
					writer.WriteLine("</body>");
					writer.WriteLine("</html>");
				}
			}
			else
			{
				IParserTrace trace = null;
				switch (m_cache.LanguageProject.MorphologicalDataOA.ActiveParser)
				{
					case "XAmple":
						trace = new XAmpleTrace(m_mediator);
						m_webPageInteractor.WordGrammarDebugger = new XAmpleWordGrammarDebugger(m_mediator, result);
						break;
					case "HC":
						trace = new HCTrace(m_mediator);
						m_webPageInteractor.WordGrammarDebugger = null;
						break;
				}

				Debug.Assert(trace != null);

				sOutput = trace.CreateResultPage(result, DoTrace);
			}
			var uri = new Uri(sOutput);
			m_htmlControl.URL = uri.AbsoluteUri;
		}