private ILexSense MakeSense(ILexEntry lme, string gloss)
		{
			var sense = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create();
			lme.SensesOS.Add(sense);
			sense.Gloss.AnalysisDefaultWritingSystem = Cache.TsStrFactory.MakeString(gloss, Cache.DefaultAnalWs);
			return sense;
		}
示例#2
0
		/// <summary>
		/// Set up the dlg in preparation to showing it.
		/// </summary>
		/// <param name="cache">FDO cache.</param>
		/// <param name="mediator">Mediator used to restore saved siz and location info.</param>
		/// <param name="startingEntry">Entry that cannot be used as a match in this dlg.</param>
		public void SetDlgInfo(FdoCache cache, Mediator mediator, ILexEntry startingEntry)
		{
			CheckDisposed();

			Debug.Assert(startingEntry != null);
			m_startingEntry = startingEntry;

			SetDlgInfo(cache, null, mediator);

			// Relocate remaining three buttons.
			Point pt = m_btnHelp.Location;
			// Make the Help btn 20 off the right edge of the dlg
			pt.X = Width - m_btnHelp.Width - 20;
			m_btnHelp.Location = pt;
			// Make the Cancel btn 10 from the left of the Help btn
			pt.X -= (m_btnClose.Width + 10);
			m_btnClose.Location = pt;
			// Make the Merge Entry btn 10 from the left of the Cancel btn.
			pt.X -= (m_btnOK.Width + 10);
			m_btnOK.Location = pt;
			SetBottomMessage();

			SetHelpTopic("khtpMergeEntry");

			//LT-3017 Launch the dialog with the Lexeme that is currently selected.
			Form = m_startingEntry.HomographForm;
		}
		private ILexEntryRef MakeLexEntryRef(ILexEntry ownerEntry, int refType)
		{
			ILexEntryRef result = null;
			result = Cache.ServiceLocator.GetInstance<ILexEntryRefFactory>().Create();
			ownerEntry.EntryRefsOS.Add(result);
			result.RefType = refType;
			return result;
		}
示例#4
0
		/// <summary>
		/// Report failure to make target a component of parent. If startedFromComplex is true, the user is looking
		/// at parent, and tried to make target a component. Otherwise, the user is looking at target, and
		/// tried to make parent a complex form.
		/// </summary>
		public static void ReportLexEntryCircularReference(ILexEntry parent, ICmObject target, bool startedFromComplex)
		{
			var itemString = target is ILexEntry ? FwCoreDlgs.ksEntry : FwCoreDlgs.ksSense;
			var msgTemplate = startedFromComplex ? FwCoreDlgs.ksComponentIsComponent : FwCoreDlgs.ksComplexFormIsComponent;
			var startedFrom = startedFromComplex ? parent.HeadWord.Text : target.ShortName;
			var msg = String.Format(msgTemplate, itemString, startedFrom);
			MessageBox.Show(Form.ActiveForm, msg, FwCoreDlgs.ksWhichIsComponent, MessageBoxButtons.OK, MessageBoxIcon.Error);
		}
示例#5
0
		/// <summary>
		/// Create a new sense and add it to the given entry.
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="sandboxMSA"></param>
		/// <param name="gloss"></param>
		/// <returns></returns>
		public ILexSense Create(ILexEntry entry, SandboxGenericMSA sandboxMSA, ITsString gloss)
		{
			var sense = new LexSense();
			entry.SensesOS.Add(sense);
			sense.SandboxMSA = sandboxMSA;

			if (gloss != null)
			{
				sense.Gloss.set_String(gloss.get_WritingSystemAt(0), gloss);
			}
			return sense;
		}
示例#6
0
		/// <summary>
		/// Create a new sense and add it to the given entry.
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="sandboxMSA"></param>
		/// <param name="gloss">string form of gloss, will be put in DefaultAnalysis ws</param>
		/// <returns></returns>
		public ILexSense Create(ILexEntry entry, SandboxGenericMSA sandboxMSA, string gloss)
		{
			// Handle gloss.
			if (!string.IsNullOrEmpty(gloss))
			{
				var defAnalWs = entry.Cache.DefaultAnalWs;
				var gls = entry.Cache.TsStrFactory.MakeString(gloss, defAnalWs);

				return Create(entry, sandboxMSA, gls);
			}

			return Create(entry, sandboxMSA, (ITsString)null);
		}
		/// <summary>
		/// It's convenient to test pretty much all these functions with one set of data.
		/// </summary>
		///
		public override void FixtureSetup()
		{
			base.FixtureSetup();
			m_wsVern = Cache.DefaultVernWs;
			m_wsAnalysis = Cache.DefaultAnalWs;
			m_hc = Cache.ServiceLocator.GetInstance<HomographConfiguration>();
			UndoableUnitOfWorkHelper.Do("undoit", "redoit", m_actionHandler,
				() =>
					{
						m_kick = MakeEntry("kick", "strike with foot");
						m_kickS1 = m_kick.SensesOS[0];
						m_rightCorrect = MakeEntry("right", "correct");
						m_rightCorrectS2 = MakeSense(m_rightCorrect, "morally perfect");
						m_rightDirection = MakeEntry("right", "turn right");
						m_rightDirectionS1 = m_rightDirection.SensesOS[0];
					});
		}
		private void SetupForLexSenseFactoryCreate(out int germanWsId, out ITsString tssGermanGloss,
			out ILexEntry entry, out ILexSenseFactory lexSenseFactory, out SandboxGenericMSA msa)
		{
			germanWsId = Cache.WritingSystemFactory.GetWsFromStr("de");
			Cache.LangProject.AnalysisWritingSystems.Add(
				Cache.WritingSystemFactory.get_EngineOrNull(germanWsId) as IWritingSystem);
			var lexFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
			tssGermanGloss = Cache.TsStrFactory.MakeString("da", germanWsId);
			entry = lexFactory.Create();
			lexSenseFactory = Cache.ServiceLocator.GetInstance<ILexSenseFactory>();
			msa = new SandboxGenericMSA
			{
				MainPOS =
					Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Where(
						pos => pos.Name.AnalysisDefaultWritingSystem.Text == "noun")
						.Cast<IPartOfSpeech>()
						.FirstOrDefault(),
				MsaType = MsaType.kStem
			};
		}
示例#9
0
		/// ------------------------------------------------------------------------------------
		internal PaLexEntry(ILexEntry lxEntry)
		{
			var svcloc = lxEntry.Cache.ServiceLocator;

			DateCreated = lxEntry.DateCreated;
			DateModified = lxEntry.DateModified;
			//ExcludeAsHeadword = lxEntry.ExcludeAsHeadword; remove
			ExcludeAsHeadword = false; // MDL: remove when IPaLexEntry is updated
			// ShowMainEntryIn = lxEntry.ShowMainEntryIn.Select(x => new PaLexShowMainEntryIn(x)).ToList(); // MDL: uncomment when IPaLexEntry is updated

			ImportResidue = lxEntry.ImportResidue.Text;

			xPronunciations = lxEntry.PronunciationsOS.Select(x => new PaLexPronunciation(x)).ToList();
			xSenses = lxEntry.SensesOS.Select(x => new PaLexSense(x)).ToList();
			xComplexForms = lxEntry.ComplexFormEntries.Select(x => PaMultiString.Create(x.LexemeFormOA.Form, svcloc)).ToList();
			xAllomorphs = lxEntry.AllAllomorphs.Select(x => PaMultiString.Create(x.Form, svcloc)).ToList();

			xLexemeForm = PaMultiString.Create(lxEntry.LexemeFormOA.Form, svcloc);
			xMorphType = PaCmPossibility.Create(lxEntry.PrimaryMorphType);
			xCitationForm = PaMultiString.Create(lxEntry.CitationForm, svcloc);
			xNote = PaMultiString.Create(lxEntry.Comment, svcloc);
			xLiteralMeaning = PaMultiString.Create(lxEntry.LiteralMeaning, svcloc);
			xBibliography = PaMultiString.Create(lxEntry.Bibliography, svcloc);
			xRestrictions = PaMultiString.Create(lxEntry.Restrictions, svcloc);
			xSummaryDefinition = PaMultiString.Create(lxEntry.SummaryDefinition, svcloc);
			xVariantOfInfo = lxEntry.VariantEntryRefs.Select(x => new PaVariantOfInfo(x)).ToList();
			xVariants = lxEntry.VariantFormEntryBackRefs.Select(x => new PaVariant(x)).ToList();
			xGuid = lxEntry.Guid;

			if (lxEntry.EtymologyOA != null)
				xEtymology = PaMultiString.Create(lxEntry.EtymologyOA.Form, svcloc);

			xComplexFormInfo = (from eref in lxEntry.EntryRefsOS
								let pcfi = PaComplexFormInfo.Create(eref)
								where pcfi != null
								select pcfi).ToList();
		}
示例#10
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (components != null)
				{
					components.Dispose();
				}
				if (matchingEntries != null)
				{
					if (matchingEntries is MatchingEntries)
					{
						(matchingEntries as MatchingEntries).SearchingChanged -= new EventHandler(matchingEntries_SearchingChanged);
						(matchingEntries as MatchingEntries).RestoreFocus -= new EventHandler(matchingEntries_RestoreFocus);
						(matchingEntries as MatchingEntries).SelectionChanged -= new SIL.FieldWorks.Common.Utils.FwSelectionChangedEventHandler(this.matchingEntries_SelectionChanged);
					}
					matchingEntries.Dispose();
				}

			}
			m_types = null;
			matchingEntries = null;
			m_startingEntry = null;

			base.Dispose(disposing);
		}
示例#11
0
		private void SwapAllomorphWithLexeme(ILexEntry entry, IMoForm allomorph, Command cmd)
		{
			using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_dataEntryForm.Cache, cmd))
			{
				entry.AlternateFormsOS.InsertAt(entry.LexemeFormOA, allomorph.IndexInOwner);
				entry.LexemeFormOA = allomorph;
			}
		}
        /// <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);
                    }
                }
            }
        }
		/// <summary>
		/// extracts the variant and component from the dialog, depending upon whether we're
		/// called from an "Insert Variant" or "Variant Of..." context.
		/// </summary>
		/// <param name="variant"></param>
		/// <param name="componentLexeme"></param>
		private void GetVariantAndComponentAndSelectedEntryType(out ILexEntry variant, out IVariantComponentLexeme componentLexeme, out ILexEntryType selectedEntryType)
		{
			variant = null;
			componentLexeme = null;
			if (m_fBackRefToVariant)
			{
				// in "Insert Variant" contexts,
				// we're calling the dialog from the component lexeme, so consider SelectedID as the variant.
				componentLexeme = m_startingEntry;
				variant = LexEntry.CreateFromDBObject(m_cache, SelectedID);
			}
			else
			{
				// in "Variant of..." contexts,
				// we're calling the dialog from the variant, so consider SelectedID the componentLexeme.
				variant = m_startingEntry;
				componentLexeme = CmObject.CreateFromDBObject(m_cache, SelectedID) as IVariantComponentLexeme;
			}
			if (m_fGetVariantEntryTypeFromTreeCombo)
				selectedEntryType = LexEntryType.CreateFromDBObject(m_cache, SelectedVariantEntryTypeHvo);
			else
				selectedEntryType = null;
		}
示例#14
0
		private static MockSelection GetValidMockSelection(ILexEntry entry)
		{
			var sel = new MockSelection();
			sel.TypeToReturn = VwSelType.kstText;
			sel.EndHvo = sel.AnchorHvo = entry.Hvo;
			sel.EndTag = sel.AnchorTag = LexEntryTags.kflidRestrictions; // arbitrary in this case
			sel.EndIch = 2;
			sel.AnchorIch = 5;
			return sel;
		}
示例#15
0
			public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
			{
				if (Entry == null) // only do it once, or we get a stack overflow
					NonUndoableUnitOfWorkHelper.DoSomehow(Parent.m_actionHandler, () => { Entry = Parent.MakeEntry("another entry"); });
			}
示例#16
0
		static private void SplitCircumfixIntoLeftAndRightAllomorphs(FdoCache cache,
			ILexEntry entry, ITsString tssLexemeForm, ILexSense sense)
		{
			string sLeftMember;
			string sRightMember;
			if (!GetCircumfixLeftAndRightParts(cache, tssLexemeForm, out sLeftMember, out sRightMember))
				return;
			// Create left and right allomorphs
			int wsVern = StringUtils.GetWsAtOffset(tssLexemeForm, 0);
			IMoMorphType mmtPrefix;
			IMoMorphType mmtSuffix;
			IMoMorphType mmtInfix;
			MoMorphType.GetMajorAffixMorphTypes(cache, out mmtPrefix, out mmtSuffix, out mmtInfix);
			int clsidForm;
			MoMorphTypeCollection mmtCol = new MoMorphTypeCollection(cache);
			IMoMorphType mmt = MoMorphType.FindMorphType(cache, mmtCol, ref sLeftMember, out clsidForm);
			if ((mmt.Hvo != mmtPrefix.Hvo) &&
				(mmt.Hvo != mmtInfix.Hvo))
				mmt = mmtPrefix; // force a prefix if it's neither a prefix nor an infix
			IMoForm allomorph = MoForm.CreateAllomorph(entry, sense.MorphoSyntaxAnalysisRA,
				StringUtils.MakeTss(sLeftMember, wsVern), mmt, false);
			mmt = MoMorphType.FindMorphType(cache, mmtCol, ref sRightMember, out clsidForm);
			if ((mmt.Hvo != mmtInfix.Hvo) &&
				(mmt.Hvo != mmtSuffix.Hvo))
				mmt = mmtSuffix; // force a suffix if it's neither a suffix nor an infix
			allomorph = MoForm.CreateAllomorph(entry, sense.MorphoSyntaxAnalysisRA,
				StringUtils.MakeTss(sRightMember, wsVern), mmt, false);
		}
示例#17
0
 /// <summary>
 /// Static version for cases where we can't afford to create the object.
 /// Note that the name is now somewhat dubious...This shows citation form if present
 /// otherwise lexeme form, otherwise question marks. Affix markers are added.
 /// </summary>
 /// <param name="entry"></param>
 /// <param name="wsVern"></param>
 /// <returns></returns>
 public static string CitationFormWithAffixTypeStaticForWs(ILexEntry entry, int wsVern)
 {
     return(CitationFormWithAffixTypeStaticForWs(entry, wsVern, DefaultHomographString()));
 }
示例#18
0
 /// <summary>
 /// The final fall-backin making a homograph form, we try the first alternate form.
 /// (Why not any others??)
 /// </summary>
 internal static string FirstAlternateForm(ILexEntry entry, int wsVern)
 {
     return(FirstAlternateForm(entry, wsVern, DefaultHomographString()));
 }
示例#19
0
 internal static string LexemeFormStaticForWs(ILexEntry entry, int wsVern)
 {
     return(LexemeFormStaticForWs(entry, wsVern, DefaultHomographString()));
 }
示例#20
0
 /// <summary>
 /// Same as ShortName, but ignores Citation form.
 /// </summary>
 internal static string LexemeFormStatic(ILexEntry entry)
 {
     return(LexemeFormStaticForWs(entry, entry.Cache.DefaultVernWs));
 }
示例#21
0
 /// <summary>
 /// Static version for avoiding creating actual object.
 /// </summary>
 public static string ShortName1StaticForWs(ILexEntry entry, int wsVern)
 {
     return(ShortName1StaticForWs(entry, wsVern, DefaultHomographString()));
 }
示例#22
0
 /// <summary>
 /// Static version for avoiding creating actual object.
 /// </summary>
 public static string ShortName1Static(ILexEntry entry)
 {
     return(ShortName1StaticForWs(entry, entry.Cache.DefaultVernWs));
 }
