Struct pairing a field ID with a TsString
예제 #1
0
		protected override void ResetMatches(string searchKey)
		{
			if (m_oldSearchKey == searchKey)
				return; // Nothing new to do, so skip it.

			// disable Go button until we rebuild our match list.
			m_btnOK.Enabled = false;
			m_oldSearchKey = searchKey;

			var ws = (IWritingSystem) m_cbWritingSystems.SelectedItem;
			int wsSelHvo = ws != null ? ws.Handle : 0;
			if (wsSelHvo == 0)
			{
				wsSelHvo = TsStringUtils.GetWsAtOffset(m_tbForm.Tss, 0);
				if (wsSelHvo == 0)
					return;
			}

			if (m_oldSearchKey != string.Empty || searchKey != string.Empty)
				StartSearchAnimation();

			ITsString tss = m_tsf.MakeString(searchKey, wsSelHvo);
			var field = new SearchField(RnGenericRecTags.kflidTitle, tss);
			m_matchingObjectsBrowser.SearchAsync(new[] { field });
		}
예제 #2
0
		protected override bool IsFieldMultiString(SearchField field)
		{
			switch (field.Flid)
			{
				case RnGenericRecTags.kflidTitle:
					return false;
			}

			throw new ArgumentException("Unrecognized field.", "field");
		}
		protected override bool IsFieldMultiString(SearchField field)
		{
			switch (field.Flid)
			{
				case ReversalIndexEntryTags.kflidReversalForm:
					return true;
			}

			throw new ArgumentException("Unrecognized field.", "field");
		}
예제 #4
0
		protected override bool IsFieldMultiString(SearchField field)
		{
			switch (field.Flid)
			{
				case WfiWordformTags.kflidForm:
					return true;
			}

			throw new ArgumentException("Unrecognized field.", "field");
		}
예제 #5
0
		protected override IEnumerable<ITsString> GetStrings(SearchField field, ICmObject obj)
		{
			var rec = (IRnGenericRec) obj;
			switch (field.Flid)
			{
				case RnGenericRecTags.kflidTitle:
					var title = rec.Title;
					if (title != null && title.Length > 0)
						yield return title;
					break;

				default:
					throw new ArgumentException("Unrecognized field.", "field");
			}
		}
예제 #6
0
		protected override IEnumerable<ITsString> GetStrings(SearchField field, ICmObject obj)
		{
			var wf = (IWfiWordform) obj;

			int ws = field.String.get_WritingSystemAt(0);
			switch (field.Flid)
			{
				case WfiWordformTags.kflidForm:
					var form = wf.Form.StringOrNull(ws);
					if (form != null && form.Length > 0)
						yield return form;
					break;

				default:
					throw new ArgumentException("Unrecognized field.", "field");
			}
		}
예제 #7
0
		protected override IEnumerable<ITsString> GetStrings(SearchField field, ICmObject obj)
		{
			var entry = (ILexEntry) obj;

			int ws = field.String.get_WritingSystemAt(0);
			switch (field.Flid)
			{
				case LexEntryTags.kflidCitationForm:
					var cf = entry.CitationForm.StringOrNull(ws);
					if (cf != null && cf.Length > 0)
						yield return cf;
					break;

				case LexEntryTags.kflidLexemeForm:
					var lexemeForm = entry.LexemeFormOA;
					if (lexemeForm != null)
					{
						var formOfLexemeForm = lexemeForm.Form.StringOrNull(ws);
						if (formOfLexemeForm != null && formOfLexemeForm.Length > 0)
							yield return formOfLexemeForm;
					}
					break;

				case LexEntryTags.kflidAlternateForms:
					foreach (IMoForm form in entry.AlternateFormsOS)
					{
						var af = form.Form.StringOrNull(ws);
						if (af != null && af.Length > 0)
							yield return af;
					}
					break;

				case LexSenseTags.kflidGloss:
					foreach (ILexSense sense in entry.SensesOS)
					{
						var gloss = sense.Gloss.StringOrNull(ws);
						if (gloss != null && gloss.Length > 0)
							yield return gloss;
					}
					break;

				default:
					throw new ArgumentException("Unrecognized field.", "field");
			}
		}
