Esempio n. 1
0
        private void LaunchRespellerDlgOnWord(ITsString tss)
        {
            if (tss == null || string.IsNullOrEmpty(tss.Text))
            {
                return;
            }

            var cache    = m_mediator.PropertyTable.GetValue("cache") as FdoCache;
            var wordform = WordformApplicationServices.GetWordformForForm(cache, tss);

            using (var luh = new RecordClerk.ListUpdateHelper(m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk))
            {
                // Launch the Respeller Dlg.
                using (var dlg = new RespellerDlg())
                {
                    var xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow;
                    if (dlg.SetDlgInfo(wordform, m_mediator, m_configurationParameters))
                    {
                        dlg.ShowDialog(xwindow);
                    }
                    else
                    {
                        MessageBox.Show(MEStrings.ksCannotRespellWordform);
                    }
                }
                //// We assume that RespellerDlg made all the necessary changes to relevant lists.
                //// no need to reload due to a propchange (e.g. change in paragraph contents).
                //luh.TriggerPendingReloadOnDispose = false;
            }
        }
Esempio n. 2
0
        private void LaunchRespellerDlgOnWord(ITsString tss)
        {
            if (tss == null || string.IsNullOrEmpty(tss.Text))
            {
                return;
            }
            FdoCache cache       = m_mediator.PropertyTable.GetValue("cache") as FdoCache;
            int      hvoWordform = WfiWordform.FindOrCreateWordform(cache, tss);

            if (hvoWordform == 0)
            {
                return;                 // paranoia.
            }
            IWfiWordform wf = WfiWordform.CreateFromDBObject(cache, hvoWordform);

            using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk))
            {
                // Launch the Respeller Dlg.
                using (RespellerDlg dlg = new RespellerDlg())
                {
                    XWindow xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow;
                    if (dlg.SetDlgInfo2(wf, m_mediator, m_configurationParameters))
                    {
                        dlg.ShowDialog(xwindow);
                    }
                    else
                    {
                        MessageBox.Show(MEStrings.ksCannotRespellWordform);
                    }
                }
                // We assume that RespellerDlg made all the necessary changes to relevant lists.
                // no need to reload due to a propchange (e.g. change in paragraph contents).
                luh.TriggerPendingReloadOnDispose = false;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Launch the Respeller dlg.
 /// </summary>
 /// <param name="argument">The xCore Command object.</param>
 /// <returns>true</returns>
 public bool OnLaunchRespellerDlg(object argument)
 {
     CheckDisposed();
     if (!InFriendliestTool)                     // See LT-8641.
     {
         LaunchRespellerDlgOnWord(ActiveWord());
         return(true);
     }
     using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk))
     {
         // Launch the Respeller Dlg.
         using (RespellerDlg dlg = new RespellerDlg())
         {
             XWindow xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow;
             if (dlg.SetDlgInfo(m_mediator, m_configurationParameters))
             {
                 dlg.ShowDialog(xwindow);
             }
             else
             {
                 MessageBox.Show(MEStrings.ksCannotRespellWordform);
             }
         }
         // We assume that RespellerDlg made all the necessary changes to relevant lists.
         // no need to reload due to a propchange (e.g. change in paragraph contents).
         luh.TriggerPendingReloadOnDispose = false;
     }
     return(true);
 }
