/// <summary>
		/// Handles the xWorks message to insert a new lexical entry.
		/// Invoked by the RecordClerk
		/// </summary>
		/// <param name="argument">The xCore Command object.</param>
		/// <returns>true, if we handled the message, otherwise false, if there was an unsupported 'classname' parameter</returns>
		public bool OnDialogInsertItemInVector(object argument)
		{
			CheckDisposed();

			Debug.Assert(argument != null && argument is XCore.Command);
			string className = XmlUtils.GetOptionalAttributeValue(
				(argument as XCore.Command).Parameters[0],
				"className");
			if (className == null || className != "LexEntry")
				return false;

			using (InsertEntryDlg dlg = new InsertEntryDlg())
			{
				FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
				Debug.Assert(cache != null);
				dlg.SetDlgInfo(cache, m_mediator, m_persistProvider);
				if (dlg.ShowDialog(Form.ActiveForm) == DialogResult.OK)
				{
					ILexEntry entry;
					bool newby;
					dlg.GetDialogInfo(out entry, out newby);
					// No need for a PropChanged here because InsertEntryDlg takes care of that. (LT-3608)
					m_mediator.SendMessage("JumpToRecord", entry.Hvo);
				}
			}
			return true; // We "handled" the message, regardless of what happened.
		}
Exemple #2
0
		//methods

		public override ObjectLabel Execute()
		{
			// Make create lex entry dialog and invoke it.
			ObjectLabel result = null;
			using (InsertEntryDlg dlg = new InsertEntryDlg())
			{
				var morphType = GetMorphType();
				dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator,
					m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.Prefix : InsertEntryDlg.MorphTypeFilterType.Suffix);
				dlg.DisableAffixTypeMainPosAndSlot();
				if (dlg.ShowDialog() == DialogResult.OK)
				{
					bool fCreated;
					ILexEntry entry;
					dlg.GetDialogInfo(out entry, out fCreated);
					if (entry == null)
						throw new ArgumentNullException("Expected entry cannot be null", "entry");
					// TODO: what do to make sure it has an infl affix msa?
					// this just assumes it will
					bool fInflAffix = false;
					foreach (var msa in entry.MorphoSyntaxAnalysesOC)
					{
						if (msa is IMoInflAffMsa)
						{
							fInflAffix = true;
							break;
						}
					}
					if (!fInflAffix)
					{
						UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(DetailControlsStrings.ksUndoCreatingInflectionalAffixCategoryItem,
							DetailControlsStrings.ksRedoCreatingInflectionalAffixCategoryItem,
							m_cache.ActionHandlerAccessor,
							() => {
								var newby = m_cache.ServiceLocator.GetInstance<IMoInflAffMsaFactory>().Create();
								entry.MorphoSyntaxAnalysesOC.Add(newby);
							});
					}
					if (entry.MorphoSyntaxAnalysesOC.Count > 0)
						result = ObjectLabel.CreateObjectLabel(m_cache, entry.MorphoSyntaxAnalysesOC.First(), "");
				}
			}
			return result;
		}
Exemple #3
0
		//methods

		public override ObjectLabel Execute()
		{
			// Make create lex entry dialog and invoke it.
			ObjectLabel result = null;
			using (InsertEntryDlg dlg = new InsertEntryDlg())
			{
				IMoMorphType morphType = GetMorphType();
				dlg.SetDlgInfo(m_cache, morphType, MsaType.kInfl, m_slot, m_mediator,
					m_fPrefix ? InsertEntryDlg.MorphTypeFilterType.prefix : InsertEntryDlg.MorphTypeFilterType.suffix);
				dlg.DisableAffixTypeMainPosAndSlot();
				if (dlg.ShowDialog() == DialogResult.OK)
				{
					bool fCreated;
					int entryID;
					dlg.GetDialogInfo(out entryID, out fCreated);
					if (entryID <= 0)
						throw new ArgumentException("Expected entry ID to be greater than 0", "entryID");
					ILexEntry lex = LexEntry.CreateFromDBObject(m_cache, entryID);
					// TODO: what do to make sure it has an infl affix msa?
					// this just assumes it will
					bool fInflAffix = false;
					foreach (IMoMorphSynAnalysis msa in lex.MorphoSyntaxAnalysesOC)
					{
						if (msa is IMoInflAffMsa)
						{
							fInflAffix = true;
							break;
						}
					}
					if (!fInflAffix)
					{
						int hvoNew = m_cache.CreateObject((int)MoInflAffMsa.kClassId,
							lex.Hvo, (int)LexEntry.LexEntryTags.kflidMorphoSyntaxAnalyses, 0);
					}
					int[] hvos = lex.MorphoSyntaxAnalysesOC.HvoArray;
					if (hvos.Length > 0)
						result = ObjectLabel.CreateObjectLabel(m_cache, hvos[0], "");
				}
			}
			return result;
		}
Exemple #4
0
		protected override void btnInsert_Click(object sender, System.EventArgs e)
		{
			using (InsertEntryDlg dlg = new InsertEntryDlg())
			{
				string form = m_tbForm.Text.Trim();
				ITsString tssFormTrimmed = StringUtils.MakeTss(form, StringUtils.GetWsAtOffset(m_tbForm.Tss, 0));
				dlg.SetDlgInfo(m_cache, tssFormTrimmed, m_mediator);
				if (dlg.ShowDialog(this) == DialogResult.OK)
				{
					dlg.GetDialogInfo(out m_selEntryID, out m_fNewlyCreated);
					if (m_fNewlyCreated)
						m_hvoNewSense = dlg.NewSenseId;
					// If we ever decide not to simulate the btnOK click at this point, then
					// the new sense id will need to be handled by a subclass differently (ie,
					// being added to the list of senses maintained by LinkEntryOrSenseDlg,
					// the selected index into that list also being changed).
					HandleMatchingSelectionChanged();
					if (btnOK.Enabled)
						btnOK.PerformClick();
				}
			}
		}