예제 #8
0
		protected override void InitializeMatchingObjects(FdoCache cache, Mediator mediator)
		{
			var xnWindow = (XmlNode) m_mediator.PropertyTable.GetValue("WindowConfiguration");
			var configNode = xnWindow.SelectSingleNode("controls/parameters/guicontrol[@id=\"WordformsBrowseView\"]/parameters");

			SearchEngine searchEngine = SearchEngine.Get(mediator, "WordformGoSearchEngine", () => new WordformGoSearchEngine(cache));

			m_matchingObjectsBrowser.Initialize(cache, FontHeightAdjuster.StyleSheetFromMediator(mediator), mediator, configNode,
				searchEngine);

			// start building index
			var wsObj = (IWritingSystem) m_cbWritingSystems.SelectedItem;
			if (wsObj != null)
			{
				ITsString tssForm = m_tsf.MakeString(string.Empty, wsObj.Handle);
				var field = new SearchField(WfiWordformTags.kflidForm, tssForm);
				m_matchingObjectsBrowser.SearchAsync(new[] { field });
			}
		}
예제 #9
0
		protected override void InitializeMatchingObjects(FdoCache cache, Mediator mediator)
		{
			var xnWindow = (XmlNode) m_mediator.PropertyTable.GetValue("WindowConfiguration");
			XmlNode configNode = xnWindow.SelectSingleNode("controls/parameters/guicontrol[@id=\"matchingReversalEntries\"]/parameters");

			var searchEngine = (ReversalEntrySearchEngine)SearchEngine.Get(mediator, "ReversalEntryGoSearchEngine-" + m_reveralIndex.Hvo,
				() => new ReversalEntrySearchEngine(cache, m_reveralIndex));
			searchEngine.FilteredEntryHvos = m_FilteredReversalEntryHvos;

			m_matchingObjectsBrowser.Initialize(cache, FontHeightAdjuster.StyleSheetFromMediator(mediator), mediator, configNode,
				searchEngine, m_cache.ServiceLocator.WritingSystemManager.Get(m_reveralIndex.WritingSystem));

			// start building index
			var wsObj = (IWritingSystem) m_cbWritingSystems.SelectedItem;
			if (wsObj != null)
			{
				ITsString tss = m_tsf.MakeString(string.Empty, wsObj.Handle);
				var field = new SearchField(ReversalIndexEntryTags.kflidReversalForm, tss);
				m_matchingObjectsBrowser.SearchAsync(new[] { field });
			}
		}
예제 #10
0
		/// <summary>
		/// Determines if the specified field is a multi-string or multi-unicode field.
		/// </summary>
		protected abstract bool IsFieldMultiString(SearchField field);
예제 #11
0
			protected override bool IsFieldMultiString(SearchField field)
			{
				return true;
			}
예제 #12
0
		private void UpdateResults(SearchField firstField, IEnumerable<int> results)
		{
			ITsString firstSearchStr = firstField.String;
			// if the firstSearchStr is null we can't get its writing system
			RecordSorter sorter = null;
			if (firstSearchStr != null)
			{
				int ws = firstSearchStr.get_WritingSystemAt(0);
				sorter = CreateFindResultSorter(firstSearchStr, ws);
			}
			int[] hvos;
			if (sorter != null)
			{
				// Convert each ICmObject in results to a IManyOnePathSortItem, and sort
				// using the sorter.
				var records = new ArrayList();
				foreach (int hvo in results.Where(hvo => StartingObject == null || StartingObject.Hvo != hvo))
					records.Add(new ManyOnePathSortItem(hvo, null, null));
				sorter.Sort(records);
				hvos = records.Cast<IManyOnePathSortItem>().Select(i => i.KeyObject).ToArray();
			}
			else
			{
				hvos = results.Where(hvo => StartingObject == null || StartingObject.Hvo != hvo).ToArray();
			}

			int count = hvos.Length;
			int prevIndex = m_bvMatches.SelectedIndex;
			int prevHvo = prevIndex == -1 ? 0 : m_bvMatches.AllItems[prevIndex];
			m_listPublisher.CacheVecProp(m_cache.LanguageProject.LexDbOA.Hvo, hvos);
			TabStop = count > 0;
			// Disable the list so that it doesn't steal the focus (LT-9481)
			m_bvMatches.Enabled = false;
			try
			{
				// LT-6366
				if (count == 0)
				{
					if (m_bvMatches.BrowseView.IsHandleCreated)
						m_bvMatches.SelectedIndex = -1;
					m_selObject = null;
				}
				else
				{
					int newIndex = 0;
					var allItems = m_bvMatches.AllItems; // This is an important optimization; each call marshals the whole list!
					for (int i = 0; i < allItems.Count; i++)
					{
						if (allItems[i] == prevHvo)
						{
							newIndex = i;
							break;
						}
					}
					if (m_bvMatches.BrowseView.IsHandleCreated)
						m_bvMatches.SelectedIndex = newIndex;
					m_selObject = m_cache.ServiceLocator.GetObject(allItems[newIndex]);
					FireSelectionChanged();
				}
			}
			finally
			{
				m_bvMatches.Enabled = true;
			}

			if (!m_searchEngine.IsBusy && SearchCompleted != null)
				SearchCompleted(this, new EventArgs());
		}