Esempio n. 4
0
        /// <summary>
        /// Launch the Respeller dlg.
        /// </summary>
        /// <param name="argument">The xCore Command object.</param>
        /// <returns>true</returns>
        public bool OnLaunchRespellerDlg(object argument)
        {
            CheckDisposed();
            if (!InFriendliestTool)                     // See LT-8641.
            {
                LaunchRespellerDlgOnWord(ActiveWord());
                return(true);
            }
            var clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk;

            using (var luh = new RecordClerk.ListUpdateHelper(clerk))
            {
                var changesWereMade = false;
                // Launch the Respeller Dlg.
                using (var dlg = new RespellerDlg())
                {
                    var xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow;
                    if (dlg.SetDlgInfo(m_mediator, m_configurationParameters))
                    {
                        dlg.ShowDialog(xwindow);
                        changesWereMade = dlg.ChangesWereMade;
                    }
                    else
                    {
                        MessageBox.Show(MEStrings.ksCannotRespellWordform);
                    }
                }
                // The Respeller dialog can't make all necessary updates, since things like occurrence
                // counts depend on which texts are included, not just the data. So make sure we reload.
                luh.TriggerPendingReloadOnDispose = changesWereMade;
                if (changesWereMade)
                {
                    // further try to refresh occurrence counts.
                    var sda = clerk.VirtualListPublisher;
                    while (sda != null)
                    {
                        if (sda is ConcDecorator)
                        {
                            ((ConcDecorator)sda).Refresh();
                            break;
                        }
                        if (!(sda is DomainDataByFlidDecoratorBase))
                        {
                            break;
                        }
                        sda = ((DomainDataByFlidDecoratorBase)sda).BaseSda;
                    }
                }
            }
            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Initialize this as an IxCoreColleague
        /// </summary>
        /// <remarks> subclasses must call this from their Init.
        /// This was done, rather than providing an Init() here in the normal way,
        /// to drive home the point that the subclass must set m_fullyInitialized
        /// to true when it is fully initialized.</remarks>
        /// <param name="mediator"></param>
        /// <param name="configurationParameters"></param>
        protected void InitBase(Mediator mediator, XmlNode configurationParameters)
        {
            Debug.Assert(m_fullyInitialized == false, "No way we are fully initialized yet!");

            m_mediator = mediator;
            m_configurationParameters = configurationParameters;

            ReadParameters();

            RecordClerk clerk = ExistingClerk;

            if (clerk == null)
            {
                // NOTE: new clerks do not typically complete ReloadList()
                // until Clerk.ActivateUI() is set (eg. here in SetupDataContext()).
                // however, we should further delay loading the list
                // if the subclass is initializing sorters/filters.
                // so we use ListUpdateHelper below to delay reloading the list.
                clerk = Clerk;
                Debug.Assert(clerk != null);
            }
            // suspend any loading of the Clerk's list items until after a
            // subclass (possibly) initializes sorters/filters
            // in SetupDataContext()
            using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(clerk))
            {
                luh.ClearBrowseListUntilReload = true;
                clerk.UpdateOwningObjectIfNeeded();
                SetTreebarAvailability();
                AddPaneBar();

                // NB: It is critical that we get added *after* our RecordClerk,
                // so that it will get messages, for example about a change of cache, before we do.
                mediator.AddColleague(this);
                SetupDataContext();
            }
            // In case it hasn't yet been loaded, load it!  See LT-10185.
            if (!Clerk.ListLoadingSuppressed && Clerk.RequestedLoadWhileSuppressed)
            {
                Clerk.UpdateList(true, true);
            }
            ShowRecord();
        }