示例#23
0
 /// <summary>
 /// Get what would be produced for the headword of the specified entry in the specified WS,
 /// if it had the specified homograph number. (This is useful when overriding homograph
 /// numbers because items are omitted in a particular publication.) Use the specified default
 /// Citation Form if no Cf or Lf is present in the entry, and return an empty string for the
 /// whole method if there is no real or default Cf.
 /// </summary>
 public static ITsString HeadWordForWsAndHn(ILexEntry entry, int wsVern, int nHomograph, string defaultCf)
 {
     return(HeadWordForWsAndHn(entry, wsVern, nHomograph, defaultCf, HomographConfiguration.HeadwordVariant.Main));
 }
示例#24
0
		IMoForm CreateNewForm(ILexEntry parent, int clsid)
		{
			switch (clsid)
			{
				case MoAffixProcessTags.kClassId:
					return parent.Services.GetInstance<IMoAffixProcessFactory>().Create();

				case MoAffixAllomorphTags.kClassId:
					return parent.Services.GetInstance<IMoAffixAllomorphFactory>().Create();

				case MoStemAllomorphTags.kClassId:
					return parent.Services.GetInstance<IMoStemAllomorphFactory>().Create();
			}
			return null;
		}
示例#25
0
		/// <summary>
		/// Create a new sense and add it to the given entry.
		/// </summary>
		/// <param name="entry"></param>
		/// <param name="dummyMSA"></param>
		/// <param name="gloss"></param>
		/// <returns></returns>
		public static ILexSense CreateSense(ILexEntry entry, DummyGenericMSA dummyMSA, string gloss)
		{
			ILexSense sense = (ILexSense)entry.SensesOS.Append(new LexSense());
			(sense as LexSense).DummyMSA = dummyMSA;

			// Handle gloss.
			if (gloss != null && gloss.Length > 0)
			{
				if (gloss.Length > 256)
				{
					System.Windows.Forms.MessageBox.Show(Strings.ksTruncatingGloss, Strings.ksWarning,
						System.Windows.Forms.MessageBoxButtons.OK,
						System.Windows.Forms.MessageBoxIcon.Warning);
					gloss = gloss.Substring(0, 256);
				}
				sense.Gloss.AnalysisDefaultWritingSystem = gloss;
			}

			return sense;
		}
示例#26
0
        private void SetupLexEntryAndSense(string formLexEntry, string senseGloss, string partOfSpeech, out ILexEntry lexEntry1_Entry, out ILexSense lexEntry1_Sense1)
        {
            ITsString tssLexEntryForm = StringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs);
            int       clsidForm;
            // create a sense with a matching gloss
            DummyGenericMSA dummyMsa       = new DummyGenericMSA();
            int             hvoSenseMsaPos = m_sandbox.GetComboItemHvo(InterlinLineChoices.kflidWordPos, 0, partOfSpeech);

            dummyMsa.MainPOS = hvoSenseMsaPos;
            lexEntry1_Entry  = LexEntry.CreateEntry(Cache,
                                                    MoMorphType.FindMorphType(Cache, new MoMorphTypeCollection(Cache), ref formLexEntry, out clsidForm), tssLexEntryForm,
                                                    senseGloss, dummyMsa);
            lexEntry1_Sense1 = lexEntry1_Entry.SensesOS[0];
        }
示例#27
0
		private string GetLexReferenceName(ILexEntry lexEntry, ILexReference lexRef, out ILexEntry parentEntry)
		{
			parentEntry = null;
			ILexRefType lexRefType = lexRef.OwnerOfClass<ILexRefType>();
			string name = lexRefType.ShortName;
			if (string.IsNullOrEmpty(name))
				name = lexRefType.Abbreviation.BestAnalysisAlternative.Text;
			var mappingType = (LexRefTypeTags.MappingTypes) lexRefType.MappingType;
			switch (mappingType)
			{
				case LexRefTypeTags.MappingTypes.kmtSenseTree:
				case LexRefTypeTags.MappingTypes.kmtEntryTree:
				case LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree:
				case LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair: // Sense Pair with different Forward/Reverse names
				case LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair: // Entry Pair with different Forward/Reverse names
				case LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair: // Entry or sense Pair with different Forward/Reverse names
					if (lexRef.TargetsRS.Count > 0)
					{
						ICmObject firstObj = lexRef.TargetsRS[0];
						ILexEntry firstEntry = null;
						switch (firstObj.ClassID)
						{
							case LexEntryTags.kClassId:
								firstEntry = (ILexEntry) firstObj;
								break;
							case LexSenseTags.kClassId:
								firstEntry = firstObj.OwnerOfClass<ILexEntry>();
								break;
						}

						if (firstEntry != lexEntry)
						{
							name = lexRefType.ReverseName.BestAnalysisAlternative.Text;
							if (string.IsNullOrEmpty(name))
								name = lexRefType.ReverseAbbreviation.BestAnalysisAlternative.Text;
						}

						if (mappingType == LexRefTypeTags.MappingTypes.kmtSenseTree
							|| mappingType == LexRefTypeTags.MappingTypes.kmtEntryTree
							|| mappingType == LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree)
						{
							parentEntry = firstEntry;
						}
					}
					break;
			}
			return name.Normalize();
		}
        public void UndoRedoIncomingRefs()
        {
            var servLoc = Cache.ServiceLocator;

            var leFact = servLoc.GetInstance <ILexEntryFactory>();
            var le1    = leFact.Create();

            var lsFact = servLoc.GetInstance <ILexSenseFactory>();
            var ls1    = lsFact.Create();

            le1.SensesOS.Add(ls1);

            if (Cache.LangProject.StatusOA == null)
            {
                Cache.LangProject.StatusOA = servLoc.GetInstance <ICmPossibilityListFactory>().Create();
            }
            var possFact = servLoc.GetInstance <ICmPossibilityFactory>();
            var status1  = possFact.Create();

            Cache.LangProject.StatusOA.PossibilitiesOS.Add(status1);

            Cache.ActionHandlerAccessor.EndUndoTask();             // so we can have our own units of work to test Undo

            // Atomic
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () => ls1.StatusRA = status1);
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(0, status1.ReferringObjects.Count);
            m_actionHandler.Redo();
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            m_actionHandler.Undo();             // leave it Undone so it doesn't affect the ref collection test below.
            Assert.AreEqual(0, status1.ReferringObjects.Count);

            // Ref sequence
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () => le1.MainEntriesOrSensesRS.Add(ls1));
            Assert.AreEqual(1, ls1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(0, ls1.ReferringObjects.Count);
            m_actionHandler.Redo();
            Assert.AreEqual(1, ls1.ReferringObjects.Count);
            m_actionHandler.Undo();             // cleanup
            Assert.AreEqual(0, ls1.ReferringObjects.Count);

            // Ref collection
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler, () => ls1.DomainTypesRC.Add(status1));
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(0, status1.ReferringObjects.Count);
            m_actionHandler.Redo();
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            m_actionHandler.Undo();             // cleanup
            Assert.AreEqual(0, status1.ReferringObjects.Count);

            ILexSense ls2 = null;

            // Now see if it happens properly when we Undo and Redo object creation and deletion.
            // Atomic
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
                                        () =>
            {
                ls2 = lsFact.Create();
                le1.SensesOS.Add(ls2);
                ls2.StatusRA = status1;
            });
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(0, status1.ReferringObjects.Count);
            m_actionHandler.Redo();
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
                                        () => le1.SensesOS.Remove(ls2));
            Assert.AreEqual(0, status1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(1, status1.ReferringObjects.Count, "incoming ref should come back on undoing delete");
            m_actionHandler.Redo();
            Assert.AreEqual(0, status1.ReferringObjects.Count, "incoming ref should go away on redoing delete");

            // collection
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
                                        () =>
            {
                ls2 = lsFact.Create();
                le1.SensesOS.Add(ls2);
                ls2.DomainTypesRC.Add(status1);
            });
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(0, status1.ReferringObjects.Count);
            m_actionHandler.Redo();
            Assert.AreEqual(1, status1.ReferringObjects.Count);
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
                                        () => le1.SensesOS.Remove(ls2));
            Assert.AreEqual(0, status1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(1, status1.ReferringObjects.Count, "incoming ref should come back on undoing delete");
            m_actionHandler.Redo();
            Assert.AreEqual(0, status1.ReferringObjects.Count, "incoming ref should go away on redoing delete");

            // sequence
            ILexEntry le2 = null;

            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
                                        () =>
            {
                le2 = leFact.Create();
                le2.MainEntriesOrSensesRS.Add(ls1);
            });
            Assert.AreEqual(1, ls1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(0, ls1.ReferringObjects.Count);
            m_actionHandler.Redo();
            Assert.AreEqual(1, ls1.ReferringObjects.Count);
            UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
                                        () => le2.Delete());
            Assert.AreEqual(0, ls1.ReferringObjects.Count);
            m_actionHandler.Undo();
            Assert.AreEqual(1, ls1.ReferringObjects.Count, "incoming ref should come back on undoing delete");
            m_actionHandler.Redo();
            Assert.AreEqual(0, ls1.ReferringObjects.Count, "incoming ref should go away on redoing delete");

            // The base class for this group of tests expects to end an Undo task after the test is over.
            Cache.ActionHandlerAccessor.BeginUndoTask("undo something", "redo something");
        }
		/// <summary>
		/// Set up the dlg in preparation to showing it.
		/// </summary>
		/// <param name="cache">FDO cache.</param>
		/// <param name="mediator"></param>
		/// <param name="entry">LexEntry</param>
		public void SetDlgInfo(FdoCache cache, Mediator mediator, ILexEntry entry)
		{
			CheckDisposed();

			Debug.Assert(cache != null);

			m_mediator = mediator;
			m_cache = cache;
			m_entry = entry;
			m_tsf = m_cache.TsStrFactory;
			m_fwTextBoxBottomMsg.WritingSystemFactory = m_cache.WritingSystemFactory;
			//m_fwTextBoxBottomMsg.WritingSystemCode = 1; // What!? Why? No longer makes ANY sense!
			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			// We want to do this BEFORE the text gets set, to avoid overriding its height properties.
			// However, because of putting multiple lines in the box, we also need to do it AFTER we set the text
			// (in SetBottomMessage) so it adjusts to the resulting even greater height.
			m_fwTextBoxBottomMsg.AdjustForStyleSheet(this, null, stylesheet);
			Font f = FontHeightAdjuster.GetFontForNormalStyle(
				m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle, stylesheet, m_cache.LanguageWritingSystemFactoryAccessor);
			foreach (IMoForm allo in entry.AlternateFormsOS)
			{
				ListViewItem lvi = m_lvAlloOptions.Items.Add(allo.Form.VernacularDefaultWritingSystem.Text);
				lvi.Tag = allo;
				lvi.UseItemStyleForSubItems = true;
				lvi.Font = f;
			}
			m_lvAlloOptions.Font = f;
			// Get location to the stored values, if any.
			object locWnd = m_mediator.PropertyTable.GetValue("swapDlgLocation");
			// And when I do this, it works the first time, but later times the window is
			// too small and doesn't show all the controls. Give up on smart location for now.
			//object szWnd = this.Size;
			object szWnd = null; // suppresses the smart location stuff.
			//if (locWnd != null && szWnd != null)
			//{
			//    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
			//    ScreenUtils.EnsureVisibleRect(ref rect);
			//    DesktopBounds = rect;
			//    StartPosition = FormStartPosition.Manual;
			//}
			m_lvAlloOptions.Items[0].Selected = true;
			Text = LexEdStrings.ksSwapLexWithAllo;
			label2.Text = LexEdStrings.ksAlternateForms;

			// Determine the help file to use, if any
			m_helpTopic = "khtpSwapLexemeWithAllomorph";

			if(m_mediator.HelpTopicProvider != null)
			{
				helpProvider = new HelpProvider();
				helpProvider.HelpNamespace = m_mediator.HelpTopicProvider.HelpFile;
				helpProvider.SetHelpKeyword(this, m_mediator.HelpTopicProvider.GetHelpString(m_helpTopic));
				helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			}
		}
        /// <summary>
        /// Remove either the given entry or any sense owned by that entry from the list.
        /// </summary>
        private static void RemoveEntryFromList(ILcmReferenceSequence <ICmObject> list, ILexEntry entry)
        {
            var objsToRemove = new List <ICmObject>();

            foreach (var item in list)
            {
                if ((item as ILexEntry) == entry)
                {
                    objsToRemove.Add(item);
                }
                else if (item is ILexSense && item.OwnerOfClass <ILexEntry>() == entry)
                {
                    objsToRemove.Add(item);
                }
            }
            foreach (var item in objsToRemove)
            {
                list.Remove(item);
            }
        }
示例#31
0
        public void DuplicateAnalysesApproval()
        {
            int    hvoBearTEST = CheckAnalysisSize("bearTEST", 0, true);
            string xmlFragment = "";
            int    anal1Hvo;
            int    anal2Hvo;
            int    anal3Hvo;

            using (FdoCache cache = FdoCache.Create("TestLangProj"))
            {
                IWfiAnalysis anal = null;
                ILexDb       ldb  = cache.LangProject.LexDbOA;

                // Bear entry
                ILexEntry bearN = (ILexEntry)ldb.EntriesOC.Add(new LexEntry());
                AddIdToList(bearN.Hvo);
                IMoStemAllomorph bearNForm = (IMoStemAllomorph)bearN.AlternateFormsOS.Append(new MoStemAllomorph());
                bearNForm.Form.VernacularDefaultWritingSystem = "bearNTEST";
                IMoStemMsa bearNMSA = (IMoStemMsa)bearN.MorphoSyntaxAnalysesOC.Add(new MoStemMsa());
                ILexSense  bearNLS  = (ILexSense)bearN.SensesOS.Append(new LexSense());;

                IWfiWordform wf = WfiWordform.CreateFromDBObject(cache, hvoBearTEST);
                // First of two duplicate analyses
                anal     = (IWfiAnalysis)wf.AnalysesOC.Add(new WfiAnalysis());
                anal1Hvo = anal.Hvo;
                IWfiMorphBundle mb = (IWfiMorphBundle)anal.MorphBundlesOS.Append(new WfiMorphBundle());
                mb.MorphRA = bearNForm;
                mb.MsaRA   = bearNMSA;
                CheckEvaluationSize(anal1Hvo, 0, true, "anal1Hvo");

                // Non-duplicate, to make sure it does not get approved.
                anal       = (IWfiAnalysis)wf.AnalysesOC.Add(new WfiAnalysis());
                anal2Hvo   = anal.Hvo;
                mb         = (IWfiMorphBundle)anal.MorphBundlesOS.Append(new WfiMorphBundle());
                mb.SenseRA = bearNLS;
                CheckEvaluationSize(anal2Hvo, 0, true, "anal2Hvo");

                // Second of two duplicate analyses
                anal       = (IWfiAnalysis)wf.AnalysesOC.Add(new WfiAnalysis());
                anal3Hvo   = anal.Hvo;
                mb         = (IWfiMorphBundle)anal.MorphBundlesOS.Append(new WfiMorphBundle());
                mb.MorphRA = bearNForm;
                mb.MsaRA   = bearNMSA;
                CheckEvaluationSize(anal3Hvo, 0, true, "anal3Hvo");
                CheckAnalysisSize("bearTEST", 3, false);

                xmlFragment =
                    "<Wordform DbRef='" + hvoBearTEST.ToString() + "' Form='bearTEST'>\n"
                    + "<WfiAnalysis>\n"
                    + "<Morphs>\n"
                    + "<Morph>\n"
                    + "<MoForm DbRef='" + bearNForm.Hvo.ToString() + "' Label='bearNTEST'/>\n"
                    + "<MSI DbRef='" + bearNMSA.Hvo.ToString() + "'/>\n"
                    + "</Morph>\n"
                    + "</Morphs>\n"
                    + "</WfiAnalysis>\n"
                    + "</Wordform>\n";
            }

            m_filer.ProcessParse(MakeXML(xmlFragment, true));
            CheckEvaluationSize(anal1Hvo, 1, false, "anal1Hvo");
            CheckEvaluationSize(anal2Hvo, 0, false, "anal2Hvo");
            CheckEvaluationSize(anal3Hvo, 1, false, "anal3Hvo");
        }
