PartOfSpeechUi provides UI-specific methods for the PartOfSpeech class.
Inheritance: CmPossibilityUi
Example #1
0
		/// <summary>
		/// Handle the context menu for inserting a POS.
		/// </summary>
		/// <param name="mediator"></param>
		/// <param name="classId"></param>
		/// <param name="hvoOwner"></param>
		/// <param name="flid"></param>
		/// <param name="insertionPosition"></param>
		/// <returns></returns>
		public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, int classId, int hvoOwner, int flid, int insertionPosition)
		{
			PartOfSpeechUi posUi = null;
			using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
			{
				FdoCache cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
				Debug.Assert(cache != null);
				var newOwner = cache.ServiceLocator.GetInstance<IPartOfSpeechRepository>().GetObject(hvoOwner);
				dlg.SetDlginfo(newOwner.OwningList, mediator, true, newOwner);
				switch (dlg.ShowDialog((Form)mediator.PropertyTable.GetValue("window")))
				{
					case DialogResult.OK: // Fall through.
					case DialogResult.Yes:
						posUi = new PartOfSpeechUi(dlg.SelectedPOS);
						mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
						break;
				}
			}
			return posUi;
		}
Example #2
0
        /// <summary>
        /// Handle the context menu for inserting a POS.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="classId"></param>
        /// <param name="hvoOwner"></param>
        /// <param name="flid"></param>
        /// <param name="insertionPosition"></param>
        /// <returns></returns>
        public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, uint classId, int hvoOwner, int flid, int insertionPosition)
        {
            PartOfSpeechUi posUi = null;

            using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
            {
                FdoCache cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
                Debug.Assert(cache != null);
                IPartOfSpeech newOwner = PartOfSpeech.CreateFromDBObject(cache, hvoOwner);
                dlg.SetDlginfo(newOwner.OwningList, mediator, true, newOwner);
                switch (dlg.ShowDialog((Form)mediator.PropertyTable.GetValue("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    posUi = new PartOfSpeechUi(dlg.SelectedPOS);
                    mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
                    break;
                }
            }
            return(posUi);
        }
Example #3
0
        /// <summary>
        /// Handle the context menu for inserting a POS.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="classId"></param>
        /// <param name="hvoOwner"></param>
        /// <param name="flid"></param>
        /// <param name="insertionPosition"></param>
        /// <returns></returns>
        public new static PartOfSpeechUi CreateNewUiObject(Mediator mediator, PropertyTable propertyTable, int classId, int hvoOwner, int flid, int insertionPosition)
        {
            PartOfSpeechUi posUi = null;

            using (MasterCategoryListDlg dlg = new MasterCategoryListDlg())
            {
                LcmCache cache = propertyTable.GetValue <LcmCache>("cache");
                Debug.Assert(cache != null);
                var newOwner = cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(hvoOwner);
                dlg.SetDlginfo(newOwner.OwningList, mediator, propertyTable, true, newOwner);
                switch (dlg.ShowDialog(propertyTable.GetValue <Form>("window")))
                {
                case DialogResult.OK:                         // Fall through.
                case DialogResult.Yes:
                    posUi = new PartOfSpeechUi(dlg.SelectedPOS);
                    mediator.SendMessage("JumpToRecord", dlg.SelectedPOS.Hvo);
                    break;
                }
            }
            return(posUi);
        }
Example #4
0
		private static CmObjectUi MakeUi(FdoCache cache, int hvo, int clsid)
		{
			IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache;
			// If we've encountered an object with this Clsid before, and this clsid isn't in
			// the switch below, the dictioanry will give us the appropriate clsid that IS in the
			// map, so the loop below will have only one iteration. Otherwise, we start the
			// search with the clsid of the object itself.
			int realClsid = m_subclasses.ContainsKey(clsid) ? m_subclasses[clsid] : clsid;
			// Each iteration investigates whether we have a CmObjectUi subclass that
			// corresponds to realClsid. If not, we move on to the base class of realClsid.
			// In this way, the CmObjectUi subclass we return is the one designed for the
			// closest base class of obj that has one.
			CmObjectUi result = null;
			while (result == null)
			{
				switch (realClsid)
				{
					// Todo: lots more useful cases.
					case WfiAnalysisTags.kClassId:
						result = new WfiAnalysisUi();
						break;
					case PartOfSpeechTags.kClassId:
						result = new PartOfSpeechUi();
						break;
					case CmPossibilityTags.kClassId:
						result = new CmPossibilityUi();
						break;
					case CmObjectTags.kClassId:
						result = new CmObjectUi();
						break;
					case LexPronunciationTags.kClassId:
						result = new LexPronunciationUi();
						break;
					case LexSenseTags.kClassId:
						result = new LexSenseUi();
						break;
					case LexEntryTags.kClassId:
						result = new LexEntryUi();
						break;
					case MoMorphSynAnalysisTags.kClassId:
						result = new MoMorphSynAnalysisUi();
						break;
					case MoStemMsaTags.kClassId:
						result = new MoStemMsaUi();
						break;
					case MoDerivAffMsaTags.kClassId:
						result = new MoDerivAffMsaUi();
						break;
					case MoInflAffMsaTags.kClassId:
						result = new MoInflAffMsaUi();
						break;
					case MoAffixAllomorphTags.kClassId:
					case MoStemAllomorphTags.kClassId:
						result = new MoFormUi();
						break;
					case ReversalIndexEntryTags.kClassId:
						result = new ReversalIndexEntryUi();
						break;
					case WfiWordformTags.kClassId:
						result = new WfiWordformUi();
						break;
					case WfiGlossTags.kClassId:
						result = new WfiGlossUi();
						break;
					default:
						realClsid = mdc.GetBaseClsId(realClsid);
						// This isn't needed because CmObject.kClassId IS 0.
						//					if (realClsid == 0)
						//					{
						//						// Somehow the class doesn't have CmObject in its inheritance path!
						//						Debug.Assert(false);
						//						// this may help make us more robust if this somehow happens.
						//						realClsid = (uint)CmObject.kClassId;
						//					}
						break;
				}
			}
			if (realClsid != clsid)
				m_subclasses[clsid] = realClsid;

			result.m_hvo = hvo;
			result.m_cache = cache;

			return result;
		}