Esempio n. 6
0
        /// <summary>
        /// Initialize this as an IxCoreColleague
        /// </summary>
        /// <remarks> subclasses must call this from their Init.
        /// This was done, rather than providing an Init() here in the normal way,
        /// to drive home the point that the subclass must set m_fullyInitialized
        /// to true when it is fully initialized.</remarks>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="configurationParameters"></param>
        protected void InitBase(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            Debug.Assert(m_fullyInitialized == false, "No way we are fully initialized yet!");

            m_mediator                = mediator;
            m_propertyTable           = propertyTable;
            m_configurationParameters = configurationParameters;

            ReadParameters();

            RecordClerk clerk = ExistingClerk;
            bool        fClerkAlreadySuppressed = false;
            bool        fClerkWasCreated        = false;

            if (clerk == null)
            {
                // We do NOT want to load the list as part of creating the clerk.
                // At earliest, we want to do so only when the ListUpdateHelper is disposed,
                // after the clerk and list are sufficiently initialized (e.g., with saved sorting and filtering
                // information) to sort correctly. This is part of a fairly convoluted attempt to prevent
                // sorting the list repeatedly during startup, even though startup involves many events
                // that normally require it to be resorted.
                // In this case the clerk will be created with its list already in the ListLoadingSuppressed state,
                // and already set to indicate that loading is necessary when suppression ends;
                // we want to pass FALSE to the ListUpdateHelper constructor, however, to pretend that the
                // list was NOT suppressed when the helper was created, so it will duly be sorted when
                // the helper is disposed.
                fClerkWasCreated = true;
                clerk            = CreateClerk(false);
                Debug.Assert(clerk != null);
            }
            else
            {
                fClerkAlreadySuppressed = clerk.ListLoadingSuppressed;                 // If we didn't create the clerk, someone else might have suppressed it.
            }
            // suspend any loading of the Clerk's list items until after a
            // subclass (possibly) initializes sorters/filters
            // in SetupDataContext()
            bool didRestoreFromPersistence = false;

            using (var luh = new RecordClerk.ListUpdateHelper(clerk, fClerkAlreadySuppressed))
            {
                luh.ClearBrowseListUntilReload = true;
                clerk.UpdateOwningObjectIfNeeded();
                SetTreebarAvailability();
                AddPaneBar();

                //Historical comments here indicated that the Clerk should be processed by the mediator before the
                //view. This is handled by Priority now, RecordView is by default just after RecordClerk in the processing.
                mediator.AddColleague(this);
                SetupDataContext();
                // Only if it was just now created should we try to restore from what we persisted.
                // Otherwise (e.g., FWR-1128) we may miss changes made to the list in other tools.
                if (fClerkWasCreated)
                {
                    didRestoreFromPersistence = RestoreSortSequence();
                }
                if (didRestoreFromPersistence)
                {
                    luh.ListWasRestored();
                }
            }
            // In case it hasn't yet been loaded, load it!  See LT-10185.
            if (!didRestoreFromPersistence && !Clerk.ListLoadingSuppressed && Clerk.RequestedLoadWhileSuppressed)
            {
                Clerk.UpdateList(true, true);               // sluggishness culprit for LT-12844 was in here
            }
            Clerk.SetCurrentFromRelatedClerk();             // See if some other clerk wants to influence our current object.
            ShowRecord();
        }
		private void LaunchRespellerDlgOnWord(ITsString tss)
		{
			if (tss == null || string.IsNullOrEmpty(tss.Text))
				return;

			var cache = m_mediator.PropertyTable.GetValue("cache") as FdoCache;
			var wordform = WordformApplicationServices.GetWordformForForm(cache, tss);
			using (var luh = new RecordClerk.ListUpdateHelper(m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk))
			{
				// Launch the Respeller Dlg.
				using (var dlg = new RespellerDlg())
				{
					var xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow;
					if (dlg.SetDlgInfo(wordform, m_mediator, m_configurationParameters))
					{
						dlg.ShowDialog(xwindow);
					}
					else
					{
						MessageBox.Show(MEStrings.ksCannotRespellWordform);
					}
				}
				//// We assume that RespellerDlg made all the necessary changes to relevant lists.
				//// no need to reload due to a propchange (e.g. change in paragraph contents).
				//luh.TriggerPendingReloadOnDispose = false;
			}
		}
		/// <summary>
		/// Launch the Respeller dlg.
		/// </summary>
		/// <param name="argument">The xCore Command object.</param>
		/// <returns>true</returns>
		public bool OnLaunchRespellerDlg(object argument)
		{
			CheckDisposed();
			if (!InFriendliestTool)		// See LT-8641.
			{
				LaunchRespellerDlgOnWord(ActiveWord());
				return true;
			}
			var clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk;
			using (var luh = new RecordClerk.ListUpdateHelper(clerk))
			{
				var changesWereMade = false;
				// Launch the Respeller Dlg.
				using (var dlg = new RespellerDlg())
				{
					var xwindow = m_mediator.PropertyTable.GetValue("window") as XWindow;
					if (dlg.SetDlgInfo(m_mediator, m_configurationParameters))
					{
						dlg.ShowDialog(xwindow);
						changesWereMade = dlg.ChangesWereMade;
					}
					else
					{
						MessageBox.Show(MEStrings.ksCannotRespellWordform);
					}
				}
				// The Respeller dialog can't make all necessary updates, since things like occurrence
				// counts depend on which texts are included, not just the data. So make sure we reload.
				luh.TriggerPendingReloadOnDispose = changesWereMade;
				if (changesWereMade)
				{
					// further try to refresh occurrence counts.
					var sda = clerk.VirtualListPublisher;
					while (sda != null)
					{
						if (sda is ConcDecorator)
						{
							((ConcDecorator)sda).Refresh();
							break;
						}
						if (!(sda is DomainDataByFlidDecoratorBase))
							break;
						sda = ((DomainDataByFlidDecoratorBase) sda).BaseSda;
					}
				}
			}
			return true;
		}