示例#32
0
 internal bool TryGetEntry(LexemeKey key, out ILexEntry entry)
 {
     entry = GetMatchingEntries(key.Type, key.LexicalForm).FirstOrDefault(e => m_homographNumbers.GetOrCreateValue(e).Number == key.Homograph);
     return(entry != null);
 }
示例#33
0
 /// <summary>
 /// Get what would be produced for the headword of the specified entry in the specified WS,
 /// if it had the specified homograph number. (This is useful when overriding homograph
 /// numbers because items are omitted in a particular publication.)
 /// </summary>
 public static ITsString HeadWordForWsAndHn(ILexEntry entry, int wsVern, int nHomograph)
 {
     return(HeadWordForWsAndHn(entry, wsVern, nHomograph, DefaultHomographString()));
 }
示例#34
0
        /// <summary>
        /// Set up the dlg in preparation to showing it.
        /// </summary>
        /// <param name="cache">FDO cache.</param>
        /// <param name="mediator">Mediator used to restore saved siz and location info.</param>
        /// <param name="propertyTable"></param>
        /// <param name="startingEntry">Entry that cannot be used as a match in this dlg.</param>
        public void SetDlgInfo(LcmCache cache, Mediator mediator, XCore.PropertyTable propertyTable, ILexEntry startingEntry)
        {
            CheckDisposed();

            Debug.Assert(startingEntry != null);
            m_startingEntry = startingEntry;

            SetDlgInfo(cache, null, mediator, propertyTable);
            SetComboWritingSystemFactory(cache);
        }
