/// <summary> /// /// </summary> public override void FixtureSetup() { base.FixtureSetup(); NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () => { // add a custom field named "MyRestrictions" to LexEntry. FieldDescription custom = new FieldDescription(Cache); custom.Class = LexEntryTags.kClassId; custom.Name = "MyRestrictions"; custom.Type = CellarPropertyType.MultiString; custom.WsSelector = (int)WritingSystemServices.kwsAnalVerns; custom.Userlabel = "MyRestrictions"; custom.UpdateCustomField(); }); }
public FDWrapper(FieldDescription fd, bool db) { m_fd = fd; m_fromDB = db; }
private void SaveModifiedLabelIfNeeded(FieldDescription fd) { string sNewLabel = CustomFieldName.Text; if (fd.Userlabel != sNewLabel) { if (m_dictModLabels.ContainsKey(fd.Id)) { m_dictModLabels[fd.Id].NewLabel = sNewLabel; } else { m_dictModLabels.Add(fd.Id, new ModifiedLabel(fd, sNewLabel, m_cache)); } } }
private void DeleteMatchingDescendants(XmlNode xnLayout, FieldDescription fd) { List<XmlNode> rgxn = new List<XmlNode>(); foreach (XmlNode xn in xnLayout.ChildNodes) { string sRef = XmlUtils.GetOptionalAttributeValue(xn, "ref"); if (sRef == "$child") { string sLabel = XmlUtils.GetOptionalAttributeValue(xn, "label"); if (sLabel == fd.Userlabel) rgxn.Add(xn); else DeleteMatchingDescendants(xn, fd); // recurse! } else if (sRef == "Custom") { string sParam = XmlUtils.GetOptionalAttributeValue(xn, "param"); if (sParam == fd.Name) rgxn.Add(xn); } } foreach (XmlNode xn in rgxn) xnLayout.RemoveChild(xn); }
public void AddModifyDeleteFieldDescription() { CheckDisposed(); SqlDataReader reader = null; try { FieldDescription fd = new FieldDescription(m_fdoCache); fd.Class = 1; fd.Userlabel = "TESTJUNK___NotPresent"; fd.Type = 1; // Make sure new ones are created as custom. Assert.AreEqual(fd.Custom, 1, "Wrong value for Custom column in new FD."); SqlCommand command = m_sqlCon.CreateCommand(); string qry1 = string.Format("select Id from Field$ where Userlabel='{0}'", fd.Userlabel); command.CommandText = qry1; object obj = command.ExecuteScalar(); // Make sure there isn't one named TESTJUNK. Assert.IsNull(obj, "New FD should be null."); fd.UpdateDatabase(); command.CommandText = qry1; obj = command.ExecuteScalar(); // Make sure newly created one exists in DB now. Assert.IsNotNull(obj, "New FD should not be null."); Assert.AreEqual(fd.Id, (int)obj); string hs = "Abandon hope all ye who enter here."; fd.HelpString = hs; fd.UpdateDatabase(); command.CommandText = string.Format("select Id from Field$ where HelpString='{0}'", fd.HelpString); obj = command.ExecuteScalar(); Assert.IsNotNull(obj, "Modified FD should not be null."); fd.MarkForDeletion = true; fd.UpdateDatabase(); command.CommandText = qry1; obj = command.ExecuteScalar(); // Make sure it no longer exists, since we just deleted it. Assert.IsNull(obj, "New FD should be null."); } finally { if (reader != null) reader.Close(); } }
/// <summary> /// Static method that returns an array of FieldDescriptor objects, /// where each one represents a row in the Field$ table. /// </summary> /// <param name="cache">FDO cache to collect the data from.</param> /// <returns>A List of FieldDescription objects, /// where each object in the array represents a row in the Field$ table.</returns> public static List<FieldDescription> FieldDescriptors(FdoCache cache) { Debug.Assert(cache != null); if (m_fieldDescriptors.ContainsKey(cache)) return m_fieldDescriptors[cache]; List<FieldDescription> list = new List<FieldDescription>(); m_fieldDescriptors[cache] = list; SqlConnection connection = null; SqlDataReader reader = null; try { string sSql = "Server=" + cache.ServerName + "; Database=" + cache.DatabaseName + "; User ID=FWDeveloper; Password=careful; Pooling=false;"; connection = new SqlConnection(sSql); connection.Open(); SqlCommand command = connection.CreateCommand(); command.CommandText = "select * from Field$"; reader = command.ExecuteReader(System.Data.CommandBehavior.SingleResult); while (reader.Read()) { FieldDescription fd = new FieldDescription(cache); for (int i = 0; i < reader.FieldCount; ++i) { if (!reader.IsDBNull(i)) { switch (reader.GetName(i)) { default: throw new Exception("Unrecognized column name."); case "Id": fd.m_id = reader.GetInt32(i); break; case "Type": fd.m_type = reader.GetInt32(i); break; case "Class": fd.m_class = reader.GetInt32(i); break; case "DstCls": fd.m_dstCls = reader.GetInt32(i); break; case "Name": fd.m_name = reader.GetString(i); break; case "Custom": fd.m_custom = reader.GetByte(i); break; case "CustomId": fd.m_customId = reader.GetGuid(i); break; case "Min": fd.m_min = reader.GetInt64(i); break; case "Max": fd.m_max = reader.GetInt64(i); break; case "Big": fd.m_big = reader.GetBoolean(i); break; case "UserLabel": fd.m_userlabel = reader.GetString(i); break; case "HelpString": fd.m_helpString = reader.GetString(i); break; case "ListRootId": fd.m_listRootId = reader.GetInt32(i); break; case "WsSelector": fd.m_wsSelector = reader.GetInt32(i); break; case "XmlUI": fd.m_xmlUI = reader.GetString(i); break; } } } list.Add(fd); } } finally { if (reader != null) reader.Close(); if (connection != null) connection.Close(); } return list; }
private Sfm2Xml.LexImportCustomField FieldDescriptionToLexImportField(FieldDescription fd) { string sig = ""; if (fd.Type == CellarPropertyType.MultiUnicode) sig = "MultiUnicode"; else if (fd.Type == CellarPropertyType.String) sig = "string"; else if (fd.Type == CellarPropertyType.OwningAtomic && fd.DstCls == StTextTags.kClassId) sig = "text"; else if (fd.Type == CellarPropertyType.ReferenceAtomic && fd.ListRootId != Guid.Empty) sig = "ListRef"; else if (fd.Type == CellarPropertyType.ReferenceCollection && fd.ListRootId != Guid.Empty) sig = "ListMultiRef"; // JohnT: added GenDate and Numeric and Integer to prevent the crash in LT-11188. // Not sure these string values are actually used for anything; if they are, it might be a problem, // because I haven't been able to track down how or where they are used. else if (fd.Type == CellarPropertyType.GenDate) sig = "Date"; else if (fd.Type == CellarPropertyType.Integer) sig = "Integer"; else if (fd.Type == CellarPropertyType.Numeric) sig = "Number"; else { throw new Exception("Error converting custom field to LexImportField - unexpected signature"); } Sfm2Xml.LexImportCustomField lif = new Sfm2Xml.LexImportCustomField( fd.Class, "NOT SURE YET _ Set In The Calling method???", //fd.CustomId, fd.Id, fd.Big, fd.WsSelector, // end of custom specific field info fd.Name, fd.Userlabel, fd.Name, sig, sig.StartsWith("List"), true, //(sig == "MultiUnicode") ? true : false, false, "MDFVALUE"); lif.ListRootId = fd.ListRootId; if (sig.StartsWith("List")) lif.IsAbbrField = true; ////lif.CustomFieldID = fd.CustomId; // save the guid for this field return lif; }
private FieldDescription CreateCustomMultipleRefFieldInLexSense(Guid listGuid) { // create new custom field for a LexSense for testing var fd = new FieldDescription(Cache) { Userlabel = "New Test Custom Field", HelpString = string.Empty, Class = LexSenseTags.kClassId, Type = CellarPropertyType.ReferenceCollection, WsSelector = 0, DstCls = CmPossibilityTags.kClassId, ListRootId = listGuid }; fd.UpdateCustomField(); return fd; }
private Sfm2Xml.LexImportCustomField FieldDescriptionToLexImportField(FieldDescription fd) { string sig = ""; if (fd.Type == (int)CellarModuleDefns.kcptMultiUnicode || fd.Type == (int)CellarModuleDefns.kcptMultiBigUnicode) sig = "MultiUnicode"; else if (fd.Type == (int)CellarModuleDefns.kcptString || fd.Type == (int)CellarModuleDefns.kcptBigString) sig = "string"; else { throw new Exception("Error converting custom field to LexImportField - unexpected signature"); } Sfm2Xml.LexImportCustomField lif = new Sfm2Xml.LexImportCustomField( fd.Class, "NOT SURE YET _ Set In The Calling method???", //fd.CustomId, fd.Id, fd.Big, fd.WsSelector, // end of custom specific field info fd.Name, fd.Userlabel, fd.Name, sig, false, true, //(sig == "MultiUnicode") ? true : false, false, "MDFVALUE"); ////lif.CustomFieldID = fd.CustomId; // save the guid for this field return lif; }
protected string GetCustomFieldHelp(FieldDescription fd) { // "About" -> Field/@uiname -> line // "When to use" -> Field/Help/Usage -> line // "Additional Settings" -> Field/Help/Settings -> line // "Interprets character mapping" -> Field/Help/Mapping -> line // "Allows multiple SFM fields" -> Field/Help/Appends -> line // "Uses list item" -> Field/Help/List -> line // "Allows an equivalent field for each langauge" -> Field/Help/Multilingual -> line // "Example(s)" -> Field/Help/Examples -> list // "Related Fields" -> Field/Help/RelatedFields -> line // "Limitations" -> Field/Help/Limitations -> bulleted list // "Extra things that will happen" -> Field/Help/Extras -> bulleted list System.Text.StringBuilder sbHelp = new System.Text.StringBuilder(); sbHelp.Append("<Field uiname=\""); sbHelp.Append(MakeVaildXML(fd.Userlabel)); sbHelp.Append("\"><Help>"); if (fd.HelpString != null && fd.HelpString.Trim().Length > 0) { sbHelp.Append("<Usage>"); sbHelp.Append(MakeVaildXML(fd.HelpString)); sbHelp.Append("</Usage>"); } sbHelp.Append("<Settings>Set the Language Descriptor to the language of this field.</Settings>"); if (fd.Type == (int)CellarModuleDefns.kcptMultiUnicode || fd.Type == (int)CellarModuleDefns.kcptMultiBigUnicode) { sbHelp.Append("<Mapping>No</Mapping>"); sbHelp.Append("<Appends>Yes, appends field contents into a single field.</Appends>"); sbHelp.Append("<List>No</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else if (fd.Type == (int)CellarModuleDefns.kcptString || fd.Type == (int)CellarModuleDefns.kcptBigString) { sbHelp.Append("<Mapping>Yes</Mapping>"); sbHelp.Append("<Appends>Yes, appends field contents into a single field.</Appends>"); sbHelp.Append("<List>No</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else { throw new Exception("bad type for custom field - code has to change"); } sbHelp.Append("</Help></Field>"); return sbHelp.ToString(); }
public void LiftImport_ExampleCustomFieldUpdatedDuringMerge() { var rangesWithStatusList = new[] { @"<?xml version=""1.0"" encoding=""UTF-8"" ?>", @"<lift-ranges>", @"<range id=""status"">", @"<range-element id=""Confirmed"" guid=""bd80cd3e-ea5e-11de-9871-0013722f8dec"">", @"<label>", @"<form lang=""en""><text>Confirmed</text></form>", @"</label>", @"<abbrev>", @"<form lang=""en""><text>Conf</text></form>", @"</abbrev>", @"</range-element>", @"<range-element id=""Pending"" guid=""bd964254-ea5e-11de-8cdf-0013722f8dec"">", @"<label>", @"<form lang=""en""><text>Pending</text></form>", @"</label>", @"<abbrev>", @"<form lang=""en""><text>Pend</text></form>", @"</abbrev>", @"</range-element>", @"</range>", @"</lift-ranges>" }; var lifDataWithExampleWithPendingStatus = new[] { @"<?xml version=""1.0"" encoding=""UTF-8"" ?>", @"<lift producer=""SIL.FLEx 8.0.10.41829"" version=""0.13"">", @"<header>", @"<ranges>", @"<range id=""status"" href=""file://*****:*****@"</ranges>", @"<fields>", @"<field tag=""EntryStatus"">", @"<form lang=""en""><text></text></form>", @"<form lang=""qaa-x-spec""><text>Class=LexEntry; Type=ReferenceAtom; WsSelector=kwsAnal; DstCls=CmPossibility; range=status</text></form>", @"</field>", @"<field tag=""CustomExampleStatus"">", @"<form lang=""en""><text></text></form>", @"<form lang=""qaa-x-spec""><text>Class=LexExampleSentence; Type=ReferenceAtom; WsSelector=kwsAnal; DstCls=CmPossibility; range=status</text></form>", @"</field>", @"</fields>", @"</header>", @"<entry dateCreated=""2013-07-14T21:32:58Z"" dateModified=""2013-07-14T21:46:21Z"" id=""tester_edae30f5-49f0-4025-97ce-3a2022bf7fa3"" guid=""edae30f5-49f0-4025-97ce-3a2022bf7fa3"">", @"<lexical-unit>", @"<form lang=""fr""><text>tester</text></form>", @"</lexical-unit>", @"<trait name=""morph-type"" value=""stem""/>", @"<trait name=""EntryStatus"" value=""Pending""/>", @"<sense id=""c1811b5c-aec1-42f7-87c2-6bbb4b76ff60"">", @"<example source=""A reference"">", @"<form lang=""fr""><text>An example sentence</text></form>", @"<translation type=""Free translation"">", @"<form lang=""en""><text>A translation</text></form>", @"</translation>", @"<note type=""reference"">", @"<form lang=""en""><text>A reference</text></form>", @"</note>", @"<trait name=""CustomExampleStatus"" value=""Pending""/>", @"</example>", @"</sense>", @"</entry>", @"</lift>" }; var lifDataWithExampleWithConfirmedStatus = new[] { @"<?xml version=""1.0"" encoding=""UTF-8"" ?>", @"<lift producer=""SIL.FLEx 8.0.10.41829"" version=""0.13"">", @"<header>", @"<ranges>", @"<range id=""status"" href=""file://*****:*****@"</ranges>", @"<fields>", @"<field tag=""EntryStatus"">", @"<form lang=""en""><text></text></form>", @"<form lang=""qaa-x-spec""><text>Class=LexEntry; Type=ReferenceAtom; WsSelector=kwsAnal; DstCls=CmPossibility; range=status</text></form>", @"</field>", @"<field tag=""CustomExampleStatus"">", @"<form lang=""en""><text></text></form>", @"<form lang=""qaa-x-spec""><text>Class=LexExampleSentence; Type=ReferenceAtom; WsSelector=kwsAnal; DstCls=CmPossibility; range=status</text></form>", @"</field>", @"</fields>", @"</header>", @"<entry dateCreated=""2014-07-14T21:32:58Z"" dateModified=""2014-07-14T21:46:21Z"" id=""tester_edae30f5-49f0-4025-97ce-3a2022bf7fa3"" guid=""edae30f5-49f0-4025-97ce-3a2022bf7fa3"">", @"<lexical-unit>", @"<form lang=""fr""><text>tester</text></form>", @"</lexical-unit>", @"<trait name=""morph-type"" value=""stem""/>", @"<trait name=""EntryStatus"" value=""Confirmed""/>", @"<sense id=""c1811b5c-aec1-42f7-87c2-6bbb4b76ff60"">", @"<example source=""A reference"">", @"<form lang=""fr""><text>An example sentence</text></form>", @"<translation type=""Free translation"">", @"<form lang=""en""><text>A translation</text></form>", @"</translation>", @"<note type=""reference"">", @"<form lang=""en""><text>A reference</text></form>", @"</note>", @"<trait name=""CustomExampleStatus"" value=""Confirmed""/>", @"</example>", @"</sense>", @"</entry>", @"</lift>" }; var wsEn = Cache.WritingSystemFactory.GetWsFromStr("en"); var statusList = Cache.ServiceLocator.GetInstance<ICmPossibilityListFactory>().CreateUnowned("status", wsEn); var confirmed = Cache.ServiceLocator.GetInstance<ICmPossibilityFactory>().Create(new Guid("bd80cd3e-ea5e-11de-9871-0013722f8dec"), statusList); confirmed.Name.set_String(wsEn, Cache.TsStrFactory.MakeString("Confirmed", wsEn)); var pending = Cache.ServiceLocator.GetInstance<ICmPossibilityFactory>().Create(new Guid("bd964254-ea5e-11de-8cdf-0013722f8dec"), statusList); pending.Name.set_String(wsEn, Cache.TsStrFactory.MakeString("Pending", wsEn)); var entryNew = new FieldDescription(Cache) { Type = CellarPropertyType.ReferenceAtomic, Class = LexEntryTags.kClassId, Name = "EntryStatus", ListRootId = statusList.Guid }; var exampleNew = new FieldDescription(Cache) { Type = CellarPropertyType.ReferenceAtomic, Class = LexExampleSentenceTags.kClassId, Name = "CustomExampleStatus", ListRootId = statusList.Guid }; entryNew.UpdateCustomField(); exampleNew.UpdateCustomField(); var repoEntry = Cache.ServiceLocator.GetInstance<ILexEntryRepository>(); var repoSense = Cache.ServiceLocator.GetInstance<ILexSenseRepository>(); Assert.AreEqual(0, repoEntry.Count); var rangeFile = CreateInputFile(rangesWithStatusList); var pendingLiftFile = CreateInputFile(lifDataWithExampleWithPendingStatus); // Verify basic import of custom field data matching existing custom list and items TryImport(pendingLiftFile, rangeFile, FlexLiftMerger.MergeStyle.MsKeepBoth, 1); Assert.AreEqual(1, repoEntry.Count); Assert.AreEqual(1, repoSense.Count); var entry = repoEntry.AllInstances().First(); var sense = repoSense.AllInstances().First(); Assert.AreEqual(1, sense.ExamplesOS.Count); var example = sense.ExamplesOS[0]; var entryCustomData = new CustomFieldData() { CustomFieldname = "EntryStatus", CustomFieldType = CellarPropertyType.ReferenceAtom, cmPossibilityNameRA = "Pending" }; var exampleCustomData = new CustomFieldData() { CustomFieldname = "CustomExampleStatus", CustomFieldType = CellarPropertyType.ReferenceAtom, cmPossibilityNameRA = "Pending" }; VerifyCustomField(entry, entryCustomData, entryNew.Id); VerifyCustomField(example, exampleCustomData, exampleNew.Id); // SUT - Verify merging of changes to custom field data var confirmedLiftFile = CreateInputFile(lifDataWithExampleWithConfirmedStatus); TryImport(confirmedLiftFile, rangeFile, FlexLiftMerger.MergeStyle.MsKeepBoth, 1); entry = repoEntry.AllInstances().First(); sense = repoSense.AllInstances().First(); Assert.AreEqual(1, sense.ExamplesOS.Count); example = sense.ExamplesOS[0]; entryCustomData.cmPossibilityNameRA = "Confirmed"; exampleCustomData.cmPossibilityNameRA = "Confirmed"; Assert.AreEqual(1, repoEntry.Count); Assert.AreEqual(1, repoSense.Count); VerifyCustomField(entry, entryCustomData, entryNew.Id); VerifyCustomField(example, exampleCustomData, exampleNew.Id); }
public void TestLiftImport5_CustomFieldsStringsAndMultiUnicode() { SetWritingSystems("fr"); var repoEntry = Cache.ServiceLocator.GetInstance<ILexEntryRepository>(); var repoSense = Cache.ServiceLocator.GetInstance<ILexSenseRepository>(); Assert.AreEqual(0, repoEntry.Count); Assert.AreEqual(0, repoSense.Count); // One custom field is defined in FW but not in the file var fdNew = new FieldDescription(Cache) { Type = CellarPropertyType.MultiUnicode, Class = LexEntryTags.kClassId, Name = "UndefinedCustom", Userlabel = "UndefinedCustom", HelpString = "some help", WsSelector = WritingSystemServices.kwsAnalVerns, DstCls = 0, ListRootId = Guid.Empty }; fdNew.UpdateCustomField(); var sOrigFile = CreateInputFile(s_LiftData5); var logFile = TryImport(sOrigFile, 2); File.Delete(sOrigFile); Assert.IsNotNull(logFile); File.Delete(logFile); Assert.AreEqual(2, repoEntry.Count); Assert.AreEqual(2, repoSense.Count); ILexEntry entry; Assert.IsTrue(repoEntry.TryGetObject(new Guid("7e4e4484-d691-4ffa-8fb1-10cf4941ac14"), out entry)); Assert.AreEqual(1, entry.SensesOS.Count); var sense0 = entry.SensesOS[0]; Assert.AreEqual(sense0.Guid, new Guid("29b7913f-0d28-4ee9-a57e-177f68a96654")); var customData = new CustomFieldData() { CustomFieldname = "CustomFldSense", CustomFieldType = CellarPropertyType.String, StringFieldText = "Sense custom fiield in English", StringFieldWs = "en" }; m_customFieldSenseIds = GetCustomFlidsOfObject(sense0); VerifyCustomField(sense0, customData, m_customFieldSenseIds["CustomFldSense"]); //=================================================================================== Assert.IsNotNull(entry.LexemeFormOA); Assert.IsNotNull(entry.LexemeFormOA.MorphTypeRA); Assert.AreEqual("stem", entry.LexemeFormOA.MorphTypeRA.Name.AnalysisDefaultWritingSystem.Text); Assert.AreEqual("Babababa", entry.LexemeFormOA.Form.VernacularDefaultWritingSystem.Text); Assert.IsNotNull(sense0.MorphoSyntaxAnalysisRA as IMoStemMsa); // ReSharper disable PossibleNullReferenceException Assert.IsNotNull((sense0.MorphoSyntaxAnalysisRA as IMoStemMsa).PartOfSpeechRA); Assert.AreEqual("Noun", (sense0.MorphoSyntaxAnalysisRA as IMoStemMsa).PartOfSpeechRA.Name.AnalysisDefaultWritingSystem.Text); // ReSharper restore PossibleNullReferenceException Assert.AreEqual("Papi", sense0.Gloss.AnalysisDefaultWritingSystem.Text); m_customFieldEntryIds = GetCustomFlidsOfObject(entry); customData = new CustomFieldData() { CustomFieldname = "UndefinedCustom", CustomFieldType = CellarPropertyType.MultiUnicode, }; customData.MultiUnicodeStrings.Add("Undefined custom field"); customData.MultiUnicodeWss.Add("en"); VerifyCustomField(entry, customData, m_customFieldEntryIds["UndefinedCustom"]); customData = new CustomFieldData() { CustomFieldname = "CustomFldEntry", CustomFieldType = CellarPropertyType.String, StringFieldText = "Entry custom field", StringFieldWs = "en" }; VerifyCustomField(entry, customData, m_customFieldEntryIds["CustomFldEntry"]); //"<field type=\"CustomFldEntryMulti\">", // "<form lang=\"fr\"><text>Entry Multi Frn</text></form>", // "<form lang=\"es\"><text>Entry Multi Spn</text></form>", // "<form lang=\"en\"><text>Entry Multi Eng</text></form>", // "</field>", customData = new CustomFieldData() { CustomFieldname = "CustomFldEntryMulti", CustomFieldType = CellarPropertyType.MultiUnicode, }; customData.MultiUnicodeStrings.Add("Entry Multi Frn"); customData.MultiUnicodeStrings.Add("Entry Multi Spn"); customData.MultiUnicodeStrings.Add("Entry Multi Eng"); customData.MultiUnicodeWss.Add("fr"); customData.MultiUnicodeWss.Add("es"); customData.MultiUnicodeWss.Add("en"); VerifyCustomField(entry, customData, m_customFieldEntryIds["CustomFldEntryMulti"]); foreach (var example in sense0.ExamplesOS) { m_customFieldExampleSentencesIds = GetCustomFlidsOfObject(example); customData = new CustomFieldData() { CustomFieldname = "CustomFldExample", CustomFieldType = CellarPropertyType.String, StringFieldText = "example sentence custom field", StringFieldWs = "fr" }; VerifyCustomField(example, customData, m_customFieldExampleSentencesIds["CustomFldExample"]); } //==================================Allomorph Custom Field Test===== MultiString var form = entry.AlternateFormsOS[0]; m_customFieldAllomorphsIds = GetCustomFlidsOfObject(form); customData = new CustomFieldData() { CustomFieldname = "CustomFldAllomorf", CustomFieldType = CellarPropertyType.MultiUnicode, }; customData.MultiUnicodeStrings.Add("Allomorph multi French"); customData.MultiUnicodeStrings.Add("Allomorph multi Spanish"); customData.MultiUnicodeStrings.Add("Allomorph multi English"); customData.MultiUnicodeWss.Add("fr"); customData.MultiUnicodeWss.Add("es"); customData.MultiUnicodeWss.Add("en"); VerifyCustomField(form, customData, m_customFieldAllomorphsIds["CustomFldAllomorf"]); //"<field type=\"CustomFldAllomorphSingle\">", //"<form lang=\"fr\"><text>Allomorph single Vernacular</text></form>", //"</field>", customData = new CustomFieldData() { CustomFieldname = "CustomFldAllomorphSingle", CustomFieldType = CellarPropertyType.String, StringFieldText = "Allomorph single Vernacular", StringFieldWs = "fr" }; VerifyCustomField(form, customData, m_customFieldAllomorphsIds["CustomFldAllomorphSingle"]); }
private void DeleteCustomField(FieldDescription fd) { // delete custom field that was added to a LexEntry for testing if (fd.IsCustomField && fd.IsInstalled) { fd.MarkForDeletion = true; AddCustomFieldDlg.UpdateCachedObjects(Cache, fd); Cache.ActionHandlerAccessor.BeginUndoTask("UndoUpdateCustomField", "RedoUpdateCustomField"); fd.UpdateCustomField(); Cache.ActionHandlerAccessor.EndUndoTask(); } FieldDescription.ClearDataAbout(); }
public ModifiedLabel(FieldDescription fd, string sNewLabel, FdoCache cache) { m_sOldLabel = fd.Userlabel; m_sNewLabel = sNewLabel; m_sClass = cache.MetaDataCacheAccessor.GetClassName((uint)fd.Class); }
protected string GetCustomFieldHelp(FieldDescription fd) { // "About" -> Field/@uiname -> line // "When to use" -> Field/Help/Usage -> line // "Additional Settings" -> Field/Help/Settings -> line // "Interprets character mapping" -> Field/Help/Mapping -> line // "Allows multiple SFM fields" -> Field/Help/Appends -> line // "Uses list item" -> Field/Help/List -> line // "Allows an equivalent field for each langauge" -> Field/Help/Multilingual -> line // "Example(s)" -> Field/Help/Examples -> list // "Related Fields" -> Field/Help/RelatedFields -> line // "Limitations" -> Field/Help/Limitations -> bulleted list // "Extra things that will happen" -> Field/Help/Extras -> bulleted list System.Text.StringBuilder sbHelp = new System.Text.StringBuilder(); sbHelp.Append("<Field uiname=\""); sbHelp.Append(MakeVaildXML(fd.Userlabel)); sbHelp.Append("\"><Help>"); if (fd.HelpString != null && fd.HelpString.Trim().Length > 0) { sbHelp.Append("<Usage>"); sbHelp.Append(MakeVaildXML(fd.HelpString)); sbHelp.Append("</Usage>"); } sbHelp.Append("<Settings>Set the Language Descriptor to the language of this field.</Settings>"); if (fd.Type == CellarPropertyType.MultiUnicode) { sbHelp.Append("<Mapping>No</Mapping>"); sbHelp.Append("<Appends>Yes, appends field contents into a single field.</Appends>"); sbHelp.Append("<List>No</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else if (fd.Type == CellarPropertyType.String) { sbHelp.Append("<Mapping>Yes</Mapping>"); sbHelp.Append("<Appends>Yes, appends field contents into a single field.</Appends>"); sbHelp.Append("<List>No</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else if (fd.Type == CellarPropertyType.OwningAtomic && fd.DstCls == StTextTags.kClassId) { sbHelp.Append("<Mapping>Yes</Mapping>"); sbHelp.Append("<Appends>Yes, appends field contents into a single field.</Appends>"); sbHelp.Append("<List>No</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else if (fd.Type == CellarPropertyType.ReferenceAtomic && fd.ListRootId != Guid.Empty) { sbHelp.Append("<Mapping>No</Mapping>"); sbHelp.Append("<Appends>No, does not append field contents into a single field.</Appends>"); sbHelp.Append("<List>Yes</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else if (fd.Type == CellarPropertyType.ReferenceCollection && fd.ListRootId != Guid.Empty) { sbHelp.Append("<Mapping>No</Mapping>"); sbHelp.Append("<Appends>Yes, appends field contents into a single field.</Appends>"); sbHelp.Append("<List>Yes</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } // JohnT: added these three for LT-11188. Not sure yet what else has to change or how this is used. else if (fd.Type == CellarPropertyType.GenDate || fd.Type == CellarPropertyType.Numeric || fd.Type == CellarPropertyType.Integer) { sbHelp.Append("<Mapping>No</Mapping>"); sbHelp.Append("<Appends>No, does not append field contents into a single field.</Appends>"); sbHelp.Append("<List>No</List>"); sbHelp.Append("<Multilingual>No</Multilingual>"); } else { throw new Exception("bad type for custom field - code has to change"); } sbHelp.Append("</Help></Field>"); return sbHelp.ToString(); }
/// <summary> /// Create a new Custom field and insert it in /// m_customFields and listViewCustomFields /// </summary> /// <returns>true if a field was saved</returns> private FDWrapper CreateNewCustomField() { m_creatingNewCustomField = true; FDWrapper fdw = null; // create new custom field FieldDescription fd = new FieldDescription(m_cache); if (fd != null) { fd.Userlabel = "New Custom Field"; fd.HelpString = ""; //set the writting system to whatever was last selected in the control if (cbWritingSystem.Enabled || fd.Type == 0) { fd.WsSelector = (cbWritingSystem.SelectedItem as IdAndString).Id; if (fd.WsSelector == LangProject.kwsAnal || fd.WsSelector == LangProject.kwsVern) fd.Type = (int)CellarModuleDefns.kcptString; else fd.Type = (int)CellarModuleDefns.kcptMultiUnicode; } // set the Entry or Sense of the new custom field to whatever was // last selecte in the control. fd.Class = (cbCreateIn.SelectedItem as IdAndString).Id; fdw = new FDWrapper(fd, false); } m_customFields.Add(fdw); //add this new Custom Field to the list //now we need to add it to the listViewBox. listViewCustomFields.SuspendLayout(); ListViewItem lvi = new ListViewItem(fdw.Fd.Userlabel); lvi.Tag = fdw; lvi.Selected = true; lvi.SubItems.Add(GetClassName(fdw.Fd.Class)); listViewCustomFields.Items.Add(lvi); listViewCustomFields.ResumeLayout(true); CustomFieldName.Text = "New Custom Field"; rtbDescription.Text = ""; //now this is the current field m_fdwCurrentField = fdw; m_creatingNewCustomField = false; return fdw; }
private FieldDescription CreateCustomAtomicReferenceFieldToCustomListInLexEntry(Guid listGuid) { // create new custom field for a LexEntry for testing var fd = new FieldDescription(Cache) { Userlabel = "New Test Custom Field", HelpString = string.Empty, Class = LexEntryTags.kClassId, Type = CellarPropertyType.ReferenceAtomic, WsSelector = 0, DstCls = CmPossibilityTags.kClassId, ListRootId = listGuid }; fd.UpdateCustomField(); return fd; }