Inheritance: SIL.FieldWorks.LexText.Controls.EntryGoDlg
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries.
		/// </summary>
		protected override void HandleChooser()
		{
			ILexRefType lrt = LexRefType.CreateFromDBObject(m_cache, m_obj.OwnerHVO);
			int type = lrt.MappingType;
			BaseGoDlg dlg = null;
			switch ((LexRefType.MappingTypes)type)
			{
				case LexRefType.MappingTypes.kmtSenseTree:
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
					break;
				case LexRefType.MappingTypes.kmtEntryTree:
					dlg = new GoDlg();
					break;
				case LexRefType.MappingTypes.kmtEntryOrSenseTree:
					dlg = new LinkEntryOrSenseDlg();
					break;
			}
			Debug.Assert(dlg != null);
			WindowParams wp = new WindowParams();

			//This method is only called when we are Replacing the
			//tree root of a Whole/Part lexical relation
			wp.m_title = String.Format(LexEdStrings.ksReplaceXEntry);
			wp.m_btnText = LexEdStrings.ks_Replace;
			wp.m_label = LexEdStrings.ksFind_;
			dlg.SetDlgInfo(m_cache, wp, m_mediator);
			dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
			if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				TargetHvo = dlg.SelectedID;
			dlg.Dispose();
		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries.
		/// </summary>
		protected override void HandleChooser()
		{
			ILexRefType lrt = LexRefType.CreateFromDBObject(m_cache, m_obj.OwnerHVO);
			int type = lrt.MappingType;
			BaseGoDlg dlg = null;
			switch ((LexRefType.MappingTypes)type)
			{
				case LexRefType.MappingTypes.kmtSenseSequence:
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
					break;
				case LexRefType.MappingTypes.kmtEntrySequence:
					dlg = new GoDlg();
					break;
				case LexRefType.MappingTypes.kmtEntryOrSenseSequence:
					dlg = new LinkEntryOrSenseDlg();
					break;
			}
			Debug.Assert(dlg != null);
			WindowParams wp = new WindowParams();
			wp.m_title = String.Format(LexEdStrings.ksIdentifyXEntry,
				lrt.Name.AnalysisDefaultWritingSystem);
			wp.m_label = LexEdStrings.ksFind_;
			wp.m_btnText = LexEdStrings.ks_Add; //for collection relation of items always have an Add button
			dlg.SetDlgInfo(m_cache, wp, m_mediator);
			dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
			if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				AddItem(dlg.SelectedID);
			dlg.Dispose();

		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries.
		/// </summary>
		protected override void HandleChooser()
		{
			ILexRefType lrt = (ILexRefType)m_obj.Owner;
			LexRefTypeTags.MappingTypes type = (LexRefTypeTags.MappingTypes)lrt.MappingType;
			BaseGoDlg dlg = null;
			try
			{
				switch (type)
				{
					case LexRefTypeTags.MappingTypes.kmtSensePair:
					case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair: // Sense pair with different Forward/Reverse names
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryPair:
					case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair: // Entry pair with different Forward/Reverse names
						dlg = new EntryGoDlg();
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryOrSensePair:
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair: // Entry or sense pair with different Forward/Reverse
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = false;
						break;
				}
				Debug.Assert(dlg != null);
				var wp = new WindowParams();
				//on creating Pair Lexical Relation have an Add button and Add in the title bar
				if (Target == null)
				{
					wp.m_title = String.Format(LexEdStrings.ksIdentifyXEntry, lrt.Name.BestAnalysisAlternative.Text);
					wp.m_btnText = LexEdStrings.ks_Add;
				}
				else //Otherwise we are Replacing the item
				{
					wp.m_title = String.Format(LexEdStrings.ksReplaceXEntry);
					wp.m_btnText = LexEdStrings.ks_Replace;
				}

				dlg.SetDlgInfo(m_cache, wp, m_mediator);
				dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				{
					if (dlg.SelectedObject != null)
					{
						AddItem(dlg.SelectedObject);
						// it is possible that the previous update has caused the data tree to refresh
						if (!IsDisposed)
							m_atomicRefView.RootBox.Reconstruct(); // view is somehow too complex for auto-update.
					}
				}
			}
			finally
			{
				if (dlg != null)
					dlg.Dispose();
			}
		}
		protected override void HandleChooser()
		{
			using (var dlg = new LinkEntryOrSenseDlg())
			{
				var wp = new WindowParams {m_title = LexEdStrings.ksIdentifySense, m_btnText = LexEdStrings.ksSetReversal};
				dlg.SetDlgInfo(m_cache, wp, m_mediator);
				dlg.SelectSensesOnly = true;
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
					AddItem(dlg.SelectedObject);
			}
		}
Beispiel #5
0
		protected override void HandleChooser()
		{
			Debug.Assert(m_obj.ClassID == LexEntry.kclsidLexEntry);
			using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
			{
				ILexEntry le = m_obj as ILexEntry;
				dlg.SetDlgInfo(m_obj.Cache, m_mediator, le);
				String str = ShowHelp.RemoveSpaces(this.Slice.Label);
				dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense-" + str);
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
					AddItem(dlg.SelectedID);

			}
		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries or senses.
		/// </summary>
		protected override void HandleChooser()
		{
			using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
			{
				WindowParams wp = new WindowParams();
				wp.m_title = LexEdStrings.ksIdentifySense;
				wp.m_label = LexEdStrings.ksFind_;
				wp.m_btnText = LexEdStrings.ksSetReversal;
				dlg.SetDlgInfo(m_cache, wp, m_mediator);
				dlg.SelectSensesOnly = true;
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
					AddItem(dlg.SelectedID);
			}
		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries.
		/// </summary>
		protected override void HandleChooser()
		{
			var lrt = (ILexRefType)m_obj.Owner;
			var type = (LexRefTypeTags.MappingTypes)lrt.MappingType;
			BaseGoDlg dlg = null;
			string sTitle = string.Empty;
			try
			{
				switch (type)
				{
					case LexRefTypeTags.MappingTypes.kmtSenseCollection:
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
						sTitle = String.Format(LexEdStrings.ksIdentifyXSense,
							lrt.Name.BestAnalysisAlternative.Text);
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryCollection:
						dlg = new EntryGoDlg();
						sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntry,
							lrt.Name.BestAnalysisAlternative.Text);
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseCollection:
						dlg = new LinkEntryOrSenseDlg();
						sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense,
							lrt.Name.BestAnalysisAlternative.Text);
						break;
				}
				Debug.Assert(dlg != null);
				var wp = new WindowParams { m_title = sTitle, m_btnText = LexEdStrings.ks_Add };
				dlg.SetDlgInfo(m_cache, wp, m_mediator);
				dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK && dlg.SelectedObject != null)
				{
					if (!((ILexReference)m_obj).TargetsRS.Contains(dlg.SelectedObject))
						AddItem(dlg.SelectedObject);
				}
			}
			finally
			{
				if (dlg != null)
					dlg.Dispose();
			}
		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries.
		/// </summary>
		protected override void HandleChooser()
		{
			ILexRefType lrt = (ILexRefType)m_obj.Owner;
			int type = lrt.MappingType;
			BaseGoDlg dlg = null;
			try
			{
				switch ((LexRefTypeTags.MappingTypes)type)
				{
					case LexRefTypeTags.MappingTypes.kmtSenseTree:
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryTree:
						dlg = new EntryGoDlg();
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree:
						dlg = new LinkEntryOrSenseDlg();
						break;
				}
				Debug.Assert(dlg != null);
				var wp = new WindowParams { m_title = String.Format(LexEdStrings.ksReplaceXEntry), m_btnText = LexEdStrings.ks_Replace };
				//This method is only called when we are Replacing the
				//tree root of a Whole/Part lexical relation
				dlg.SetDlgInfo(m_cache, wp, m_mediator);
				dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				{
					if (dlg.SelectedObject != null)
						AddItem(dlg.SelectedObject);
				}
			}
			finally
			{
				if (dlg != null)
					dlg.Dispose();
			}
		}
		/// <summary>
		/// This method is called when we are creating a new lexical relation slice.
		/// If the user selects an item it's hvo is returned.
		/// Otherwise 0 is returned and the lexical relation should not be created.
		/// </summary>
		/// <param name="lrt"></param>
		/// <returns></returns>
		private int GetChildObjectHvo(ILexRefType lrt)
		{
			int hvoFirst = 0;
			BaseEntryGoDlg dlg = null;
			string sTitle = "";
			switch ((LexRefType.MappingTypes)lrt.MappingType)
			{
				case LexRefType.MappingTypes.kmtEntryOrSensePair:
				case LexRefType.MappingTypes.kmtEntryOrSenseAsymmetricPair: // Entry or sense pair with different Forward/Reverse
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = false;
					sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense,
						 lrt.Name.BestAnalysisAlternative.Text);
					break;

				case LexRefType.MappingTypes.kmtSenseCollection:
				case LexRefType.MappingTypes.kmtSensePair:
				case LexRefType.MappingTypes.kmtSenseAsymmetricPair: // Sense pair with different Forward/Reverse names
				case LexRefType.MappingTypes.kmtSenseSequence:
				case LexRefType.MappingTypes.kmtSenseTree:
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
					sTitle = String.Format(LexEdStrings.ksIdentifyXSense,
						lrt.Name.BestAnalysisAlternative.Text);
					break;

				case LexRefType.MappingTypes.kmtEntryCollection:
				case LexRefType.MappingTypes.kmtEntryPair:
				case LexRefType.MappingTypes.kmtEntryAsymmetricPair: // Entry pair with different Forward/Reverse names
				case LexRefType.MappingTypes.kmtEntrySequence:
				case LexRefType.MappingTypes.kmtEntryTree:
					dlg = new GoDlg();
					sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntry,
						lrt.Name.BestAnalysisAlternative.Text);
					break;

				case LexRefType.MappingTypes.kmtEntryOrSenseCollection:
				case LexRefType.MappingTypes.kmtEntryOrSenseSequence:
				case LexRefType.MappingTypes.kmtEntryOrSenseTree:
					dlg = new LinkEntryOrSenseDlg();
					sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense,
						lrt.Name.BestAnalysisAlternative.Text);
					break;
				default:
					Debug.Assert(lrt.MappingType == (int)LexRefType.MappingTypes.kmtSenseAsymmetricPair ||
						lrt.MappingType == (int)LexRefType.MappingTypes.kmtSenseTree);
					return 0;
			}
			Debug.Assert(dlg != null);
			WindowParams wp = new WindowParams();
			wp.m_title = sTitle;
			wp.m_label = LexEdStrings.ksFind_;
			wp.m_btnText = LexEdStrings.ks_Add;

			// Don't display the current entry in the list of matching entries.  See LT-2611.
			ICmObject objEntry = this.Object;
			while (objEntry.ClassID == LexSense.kclsidLexSense)
				objEntry = CmObject.CreateFromDBObject(m_cache, objEntry.OwnerHVO);
			Debug.Assert(objEntry.ClassID == LexEntry.kclsidLexEntry);
			dlg.StartingEntry = objEntry as ILexEntry;

			dlg.SetDlgInfo(m_cache, wp, Mediator);
			dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
			if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				hvoFirst = dlg.SelectedID;
			dlg.Dispose();
			return hvoFirst;
		}
		/// <summary>
		/// This method is called when we are creating a new lexical relation slice.
		/// If the user selects an item it's hvo is returned.
		/// Otherwise 0 is returned and the lexical relation should not be created.
		/// </summary>
		/// <param name="lrt"></param>
		/// <returns></returns>
		private int GetRootObjectHvo(ILexRefType lrt)
		{
			int hvoFirst = 0;
			BaseEntryGoDlg dlg = null;
			switch ((LexRefType.MappingTypes)lrt.MappingType)
			{
				case LexRefType.MappingTypes.kmtSenseAsymmetricPair:
				case LexRefType.MappingTypes.kmtSenseTree:
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
					break;
				case LexRefType.MappingTypes.kmtEntryAsymmetricPair:
				case LexRefType.MappingTypes.kmtEntryTree:
					dlg = new GoDlg();
					break;
				case LexRefType.MappingTypes.kmtEntryOrSenseAsymmetricPair:
				case LexRefType.MappingTypes.kmtEntryOrSenseTree:
					dlg = new LinkEntryOrSenseDlg();
					break;
				default:
					Debug.Assert(lrt.MappingType == (int)LexRefType.MappingTypes.kmtSenseAsymmetricPair ||
						lrt.MappingType == (int)LexRefType.MappingTypes.kmtSenseTree);
					return 0;
			}
			Debug.Assert(dlg != null);
			WindowParams wp = new WindowParams();
			//wp.m_title = String.Format(LexEdStrings.ksIdentifyXEntry,
			//   lrt.Name.AnalysisDefaultWritingSystem);
			wp.m_title = String.Format(LexEdStrings.ksIdentifyXEntry,
				lrt.ReverseName.BestAnalysisAlternative.Text);
			wp.m_label = LexEdStrings.ksFind_;
			//wp.m_btnText = LexEdStrings.ks_Link;
			wp.m_btnText = LexEdStrings.ks_Add;
			dlg.SetDlgInfo(m_cache, wp, Mediator);
			dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
			if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				hvoFirst = dlg.SelectedID;
			dlg.Dispose();
			return hvoFirst;
		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries or senses.
		/// </summary>
		protected override void HandleChooser()
		{
			Debug.Assert(m_flid == (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes ||
				m_flid == (int)LexEntryRef.LexEntryRefTags.kflidPrimaryLexemes);
			if (m_flid == (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes)
			{
				using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
				{
					ILexEntry le = null;
					if (m_obj.ClassID == LexEntry.kclsidLexEntry)
					{
						// filter this entry from the list.
						le = m_obj as ILexEntry;
					}
					else
					{
						// assume the owner is the entry (e.g. owner of LexEntryRef)
						int hvoEntry = m_cache.GetOwnerOfObjectOfClass(m_obj.Hvo, LexEntry.kclsidLexEntry);
						if (hvoEntry != 0)
							le = LexEntry.CreateFromDBObject(m_cache, hvoEntry);
					}
					dlg.SetDlgInfo(m_cache, m_mediator, le);
					String str = ShowHelp.RemoveSpaces(this.Slice.Label);
					dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense-" + str);
					if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
						AddItem(dlg.SelectedID);
				}
			}
			else if (m_flid == (int)LexEntryRef.LexEntryRefTags.kflidPrimaryLexemes)
			{
				string displayWs = "analysis vernacular";
				if (m_configurationNode != null)
				{
					XmlNode node = m_configurationNode.SelectSingleNode("deParams");
					if (node != null)
						displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
				}
				ILexEntryRef ler = m_obj as ILexEntryRef;
				Debug.Assert(ler != null);
				List<int> candidates = new List<int>();
				candidates.AddRange(ler.ComponentLexemesRS.HvoArray);
				ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates,
					m_displayNameProperty, displayWs);
				using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null,
					labels, "PrimaryLexemes", m_cache, ler.PrimaryLexemesRS.HvoArray, false))

				{
					chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);	// may set TextParamHvo

					chooser.Text = "Choose where to show subentry";

					//chooser.ReplaceTreeView(Mediator, "WordformsBrowseView");

					chooser.InitializeExtras(null,Mediator);
					chooser.AddLink("Add a Component...", ReallySimpleListChooser.LinkType.kDialogLink,
						new AddComponentChooserCommand(m_cache, false, null, m_mediator, m_obj, FindForm()));
					DialogResult res = chooser.ShowDialog();
					if (DialogResult.Cancel == res)
						return;
					if (chooser.ChosenHvos != null)
						SetItems(chooser.ChosenHvos);
				}
			}
		}
		public override ObjectLabel Execute()
		{
			ObjectLabel result = null;
			if (m_ler != null)
			{
				using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
				{
					ILexEntry le = null;
					// assume the owner is the entry (e.g. owner of LexEntryRef)
					int hvoEntry = m_cache.GetOwnerOfObjectOfClass(m_ler.Hvo, LexEntry.kclsidLexEntry);
					if (hvoEntry != 0)
						le = LexEntry.CreateFromDBObject(m_cache, hvoEntry);
					dlg.SetDlgInfo(m_cache, m_mediator, le);
					dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense");
					if (dlg.ShowDialog(m_form) == DialogResult.OK)
					{
						int hvo = dlg.SelectedID;
						if (hvo != 0 && !m_ler.ComponentLexemesRS.Contains(hvo))
							m_ler.ComponentLexemesRS.Append(hvo);
					}
				}
			}
			return result;
		}
		/// <summary>
		/// Override method to handle launching of a chooser for selecting lexical entries.
		/// </summary>
		protected override void HandleChooser()
		{
			ILexRefType lrt = LexRefType.CreateFromDBObject(m_cache, m_obj.OwnerHVO);
			LexRefType.MappingTypes type = (LexRefType.MappingTypes)lrt.MappingType;
			BaseGoDlg dlg = null;
			switch (type)
			{
				case LexRefType.MappingTypes.kmtSensePair:
				case LexRefType.MappingTypes.kmtSenseAsymmetricPair: // Sense pair with different Forward/Reverse names
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
					break;
				case LexRefType.MappingTypes.kmtEntryPair:
				case LexRefType.MappingTypes.kmtEntryAsymmetricPair: // Entry pair with different Forward/Reverse names
					dlg = new GoDlg();
					break;
				case LexRefType.MappingTypes.kmtEntryOrSensePair:
				case LexRefType.MappingTypes.kmtEntryOrSenseAsymmetricPair: // Entry or sense pair with different Forward/Reverse
					dlg = new LinkEntryOrSenseDlg();
					(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = false;
					break;
			}
			Debug.Assert(dlg != null);
			WindowParams wp = new WindowParams();
			//on creating Pair Lexical Relation have an Add button and Add in the title bar
			if ( TargetHvo == 0 )
			{
				wp.m_title = String.Format(LexEdStrings.ksIdentifyXEntry,
				lrt.Name.AnalysisDefaultWritingSystem);
				wp.m_btnText = LexEdStrings.ks_Add;
			}
			else //Otherwise we are Replacing the item
			{
				wp.m_title = String.Format(LexEdStrings.ksReplaceXEntry);
				wp.m_btnText = LexEdStrings.ks_Replace;
			}

			wp.m_label = LexEdStrings.ksFind_;

			dlg.SetDlgInfo(m_cache, wp, m_mediator);
			dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
			if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
				TargetHvo = dlg.SelectedID;
			dlg.Dispose();
		}
		/// <summary>
		/// This method is called when we are creating a new lexical relation slice.
		/// If the user selects an item it's hvo is returned.
		/// Otherwise 0 is returned and the lexical relation should not be created.
		/// </summary>
		/// <param name="lrt"></param>
		/// <returns></returns>
		private ICmObject GetChildObject(ILexRefType lrt)
		{
			ICmObject first = null;
			EntryGoDlg dlg = null;
			string sTitle = string.Empty;
			try
			{
				switch ((LexRefTypeTags.MappingTypes)lrt.MappingType)
				{
					case LexRefTypeTags.MappingTypes.kmtEntryOrSensePair:
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair:
						// Entry or sense pair with different Forward/Reverse
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = false;
						sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense, lrt.Name.BestAnalysisAlternative.Text);
						break;

					case LexRefTypeTags.MappingTypes.kmtSenseCollection:
					case LexRefTypeTags.MappingTypes.kmtSensePair:
					case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair:
					// Sense pair with different Forward/Reverse names
					case LexRefTypeTags.MappingTypes.kmtSenseSequence:
					case LexRefTypeTags.MappingTypes.kmtSenseTree:
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
						sTitle = String.Format(LexEdStrings.ksIdentifyXSense, lrt.Name.BestAnalysisAlternative.Text);
						break;

					case LexRefTypeTags.MappingTypes.kmtEntryCollection:
					case LexRefTypeTags.MappingTypes.kmtEntryPair:
					case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair:
					// Entry pair with different Forward/Reverse names
					case LexRefTypeTags.MappingTypes.kmtEntrySequence:
					case LexRefTypeTags.MappingTypes.kmtEntryTree:
						dlg = new EntryGoDlg();
						sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntry, lrt.Name.BestAnalysisAlternative.Text);
						break;

					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseCollection:
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseSequence:
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree:
						dlg = new LinkEntryOrSenseDlg();
						sTitle = String.Format(LexEdStrings.ksIdentifyXLexEntryOrSense, lrt.Name.BestAnalysisAlternative.Text);
						break;
					default:
						Debug.Assert(lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair || lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree);
						return null;
				}
				Debug.Assert(dlg != null);
				var wp = new WindowParams { m_title = sTitle, m_btnText = LexEdStrings.ks_Add };

				// Don't display the current entry in the list of matching entries.  See LT-2611.
				ICmObject objEntry = this.Object;
				while (objEntry.ClassID == LexSenseTags.kClassId)
					objEntry = objEntry.Owner;
				Debug.Assert(objEntry.ClassID == LexEntryTags.kClassId);
				dlg.StartingEntry = objEntry as ILexEntry;

				dlg.SetDlgInfo(m_cache, wp, Mediator);
				dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
					first = dlg.SelectedObject;
				return first;
			}
			finally
			{
				if (dlg != null)
					dlg.Dispose();
			}
		}
		/// <summary>
		/// This method is called when we are creating a new lexical relation slice.
		/// If the user selects an item it's hvo is returned.
		/// Otherwise 0 is returned and the lexical relation should not be created.
		/// </summary>
		/// <param name="lrt"></param>
		/// <returns></returns>
		private ICmObject GetRootObject(ILexRefType lrt)
		{
			ICmObject first = null;
			EntryGoDlg dlg = null;
			try
			{
				switch ((LexRefTypeTags.MappingTypes)lrt.MappingType)
				{
					case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair:
					case LexRefTypeTags.MappingTypes.kmtSenseTree:
						dlg = new LinkEntryOrSenseDlg();
						(dlg as LinkEntryOrSenseDlg).SelectSensesOnly = true;
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair:
					case LexRefTypeTags.MappingTypes.kmtEntryTree:
						dlg = new EntryGoDlg();
						break;
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair:
					case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree:
						dlg = new LinkEntryOrSenseDlg();
						break;
					default:
						Debug.Assert(lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair || lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree);
						return null;
				}
				Debug.Assert(dlg != null);
				var wp = new WindowParams { m_title = String.Format(LexEdStrings.ksIdentifyXEntry, lrt.ReverseName.BestAnalysisAlternative.Text), m_btnText = LexEdStrings.ks_Add };
				dlg.SetDlgInfo(m_cache, wp, Mediator);
				dlg.SetHelpTopic("khtpChooseLexicalRelationAdd");
				if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
					first = dlg.SelectedObject;
				return first;
			}
			finally
			{
				if (dlg != null)
					dlg.Dispose();
			}
		}
		protected override void HandleChooser()
		{
			if (m_flid == LexEntryRefTags.kflidComponentLexemes)
			{
				using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
				{
					ILexEntry le = null;
					if (m_obj.ClassID == LexEntryTags.kClassId)
					{
						// filter this entry from the list.
						le = m_obj as ILexEntry;
					}
					else
					{
						// assume the owner is the entry (e.g. owner of LexEntryRef)
						le = m_obj.OwnerOfClass<ILexEntry>();
					}
					dlg.SetDlgInfo(m_cache, m_mediator, le);
					String str = ShowHelp.RemoveSpaces(this.Slice.Label);
					dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense-" + str);
					if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
						AddItem(dlg.SelectedObject);
				}
			}
			else if (m_flid == LexEntryRefTags.kflidPrimaryLexemes)
			{
				string displayWs = "analysis vernacular";
				if (m_configurationNode != null)
				{
					XmlNode node = m_configurationNode.SelectSingleNode("deParams");
					if (node != null)
						displayWs = XmlUtils.GetAttributeValue(node, "ws", "analysis vernacular").ToLower();
				}
				ILexEntryRef ler = m_obj as ILexEntryRef;
				Debug.Assert(ler != null);
				var labels = ObjectLabel.CreateObjectLabels(m_cache, ler.ComponentLexemesRS.Cast<ICmObject>(),
					m_displayNameProperty, displayWs);
				using (ReallySimpleListChooser chooser = new ReallySimpleListChooser(null,
					labels, "PrimaryLexemes", m_cache, ler.PrimaryLexemesRS.Cast<ICmObject>(),
					false, m_mediator.HelpTopicProvider))
				{
					chooser.HideDisplayUsageCheckBox();
					chooser.SetObjectAndFlid(m_obj.Hvo, m_flid);	// may set TextParamHvo
					chooser.Text = LexEdStrings.ksChooseWhereToShowSubentry;
					chooser.SetHelpTopic(Slice.GetChooserHelpTopicID());
					chooser.InitializeExtras(null, Mediator);
					chooser.AddLink(LexEdStrings.ksAddAComponent, ReallySimpleListChooser.LinkType.kDialogLink,
						new AddPrimaryLexemeChooserCommand(m_cache, false, null, m_mediator, m_obj, FindForm()));
					DialogResult res = chooser.ShowDialog();
					if (DialogResult.Cancel == res)
						return;
					if (chooser.ChosenObjects != null)
						SetItems(chooser.ChosenObjects);
				}
			}
			else
			{
				string fieldName = m_obj.Cache.MetaDataCacheAccessor.GetFieldName(m_flid);
				Debug.Assert(m_obj is ILexEntry || m_obj is ILexSense);
				switch(fieldName)
				{
					case "ComplexFormEntries":
						using (var dlg = new EntryGoDlg())
						{
							dlg.StartingEntry = m_obj as ILexEntry ?? (m_obj as ILexSense).Entry;
							dlg.SetDlgInfo(m_cache, null, m_mediator);
							String str = ShowHelp.RemoveSpaces(Slice.Label);
							dlg.SetHelpTopic("khtpChooseComplexFormEntryOrSense-" + str);
							dlg.SetOkButtonText(LexEdStrings.ksMakeComponentOf);
							if (dlg.ShowDialog(FindForm()) == DialogResult.OK)
							{
								try
								{
									UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoAddComplexForm, LexEdStrings.ksRedoAddComplexForm,
										m_obj.Cache.ActionHandlerAccessor,
										() => ((ILexEntry)dlg.SelectedObject).AddComponent(m_obj));
								}
								catch (ArgumentException)
								{
									MessageBoxes.ReportLexEntryCircularReference((ILexEntry) dlg.SelectedObject, m_obj, false);
								}
							}
						}
						break;
					case "VisibleComplexFormEntries": // obsolete?
					case "Subentries":
						HandleChooserForBackRefs(fieldName, false);
						break;
					case "VisibleComplexFormBackRefs":
						HandleChooserForBackRefs(fieldName, true);
						break;
					default:
						Debug.Fail("EntrySequenceReferenceLauncher should only be used for variants, components, or complex forms");
						break;
				}
			}
		}
		public override ObjectLabel Execute()
		{
			ObjectLabel result = null;
			if (m_lexEntryRef != null)
			{
				using (LinkEntryOrSenseDlg dlg = new LinkEntryOrSenseDlg())
				{
					ILexEntry le = null;
					// assume the owner is the entry (e.g. owner of LexEntryRef)
					le = m_lexEntryRef.OwnerOfClass<ILexEntry>();
					dlg.SetDlgInfo(m_cache, m_mediator, le);
					dlg.SetHelpTopic("khtpChooseLexicalEntryOrSense");
					if (dlg.ShowDialog(m_parentWindow) == DialogResult.OK)
					{
						ICmObject obj = dlg.SelectedObject;
						if (obj != null)
						{
							if (!m_lexEntryRef.PrimaryLexemesRS.Contains(obj))
							{
								try
								{
									UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(
										LexEdStrings.ksUndoCreatingEntry,
										LexEdStrings.ksRedoCreatingEntry,
										Cache.ActionHandlerAccessor,
										() =>
											{
												if (!m_lexEntryRef.ComponentLexemesRS.Contains(obj))
													m_lexEntryRef.ComponentLexemesRS.Add(obj);
												m_lexEntryRef.PrimaryLexemesRS.Add(obj);
											});
								}
								catch (ArgumentException)
								{
									MessageBoxes.ReportLexEntryCircularReference((ILexEntry) m_lexEntryRef.Owner, obj, true);
								}
							}
						}
					}
				}
			}
			return result;
		}