示例#35
0
        public void ReplaceUndoTest()
        {
            ILexEntry kick       = null;
            ILexEntry bucket     = null;
            ILexEntry the        = null;
            ILexEntry kickBucket = null;

            kick       = MakeEntryWithForm("kick");
            bucket     = MakeEntryWithForm("bucket");
            the        = MakeEntryWithForm("the");
            kickBucket = MakeEntryWithForm("kick the bucket");
            kickBucket.AddComponent(kick);
            kickBucket.AddComponent(the);
            kickBucket.AddComponent(bucket);
            var entryRef = kickBucket.EntryRefsOS[0];

            Assert.That(entryRef.PrimaryLexemesRS[0], Is.EqualTo(kick));
            m_actionHandler.EndUndoTask();
            UndoableUnitOfWorkHelper.Do("doit", "undoit", Cache.ActionHandlerAccessor,
                                        () => entryRef.ComponentLexemesRS.Replace(0, 3, new[] { bucket, the, kick }));
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(bucket));           //test that the replace made the proper order change
            m_actionHandler.Undo();
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));             //test that the order change was reversed

            UndoableUnitOfWorkHelper.Do("doit", "undoit", Cache.ActionHandlerAccessor,
                                        () => entryRef.ComponentLexemesRS.Replace(0, 3, new[] { kick, the }));
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(2));             //test that the replace removed the last item
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));             //should be unchanged

            m_actionHandler.Undo();
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(3));             //test that the undo restored the last item
            Assert.That(entryRef.ComponentLexemesRS[2], Is.EqualTo(bucket));           //test that the order change was reversed

            m_actionHandler.Redo();
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(2));             //test that the replace removed the last item
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));             //should be unchanged

            UndoableUnitOfWorkHelper.Do("doit", "undoit", Cache.ActionHandlerAccessor,
                                        () => entryRef.ComponentLexemesRS.Replace(0, 0, new[] { bucket }));
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(3));             //we inserted one
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(bucket));           //the inserted one
            Assert.That(entryRef.ComponentLexemesRS[1], Is.EqualTo(kick));             //old first item now in slot 1

            m_actionHandler.Undo();
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(2));             //bucket is back out
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));             //moved back to index 0

            UndoableUnitOfWorkHelper.Do("doit", "undoit", Cache.ActionHandlerAccessor,
                                        () => entryRef.ComponentLexemesRS.Replace(1, 1, new[] { bucket, the }));
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(3));            //should now be kick bucket the
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));            //unchanged
            Assert.That(entryRef.ComponentLexemesRS[1], Is.EqualTo(bucket));          //inserted
            Assert.That(entryRef.ComponentLexemesRS[2], Is.EqualTo(the));             //moved

            UndoableUnitOfWorkHelper.Do("doit", "undoit", Cache.ActionHandlerAccessor,
                                        () => entryRef.ComponentLexemesRS.Replace(1, 1, new[] { bucket, the, bucket }));
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(5));            //should now be kick bucket the bucket the
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));            //unchanged
            Assert.That(entryRef.ComponentLexemesRS[1], Is.EqualTo(bucket));          //replaced with itself
            Assert.That(entryRef.ComponentLexemesRS[2], Is.EqualTo(the));             //inserted
            Assert.That(entryRef.ComponentLexemesRS[3], Is.EqualTo(bucket));          //inserted
            Assert.That(entryRef.ComponentLexemesRS[4], Is.EqualTo(the));             //moved

            m_actionHandler.Undo();
            Assert.That(entryRef.ComponentLexemesRS.Count, Is.EqualTo(3));             //should now be back to kick bucket the
            Assert.That(entryRef.ComponentLexemesRS[0], Is.EqualTo(kick));
            Assert.That(entryRef.ComponentLexemesRS[1], Is.EqualTo(bucket));
            Assert.That(entryRef.ComponentLexemesRS[2], Is.EqualTo(the));
        }
		public void ParserDataChanges()
		{
			XmlNode node;
#if !ShowDumpResult
			m_fxtResult.Save(Path.Combine(System.IO.Path.GetTempPath(), "TestFxtUpdateBefore.xml"));
#endif
			// -------------
			// Make data changes
			// -------------
			// Make a change to stem allomorph
			ILangProject lp = Cache.LangProject;
			ILexDb lexdb = lp.LexDbOA;
			int[] aiLexEntries = lexdb.EntriesOC.HvoArray;
			int hvoLexEntry = aiLexEntries[0];
			ILexEntry lexEntry = CmObject.CreateFromDBObject(Cache, hvoLexEntry) as ILexEntry;
			Assert.IsNotNull(lexEntry);
			IMoStemAllomorph stemAllomorph = lexEntry.LexemeFormOA as IMoStemAllomorph;
			Assert.IsNotNull(stemAllomorph);
			stemAllomorph.Form.SetAlternative("bili-changed", Cache.DefaultVernWs);
			int hvoStemAllomorph = stemAllomorph.Hvo;
			stemAllomorph.IsAbstract = true;

			// Delete an affix allomorph
			hvoLexEntry = aiLexEntries[3];
			lexEntry = CmObject.CreateFromDBObject(Cache, hvoLexEntry) as ILexEntry;
			Assert.IsNotNull(lexEntry);
			IMoAffixAllomorph affixAllomorph = lexEntry.AlternateFormsOS[1] as IMoAffixAllomorph;
			Assert.IsNotNull(affixAllomorph);
			int hvoAffixAllomorph = affixAllomorph.Hvo;
			lexEntry.AlternateFormsOS.RemoveAt(1);
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoLexEntry, (int)LexEntry.LexEntryTags.kflidAlternateForms, 1, 0, 1);

			// Add a new affix allomorph
			IMoAffixAllomorph newAffixAllomorph = new MoAffixAllomorph();
			lexEntry.AlternateFormsOS.Append(newAffixAllomorph);
			newAffixAllomorph.Form.SetAlternative("him-new", Cache.DefaultVernWs);
			int hvoNewAffixAllomorph = newAffixAllomorph.Hvo;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoLexEntry, (int)LexEntry.LexEntryTags.kflidAlternateForms, lexEntry.AlternateFormsOS.Count - 1, 1, 0);

			// add a compound rule
			IMoMorphData morphData = lp.MorphologicalDataOA;
			IMoEndoCompound compRuleNew = new MoEndoCompound();
			morphData.CompoundRulesOS.Append(compRuleNew);
			string sCompRuleName = "new compound rule";
			compRuleNew.Name.AnalysisDefaultWritingSystem = sCompRuleName;
			compRuleNew.HeadLast = true;
			int hvoPOS = lp.PartsOfSpeechOA.PossibilitiesOS.FirstItem.Hvo;
			compRuleNew.LeftMsaOA.PartOfSpeechRAHvo = hvoPOS;
			compRuleNew.RightMsaOA.PartOfSpeechRAHvo = hvoPOS;
			compRuleNew.OverridingMsaOA.PartOfSpeechRAHvo = hvoPOS;
			// Change compound rule description
			const string ksCompRuleDescription = "new description";
			compRuleNew.Description.AnalysisDefaultWritingSystem.Text = ksCompRuleDescription;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, morphData.Hvo, (int)MoMorphData.MoMorphDataTags.kflidCompoundRules, morphData.CompoundRulesOS.Count - 1, 1, 0);

			// delete a compound rule
			IMoExoCompound compRuleDeleted = morphData.CompoundRulesOS.FirstItem as IMoExoCompound;
			int hvoCompRuleDeletedLeftMsa = compRuleDeleted.LeftMsaOAHvo;
			int hvoCompRuleDeletedRightMsa = compRuleDeleted.RightMsaOAHvo;
			int hvoCompRuleDeletedToMsa = compRuleDeleted.ToMsaOAHvo;
			morphData.CompoundRulesOS.RemoveAt(0);

			// add an ad hoc co-prohibition
			IMoAlloAdhocProhib alloAdHoc = new MoAlloAdhocProhib();
			morphData.AdhocCoProhibitionsOC.Add(alloAdHoc);
			alloAdHoc.Adjacency = 2;
			alloAdHoc.FirstAllomorphRAHvo = hvoNewAffixAllomorph;
			alloAdHoc.RestOfAllosRS.Append(hvoNewAffixAllomorph);

			// change a "rest of allos" in extant ad hoc co-prohibition
			int[] hvosAdHocProhibs = morphData.AdhocCoProhibitionsOC.HvoArray;
			IMoAlloAdhocProhib alloAdHocOld =
				CmObject.CreateFromDBObject(Cache, hvosAdHocProhibs[9]) as IMoAlloAdhocProhib;
			IMoAffixAllomorph alloAdHicOldFirstRestOfAllos = alloAdHocOld.RestOfAllosRS.FirstItem as IMoAffixAllomorph;
			IMoAffixAllomorph affixAllomorph2 = lexEntry.AlternateFormsOS[0] as IMoAffixAllomorph;
			alloAdHocOld.RestOfAllosRS.Append(affixAllomorph2);
			alloAdHocOld.RestOfAllosRS.RemoveAt(0);
			alloAdHocOld.Adjacency = 2;

			//Add a new productivity restriction
			ICmPossibilityList prodRestricts = morphData.ProdRestrictOA;
			ICmPossibility prodRestriction = new CmPossibility();
			prodRestricts.PossibilitiesOS.Append(prodRestriction);
			string sNewProdRestrictName = "new exception feature";
			prodRestriction.Name.AnalysisDefaultWritingSystem = sNewProdRestrictName;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, prodRestricts.Hvo, (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities, prodRestricts.PossibilitiesOS.Count - 1, 1, 0);

			// Change a phonological enviroment string representation
			IPhPhonData phonData = lp.PhonologicalDataOA;
			IPhEnvironment env = phonData.EnvironmentsOS.FirstItem;
			const string ksEnvStringRep = "/ _ [C] [V] a e i o u";
			env.StringRepresentation.Text = ksEnvStringRep;

			// Add a new phonological enviroment string representation
			IPhEnvironment envNew = new PhEnvironment();
			phonData.EnvironmentsOS.Append(envNew);
			envNew.StringRepresentation.Text = "/ _ m";
			int hvoPhonData = phonData.Hvo;
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoPhonData, (int)PhPhonData.PhPhonDataTags.kflidEnvironments, phonData.EnvironmentsOS.Count - 1, 1, 0);

			// Change parser parameters (to test Unicode string field type)
			string sParserParameters = morphData.ParserParameters.Trim();
			int i = sParserParameters.IndexOf("</ParserParameters>");
			string sNewParserParameters = sParserParameters.Substring(0, i) + "<HermitCrab><stuff>1</stuff></HermitCrab>" + "</ParserParameters>";
			morphData.ParserParameters = sNewParserParameters;

			// Delete a lex entry
			int[] hvosEntries = lexdb.EntriesOC.HvoArray;
			int hvoEntryDeleted = hvosEntries[hvosEntries.Length - 4];
			ILexEntry entryDeleted = CmObject.CreateFromDBObject(Cache, hvoEntryDeleted) as ILexEntry;
			int hvoEntryDeletedLexemeForm = entryDeleted.LexemeFormOAHvo;
			int[] hvosEntryDeletedAlternateForms = entryDeleted.AlternateFormsOS.HvoArray;
			int[] hvosEntryDeletedMSAs = entryDeleted.MorphoSyntaxAnalysesOC.HvoArray;
			int[] hvosEntryDeletedSenses = entryDeleted.SensesOS.HvoArray;
			//entryDeleted.LexemeFormOA.DeleteUnderlyingObject();
			lexdb.EntriesOC.Remove(hvosEntries[hvosEntries.Length - 4]);
			//Cache.PropChanged(null, PropChangeType.kpctNotifyAll, morphData.Hvo, (int)MoMorphData.MoMorphDataTags.kflidParserParameters, 0, 0, 0);

			// Create a new lex entry
			ILexEntry entryNew = new LexEntry();
			lexdb.EntriesOC.Add(entryNew);

			IMoAffixAllomorph alloNew = new MoAffixAllomorph();
			entryNew.LexemeFormOA = alloNew;
			string sNewAlloForm = "dem";
			alloNew.Form.VernacularDefaultWritingSystem = sNewAlloForm;
			alloNew.MorphTypeRA = (IMoMorphType)lexdb.MorphTypesOA.LookupPossibilityByGuid(new Guid(MoMorphType.kguidMorphPrefix));

			IMoAffixAllomorph alloNew2 = new MoAffixAllomorph();
			entryNew.AlternateFormsOS.Append(alloNew2);
			string sNewAlloForm2 = "den";
			alloNew2.Form.VernacularDefaultWritingSystem = sNewAlloForm2;
			alloNew2.MorphTypeRA = (IMoMorphType)lexdb.MorphTypesOA.LookupPossibilityByGuid(new Guid(MoMorphType.kguidMorphPrefix));
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, entryNew.Hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms, entryNew.AlternateFormsOS.Count - 1, 1, 0);

			ILexSense sense = new LexSense();
			entryNew.SensesOS.Append(sense);
			string sGloss = "MeToo";
			sense.Gloss.AnalysisDefaultWritingSystem = sGloss;

			IMoInflAffMsa inflAffixMsa = new MoInflAffMsa();
			entryNew.MorphoSyntaxAnalysesOC.Add(inflAffixMsa);
			sense.MorphoSyntaxAnalysisRA = inflAffixMsa;
			int[] hvosPOSes = lp.PartsOfSpeechOA.PossibilitiesOS.HvoArray;
			int hvoVerb = hvosPOSes[12];
			inflAffixMsa.PartOfSpeechRAHvo = hvoVerb;
			IPartOfSpeech pos = CmObject.CreateFromDBObject(Cache, hvoVerb) as IPartOfSpeech;
			int hvoSlot = pos.AffixSlotsOC.HvoArray[2];
			inflAffixMsa.SlotsRC.Add(hvoSlot);
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, entryNew.Hvo, (int)LexEntry.LexEntryTags.kflidSenses, entryNew.SensesOS.Count - 1, 1, 0);

			// Add an inflectional template
			int[] hvoVerbSubCats = pos.SubPossibilitiesOS.HvoArray;
			int hvoIntransVerb = hvoVerbSubCats[2];
			IPartOfSpeech posVI = CmObject.CreateFromDBObject(Cache, hvoIntransVerb) as IPartOfSpeech;
			IMoInflAffixTemplate affixTemplate = new MoInflAffixTemplate();
			posVI.AffixTemplatesOS.Append(affixTemplate);
			affixTemplate.Name.AnalysisDefaultWritingSystem = "derived verb";
			affixTemplate.Final = false;
			affixTemplate.SuffixSlotsRS.Append(hvoSlot);
			Cache.PropChanged(null, PropChangeType.kpctNotifyAll, posVI.Hvo, (int)PartOfSpeech.PartOfSpeechTags.kflidAffixTemplates, posVI.AffixTemplatesOS.Count - 1, 1, 0);

			// add a phonological feature
			IFsClosedFeature consFeat = new FsClosedFeature();
			Cache.LangProject.PhFeatureSystemOA.FeaturesOC.Add(consFeat);
			consFeat.Name.AnalysisDefaultWritingSystem = "consonantal";
			consFeat.Abbreviation.AnalysisDefaultWritingSystem = "cons";
			IFsSymFeatVal consPlus = new FsSymFeatVal();
			consFeat.ValuesOC.Add(consPlus);
			consPlus.SimpleInit("+", "positive");
			IFsSymFeatVal consMinus = new FsSymFeatVal();
			consFeat.ValuesOC.Add(consMinus);
			consMinus.SimpleInit("-", "negative");
			IFsFeatStrucType fsType = null;
			if (Cache.LangProject.PhFeatureSystemOA.TypesOC.Count == 0)
			{
				fsType = new FsFeatStrucType();
				Cache.LangProject.PhFeatureSystemOA.TypesOC.Add(fsType);
				fsType.Abbreviation.AnalysisDefaultWritingSystem = "Phon";
			}
			else
			{
				foreach (IFsFeatStrucType type in Cache.LangProject.PhFeatureSystemOA.TypesOC)
				{
					fsType = type;
					break;
				}
			}
			fsType.FeaturesRS.Append(consFeat);

			// add a feature-based NC
			IPhNCFeatures featNC = new PhNCFeatures();
			Cache.LangProject.PhonologicalDataOA.NaturalClassesOS.Append(featNC);
			featNC.Name.AnalysisDefaultWritingSystem = "Consonants (Features)";
			featNC.Abbreviation.AnalysisDefaultWritingSystem = "CF";
			IFsFeatStruc fs = new FsFeatStruc();
			featNC.FeaturesOA = fs;
			IFsClosedValue val = fs.FindOrCreateClosedValue(consFeat.Hvo);
			val.FeatureRA = consFeat;
			val.ValueRA = consPlus;
			featNC.NotifyNew();

			// add phonological rule
			IPhRegularRule regRule = new PhRegularRule();
			Cache.LangProject.PhonologicalDataOA.PhonRulesOS.Append(regRule);
			regRule.NotifyNew();
			regRule.Name.AnalysisDefaultWritingSystem = "regular rule";
			IPhSimpleContextSeg segCtxt = new PhSimpleContextSeg();
			regRule.RightHandSidesOS[0].StrucChangeOS.Append(segCtxt);
			IPhPhoneme phoneme = null;
			foreach (IPhPhoneme phon in Cache.LangProject.PhonologicalDataOA.PhonemeSetsOS[0].PhonemesOC)
			{
				phoneme = phon;
				break;
			}
			segCtxt.FeatureStructureRA = phoneme;
			segCtxt.NotifyNew();

			IPhSimpleContextNC ncCtxt = new PhSimpleContextNC();
			regRule.RightHandSidesOS[0].LeftContextOA = ncCtxt;
			ncCtxt.FeatureStructureRA = featNC;
			ncCtxt.NotifyNew();

			// add a morphological rule
			IMoAffixProcess affRule = new MoAffixProcess();
			entryNew.AlternateFormsOS.Append(affRule);
			affRule.NotifyNew();
			ncCtxt = new PhSimpleContextNC();
			affRule.InputOS.Append(ncCtxt);
			ncCtxt.FeatureStructureRA = featNC;
			ncCtxt.NotifyNew();
			IMoCopyFromInput copy = new MoCopyFromInput();
			affRule.OutputOS.Append(copy);
			copy.ContentRA = ncCtxt;
			copy.NotifyNew();

			// -----------
			// Update the FXT result
			// -----------
			XmlDocument updatedFxtResult = UpdateFXT();

			// -----------
			// Test the updated results
			// -----------

			// Test changed stem allomorph: checks on MultiUnicode and boolean
			node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvoStemAllomorph + "']");
			Assert.IsNotNull(node);
			Assert.AreEqual(stemAllomorph.Form.VernacularDefaultWritingSystem, node.InnerText, "stem allomorph form change failed");
			XmlNode contentNode = node.SelectSingleNode("@IsAbstract");
			Assert.AreEqual("1", contentNode.InnerText, "stem allomorph is abstract should be true (=1)");

			// Test deleted affix allomorph: checks on owning sequence
			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + hvoAffixAllomorph + "']");
			Assert.IsNull(node, "Deleted affix allomorph should be null");
			node =
				updatedFxtResult.SelectSingleNode("//LexEntry[@id='" + hvoLexEntry + "']/AlternateForms[@dst='" +
												  hvoAffixAllomorph + "']");
			Assert.IsNull(node, "LexEntry should no longer have deleted alternate form");

			// Test added new affix allomorph: checks on owning sequence owned by an item with an @Id; also checks on addition of MoAffixAllomorph via AllAllomorphs
			string sXPath = "//LexEntry[@Id='" + hvoLexEntry + "']/AlternateForms[@dst='" +
							hvoNewAffixAllomorph + "']";
			node = updatedFxtResult.SelectSingleNode(sXPath);
			Assert.IsNotNull(node, "LexEntry should have added alternate form");
			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + hvoNewAffixAllomorph + "']");
			Assert.IsNotNull(node, "Added affix allomorph should be present");
			sXPath = "//LexEntry[@Id='" + hvoLexEntry + "']";
			node = updatedFxtResult.SelectSingleNode(sXPath);
			XmlNodeList nodes = node.SelectNodes("AlternateForms");
			Assert.AreEqual(3, nodes.Count, "Expected three Alternate forms in lex entry.");

			//Test newly added compound rule: checks on owning sequence owned by an Id-less element; also on multistring
			node = updatedFxtResult.SelectSingleNode("//MoEndoCompound[@Id='" + compRuleNew.Hvo + "']");
			Assert.IsNotNull(node, "did not find newly added compound rule");
			contentNode = node.SelectSingleNode("@HeadLast");
			Assert.IsNotNull(contentNode, "missing headlast attribute for coompound rule");
			Assert.AreEqual("1", contentNode.InnerText, "compound rule headlast value differs");
			contentNode = node.SelectSingleNode("Name");
			Assert.IsNotNull(contentNode, "missing Name for compound rule");
			Assert.AreEqual(sCompRuleName, contentNode.InnerText, "compound rule name differs");
			// check on MultiString
			contentNode = node.SelectSingleNode("Description");
			Assert.AreEqual(ksCompRuleDescription, contentNode.InnerText, "compound rule description differs");
			// check on count
			node = updatedFxtResult.SelectSingleNode("//CompoundRules");
			nodes = node.SelectNodes("MoExoCompound | MoEndoCompound");
			Assert.AreEqual(6, nodes.Count, "Expected seven compound rules.");
			// check on owningAtom
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.LeftMsaOAHvo + "']");
			Assert.IsNotNull(node, "missing real MoStemMsa for LeftMsa of newly added compound rule");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.RightMsaOAHvo + "']");
			Assert.IsNotNull(node, "missing real MoStemMsa for RightMsa of newly added compound rule");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + compRuleNew.OverridingMsaOAHvo + "']");
			Assert.IsNotNull(node, "missing real MoStemMsa for OverridingMsa of newly added compound rule");

			// Test deleted compound rule
			node = updatedFxtResult.SelectSingleNode("//MoExoCompound[@Id='" + compRuleDeleted.Hvo + "']");
			Assert.IsNull(node, "compound rule should be deleted");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedLeftMsa + "']");
			Assert.IsNull(node, "compound rule left MSA should be deleted");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedRightMsa + "']");
			Assert.IsNull(node, "compound rule right MSA should be deleted");
			node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvoCompRuleDeletedToMsa + "']");
			Assert.IsNull(node, "compound rule to MSA should be deleted");

			//Test newly added allomorph ad hoc rule: checks on owning collection
			node = updatedFxtResult.SelectSingleNode("//MoAlloAdhocProhib[@Id='" + alloAdHoc.Hvo + "']");
			Assert.IsNotNull(node, "did not find newly added allo ad hoc rule");
			contentNode = node.SelectSingleNode("@Adjacency");
			Assert.IsNotNull(contentNode, "missing adjacency attribute for allo ad hoc rule");
			Assert.AreEqual("2",contentNode.InnerText, "allo ad hoc rule adjacency value differs");
			contentNode = node.SelectSingleNode("FirstAllomorph");
			Assert.IsNotNull(contentNode, "missing FirstAllomorph for allo ad hoc rule");
			contentNode = contentNode.SelectSingleNode("@dst");
			Assert.IsNotNull(contentNode, "missing dst attribute of FirstAllomorph for allo ad hoc rule");
			Assert.AreEqual(hvoNewAffixAllomorph.ToString(), contentNode.InnerText, "FirstAllomorph of allo ad hoc rule differs");
			contentNode = node.SelectSingleNode("RestOfAllos");
			Assert.IsNotNull(contentNode, "missing RestOfAllos for allo ad hoc rule");
			contentNode = contentNode.SelectSingleNode("@dst");
			Assert.IsNotNull(contentNode, "missing dst attribute of RestOfAllos for allo ad hoc rule");
			Assert.AreEqual(hvoNewAffixAllomorph.ToString(), contentNode.InnerText, "RestOfAllos of allo ad hoc rule differs");

			// test change of a "rest of allos" in extant ad hoc co-prohibition: check on reference sequence
			node = updatedFxtResult.SelectSingleNode("//MoAlloAdhocProhib[@Id='" + alloAdHocOld.Hvo + "']");
			Assert.IsNotNull(node, "did not find old allo ad hoc rule");
			contentNode = node.SelectSingleNode("RestOfAllos");
			Assert.IsNotNull(contentNode, "missing RestOfAllos for old allo ad hoc rule");
			contentNode = contentNode.SelectSingleNode("@dst");
			Assert.IsNotNull(contentNode, "missing dst attribute of RestOfAllos for old allo ad hoc rule");
			Assert.AreEqual(affixAllomorph2.Hvo.ToString(), contentNode.InnerText, "RestOfAllos of old allo ad hoc rule differs");
			nodes = node.SelectNodes("RestOfAllos");
			Assert.AreEqual(1, nodes.Count, "count of RestOfAllos of old allo ad hoc rule differs");
			// check on integer change
			contentNode = node.SelectSingleNode("@Adjacency");
			Assert.AreEqual("2", contentNode.InnerText, "Adjacency differs");
			node =
				updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloAdHicOldFirstRestOfAllos.Hvo + "']");
			Assert.IsNotNull(node, "Original RestOfAllos allomorph should still be present");
			nodes = updatedFxtResult.SelectNodes("//MoAffixAllomorph[@Id='" + affixAllomorph2.Hvo + "']");
			Assert.AreEqual(1, nodes.Count, "Should only be one instance of new allomorph in RestOfAllos");


			// Test added productivity restriction: check on CmPossibilityList
			node = updatedFxtResult.SelectSingleNode("//ProdRestrict/CmPossibility");
			Assert.IsNotNull(node, "Did not find newly added productivity restriction");
			node = node.SelectSingleNode("Name");
			Assert.IsNotNull(node, "Expected Name node in productivity restrictioni");
			Assert.AreEqual(sNewProdRestrictName, node.InnerText, "name of productivity restriction differs");

			// Test phonological environment string representation: check on string
			node = updatedFxtResult.SelectSingleNode("//PhEnvironment[@Id='" + env.Hvo + "']/@StringRepresentation");
			Assert.AreEqual(ksEnvStringRep, node.InnerText, "phonological environment string differs");

			// Test adding a phonological environment string representation:
			// check on case where parent of owner has Id and is class name;
			// also check on case where there is a comment/text node within the result nodes
			node = updatedFxtResult.SelectSingleNode("//PhEnvironment[@Id='" + envNew.Hvo + "']");
			Assert.IsNotNull(node, "missing newly added phonological environment");
			nodes = updatedFxtResult.SelectNodes("//PhEnvironment");
			Assert.AreEqual(11, nodes.Count, "number of PhEnvironments differs");

			// Test Parser Parameters: check on unicode string
			node = updatedFxtResult.SelectSingleNode("//ParserParameters");
			string sResultParseParameters = node.OuterXml.Trim();
			Assert.AreEqual(sNewParserParameters, sResultParseParameters, "Parser Parameters content differs");

			// Test deletion of a lex entry: check on finding LexDb when there is no class LexDb in FXT file
			nodes = updatedFxtResult.SelectNodes("//LexEntry");
			Assert.AreEqual(61, nodes.Count, "number of LexEntries differs");
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + hvoEntryDeleted + "']");
			Assert.IsNull(node, "Deleted lex entry should be missing");
			foreach (int hvo in hvosEntryDeletedAlternateForms)
			{
				node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvo + "'] | //MoAffixAllomorph[@Id='" + hvo + "']");
				Assert.IsNull(node, "deleted entry's alternate form should also be gone");
			}
			foreach (int hvo in hvosEntryDeletedMSAs)
			{
				node = updatedFxtResult.SelectSingleNode("//MoStemMsa[@Id='" + hvo + "']");
				Assert.IsNull(node, "deleted entry's msa should also be gone");
			}
			foreach (int hvo in hvosEntryDeletedSenses)
			{
				node = updatedFxtResult.SelectSingleNode("//LexSense[@Id='" + hvo + "']");
				Assert.IsNull(node, "deleted entry's lexsense should also be gone");
			}
			node = updatedFxtResult.SelectSingleNode("//MoStemAllomorph[@Id='" + hvoEntryDeletedLexemeForm + "']");
			Assert.IsNull(node, "deleted entry's lexeme form should also be gone");

			// Test adding new entry
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + entryNew.Hvo + "']");
			Assert.IsNotNull(node, "new lex entry is missing");
			contentNode = node.SelectSingleNode("LexemeForm[@dst='" + alloNew.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing lexeme form for new entry");
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + alloNew2.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing alternate form in new lex entry");
			contentNode = node.SelectSingleNode("Sense[@dst='" + sense.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing sense in new lex entry");
			contentNode = node.SelectSingleNode("MorphoSyntaxAnalysis[@dst='" + inflAffixMsa.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing msa in new lex entry");
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + affRule.Hvo + "']");
			Assert.IsNotNull(contentNode, "missing affix process rule in new lex entry");

			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloNew.Hvo + "']");
			Assert.IsNotNull(node, "new lexeme form affix allomorph for new lex entry is missing");
			contentNode = node.SelectSingleNode("@MorphType");
			Assert.IsNotNull(contentNode, "@MorphType missing for new MoAffixAllomorph in lexeme form of new lex entry");
			IMoMorphType typeNew = MoMorphType.CreateFromDBObject(Cache, Convert.ToInt32(contentNode.InnerText));
			string sGuidNew = typeNew.Guid.ToString();
			Assert.AreEqual(MoMorphType.kguidMorphPrefix, sGuidNew, "morph type wrong for new MoAffixAllomorph in lexeme form of new lex entry");
			contentNode = node.SelectSingleNode("Form");
			Assert.IsNotNull(contentNode, "Form missing for new MoAffixAllomorph in lexeme form new lex entry");
			Assert.AreEqual(sNewAlloForm, contentNode.InnerText, "form wrong for new MoAffixAllomorph in lexeme form of new lex entry");

			node = updatedFxtResult.SelectSingleNode("//MoAffixAllomorph[@Id='" + alloNew2.Hvo + "']");
			Assert.IsNotNull(node, "new alternate form affix allomorph for new lex entry is missing");
			contentNode = node.SelectSingleNode("@MorphType");
			Assert.IsNotNull(contentNode, "@MorphType missing for new MoAffixAllomorph in alternate form of new lex entry");
			typeNew = MoMorphType.CreateFromDBObject(Cache, Convert.ToInt32(contentNode.InnerText));
			sGuidNew = typeNew.Guid.ToString();
			Assert.AreEqual(MoMorphType.kguidMorphPrefix, sGuidNew, "morph type wrong for new MoAffixAllomorph in lexeme form of new lex entry");
			contentNode = node.SelectSingleNode("Form");
			Assert.IsNotNull(contentNode, "Form missing for new MoAffixAllomorph in alternate form new lex entry");
			Assert.AreEqual(sNewAlloForm2, contentNode.InnerText, "form wrong for new MoAffixAllomorph in alternate form of new lex entry");

			node = updatedFxtResult.SelectSingleNode("//LexSense[@Id='" + sense.Hvo + "']");
			Assert.IsNotNull(node, "new sense for new lex entry is missing");
			contentNode = node.SelectSingleNode("Gloss");
			Assert.IsNotNull(contentNode, "Gloss missing for new LexSense in new lex entry");
			Assert.AreEqual(sGloss, contentNode.InnerText, "Gloss wrong for new LexSense in new lex entry");

			node = updatedFxtResult.SelectSingleNode("//MoInflAffMsa[@Id='" + inflAffixMsa.Hvo + "']");
			Assert.IsNotNull(node, "new infl affix msa for new lex entry is missing");
			contentNode = node.SelectSingleNode("@PartOfSpeech");
			Assert.IsNotNull(contentNode, "@PartOfSpeech missing for new MoInflAffMsa in new lex entry");
			Assert.AreEqual(hvoVerb.ToString(), contentNode.InnerText, "part of speech wrong for new MoInflAffMsa in new lex entry");
			contentNode = node.SelectSingleNode("Slots/@dst");
			Assert.IsNotNull(contentNode, "Slots missing for new MoInflAffMsa in new lex entry");
			Assert.AreEqual(hvoSlot.ToString(), contentNode.InnerText, "slot wrong for new MoInflAffMsa in new lex entry");

			// Test adding new template
			node = updatedFxtResult.SelectSingleNode("//MoInflAffixTemplate[@Id='" + affixTemplate.Hvo + "']");
			Assert.IsNotNull(node, "new affix template missing");
			node =
				updatedFxtResult.SelectSingleNode("//PartOfSpeech[@Id='" + hvoIntransVerb +
												  "']/AffixTemplates/MoInflAffixTemplate[@Id='" + affixTemplate.Hvo +
												  "']");
			Assert.IsNotNull(node, "new affix template is in intransitive verb");

			// Test adding new phonological feature
			node = updatedFxtResult.SelectSingleNode("//PhFeatureSystem/Features/FsClosedFeature[@Id='" + consFeat.Hvo + "']");
			Assert.IsNotNull(node, "new phonological feature is missing");
			contentNode = node.SelectSingleNode("Abbreviation");
			Assert.IsNotNull(contentNode, "Abbreviation missing from new phonological feature");
			Assert.AreEqual(contentNode.InnerText, consFeat.Abbreviation.AnalysisDefaultWritingSystem, "Abbreviation wrong for new phonological feature");
			nodes = node.SelectNodes("Values/FsSymFeatVal");
			Assert.IsNotNull(nodes, "values missing from new phonological feature");
			Assert.AreEqual(nodes.Count, 2, "incorrect number of values in new phonological feature");
			node = updatedFxtResult.SelectSingleNode("//PhFeatureSystem/Types/FsFeatStrucType/Features/Feature[@dst='" + consFeat.Hvo + "']");
			Assert.IsNotNull(node, "reference to new phonological feature is missing from phonological feature system");

			// Test adding new feature-based NC
			node = updatedFxtResult.SelectSingleNode("//PhNCFeatures[@Id='" + featNC.Hvo + "']");
			Assert.IsNotNull(node, "new feature-based NC is missing");
			contentNode = node.SelectSingleNode("Abbreviation");
			Assert.IsNotNull(contentNode, "Abbreviation missing from new feature-based NC");
			Assert.AreEqual(contentNode.InnerText, featNC.Abbreviation.AnalysisDefaultWritingSystem, "Abbreviation wrong for new feature-based NC");
			contentNode = node.SelectSingleNode("FsFeatStruc/FsClosedValue[@Id='" + val.Hvo + "']");
			Assert.IsNotNull(contentNode, "value missing from new feature-based NC");
			Assert.AreEqual((contentNode as XmlElement).GetAttribute("Feature"), consFeat.Hvo.ToString(), "closed value feature is wrong in new feature-based NC");
			Assert.AreEqual((contentNode as XmlElement).GetAttribute("Value"), consPlus.Hvo.ToString(), "closed value is wrong in new feature-based NC");

			// Test adding new phonological rule
			node = updatedFxtResult.SelectSingleNode("//PhRegularRule[@Id='" + regRule.Hvo + "']");
			Assert.IsNotNull(node, "new phonological rule is missing");
			nodes = node.SelectNodes("StrucDesc/*");
			Assert.AreEqual(nodes.Count, 0);
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/StrucChange/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']");
			Assert.IsNotNull(contentNode, "phoneme simple context missing in new phonological rule");
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/LeftContext/PhSimpleContextNC[@dst='" + featNC.Hvo + "']");
			Assert.IsNotNull(contentNode, "NC simple context missing in new phonological rule");

			// Test adding new morphological rule
			node = updatedFxtResult.SelectSingleNode("//Lexicon/Allomorphs/MoAffixProcess[@Id='" + affRule.Hvo + "']");
			Assert.IsNotNull(node, "new morphological rule is missing");
			contentNode = node.SelectSingleNode("Input/PhSimpleContextNC[@dst='" + featNC.Hvo + "']");
			Assert.IsNotNull(contentNode, "NC simple context missing in new morphological rule");
			contentNode = node.SelectSingleNode("Output/MoCopyFromInput/Content[@dst='" + ncCtxt.Hvo + "']");
			Assert.IsNotNull(contentNode, "copy from input missing in new morphological rule");

			// Modify a phonological rule
			segCtxt = new PhSimpleContextSeg();
			regRule.StrucDescOS.Append(segCtxt);
			segCtxt.FeatureStructureRA = phoneme;
			segCtxt.NotifyNew();
			regRule.RightHandSidesOS[0].StrucChangeOS[0].DeleteUnderlyingObject();
			IPhPhonContext oldCtxt = regRule.RightHandSidesOS[0].LeftContextOA;
			Cache.LangProject.PhonologicalDataOA.ContextsOS.Append(oldCtxt);
			IPhSequenceContext seqCtxt = new PhSequenceContext();
			regRule.RightHandSidesOS[0].LeftContextOA = seqCtxt;
			seqCtxt.MembersRS.Append(oldCtxt);
			seqCtxt.NotifyNew();
			IPhSimpleContextBdry bdryCtxt = new PhSimpleContextBdry();
			Cache.LangProject.PhonologicalDataOA.ContextsOS.Append(bdryCtxt);
			bdryCtxt.FeatureStructureRAHvo = Cache.GetIdFromGuid(LangProject.kguidPhRuleWordBdry);
			bdryCtxt.NotifyNew();
			seqCtxt.MembersRS.Append(bdryCtxt);

			// Modify a morphological rule
			entryNew.LexemeFormOA = affRule;
			IMoInsertPhones insertPhones = new MoInsertPhones();
			affRule.OutputOS.InsertAt(insertPhones, 0);
			insertPhones.ContentRS.Append(phoneme);
			insertPhones.NotifyNew();
			affRule.InputOS[1].DeleteUnderlyingObject();

			// change order of a sequence vector
			lexEntry.AlternateFormsOS.InsertAt(newAffixAllomorph, 0);

			updatedFxtResult = UpdateFXT();

			// Test modifying a phonological rule
			node = updatedFxtResult.SelectSingleNode("//PhRegularRule[@Id='" + regRule.Hvo + "']");
			contentNode = node.SelectSingleNode("StrucDesc/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']");
			Assert.IsNotNull(contentNode, "phoneme simple context missing from StrucDesc in modified phonological rule");
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/StrucChange/PhSimpleContextSeg[@dst='" + phoneme.Hvo + "']");
			Assert.IsNull(contentNode, "phoneme simple context is not missing from StrucChange in modified phonological rule");
			contentNode = node.SelectSingleNode("RightHandSides/PhSegRuleRHS/LeftContext/PhSequenceContext[@Id='" + seqCtxt.Hvo + "']");
			Assert.IsNotNull(contentNode, "sequence context missing from modified phonological rule");
			contentNode = contentNode.SelectSingleNode("Members[@dst='" + bdryCtxt.Hvo + "']");
			Assert.IsNotNull(contentNode, "boundary context missing from sequence context in modified phonological rule");
			node = updatedFxtResult.SelectSingleNode("//PhPhonData/Contexts/PhSimpleContextBdry[@Id='" + bdryCtxt.Hvo + "']");
			Assert.IsNotNull(node, "boundary context missing from contexts in phonological data");

			// Test modifying a morphological rule
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + entryNew.Hvo + "']");
			contentNode = node.SelectSingleNode("LexemeForm[@dst='" + affRule.Hvo + "']");
			Assert.IsNotNull(contentNode, "affix process rule is not the lexeme form for the lex entry");
			node = updatedFxtResult.SelectSingleNode("//Lexicon/Allomorphs/MoAffixProcess[@Id='" + affRule.Hvo + "']");
			contentNode = node.SelectSingleNode("Input/PhSimpleContextNC[@dst='" + featNC.Hvo + "']");
			Assert.IsNull(contentNode, "NC simple context was not removed from morphological rule");
			nodes = node.SelectNodes("Output/*");
			Assert.AreEqual(nodes.Count, 2, "incorrect number of mappings in morphological rule");
			contentNode = node.SelectSingleNode("Output/*[position() = 1 and @Id='" + insertPhones.Hvo + "']");
			Assert.IsNotNull(contentNode, "insert phones missing from morphological rule");

			// Test changing order of a sequence vector
			node = updatedFxtResult.SelectSingleNode("//LexEntry[@Id='" + lexEntry.Hvo + "']");
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[0].Hvo + "']/@ord");
			Assert.AreEqual("0", contentNode.InnerText);
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[1].Hvo + "']/@ord");
			Assert.AreEqual("1", contentNode.InnerText);
			contentNode = node.SelectSingleNode("AlternateForms[@dst='" + lexEntry.AlternateFormsOS[2].Hvo + "']/@ord");
			Assert.AreEqual("2", contentNode.InnerText);
		}