예제 #13
0
 /// <summary>
 /// Gets the searchable strings of an object.
 /// </summary>
 protected abstract IEnumerable <ITsString> GetStrings(SearchField field, ICmObject obj);
예제 #14
0
		protected override bool IsFieldMultiString(SearchField field)
		{
			switch (field.Flid)
			{
				case LexEntryTags.kflidCitationForm:
				case LexEntryTags.kflidLexemeForm:
				case LexEntryTags.kflidAlternateForms:
				case LexSenseTags.kflidGloss:
					return true;
			}
			throw new ArgumentException("Unrecognized field.", "field");
		}
예제 #15
0
 /// <summary>
 /// Determines if the specified field is a multi-string or multi-unicode field.
 /// </summary>
 protected abstract bool IsFieldMultiString(SearchField field);
예제 #16
0
			protected override IEnumerable<ITsString> GetStrings(SearchField field, ICmObject obj)
			{
				var entry = (ILexEntry) obj;

				int ws = field.String.get_WritingSystemAt(0);
				switch (field.Flid)
				{
					case LexEntryTags.kflidLexemeForm:
						if (entry.LexemeFormOA != null)
						{
							var lf = entry.LexemeFormOA.Form.StringOrNull(ws);
							if (lf != null && lf.Length > 0)
								yield return lf;
						}
						break;

					case LexSenseTags.kflidGloss:
						foreach (ILexSense sense in entry.SensesOS)
						{
							var gloss = sense.Gloss.StringOrNull(ws);
							if (gloss != null && gloss.Length > 0)
								yield return gloss;
						}
						break;
				}
			}
예제 #17
0
		/// <summary>
		/// Builds the search index.
		/// </summary>
		private int BuildIndex(int i, SearchField field, Func<bool> isSearchCanceled)
		{
			if (m_searchableObjs == null)
				m_searchableObjs = GetSearchableObjects();

			for (; i < m_searchableObjs.Count; i++)
			{
				if (isSearchCanceled())
					break;
				foreach (ITsString tss in GetStrings(field, m_searchableObjs[i]))
					m_searcher.Add(m_searchableObjs[i].Hvo, field.Flid, tss);
			}
			return i;
		}
예제 #18
0
		/// <summary>
		/// Gets the searchable strings of an object.
		/// </summary>
		protected abstract IEnumerable<ITsString> GetStrings(SearchField field, ICmObject obj);
예제 #19
0
		protected override void ResetMatches(string searchKey)
		{
			if (m_oldSearchKey == searchKey)
				return; // Nothing new to do, so skip it.

			// disable Go button until we rebuild our match list.
			m_btnOK.Enabled = false;
			m_oldSearchKey = searchKey;

			var wsObj = (IWritingSystem) m_cbWritingSystems.SelectedItem;
			if (wsObj == null)
				return;

			if (m_oldSearchKey != string.Empty || searchKey != string.Empty)
				StartSearchAnimation();

			ITsString tss = m_tsf.MakeString(searchKey, wsObj.Handle);
			var field = new SearchField(ReversalIndexEntryTags.kflidReversalForm, tss);
			m_matchingObjectsBrowser.SearchAsync(new[] { field });
		}
