Ejemplo n.º 1
0
		/// <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.
		}
Ejemplo n.º 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;
		}
Ejemplo n.º 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;
		}
Ejemplo n.º 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();
				}
			}
		}
Ejemplo n.º 5
0
		public bool OnAddToLexicon(object argument)
		{
			CheckDisposed();

			int ichMin;
			int ichLim;
			int hvo;
			int tag;
			int ws;
			ITsString tss;
			GetWordLimitsOfSelection(out ichMin, out ichLim, out hvo, out tag, out ws, out tss);
			if (ws == 0)
				ws = GetWsFromString(tss, ichMin, ichLim);
			if (ichLim > ichMin && ws == m_cache.DefaultVernWs)
			{
				ITsStrBldr tsb = tss.GetBldr();
				if (ichLim < tsb.Length)
					tsb.Replace(ichLim, tsb.Length, null, null);
				if (ichMin > 0)
					tsb.Replace(0, ichMin, null, null);
				ITsString tssForm = tsb.GetString();
				using (var dlg = new InsertEntryDlg())
				{
					dlg.SetDlgInfo(m_cache, tssForm, m_mediator);
					if (dlg.ShowDialog(this) == DialogResult.OK)
					{
						// is there anything special we want to do?
					}
				}
				return true;
			}
			return false;
		}
Ejemplo n.º 6
0
			private void SetupDlgToCreateEntry(InsertEntryDlg dlg, ITsString tssFullForm, FdoCache cache)
			{
				dlg.SetDlgInfo(cache, tssFullForm, m_sandbox.Mediator);
				int cMorphs = m_caches.DataAccess.get_VecSize(m_hvoSbWord, ktagSbWordMorphs);
				if (cMorphs == 1)
				{
					// Make this string the gloss of the dlg.
					ITsString tssGloss = m_sandbox.Caches.DataAccess.get_MultiStringAlt(
						m_sandbox.RootWordHvo, ktagSbWordGloss,
						m_sandbox.Caches.MainCache.DefaultAnalWs);
					int hvoSbPos = m_sandbox.Caches.DataAccess.get_ObjectProp(m_sandbox.RootWordHvo,
						ktagSbWordPos);
					int hvoRealPos = m_sandbox.Caches.RealHvo(hvoSbPos);
					dlg.Pos = hvoRealPos;
					dlg.TssGloss = tssGloss;
					// Also copy any other glosses we have.
					foreach (int ws in m_sandbox.Caches.MainCache.LangProject.CurAnalysisWssRS.HvoArray)
					{
						ITsString tss = m_sandbox.Caches.DataAccess.get_MultiStringAlt(m_sandbox.RootWordHvo, ktagSbWordGloss, ws);
						dlg.SetInitialGloss(ws, tss);
					}
				}
			}