示例#37
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public BaseEntryGoDlg() : base()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			InitializeComponentsFromBaseGoDlg();
			SetHelpTopic("khtpFindInDictionary"); // Default help topic ID
			m_startingEntry = null;

			// We will add it to controls when we want to show it.
			(matchingEntries as MatchingEntries).SearchingChanged += new EventHandler(matchingEntries_SearchingChanged);

		}
示例#38
0
        /// <summary>
        /// decide whether to display this tree insert Menu Item
        /// </summary>
        /// <param name="commandObject"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public override bool OnDisplayDataTreeInsert(object commandObject, ref UIItemDisplayProperties display)
        {
            Slice slice = m_dataEntryForm.CurrentSlice;

            if (slice == null && m_dataEntryForm.Slices.Count > 0)
            {
                slice = m_dataEntryForm.FieldAt(0);
            }
            if (slice == null || slice.IsDisposed ||
                (m_propertyTable.GetValue <RecordClerk>("ActiveClerk")).ListSize == 0)
            {
                // don't display the datatree menu/toolbar items when we don't have a data tree slice.
                // (If the slice is disposed, we're in a weird state, possibly trying to update the toolbar during OnIdle though we haven't
                // in fact finished reconstructing the tree. Leave things disabled, and hope they will get enabled
                // on the next call when things have stabilized.)
                display.Visible = false;
                display.Enabled = false;
                return(true);
            }

            base.OnDisplayDataTreeInsert(commandObject, ref display);

            if (!(slice.Object is ILexEntry) && !(slice.ContainingDataTree.Root is ILexEntry))
            {
                return(false);
            }
            ILexEntry entry = slice.Object as ILexEntry;

            if (entry == null)
            {
                entry = slice.ContainingDataTree.Root as ILexEntry;
            }
            if (entry == null || !entry.IsValidObject)
            {
                // At one point this could happen during delete object. Not sure it will be possible when I
                // finish debugging that, but the defensive programming doesn't hurt.
                display.Enabled = false;
                display.Visible = false;
                return(true);
            }
            XCore.Command command = (XCore.Command)commandObject;

            if (command.Id.EndsWith("AffixProcess"))
            {
                var  mmt    = entry.PrimaryMorphType;
                bool enable = mmt != null && mmt.IsAffixType;
                display.Enabled = enable;
                display.Visible = enable;
                return(true);
            }

            //if there aren't any alternate forms, go ahead and let the user choose either kind
            if (entry.AlternateFormsOS.Count == 0)
            {
                return(true);
            }

            if (command.Id.EndsWith("AffixAllomorph"))
            {
                if (!(entry.AlternateFormsOS[0] is IMoAffixAllomorph))
                {
                    display.Visible = false;
                }
                return(true);
            }

            if (command.Id.EndsWith("StemAllomorph"))
            {
                if (!(entry.AlternateFormsOS[0] is IMoStemAllomorph))
                {
                    display.Visible = false;
                }
                return(true);
            }

            return(true);           //we handled this, no need to ask anyone else.
        }
示例#39
0
		private void SwapAllomorphWithLexeme(ILexEntry entry, IMoForm allomorph, Command cmd)
		{
			UndoableUnitOfWorkHelper.Do(cmd.UndoText, cmd.RedoText, entry, () =>
			{
				entry.AlternateFormsOS.Insert(allomorph.IndexInOwner, entry.LexemeFormOA);
				entry.LexemeFormOA = allomorph;
			});
		}