예제 #20
0
		/// <summary>
		/// Reset the list of matching items.
		/// </summary>
		/// <param name="searchKey"></param>
		protected override void ResetMatches(string searchKey)
		{
			var wsObj = (IWritingSystem) m_cbWritingSystems.SelectedItem;
			int wsSelHvo = wsObj != null ? wsObj.Handle : 0;

			string form;
			int vernWs;
			if (!GetSearchKey(wsSelHvo, searchKey, out form, out vernWs))
			{
				var ws = TsStringUtils.GetWsAtOffset(m_tbForm.Tss, 0);
				if (!GetSearchKey(ws, searchKey, out form, out vernWs))
					return;
				wsSelHvo = ws;
			}

			if (m_oldSearchKey == searchKey && m_oldSearchWs == wsSelHvo)
				return; // Nothing new to do, so skip it.

			if (m_oldSearchKey != string.Empty || searchKey != string.Empty)
				StartSearchAnimation();

			// disable Go button until we rebuild our match list.
			m_btnOK.Enabled = false;
			m_oldSearchKey = searchKey;
			m_oldSearchWs = wsSelHvo;

			ITsString tssForm = m_tsf.MakeString(form ?? string.Empty, vernWs);
			var field = new SearchField(WfiWordformTags.kflidForm, tssForm);
			m_matchingObjectsBrowser.SearchAsync(new[] { field });
		}
예제 #21
0
        private void UpdateResults(SearchField firstField, IEnumerable <int> results)
        {
            ITsString firstSearchStr = firstField.String;
            // if the firstSearchStr is null we can't get its writing system
            RecordSorter sorter = null;

            if (firstSearchStr != null)
            {
                int ws = firstSearchStr.get_WritingSystemAt(0);
                sorter = CreateFindResultSorter(firstSearchStr, ws);
            }
            int[] hvos;
            if (sorter != null)
            {
                // Convert each ICmObject in results to a IManyOnePathSortItem, and sort
                // using the sorter.
                var records = new ArrayList();
                foreach (int hvo in results.Where(hvo => StartingObject == null || StartingObject.Hvo != hvo))
                {
                    records.Add(new ManyOnePathSortItem(hvo, null, null));
                }
                sorter.Sort(records);
                hvos = records.Cast <IManyOnePathSortItem>().Select(i => i.KeyObject).ToArray();
            }
            else
            {
                hvos = results.Where(hvo => StartingObject == null || StartingObject.Hvo != hvo).ToArray();
            }

            int count     = hvos.Length;
            int prevIndex = m_bvMatches.SelectedIndex;
            int prevHvo   = prevIndex == -1 ? 0 : m_bvMatches.AllItems[prevIndex];

            m_listPublisher.CacheVecProp(m_cache.LanguageProject.LexDbOA.Hvo, hvos);
            TabStop = count > 0;
            // Disable the list so that it doesn't steal the focus (LT-9481)
            m_bvMatches.Enabled = false;
            try
            {
                // LT-6366
                if (count == 0)
                {
                    if (m_bvMatches.BrowseView.IsHandleCreated)
                    {
                        m_bvMatches.SelectedIndex = -1;
                    }
                    m_selObject = null;
                }
                else
                {
                    int newIndex = 0;
                    var allItems = m_bvMatches.AllItems;                     // This is an important optimization; each call marshals the whole list!
                    for (int i = 0; i < allItems.Count; i++)
                    {
                        if (allItems[i] == prevHvo)
                        {
                            newIndex = i;
                            break;
                        }
                    }
                    if (m_bvMatches.BrowseView.IsHandleCreated)
                    {
                        m_bvMatches.SelectedIndex = newIndex;
                    }
                    m_selObject = m_cache.ServiceLocator.GetObject(allItems[newIndex]);
                    FireSelectionChanged();
                }
            }
            finally
            {
                m_bvMatches.Enabled = true;
            }

            if (!m_searchEngine.IsBusy && SearchCompleted != null)
            {
                SearchCompleted(this, new EventArgs());
            }
        }