示例#40
0
        protected override void Init()
        {
            m_entryFactory         = Cache.ServiceLocator.GetInstance <ILexEntryFactory>();
            m_senseFactory         = Cache.ServiceLocator.GetInstance <ILexSenseFactory>();
            m_exampleFactory       = Cache.ServiceLocator.GetInstance <ILexExampleSentenceFactory>();
            m_lexEntryRefFactory   = Cache.ServiceLocator.GetInstance <ILexEntryRefFactory>();
            m_lexRefTypeFactory    = Cache.ServiceLocator.GetInstance <ILexRefTypeFactory>();
            m_lexRefFactory        = Cache.ServiceLocator.GetInstance <ILexReferenceFactory>();
            m_possListFactory      = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>();
            m_revIndexFactory      = Cache.ServiceLocator.GetInstance <IReversalIndexFactory>();
            m_revIndexEntryFactory = Cache.ServiceLocator.GetInstance <IReversalIndexEntryFactory>();

            m_flidReferringSenses = Cache.MetaDataCacheAccessor.GetFieldId2(CmSemanticDomainTags.kClassId, "ReferringSenses",
                                                                            false);
            m_application = new MockFwXApp(new MockFwManager {
                Cache = Cache
            }, null, null);
            var configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname);

            m_window = new MockFwXWindow(m_application, configFilePath);
            ((MockFwXWindow)m_window).Init(Cache);             // initializes Mediator values

            UndoableUnitOfWorkHelper.Do("do", "undo", Cache.ActionHandlerAccessor,
                                        () =>
            {
                m_domainBadWords    = Cache.ServiceLocator.GetInstance <ICmSemanticDomainFactory>().Create();
                m_domainTemperature = Cache.ServiceLocator.GetInstance <ICmSemanticDomainFactory>().Create();
                Cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Add(m_domainBadWords);
                Cache.LangProject.SemanticDomainListOA.PossibilitiesOS.Add(m_domainTemperature);
                m_mainDict = Cache.LangProject.LexDbOA.PublicationTypesOA.PossibilitiesOS[0];
                m_blank    = MakeEntry("blank", "swear word", true);
                m_blank.SensesOS[0].SemanticDomainsRC.Add(m_domainBadWords);
                m_hot     = MakeEntry("hot", "high temperature", false);
                m_hotTemp = m_hot.SensesOS[0];
                m_hotTemp.SemanticDomainsRC.Add(m_domainTemperature);
                m_trouble = MakeSense(m_hot, "trouble");
                m_trouble.DoNotPublishInRC.Add(m_mainDict);
                m_trouble.PicturesOS.Add(Cache.ServiceLocator.GetInstance <ICmPictureFactory>().Create());
                m_desirable = MakeSense(m_hot, "desirable");
                m_fastCar   = MakeSense(m_desirable, "fast (car)");

                m_badHot  = MakeExample(m_hotTemp, "a hot pile of blank", true);
                m_goodHot = MakeExample(m_hotTemp, "a hot bath", false);

                m_water              = MakeEntry("water", "H2O", false);
                m_waterH2O           = m_water.SensesOS[0];
                m_hotWater           = MakeEntry("hot water", "trouble", false);
                m_hotWaterComponents = MakeEntryRef(m_hotWater, new ICmObject[] { m_trouble, m_waterH2O },
                                                    new ICmObject[] { m_trouble, m_waterH2O },
                                                    LexEntryRefTags.krtComplexForm);

                m_blank2      = MakeEntry("blank", "vacant", false);
                m_blank3      = MakeEntry("blank", "erase", false);
                m_water2      = MakeEntry("water", "urinate", true);
                m_waterPrefix = MakeEntry("water", "aquatic", false);
                m_waterPrefix.LexemeFormOA.MorphTypeRA = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>()
                                                         .GetObject(MoMorphTypeTags.kguidMorphPrefix);

                m_synonym       = MakeRefType("synonym", null, (int)LexRefTypeTags.MappingTypes.kmtSenseCollection);
                m_blip          = MakeEntry("blip", "rude word", true);
                m_bother        = MakeEntry("bother", "I'm annoyed by that", false);
                m_ouch          = MakeEntry("ouch", "that hurt", false);
                m_blipOuch      = MakeSense(m_blip.SensesOS[0], "rude ouch");
                m_blankSynonyms = MakeLexRef(m_synonym, new ICmObject[] { m_blank, m_ouch.SensesOS[0], m_blip.SensesOS[0], m_blipOuch, m_bother });

                m_problem         = MakeEntry("problem", "difficulty", false);
                m_problemSynonyms = MakeLexRef(m_synonym, new ICmObject[] { m_problem, m_trouble });

                m_body       = MakeEntry("body", "body", true);
                m_arm        = MakeEntry("arm", "arm", false);
                m_leg        = MakeEntry("leg", "leg", false);
                m_belly      = MakeEntry("belly", "belly", true);
                m_torso      = MakeEntry("torso", "torso", false);
                m_partWhole  = MakeRefType("partWhole", null, (int)LexRefTypeTags.MappingTypes.kmtEntryTree);
                m_bodyParts  = MakeLexRef(m_partWhole, new ICmObject[] { m_body, m_arm, m_leg.SensesOS[0], m_torso, m_belly });
                m_torsoParts = MakeLexRef(m_partWhole, new ICmObject[] { m_torso, m_arm, m_belly });

                m_hotBlank = MakeEntry("hotBlank", "problem rude word", false);
                MakeEntryRef(m_hotBlank, new ICmObject[] { m_trouble, m_water2 },
                             new ICmObject[] { m_trouble, m_water2 },
                             LexEntryRefTags.krtComplexForm);

                m_blueColor = MakeEntry("blue", "color blue", false);
                m_blueCold  = MakeEntry("blue", "cold", false);
                m_blueMusic = MakeEntry("blue", "jazzy", false);
                m_blueSad   = MakeEntry("blue", "sad", false);

                m_blueMusic.HomographNumber = 2;                               // will duplicate blue cold; pathological, but should not crash.
                m_blueSad.HomographNumber   = 3;                               // will conflict with renumbered blueMusic

                m_bluer             = m_blueColor.SensesOS[0];
                m_sky               = MakeEntry("sky", "interface between atmosphere and space", false, true);                   // true excludes as headword
                m_skyReal           = m_sky.SensesOS[0];
                m_blueSky           = MakeEntry("blue sky", "clear, huge potential", false);
                m_blueSkyComponents = MakeEntryRef(m_blueSky, new ICmObject[] { m_blueColor, m_skyReal },
                                                   new ICmObject[] { m_bluer, m_skyReal },
                                                   LexEntryRefTags.krtComplexForm);

                m_ringBell   = MakeEntry("ring", "bell", false);
                m_ringCircle = MakeEntry("ring", "circle", false, true);
                m_ringGold   = MakeEntry("ring", "gold", false);

                m_blackVerb  = MakeEntry("black", "darken", false, true);
                m_blackColor = MakeEntry("black", "dark", false);

                m_hotArm           = MakeEntry("hotarm", "pitcher", false);
                m_hotArmComponents = MakeEntryRef(m_hotArm, new ICmObject[] { m_hot, m_arm },
                                                  new ICmObject[] { m_hot, m_arm },
                                                  LexEntryRefTags.krtComplexForm);
                m_hotArm.DoNotPublishInRC.Add(m_mainDict);
                m_hotArmComponents.ShowComplexFormsInRS.Add(m_hot);

                m_nolanryan           = MakeEntry("Nolan_Ryan", "pitcher", false);
                m_nolanryanComponents = MakeEntryRef(m_nolanryan, new ICmObject[] { m_hot },
                                                     new ICmObject[] { m_hot },
                                                     LexEntryRefTags.krtVariant);
                m_nolanryanComponents.VariantEntryTypesRS.Add(
                    (ILexEntryType)Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS[0]);
                m_nolanryan.DoNotPublishInRC.Add(m_mainDict);

                m_edName   = MakeEntry("ed", "someone called ed", false);
                m_edSuffix = MakeEntry("ed", "past", false, false, true);

                m_revIndex = CreateInterestingReversalEntries();

                m_publisher = new MockPublisher((ISilDataAccessManaged)Cache.DomainDataByFlid, kmainFlid);
                m_publisher.SetOwningPropValue(Cache.LangProject.LexDbOA.Entries.Select(le => le.Hvo).ToArray());
                m_decorator = new DictionaryPublicationDecorator(Cache, m_publisher, ObjectListPublisher.OwningFlid);

                m_revPublisher = new MockPublisher((ISilDataAccessManaged)Cache.DomainDataByFlid, kmainFlid);
                m_revPublisher.SetOwningPropValue(m_revIndex.AllEntries.Select(rie => rie.Hvo).ToArray());
                m_revDecorator = new DictionaryPublicationDecorator(Cache, m_revPublisher, ObjectListPublisher.OwningFlid);
            });
        }
示例#41
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a new LexicalEntry from the specified lexical entry in the DB
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private LexicalEntry CreateEntryFromDbEntry(LexemeType type, ILexEntry dbEntry)
		{
			if (type == LexemeType.Word)
				throw new ArgumentException("Lexeme type specified can not be created from a LexEntry");

			// A homograph number of zero in the DB means there is only one entry for the wordform.
			// However, the interface requires there be an entry with a homograph of one even if
			// there is only one entry.
			LexicalEntry entry = new LexicalEntry(type, dbEntry.HomographForm,
				dbEntry.HomographNumber > 0 ? dbEntry.HomographNumber : 1);

			// Add the senses to the interface (non-DB) entry
			foreach (ILexSense dbSense in dbEntry.SensesOS)
			{
				LexSense sense = new LexSense(dbSense.Guid.ToString());
				AddDbGlossesToSense(sense, dbSense.Gloss);
				entry.Senses.Add(sense); // Add the sense to the list of senses
			}
			return entry;
		}
        public LfCommentRegarding FromTargetGuid(Guid guidOfUnknownFdoObject, FieldLists fieldConfigs)
        {
            var result = new LfCommentRegarding();             // Worst case, we'll return this empty object rather than null

            if (!_servLoc.ObjectRepository.IsValidObjectId(guidOfUnknownFdoObject))
            {
                return(result);
            }
            ICmObject fdoObject = _servLoc.ObjectRepository.GetObject(guidOfUnknownFdoObject);

            if (fdoObject == null)
            {
                return(result);
            }
            result.TargetGuid = fdoObject.Guid.ToString();
            switch (fdoObject.ClassID)
            {
            case LexEntryTags.kClassId:
            {
                var entry = fdoObject as ILexEntry;
                if (entry != null)                         // Paranoia; should never happen, but check anyway
                {
                    result.Word    = entry.ShortName;
                    result.Meaning = entry.NumberOfSensesForEntry < 1 ? "" : Definition(entry.SensesOS[0]);
                }
                break;
            }

            case LexSenseTags.kClassId:
            {
                var sense = fdoObject as ILexSense;
                if (sense == null || sense.Entry == null)                         // Paranoia; should never happen, but check anyway
                {
                    return(result);
                }
                ILexEntry entry = sense.Entry;
                result.TargetGuid          = entry.Guid.ToString();
                result.Word                = entry.ShortName;
                result.Meaning             = Definition(sense);
                result.Field               = MagicStrings.LfFieldNameForDefinition;           // Even if it's really the gloss, we'll say it's the definition for LF display purposes
                result.FieldNameForDisplay = FieldNameForDisplay(result.Field, fieldConfigs.senseConfig);
                result.FieldValue          = result.Meaning;
                break;
            }

            case LexExampleSentenceTags.kClassId:
            {
                var example = fdoObject as ILexExampleSentence;
                if (example == null || example.Owner == null)                         // Paranoia; should never happen, but check anyway
                {
                    return(result);
                }
                var sense = example.Owner as ILexSense;                         // Example sentences are always owned by senses
                if (sense == null || sense.Entry == null)                       // Paranoia; should never happen, but check anyway
                {
                    return(result);
                }
                ILexEntry entry = sense.Entry;
                result.TargetGuid          = entry.Guid.ToString();
                result.Word                = entry.ShortName;
                result.Meaning             = Definition(sense);
                result.Field               = MagicStrings.LfFieldNameForExampleSentence;           // Even if it's really a subfield of the example, we'll say it's the example for LF display purposes
                result.FieldNameForDisplay = FieldNameForDisplay(result.Field, fieldConfigs.exampleConfig);
                result.FieldValue          = ExampleValue(example);
                break;
            }

            default:
            {
                // Last-ditch effort: climb the owner chain and maybe we'll hit a LexEntry
                while (fdoObject.Owner != null && fdoObject.ClassID != LexEntryTags.kClassId)
                {
                    fdoObject = fdoObject.Owner;
                }
                if (fdoObject != null && fdoObject.ClassID == LexEntryTags.kClassId)
                {
                    var entry = fdoObject as ILexEntry;
                    if (entry != null)
                    {
                        result.Word    = entry.ShortName;
                        result.Meaning = entry.NumberOfSensesForEntry < 1 ? "" : Definition(entry.SensesOS[0]);
                    }
                }
                // But if we didn't, then just give up
                break;
            }
            }
            return(result);
        }
示例#43
0
		/// <summary>
		/// find the best existing LexEntry option matching 'homographform' (and possibly 'sDefnTarget')
		/// in order to determine if we should merge leTarget into that entry.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="homographForm"></param>
		/// <param name="sDefnTarget"></param>
		/// <param name="leTarget">a LexEntry that you want to consider merging into a more appropriate LexEntry,
		/// if null, we ignore 'newHvos' and 'hvoDomain'</param>
		/// <param name="newHvos"></param>
		/// <param name="hvoDomain"></param>
		/// <param name="fGotExactMatch"></param>
		/// <returns></returns>
		private static ILexEntry FindBestLexEntryAmongstHomographs(FdoCache cache,
			string homographForm, string sDefnTarget, ILexEntry leTarget, Set<int> newHvos,
			int hvoDomain, out bool fGotExactMatch)
		{
			ILexEntry leSaved = null;
			List<ILexEntry> rgEntries = LexEntry.CollectHomographs(homographForm, 0,
				LexEntry.GetHomographList(cache, homographForm),
				MoMorphType.kmtStem, true);
			leSaved = null; // saved entry to merge into (from previous iteration)
			bool fSavedIsOld = false; // true if leSaved is old (and non-null).
			fGotExactMatch = false; // true if we find a match for cf AND defn.
			bool fCurrentIsNew = false;
			foreach (ILexEntry leCurrent in rgEntries)
			{
				if (leTarget != null)
				{
					if (leCurrent.Hvo == leTarget.Hvo)
						continue; // not interested in merging with ourself.
					// See if this is one of the newly added entries. If it is, it has exactly one sense,
					// and that sense is in our list.
					fCurrentIsNew = leCurrent.SensesOS.Count == 1 && newHvos.Contains(leCurrent.SensesOS.HvoArray[0]);
					if (fCurrentIsNew && leCurrent.Hvo > leTarget.Hvo)
						continue;  // won't consider ANY kind of merge with a new object of greater HVO.
				}
				// Decide whether lexE should be noted as the entry that we will merge with if
				// we don't find an exact match.
				if (!fGotExactMatch) // leMerge is irrelevant if we already got an exact match.
				{
					if (leSaved == null)
					{
						leSaved = leCurrent;
						fSavedIsOld = !fCurrentIsNew;
					}
					else // we have already found a candidate
					{
						if (fSavedIsOld)
						{
							// We will only consider the new one if it is also old, and
							// (rather arbitrarily) if it has a smaller HVO
							if ((!fCurrentIsNew) && leCurrent.Hvo < leSaved.Hvo)
							{
								leSaved = leCurrent; // fSavedIsOld stays true.
							}
						}
						else // we already have a candidate, but it is another of the new entries
						{
							// if current is old, we'll use it for sure
							if (!fCurrentIsNew)
							{
								leSaved = leCurrent;
								fSavedIsOld = false; // since fCurrentIsNew is false.
							}
							else
							{
								// we already have a new candidate (which must have a smaller hvo than target)
								// and now we have another new entry which matches!
								// We'll prefer it only if its hvo is smaller still.
								if (leCurrent.Hvo < leSaved.Hvo)
								{
									leSaved = leCurrent; // fSavedIsOld stays false.
								}
							}
						}
					}
				}

				// see if we want to try to find a matching existing sense.
				if (sDefnTarget == null)
					continue;
				// This deals with all senses in the entry,
				// whether owned directly by the entry or by its senses
				// at whatever level.
				// If the new definition matches an existing defintion (or if both
				// are missing) add the current domain to the existing sense.
				// Note: if more than one sense has the same definition (maybe missing) we should
				// add the domain to all senses--not just the first one encountered.
				foreach (ILexSense lexS in leCurrent.AllSenses)
				{
					if (lexS.Definition != null
						&& lexS.Definition.AnalysisDefaultWritingSystem != null)
					{
						string sDefnCurrent = lexS.Definition.AnalysisDefaultWritingSystem.UnderlyingTsString.Text;
						if ((sDefnCurrent == null && sDefnTarget == null) ||
							(sDefnCurrent != null && sDefnTarget != null && sDefnCurrent.Trim() == sDefnTarget.Trim()))
						{
							// We found a sense that has the same citation form and definition as the one
							// we're trying to merge.
							// Add the new domain to that sense (if not already present), delete the temporary one,
							// and return. (We're not displaying this sense, so don't bother trying to update the display)
							if (hvoDomain > 0 && !lexS.SemanticDomainsRC.Contains(hvoDomain))
								lexS.SemanticDomainsRC.Add(hvoDomain);
							fGotExactMatch = true;
						}
					}
				}
			} // loop over matching entries

			return leSaved;
		}
示例#44
0
        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;
                }
            }
        }
示例#45
0
		static private void SetCircumfixLexemeForm(FdoCache cache, ILexEntry entry, ITsString tssLexemeForm, IMoMorphType morphType)
		{
			int iHvo = cache.CreateObject(MoAffixAllomorph.kClassId, entry.Hvo, (int)LexEntry.LexEntryTags.kflidLexemeForm, 0);
			MoAffixAllomorph lexemeAllo = new MoAffixAllomorph(cache, iHvo);
			lexemeAllo.Form.SetAlternativeTss(tssLexemeForm);
			lexemeAllo.MorphTypeRA = morphType;
			lexemeAllo.IsAbstract = true;
		}
示例#46
0
        /// <summary>
        /// Initialize the dialog before showing it.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="entry"></param>
        /// <param name="titleForEdit">Edit title appropriate to the button's context.</param>
        public void SetDlgInfo(FdoCache cache, IPersistenceProvider persistProvider,
                               Mediator mediator, ILexEntry entry, SandboxGenericMSA sandboxMsa, int hvoOriginalMsa,
                               bool useForEdit, string titleForEdit)
        {
            CheckDisposed();

            Debug.Assert(m_cache == null);
            MsaType msaType = sandboxMsa.MsaType;

            m_cache    = cache;
            m_mediator = mediator;

            if (useForEdit)
            {
                // Change the window title and the OK button text.
                Text        = titleForEdit;
                s_helpTopic = "khtpEditGrammaticalFunction";
                btnOk.Text  = LexText.Controls.LexTextControls.ks_OK;
            }
            helpProvider.HelpNamespace = mediator.HelpTopicProvider.HelpFile;
            helpProvider.SetHelpKeyword(this, mediator.HelpTopicProvider.GetHelpString(s_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

            // Set font, writing system factory, and code for the edit box.
            float          fntSize   = label1.Font.Size * 2.0F;
            IWritingSystem defVernWs = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

            m_fwtbCitationForm.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbCitationForm.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbCitationForm.WritingSystemCode    = defVernWs.Handle;
            m_fwtbCitationForm.AdjustForStyleSheet(this, null, mediator);
            m_fwtbCitationForm.AdjustStringHeight = false;
            m_fwtbCitationForm.Tss       = entry.HeadWord;
            m_fwtbCitationForm.HasBorder = false;

            m_fwtbSenses.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbSenses.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbSenses.WritingSystemCode    = defVernWs.Handle;
            m_fwtbSenses.AdjustForStyleSheet(this, null, mediator);
            m_fwtbSenses.AdjustStringHeight = false;

            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_cache.DefaultAnalWs);
            var msaRepository = m_cache.ServiceLocator.GetInstance <IMoMorphSynAnalysisRepository>();

            if (hvoOriginalMsa != 0)
            {
                foreach (var sense in entry.AllSenses)
                {
                    if (sense.MorphoSyntaxAnalysisRA != null)
                    {
                        if (sense.MorphoSyntaxAnalysisRA == msaRepository.GetObject(hvoOriginalMsa))
                        {
                            if (tisb.Text != null)
                            {
                                tisb.Append(", ");                                      // REVIEW: IS LOCALIZATION NEEDED FOR BUILDING THIS LIST?
                            }
                            tisb.AppendTsString(sense.ShortNameTSS);
                        }
                    }
                }
            }
            m_fwtbSenses.Tss       = tisb.GetString();
            m_fwtbSenses.HasBorder = false;

            m_msaGroupBox.Initialize(m_cache, m_mediator, this, sandboxMsa);
            int oldHeight = m_msaGroupBox.Height;
            int newHeight = Math.Max(oldHeight, m_msaGroupBox.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta > 0)
            {
                m_msaGroupBox.AdjustInternalControlsAndGrow();
                Debug.Assert(m_msaGroupBox.Height == m_msaGroupBox.PreferredHeight);
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_msaGroupBox);
            }

            if (mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue("msaCreatorDlgLocation");
                // JohnT: this dialog can't be resized. So it doesn't make sense to
                // remember a size. If we do, we need to override OnLoad (as in SimpleListChooser)
                // to prevent the dialog growing every time at 120 dpi. But such an override
                // makes it too small to show all the controls at the default size.
                // It's better just to use the default size until it's resizeable for some reason.
                //m_mediator.PropertyTable.GetValue("msaCreatorDlgSize");
                object szWnd = this.Size;
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }
        }
示例#47
0
        /// <summary>
        /// The user selected an item; now we actually need a LexEntryRef.
        /// </summary>
        /// <param name="hvoNew"></param>
        private void AddItem(ICmObject newObj)
        {
            CheckDisposed();

            bool   fForVariant = XmlUtils.GetOptionalBooleanAttributeValue(m_configurationNode, "forVariant", false);
            string sUndo, sRedo;

            if (fForVariant)
            {
                sUndo = LexEdStrings.ksUndoVariantOf;
                sRedo = LexEdStrings.ksRedoVariantOf;
            }
            else
            {
                sUndo = LexEdStrings.ksUndoAddComponent;
                sRedo = LexEdStrings.ksRedoAddComponent;
            }
            try
            {
                UndoableUnitOfWorkHelper.Do(sUndo, sRedo, m_obj,
                                            () =>
                {
                    ILexEntry ent = m_obj as ILexEntry;

                    // It IS a ghost slice after all; it shouldn't already have any of whatever we're about to add.
                    Debug.Assert(!(fForVariant ? ent.VariantEntryRefs.Any() : ent.ComplexFormEntryRefs.Any()));
                    if (fForVariant ? ent.VariantEntryRefs.Any() : ent.ComplexFormEntryRefs.Any())
                    {
                        return;
                    }

                    // Adapted from part of DtMenuHandler.AddNewLexEntryRef.
                    ILexEntryRef ler = ent.Services.GetInstance <ILexEntryRefFactory>().Create();
                    ent.EntryRefsOS.Add(ler);
                    if (fForVariant)
                    {
                        const string unspecVariantEntryTypeGuid = "3942addb-99fd-43e9-ab7d-99025ceb0d4e";
                        var type = ent.Cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS
                                   .First(lrt => lrt.Guid.ToString() == unspecVariantEntryTypeGuid) as ILexEntryType;
                        ler.VariantEntryTypesRS.Add(type);
                        ler.RefType        = LexEntryRefTags.krtVariant;
                        ler.HideMinorEntry = 0;
                    }
                    else
                    {
                        ler.RefType = LexEntryRefTags.krtComplexForm;
                        const string unspecComplexFormEntryTypeGuid = "fec038ed-6a8c-4fa5-bc96-a4f515a98c50";
                        var type = ent.Cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS
                                   .First(lrt => lrt.Guid.ToString() == unspecComplexFormEntryTypeGuid) as ILexEntryType;
                        ler.ComplexEntryTypesRS.Add(type);
                        ler.HideMinorEntry = 0;                         // LT-10928
                        // Logic similar to this is in EntrySequenceReferenceLauncher.AddNewObjectsToProperty()
                        // (when LER already exists so slice is not ghost)
                        ler.PrimaryLexemesRS.Add(newObj);
                        // Since it's a new LER, we can't know it to be a derivative, so by default it is visible.
                        // but do NOT do that here, it's now built into the process of adding it to PrimaryLexemes,
                        // and we don't want to do it twice.
                        ent.ChangeRootToStem();
                    }
                    // Must do this AFTER setting the RefType (so dependent virtual properties can be updated properly)
                    ler.ComponentLexemesRS.Add(newObj);
                });
            }
            catch (ArgumentException)
            {
                MessageBoxes.ReportLexEntryCircularReference((ILexEntry)m_obj, newObj, true);
            }
        }
示例#48
0
		public override void TestSetup()
		{
			base.TestSetup();


			IManyOnePathSortItem mopsi = new ManyOnePathSortItem(Cache.LangProject);
			m_list = new ArrayList();
			m_list.Add(mopsi);
			var leFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
			UndoableUnitOfWorkHelper.Do("undoit", "redoit", Cache.ActionHandlerAccessor, () =>
			{
				m_le1 = leFactory.Create();
				m_le2 = leFactory.Create();
			});
			mopsi = new ManyOnePathSortItem(Cache.LangProject.LexDbOA.Hvo, new int[] { m_le1.Hvo, m_le2.Hvo }, new int[] { 2, 3 });
			m_list.Add(mopsi);
		}
示例#49
0
		private string GetLexReferenceName(ILexEntry lexEntry, ILexRefType lexRefType)
		{
			// The name we want to use for our lex reference is either the name or the reverse name
			// (depending on the direction of the relationship, if relevant) of the owning lex ref type.
			ITsString lexReferenceName = lexRefType.Name.BestVernacularAnalysisAlternative;

			if (lexRefType.MappingType == (int)MappingTypes.kmtEntryAsymmetricPair ||
				lexRefType.MappingType == (int)MappingTypes.kmtEntryOrSenseAsymmetricPair ||
				lexRefType.MappingType == (int)MappingTypes.kmtSenseAsymmetricPair ||
				lexRefType.MappingType == (int)MappingTypes.kmtEntryTree ||
				lexRefType.MappingType == (int)MappingTypes.kmtEntryOrSenseTree ||
				lexRefType.MappingType == (int)MappingTypes.kmtSenseTree)
			{
				if (lexEntry.OwnOrd == 0 && lexRefType.Name != null) // the original code had a check for name length as well.
					lexReferenceName = lexRefType.ReverseName.BestAnalysisAlternative;
			}

			return lexReferenceName.Text;
		}
示例#50
0
        /// <summary>
        /// Convert Lcm lex entry to LF lex entry.
        /// </summary>
        /// <returns>LF entry
        /// <param name="LcmEntry">Lcm entry.</param>
        private LfLexEntry LcmLexEntryToLfLexEntry(ILexEntry LcmEntry)
        {
            if (LcmEntry == null)
            {
                return(null);
            }

            ILgWritingSystem AnalysisWritingSystem   = ServiceLocator.LanguageProject.DefaultAnalysisWritingSystem;
            ILgWritingSystem VernacularWritingSystem = ServiceLocator.LanguageProject.DefaultVernacularWritingSystem;

            var lfEntry = new LfLexEntry();

            IMoForm LcmLexeme = LcmEntry.LexemeFormOA;

            if (LcmLexeme == null)
            {
                lfEntry.Lexeme = null;
            }
            else
            {
                lfEntry.Lexeme = ToMultiText(LcmLexeme.Form);
            }
            // Other fields of LcmLexeme (AllomorphEnvironments, LiftResidue, MorphTypeRA, etc.) not mapped

            // Fields below in alphabetical order by ILexSense property, except for Lexeme
            foreach (IMoForm allomorph in LcmEntry.AlternateFormsOS)
            {
                // Do nothing; LanguageForge doesn't currently handle allomorphs, so we don't convert them
            }
            lfEntry.EntryBibliography = ToMultiText(LcmEntry.Bibliography);
            // TODO: Consider whether to use LcmEntry.CitationFormWithAffixType instead
            // (which would produce "-s" instead of "s" for the English plural suffix, for instance)
            lfEntry.CitationForm = ToMultiText(LcmEntry.CitationForm);
            lfEntry.Note         = ToMultiText(LcmEntry.Comment);

            // DateModified and DateCreated can be confusing, because LF and Lcm are doing two different
            // things with them. In Lcm, there is just one DateModified and one DateCreated; simple. But
            // in LF, there is an AuthorInfo record as well, which contains its own ModifiedDate and CreatedDate
            // fields. (Note the word order: there's LfEntry.DateCreated, and LfEntry.AuthorInfo.CreatedDate).

            // The conversion we have chosen to use is: AuthorInfo will correspond to Lcm. So Lcm.DateCreated
            // becomes AuthorInfo.CreatedDate, and Lcm.DateModified becomes AuthorInfo.ModifiedDate. The two
            // fields on the LF entry will instead refer to when the *Mongo record* was created or modified,
            // and the LfEntry.DateCreated and LfEntry.DateModified fields will never be put into Lcm.

            var now = DateTime.UtcNow;

            if (LfProject.IsInitialClone)
            {
                lfEntry.DateCreated = now;
            }
            // LanguageForge needs this modified to know there is changed data
            lfEntry.DateModified = now;

            if (lfEntry.AuthorInfo == null)
            {
                lfEntry.AuthorInfo = new LfAuthorInfo();
            }
            lfEntry.AuthorInfo.CreatedByUserRef  = null;
            lfEntry.AuthorInfo.CreatedDate       = LcmEntry.DateCreated.ToUniversalTime();
            lfEntry.AuthorInfo.ModifiedByUserRef = null;
            lfEntry.AuthorInfo.ModifiedDate      = LcmEntry.DateModified.ToUniversalTime();

#if DBVERSION_7000068
            ILexEtymology LcmEtymology = LcmEntry.EtymologyOA;
#else
            // TODO: Once LF's data model is updated from a single etymology to an array,
            // convert all of them instead of just the first. E.g.,
            // foreach (ILexEtymology LcmEtymology in LcmEntry.EtymologyOS) { ... }
            ILexEtymology LcmEtymology = null;
            if (LcmEntry.EtymologyOS.Count > 0)
            {
                LcmEtymology = LcmEntry.EtymologyOS.First();
            }
#endif
            if (LcmEtymology != null)
            {
                lfEntry.Etymology        = ToMultiText(LcmEtymology.Form);
                lfEntry.EtymologyComment = ToMultiText(LcmEtymology.Comment);
                lfEntry.EtymologyGloss   = ToMultiText(LcmEtymology.Gloss);
#if DBVERSION_7000068
                lfEntry.EtymologySource = LfMultiText.FromSingleStringMapping(AnalysisWritingSystem.Id, LcmEtymology.Source);
#else
                lfEntry.EtymologySource = ToMultiText(LcmEtymology.LanguageNotes);
#endif
                // LcmEtymology.LiftResidue not mapped
            }
            lfEntry.Guid = LcmEntry.Guid;
            if (LcmEntry.LIFTid == null)
            {
                lfEntry.LiftId = null;
            }
            else
            {
                lfEntry.LiftId = LcmEntry.LIFTid.Normalize(System.Text.NormalizationForm.FormC);                  // Because LIFT files on disk are NFC and we need to make sure LiftIDs match those on disk
            }
            lfEntry.LiteralMeaning = ToMultiText(LcmEntry.LiteralMeaning);
            if (LcmEntry.PrimaryMorphType != null)
            {
                lfEntry.MorphologyType = LcmEntry.PrimaryMorphType.NameHierarchyString;
            }
            // TODO: Once LF's data model is updated from a single pronunciation to an array of pronunciations, convert all of them instead of just the first. E.g.,
            //foreach (ILexPronunciation LcmPronunciation in LcmEntry.PronunciationsOS) { ... }
            if (LcmEntry.PronunciationsOS.Count > 0)
            {
                ILexPronunciation LcmPronunciation = LcmEntry.PronunciationsOS.First();
                lfEntry.Pronunciation = ToMultiText(LcmPronunciation.Form);
                lfEntry.CvPattern     = LfMultiText.FromSingleITsString(LcmPronunciation.CVPattern, ServiceLocator.WritingSystemFactory);
                lfEntry.Tone          = LfMultiText.FromSingleITsString(LcmPronunciation.Tone, ServiceLocator.WritingSystemFactory);
                // TODO: Map LcmPronunciation.MediaFilesOS properly (converting video to sound files if necessary)
                lfEntry.Location = ToStringField(LocationListCode, LcmPronunciation.LocationRA);
            }
            lfEntry.EntryRestrictions = ToMultiText(LcmEntry.Restrictions);
            if (lfEntry.Senses == null)             // Shouldn't happen, but let's be careful
            {
                lfEntry.Senses = new List <LfSense>();
            }
            lfEntry.Senses.AddRange(LcmEntry.SensesOS.Select(LcmSenseToLfSense));
            lfEntry.SummaryDefinition = ToMultiText(LcmEntry.SummaryDefinition);

            BsonDocument customFieldsAndGuids = _convertCustomField.GetCustomFieldsForThisCmObject(LcmEntry, "entry", ListConverters);
            BsonDocument customFieldsBson     = customFieldsAndGuids["customFields"].AsBsonDocument;
            BsonDocument customFieldGuids     = customFieldsAndGuids["customFieldGuids"].AsBsonDocument;

            lfEntry.CustomFields     = customFieldsBson;
            lfEntry.CustomFieldGuids = customFieldGuids;

            return(lfEntry);

            /* Fields not mapped because it doesn't make sense to map them (e.g., Hvo, backreferences, etc):
             * LcmEntry.ComplexFormEntries;
             * LcmEntry.ComplexFormEntryRefs;
             * LcmEntry.ComplexFormsNotSubentries;
             * LcmEntry.EntryRefsOS;
             * LcmEntry.HasMoreThanOneSense;
             * LcmEntry.HeadWord; // Read-only virtual property
             * LcmEntry.IsMorphTypesMixed; // Read-only property
             * LcmEntry.LexEntryReferences;
             * LcmEntry.MainEntriesOrSensesRS;
             * LcmEntry.MinimalLexReferences;
             * LcmEntry.MorphoSyntaxAnalysesOC;
             * LcmEntry.MorphTypes;
             * LcmEntry.NumberOfSensesForEntry;
             * LcmEntry.PicturesOfSenses;
             *
             */

            /* Fields that would make sense to map, but that we don't because LF doesn't handle them (e.g., allomorphs):
             * LcmEntry.AllAllomorphs; // LF doesn't handle allomorphs, so skip all allomorph-related fields
             * LcmEntry.AlternateFormsOS;
             * LcmEntry.CitationFormWithAffixType; // Citation form already mapped
             * LcmEntry.DoNotPublishInRC;
             * LcmEntry.DoNotShowMainEntryInRC;
             * LcmEntry.DoNotUseForParsing;
             * LcmEntry.HomographForm;
             * LcmEntry.HomographFormKey;
             * LcmEntry.HomographNumber;
             * LcmEntry.ImportResidue;
             * LcmEntry.LiftResidue;
             * LcmEntry.PronunciationsOS
             * LcmEntry.PublishAsMinorEntry;
             * LcmEntry.PublishIn;
             * LcmEntry.ShowMainEntryIn;
             * LcmEntry.Subentries;
             * LcmEntry.VariantEntryRefs;
             * LcmEntry.VariantFormEntries;
             * LcmEntry.VisibleComplexFormBackRefs;
             * LcmEntry.VisibleComplexFormEntries;
             * LcmEntry.VisibleVariantEntryRefs;
             *
             */
        }
示例#51
0
		// Swap values of various attributes between an existing form that is a LexemeForm and
		// a newly created one. Includes adding the new one to the alternate forms of the entry, and
		// the id of the old one to a map of things to delete.
		private void SwapFormValues(ILexEntry entry, IMoForm origForm, IMoForm newForm, int typeHvo, Set<int> idsToDel)
		{
			entry.AlternateFormsOS.Add(newForm);
			origForm.SwapReferences(newForm);
			var muaOrigForm = origForm.Form;
			var muaNewForm = newForm.Form;
			muaNewForm.MergeAlternatives(muaOrigForm);
			newForm.MorphTypeRA = m_cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(typeHvo);
			idsToDel.Add(origForm.Hvo);
		}
示例#52
0
        /// <summary>
        /// </summary>
        /// <param name="formLexEntry"></param>
        /// <param name="senseGloss"></param>
        /// <param name="partOfSpeech"></param>
        /// <param name="lexEntry1_Entry"></param>
        /// <param name="lexEntry1_Sense1"></param>
        private void SetupLexEntryAndSense(string formLexEntry, string senseGloss, string partOfSpeech, out ILexEntry lexEntry1_Entry, out ILexSense lexEntry1_Sense1)
        {
            ITsString tssLexEntryForm = TsStringUtils.MakeTss(formLexEntry, Cache.DefaultVernWs);
            // create a sense with a matching gloss
            var entryComponents = MorphServices.BuildEntryComponents(Cache, tssLexEntryForm);
            int hvoSenseMsaPos  = m_sandbox.GetComboItemHvo(InterlinLineChoices.kflidWordPos, 0, partOfSpeech);

            if (hvoSenseMsaPos != 0)
            {
                entryComponents.MSA.MainPOS = Cache.ServiceLocator.GetInstance <IPartOfSpeechRepository>().GetObject(hvoSenseMsaPos);
            }
            entryComponents.GlossAlternatives.Add(TsStringUtils.MakeTss(senseGloss, Cache.DefaultAnalWs));
            ILexEntry newEntry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(entryComponents);

            lexEntry1_Entry  = newEntry;
            lexEntry1_Sense1 = newEntry.SensesOS[0];
        }
示例#53
0
		private void SetLexeme(ILexEntry le, string form)
		{
			UndoableUnitOfWorkHelper.Do("Undo stuff", "Redo stuff", m_actionHandler,
				() =>
					{
						var lf = le.Services.GetInstance<IMoStemAllomorphFactory>().Create();
						le.LexemeFormOA = lf;
						lf.Form.VernacularDefaultWritingSystem = lf.Cache.TsStrFactory.MakeString(form,
							Cache.DefaultVernWs);
					});
		}
示例#54
0
        private IWfiMorphBundle SetupMorphBundleForEntry(AnalysisOccurrence cba0_0, string gloss, ILexEntry lexEntry1_Entry, ILexSense lexEntry1_Sense1, out IWfiWordform wf)
        {
            IWfiAnalysis analysis = SetupAnalysisForEntry(cba0_0, gloss, lexEntry1_Sense1, out wf);

            return(AppendMorphBundleToAnalysis(lexEntry1_Entry, lexEntry1_Sense1, analysis));
        }
示例#55
0
        public void TwoAnalyses()
        {
            int    hvoBearTEST = CheckAnalysisSize("bearsTEST", 0, true);
            string xmlFragment = "";

            using (FdoCache cache = FdoCache.Create("TestLangProj"))
            {
                ILexDb ldb = cache.LangProject.LexDbOA;

                // Noun
                ILexEntry bearN = (ILexEntry)ldb.EntriesOC.Add(new LexEntry());
                AddIdToList(bearN.Hvo);
                IMoStemAllomorph bearNForm = (IMoStemAllomorph)bearN.AlternateFormsOS.Append(new MoStemAllomorph());
                bearNForm.Form.VernacularDefaultWritingSystem = "bearNTEST";
                IMoStemMsa bearNMSA = (IMoStemMsa)bearN.MorphoSyntaxAnalysesOC.Add(new MoStemMsa());

                ILexEntry sPL = (ILexEntry)ldb.EntriesOC.Add(new LexEntry());
                AddIdToList(sPL.Hvo);
                IMoAffixAllomorph sPLForm = (IMoAffixAllomorph)sPL.AlternateFormsOS.Append(new MoAffixAllomorph());
                sPLForm.Form.VernacularDefaultWritingSystem = "sPLTEST";
                IMoInflAffMsa sPLMSA =
                    (IMoInflAffMsa)sPL.MorphoSyntaxAnalysesOC.Add(new MoInflAffMsa());

                // Verb
                ILexEntry bearV = (ILexEntry)ldb.EntriesOC.Add(new LexEntry());
                AddIdToList(bearV.Hvo);
                IMoStemAllomorph bearVForm = (IMoStemAllomorph)bearV.AlternateFormsOS.Append(new MoStemAllomorph());
                bearVForm.Form.VernacularDefaultWritingSystem = "bearVTEST";
                IMoStemMsa bearVMSA = (IMoStemMsa)bearV.MorphoSyntaxAnalysesOC.Add(new MoStemMsa());

                ILexEntry sAGR = (ILexEntry)ldb.EntriesOC.Add(new LexEntry());
                AddIdToList(sAGR.Hvo);
                IMoAffixAllomorph sAGRForm = (IMoAffixAllomorph)sAGR.AlternateFormsOS.Append(new MoAffixAllomorph());
                sAGRForm.Form.VernacularDefaultWritingSystem = "sAGRTEST";
                IMoInflAffMsa sAGRMSA =
                    (IMoInflAffMsa)sAGR.MorphoSyntaxAnalysesOC.Add(new MoInflAffMsa());


                xmlFragment = "<Wordform DbRef='" + hvoBearTEST.ToString() + "' Form='bearsTEST'>\n"
                              + "<WfiAnalysis>\n"
                              + "<Morphs>\n"
                              + "<Morph>\n"
                              + "<MoForm DbRef='" + bearNForm.Hvo.ToString() + "' Label='bearNTEST'/>\n"
                              + "<MSI DbRef='" + bearNMSA.Hvo.ToString() + "'/>\n"
                              + "</Morph>\n"
                              + "<Morph>\n"
                              + "<MoForm DbRef='" + sPLForm.Hvo.ToString() + "' Label='sPLTEST'/>\n"
                              + "<MSI DbRef='" + sPLMSA.Hvo.ToString() + "'/>\n"
                              + "</Morph>\n"
                              + "</Morphs>\n"
                              + "</WfiAnalysis>\n"
                              + "<WfiAnalysis>\n"
                              + "<Morphs>\n"
                              + "<Morph>\n"
                              + "<MoForm DbRef='" + bearVForm.Hvo.ToString() + "' Label='bearVTEST'/>\n"
                              + "<MSI DbRef='" + bearVMSA.Hvo.ToString() + "'/>\n"
                              + "</Morph>\n"
                              + "<Morph>\n"
                              + "<MoForm DbRef='" + sAGRForm.Hvo.ToString() + "' Label='sAGRTEST'/>\n"
                              + "<MSI DbRef='" + sAGRMSA.Hvo.ToString() + "'/>\n"
                              + "</Morph>\n"
                              + "</Morphs>\n"
                              + "</WfiAnalysis>\n"
                              + "</Wordform>\n";
            }
            m_filer.ProcessParse(MakeXML(xmlFragment, true));
            CheckAnalysisSize("bearsTEST", 2, false);
        }
示例#56
0
 public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
 {
     if (Entry == null)                 // only do it once, or we get a stack overflow
     {
         NonUndoableUnitOfWorkHelper.DoSomehow(Parent.m_actionHandler, () => { Entry = Parent.MakeEntry("another entry"); });
     }
 }
		private ILexEntryRef FindMatchingEntryRef(ILexEntry variant, IVariantComponentLexeme componentLexeme, ILexEntryType selectedEntryType)
		{
			ILexEntryRef matchingEntryRef = null;
			if (variant != null)
			{
				// see if the starting entry has the SelectedID already as a ComponentLexeme
				matchingEntryRef = (variant as LexEntry).FindMatchingVariantEntryRef(componentLexeme,
					selectedEntryType);
			}
			else
			{
				// determine whether the selected entry or sense is already
				// linked to an existing variant with the given lexeme form.
				matchingEntryRef = LexEntry.FindMatchingVariantEntryBackRef(componentLexeme,
					selectedEntryType, m_tssVariantLexemeForm);
			}
			return matchingEntryRef;
		}
示例#58
0
 /// <summary>
 /// This allows us to get the headword without actually creating an instance...
 /// which can be slow.
 /// </summary>
 internal static ITsString HeadWordStaticForWs(ILexEntry entry, int wsVern)
 {
     return(HeadWordForWsAndHn(entry, wsVern, entry.HomographNumber));
 }
示例#59
0
		/// <summary>
		/// Initialize the dialog before showing it.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="entry"></param>
		/// <param name="titleForEdit">Edit title appropriate to the button's context.</param>
		public void SetDlgInfo(FdoCache cache, IPersistenceProvider persistProvider,
			Mediator mediator, ILexEntry entry, DummyGenericMSA dummyMsa, int hvoOriginalMsa,
			bool useForEdit, string titleForEdit)
		{
			CheckDisposed();

			Debug.Assert(m_cache == null);
			MsaType msaType = dummyMsa.MsaType;

			m_cache = cache;
			m_mediator = mediator;

			if (useForEdit)
			{
				// Change the window title and the OK button text.
				Text = titleForEdit;
				s_helpTopic = "khtpEditGrammaticalFunction";
				this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
				btnOk.Text = LexText.Controls.LexTextControls.ks_OK;
			}

			// Set font, writing system factory, and code for the edit box.
			float fntSize = label1.Font.Size * 2.0F;
			m_fwtbCitationForm.Font =
				new Font(m_cache.LangProject.DefaultVernacularWritingSystemFont, fntSize);
			m_fwtbCitationForm.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
			m_fwtbCitationForm.WritingSystemCode =
				m_cache.LangProject.DefaultVernacularWritingSystem;
			m_fwtbCitationForm.AdjustForStyleSheet(this, null, mediator);
			m_fwtbCitationForm.AdjustStringHeight = false;
			m_fwtbCitationForm.Tss = entry.HeadWord;
			m_fwtbCitationForm.HasBorder = false;

			m_fwtbSenses.Font =
				new Font(m_cache.LangProject.DefaultVernacularWritingSystemFont, fntSize);
			m_fwtbSenses.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
			m_fwtbSenses.WritingSystemCode =
				m_cache.LangProject.DefaultVernacularWritingSystem;
			m_fwtbSenses.AdjustForStyleSheet(this, null, mediator);
			m_fwtbSenses.AdjustStringHeight = false;

			string sSenses = string.Empty;
			ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
			foreach (ILexSense sense in entry.AllSenses)
			{
				if (sense.MorphoSyntaxAnalysisRA != null)
				{
					if (sense.MorphoSyntaxAnalysisRAHvo == hvoOriginalMsa)
					{
						if (tisb.Text != null)
							tisb.Append(", ");	// REVIEW: IS LOCALIZATION NEEDED FOR BUILDING THIS LIST?
						tisb.AppendTsString(sense.ShortNameTSS);
					}
				}
			}
			m_fwtbSenses.Tss = tisb.GetString();
			m_fwtbSenses.HasBorder = false;

			m_msaGroupBox.Initialize(m_cache, m_mediator, this, dummyMsa);
			int oldHeight = m_msaGroupBox.Height;
			int newHeight = Math.Max(oldHeight, m_msaGroupBox.PreferredHeight);
			int delta = newHeight - oldHeight;
			if (delta > 0)
			{
				m_msaGroupBox.AdjustInternalControlsAndGrow();
				Debug.Assert(m_msaGroupBox.Height == m_msaGroupBox.PreferredHeight);
				FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_msaGroupBox);
			}

			if (mediator != null)
			{
				// Reset window location.
				// Get location to the stored values, if any.
				object locWnd = m_mediator.PropertyTable.GetValue("msaCreatorDlgLocation");
				// JohnT: this dialog can't be resized. So it doesn't make sense to
				// remember a size. If we do, we need to override OnLoad (as in SimpleListChooser)
				// to prevent the dialog growing every time at 120 dpi. But such an override
				// makes it too small to show all the controls at the default size.
				// It's better just to use the default size until it's resizeable for some reason.
				//m_mediator.PropertyTable.GetValue("msaCreatorDlgSize");
				object szWnd = this.Size;
				if (locWnd != null && szWnd != null)
				{
					Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
					ScreenUtils.EnsureVisibleRect(ref rect);
					DesktopBounds = rect;
					StartPosition = FormStartPosition.Manual;
				}
			}
		}
示例#60
0
 /// <summary>
 /// </summary>
 /// <param name="formLexEntry"></param>
 /// <param name="senseGloss"></param>
 /// <param name="lexEntry1_Entry"></param>
 /// <param name="lexEntry1_Sense1"></param>
 private void SetupLexEntryAndSense(string formLexEntry, string senseGloss, out ILexEntry lexEntry1_Entry, out ILexSense lexEntry1_Sense1)
 {
     SetupLexEntryAndSense(formLexEntry, senseGloss, "adjunct", out lexEntry1_Entry, out lexEntry1_Sense1);
 }