Exemplo n.º 1
0
		private int HasPossibilityReferences(out ICmPossibility poss1)
		{
			var refs = m_listToDelete.ReallyReallyAllPossibilities.Where(
				poss => poss.ReferringObjects.Count > 0).ToList();
			poss1 = refs.FirstOrDefault();
			return refs.Count;
		}
Exemplo n.º 2
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			//m_inMemoryCache.InitializeAnnotationDefs();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;
			m_text = new Text();
			Cache.LangProject.TextsOC.Add(m_text);
			m_para = new StTxtPara();
			StText text = new StText();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Append(m_para);
			m_trans = new CmTranslation();
			m_para.TranslationsOC.Add(m_trans);
			kflidFT = StTxtPara.SegmentFreeTranslationFlid(Cache);
			kflidSegments = StTxtPara.SegmentsFlid(Cache);
			m_btPoss = Cache.LangProject.TranslationTagsOA.LookupPossibilityByGuid(
				LangProject.kguidTranBackTranslation);
			m_trans.TypeRA = m_btPoss;
			m_fWasUseScriptDigits = Cache.LangProject.TranslatedScriptureOA.UseScriptDigits;
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
			// do we need to set status?
		}
        public string LfItemKeyString(ICmPossibility fdoOptionListItem, int ws)
        {
            string result;
            if (fdoOptionListItem == null)
                return null;

            if (_lfOptionList != null)
            {
                if (_lfOptionListItemKeyByGuid.TryGetValue(fdoOptionListItem.Guid, out result))
                    return result;

                // We shouldn't get here, because the option list SHOULD be pre-populated.
                _logger.Error("Got an option list item without a corresponding LF option list item. " +
                    "In option list name '{0}', list code '{1}': " +
                    "FDO option list item '{2}' had GUID {3} but no LF option list item was found",
                    _lfOptionList.Name, _lfOptionList.Code,
                    fdoOptionListItem.AbbrAndName, fdoOptionListItem.Guid
                );
                return null;
            }

            if (fdoOptionListItem.Abbreviation == null || fdoOptionListItem.Abbreviation.get_String(ws) == null)
            {
                // Last-ditch effort
                char ORC = '\ufffc';
                return fdoOptionListItem.AbbrevHierarchyString.Split(ORC).LastOrDefault();
            }
            else
            {
                return ConvertFdoToMongoTsStrings.TextFromTsString(fdoOptionListItem.Abbreviation.get_String(ws), _wsf);
            }
        }
Exemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="XmlNoteCategory"/> class based on the
		/// specified category.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public XmlNoteCategory(ICmPossibility category, ILgWritingSystemFactory lgwsf)
		{
			List<CategoryNode> categoryList = GetCategoryHierarchyList(category);
			m_categoryPath = category.NameHierarchyString;

			InitializeCategory(categoryList, lgwsf);
		}
Exemplo n.º 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Implement CreateTestData, called by InMemoryFdoTestBase set up.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			var servloc = Cache.ServiceLocator;

			ICmPossibilityFactory possibilityFactory = servloc.GetInstance<ICmPossibilityFactory>();
			// Add an annotation category (for Discourse)
			m_categoryDiscourse = possibilityFactory.Create();
			var affixCatList = servloc.GetInstance<ICmPossibilityListFactory>().Create();
			Cache.LangProject.AffixCategoriesOA = affixCatList;
			affixCatList.PossibilitiesOS.Add(m_categoryDiscourse);

			// Add an annotation category (for Grammar)
			m_categoryGrammar = possibilityFactory.Create();
			affixCatList.PossibilitiesOS.Add(m_categoryGrammar);

			// add a sub-annotation category (for "Pronominal reference")
			m_categoryGrammar_PronominalRef = possibilityFactory.Create();
			m_categoryGrammar.SubPossibilitiesOS.Add(m_categoryGrammar_PronominalRef);

			// Set up a filter, with a CmCell we can test on.
			ICmFilter filter = servloc.GetInstance<ICmFilterFactory>().Create();
			Cache.LangProject.FiltersOC.Add(filter);
			ICmRow row = servloc.GetInstance<ICmRowFactory>().Create();
			filter.RowsOS.Add(row);
			m_cell = servloc.GetInstance<ICmCellFactory>().Create();
			row.CellsOS.Add(m_cell);
		}
Exemplo n.º 6
0
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_logic = new TestCCLogic(Cache, m_chart, m_stText);
			m_helper.Logic = m_logic;
			m_logic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
			m_template = m_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = m_helper.SetupAChart();
			m_helper.MakeDefaultChartMarkers();
		}
Exemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Validates the type RA.
		/// </summary>
		/// <param name="newObjValue">The new obj value.</param>
		/// ------------------------------------------------------------------------------------
		partial void ValidateTypeRA(ref ICmPossibility newObjValue)
		{
			// For Flex Example Sentences, it's quite legal for the user to mark the type as
			// unknown/empty/null.  See FWR-549.
			if (newObjValue == null && OwningFlid != LexExampleSentenceTags.kflidTranslations)
				throw new ArgumentException("New value must not be null.");

			// This check only applies if the translation belongs to a paragraph.
			if (Cache.FullyInitializedAndReadyToRock && Owner is IStTxtPara &&
				newObjValue.Guid != LangProjectTags.kguidTranBackTranslation)
			{
				throw new ArgumentException("Back translations are the only type of translation allowed for paragraphs");
			}
		}
Exemplo n.º 8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the selected possibilites for the specified node and its children.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private IEnumerable <ICmPossibility> GetSelectedPossibilites(TreeNode node)
        {
            if (IsNodeSelected(node))
            {
                ICmPossibility poss = node.Tag as ICmPossibility;
                if (poss != null)
                {
                    yield return(poss);
                }
            }

            foreach (TreeNode childNode in node.Nodes)
            {
                foreach (ICmPossibility poss in GetSelectedPossibilites(childNode))
                {
                    yield return(poss);
                }
            }
        }
        private void AddListToMenu(ToolStrip menu, ICmPossibility tagList)
        {
            Debug.Assert(tagList.SubPossibilitiesOS.Count > 0, "There should be sub-possibilities here!");

            // Add the main entry first
            ToolStripMenuItem tagSubmenu = new ToolStripMenuItem(tagList.Name.BestAnalysisAlternative.Text);

            menu.Items.Add(tagSubmenu);

            foreach (ICmPossibility poss in tagList.SubPossibilitiesOS)
            {
                // Add 'tag' BestDefaultAnalWS Name to menu
                var tagItem = new TagPossibilityMenuItem(poss);
                tagItem.Click  += Tag_Item_Click;
                tagItem.Text    = poss.Name.BestAnalysisAlternative.Text;
                tagItem.Checked = DoSelectedOccurrencesHaveTag(poss);
                tagSubmenu.DropDownItems.Add(tagItem);
            }
        }
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_cclogic = new TestCCLogic(Cache, m_chart, m_stText);
			m_cclogic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
			m_helper.Logic = m_cclogic;
			m_template = m_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = m_helper.SetupAChart();
			m_origCell = null;
			// Test must fill in the ClickedCell in the CChartSentenceElements object
			m_eligCols = m_allColumns.ToArray();
			// CChartSentenceElements always starts with all columns
			m_eligRows = null;
			// Test must fill in EligibleRows in the CChartSentenceElements object
			m_sentElem = new CChartSentenceElements(m_origCell, m_eligRows, m_eligCols);
			m_dlgLogicPrepose = new AdvancedMTDialogLogic(Cache, true, m_sentElem);
			m_dlgLogicPostpose = new AdvancedMTDialogLogic(Cache, false, m_sentElem);
			// create one each direction; test both
		}
Exemplo n.º 11
0
 protected override void CreateTestData()
 {
     base.CreateTestData();
     m_cclogic        = new TestCCLogic(Cache, m_chart, m_stText);
     m_cclogic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
     m_helper.Logic   = m_cclogic;
     m_template       = m_helper.MakeTemplate(out m_allColumns);
     // Note: do this AFTER creating the template, which may also create the DiscourseData object.
     m_chart    = m_helper.SetupAChart();
     m_origCell = null;
     // Test must fill in the ClickedCell in the CChartSentenceElements object
     m_eligCols = m_allColumns.ToArray();
     // CChartSentenceElements always starts with all columns
     m_eligRows = null;
     // Test must fill in EligibleRows in the CChartSentenceElements object
     m_sentElem         = new CChartSentenceElements(m_origCell, m_eligRows, m_eligCols);
     m_dlgLogicPrepose  = new AdvancedMTDialogLogic(Cache, true, m_sentElem);
     m_dlgLogicPostpose = new AdvancedMTDialogLogic(Cache, false, m_sentElem);
     // create one each direction; test both
 }
        protected override void CreateTestData()
        {
            m_noun = MakePartOfSpeech("noun");
            m_verb = MakePartOfSpeech("verb");
            m_adj  = MakePartOfSpeech("adj");

            IFsFeatureSystem msFeatSys = Cache.LanguageProject.MsFeatureSystemOA;

            m_inflType = AddFSType(msFeatSys, "infl",
                                   AddComplexFeature(msFeatSys, "nounAgr", AddClosedFeature(msFeatSys, "num", "sg", "pl")),
                                   AddClosedFeature(msFeatSys, "tense", "pres"));

            m_np = Cache.LangProject.GetDefaultTextTagList().ReallyReallyAllPossibilities.Single(poss => poss.Abbreviation.BestAnalysisAlternative.Text == "Noun Phrase");

            ILexEntry ni   = MakeEntry("ni-", m_verb, "1SgSubj");
            ILexEntry him  = MakeEntry("him-", m_verb, "3SgObj");
            ILexEntry bili = MakeEntry("bili", m_verb, "to see");
            ILexEntry ra   = MakeEntry("-ra", m_verb, "Pres", new FS {
                { GetFeature("tense"), GetValue("pres") }
            });

            ILexEntry pus = MakeEntry("pus", m_adj, "green");

            ILexEntry yalo = MakeEntry("yalo", m_noun, "mat");
            ILexEntry la   = MakeEntry("-la", m_noun, "1SgPoss", new FS {
                { GetFeature("nounAgr"), new FS {
                      { GetFeature("num"), GetValue("sg") }
                  } }
            });

            MakeWordform("nihimbilira", "I see", m_verb, ni, him, bili, ra);
            MakeWordform("pus", "green", m_adj, pus);
            MakeWordform("yalola", "my mat", m_noun, yalo, la);
            MakeWordform("ban", "test", MakePartOfSpeech("pos"));

            m_text = MakeText("nihimbilira pus, yalola ban.");

            var para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();

            MakeTag(m_text, m_np, para.SegmentsOS.First(), 1, para.SegmentsOS.First(), 3);
        }
Exemplo n.º 13
0
        public IEnumerable <string> GetFdoAbbrevsForField(ILexSense fdoSense, int fieldId)
        {
            var      foo   = fdoSense.Guid;
            FdoCache cache = _cache;
            int      size  = cache.DomainDataByFlid.get_VecSize(fdoSense.Hvo, fieldId);

            for (int i = 0; i < size; i++)
            {
                int       itemHvo = cache.DomainDataByFlid.get_VecItem(fdoSense.Hvo, fieldId, i);
                ICmObject obj     = cache.ServiceLocator.GetObject(itemHvo);
                // Note that we check for CmCustomItemTags.kClassId, *not* CmPossibilityTags.kClassId. This field has a custom list as its target.
                Assert.That(obj.ClassID, Is.EqualTo(CmCustomItemTags.kClassId), "Custom Multi ListRef field in test data should point to CmCustomItem objects, not CmPossibility (or anything else)");
                ICmPossibility poss = obj as ICmPossibility;
                Assert.That(poss, Is.Not.Null);
                Assert.That(poss.Abbreviation, Is.Not.Null);
                ITsString enAbbr = poss.Abbreviation.get_String(_wsEn);
                Assert.That(enAbbr, Is.Not.Null);
                Assert.That(enAbbr.Text, Is.Not.Null);
                yield return(enAbbr.Text);
            }
        }
Exemplo n.º 14
0
 private void ReadSubPossibilitiesFromXml(XmlReader xrdr, string sItemClassName,
                                          Dictionary <string, ICmPossibility> mapNameToPoss)
 {
     if (xrdr.ReadToDescendant(sItemClassName))
     {
         do
         {
             string sGuid = xrdr.GetAttribute("guid");
             xrdr.MoveToElement();
             ICmPossibility poss = null;
             Guid           guid = Guid.Empty;
             if (!String.IsNullOrEmpty(sGuid))
             {
                 guid = new Guid(sGuid);
                 PossibilityRepository.TryGetObject(guid, out poss);
             }
             ReadPossItem(xrdr.ReadSubtree(), poss, sItemClassName, mapNameToPoss);
         } while (xrdr.ReadToNextSibling(sItemClassName));
     }
     xrdr.Read();                // reads end element.
 }
Exemplo n.º 15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets a list of the category hierarchy with the top-level category in the first
        /// item of the list and the last item of the list containing information for the given
        /// category.
        /// </summary>
        /// <param name="category">The category.</param>
        /// ------------------------------------------------------------------------------------
        private List <CategoryNode> GetCategoryHierarchyList(ICmPossibility category)
        {
            List <CategoryNode> categoryList = new List <CategoryNode>();
            ITsString           tssCategory  = null;
            int ws = -1;

            // Go through the hierarchy getting the name of categories until the top-level
            // CmPossibility is found.
            ICmObject categoryObj = category;

            while (categoryObj is ICmPossibility)
            {
                tssCategory = ((ICmPossibility)categoryObj).Name.GetAlternativeOrBestTss(
                    category.Cache.DefaultAnalWs, out ws);
                categoryList.Insert(0, new CategoryNode(tssCategory.Text, ws));

                categoryObj = categoryObj.Owner;
            }

            return(categoryList);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Generate a key by appending the name of this CmPossibility to the names of
        /// each of its owning CmPossibilities (if the owner is a CmPossibility).  The
        /// result is a rooted path of English CmPossibility names separated by colons,
        /// with a leading colon preceding the CmPossibility at the top level of the list.
        /// This allows items at lower levels of the list to have the same name without
        /// being confused.
        /// </summary>
        private string GetKeyForPossibility(ICmPossibility item)
        {
            ITsString tss = item.Name.get_String(m_wsEn);

            if (tss == null)
            {
                return(String.Empty);
            }
            string name = tss.Text;

            if (String.IsNullOrEmpty(name))
            {
                return(String.Empty);
            }
            var ownerPath = String.Empty;

            if (item.Owner is ICmPossibility)
            {
                ownerPath = GetKeyForPossibility(item.Owner as ICmPossibility);
            }
            return(String.Format("{0}:{1}", ownerPath, name));
        }
Exemplo n.º 17
0
        private void m_btnOK_Click(object sender, EventArgs e)
        {
            var node = (HvoTreeNode)m_tagComboBox.SelectedNode;

            if (node.Hvo != 0)
            {
                ICmPossibility tag = m_cache.ServiceLocator.GetInstance <ICmPossibilityRepository>().GetObject(node.Hvo);
                if (tag.OwningPossibility != null)
                {
                    m_node.Tag   = tag;
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show(this, ITextStrings.ksInvalidTagMsg, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                DialogResult = DialogResult.OK;
            }
        }
Exemplo n.º 18
0
        public void Range()
        {
            // Setup test values
            Cache.LangProject.PeopleOA = new CmPossibilityList();
            ICmPossibility person1 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person1.ForeColor = 1;
            ICmPossibility person2 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person2.ForeColor = 3;
            ICmPossibility person3 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person3.ForeColor = 5;
            ICmPossibility person4 = Cache.LangProject.PeopleOA.PossibilitiesOS.Append(new CmPerson());

            person4.ForeColor = 7;

            // Setup filter
            FdoOwningCollection <ICmFilter> filtersCol = Cache.LangProject.FiltersOC;
            ICmFilter filter = filtersCol.Add(new CmFilter());

            filter.ColumnInfo = CmPossibility.kClassId + "," + (int)CmPossibility.CmPossibilityTags.kflidForeColor +
                                "|" + CmPossibility.kClassId + "," + (int)CmPossibility.CmPossibilityTags.kflidForeColor;
            ICmRow  row   = filter.RowsOS.Append(new CmRow());
            ICmCell cell1 = row.CellsOS.Append(new DummyCmCell());

            cell1.Contents.Text = "<= 5";
            ICmCell cell2 = row.CellsOS.Append(new DummyCmCell());

            cell2.Contents.Text = ">= 3";

            // Check the result
            ((CmFilter)filter).InitCriteria();
            Assert.IsFalse(((CmFilter)filter).MatchesCriteria(person1.Hvo));
            Assert.IsTrue(((CmFilter)filter).MatchesCriteria(person2.Hvo));
            Assert.IsTrue(((CmFilter)filter).MatchesCriteria(person3.Hvo));
            Assert.IsFalse(((CmFilter)filter).MatchesCriteria(person4.Hvo));
        }
Exemplo n.º 19
0
        public void GetAllPossibilities()
        {
            CheckDisposed();

            // We use the following hierarchy:
            // top - 1 -  1.1 - 1.1.1
            //     \ 2 \- 1.2
            //          \ 1.3
            // which are 7 CmPossibility objects
            ICmPossibility top = Cache.LangProject.PartsOfSpeechOA.PossibilitiesOS.Append(new CmPossibility());
            ICmPossibility one = top.SubPossibilitiesOS.Append(new CmPossibility());    // 1

            top.SubPossibilitiesOS.Append(new CmPossibility());                         // 2
            ICmPossibility oneone = one.SubPossibilitiesOS.Append(new CmPossibility()); // 1.1

            one.SubPossibilitiesOS.Append(new CmPossibility());                         // 1.2
            one.SubPossibilitiesOS.Append(new CmPossibility());                         // 1.3
            oneone.SubPossibilitiesOS.Append(new CmPossibility());                      // 1.1.1

            Set <ICmPossibility> al = Cache.LangProject.PartsOfSpeechOA.ReallyReallyAllPossibilities;

            Assert.AreEqual(7, al.Count, "Wrong number of possibilites.");
        }
Exemplo n.º 20
0
 /// <summary>
 /// Create one. The SDA passed MAY be the DomainDataByFlid of the cache, but it is usually another
 /// decorator.
 /// </summary>
 public DictionaryPublicationDecorator(FdoCache cache, ISilDataAccessManaged domainDataByFlid, int mainFlid, ICmPossibility publication)
     : base(domainDataByFlid)
 {
     Cache                     = cache;
     m_entryRepo               = Cache.ServiceLocator.GetInstance <ILexEntryRepository>();
     m_lexRefRepo              = Cache.ServiceLocator.GetInstance <ILexReferenceRepository>();
     m_senseRepo               = Cache.ServiceLocator.GetInstance <ILexSenseRepository>();
     m_lerRepo                 = Cache.ServiceLocator.GetInstance <ILexEntryRefRepository>();
     m_LexDbEntriesFlid        = mainFlid;
     m_headwordFlid            = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "HeadWord", false);
     m_mlHeadwordFlid          = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "MLHeadWord", false);
     m_picsOfSensesFlid        = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "PicturesOfSenses", false);
     m_senseOutlineFlid        = Cache.MetaDataCacheAccessor.GetFieldId2(LexSenseTags.kClassId, "LexSenseOutline", false);
     m_mlOwnerOutlineFlid      = Cache.MetaDataCacheAccessor.GetFieldId2(LexSenseTags.kClassId, "MLOwnerOutlineName", false);
     m_publishAsMinorEntryFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "PublishAsMinorEntry", false);
     m_headwordRefFlid         = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "HeadWordRef", false);
     m_headwordReversalFlid    = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "ReversalName", false);
     m_reversalNameFlid        = Cache.MetaDataCacheAccessor.GetFieldId2(LexSenseTags.kClassId, "ReversalName", false);
     Publication               = publication;
     BuildExcludedObjects();
     BuildFieldsToFilter();
     BuildHomographInfo();
 }
Exemplo n.º 21
0
        public string LfItemKeyString(ICmPossibility fdoOptionListItem, int ws)
        {
            string result;

            if (fdoOptionListItem == null)
            {
                return(null);
            }

            if (_lfOptionList != null)
            {
                if (_lfOptionListItemKeyByGuid.TryGetValue(fdoOptionListItem.Guid, out result))
                {
                    return(result);
                }

                // We shouldn't get here, because the option list SHOULD be pre-populated.
                _logger.Error("Got an option list item without a corresponding LF option list item. " +
                              "In option list name '{0}', list code '{1}': " +
                              "FDO option list item '{2}' had GUID {3} but no LF option list item was found",
                              _lfOptionList.Name, _lfOptionList.Code,
                              fdoOptionListItem.AbbrAndName, fdoOptionListItem.Guid
                              );
                return(null);
            }

            if (fdoOptionListItem.Abbreviation == null || fdoOptionListItem.Abbreviation.get_String(ws) == null)
            {
                // Last-ditch effort
                char ORC = '\ufffc';
                return(fdoOptionListItem.AbbrevHierarchyString.Split(ORC).LastOrDefault());
            }
            else
            {
                return(ConvertFdoToMongoTsStrings.TextFromTsString(fdoOptionListItem.Abbreviation.get_String(ws), _wsf));
            }
        }
        protected override void PopulatePossibilityFromExtraData(ICmPossibility poss)
        {
            ICmSemanticDomain semdom = poss as ICmSemanticDomain;

            if (semdom == null)
            {
                return;
            }
            ILgWritingSystemFactory wsf = semdom.Cache.WritingSystemFactory;
            var questionFactory         = semdom.Cache.ServiceLocator.GetInstance <ICmDomainQFactory>();
            Dictionary <string, List <SemDomQuestion> > questionsByWs = GetExtraDataWsDict <SemDomQuestion>("Questions");
            // This dict looks like {"en": (question 1, question 2...)} but each question object wants to get data that
            // looks more or less like {"en": "the question in English", "fr": "la question en francais"}...
            // So first we ensure that there are enough question objects available, and then we'll access them by index
            // as we step through the writing systems.
            int numQuestions = questionsByWs.Values.Select(questionList => questionList.Count).Max();

            while (semdom.QuestionsOS.Count < numQuestions)
            {
                semdom.QuestionsOS.Add(questionFactory.Create());
            }
            foreach (string ws in questionsByWs.Keys)
            {
                int wsId = wsf.GetWsFromStr(ws);
                int i    = 0;
                foreach (SemDomQuestion qStruct in questionsByWs[ws])
                {
                    // TODO: Find out what set_String() would do with a null value. Would it remove the string?
                    // If it would *remove* it, then we might be able to replace string.Empty with nulls in the code below
                    // Right now, just be extra-cautious and ensure we never put nulls into set_String().
                    semdom.QuestionsOS[i].Question.set_String(wsId, qStruct.Question ?? string.Empty);
                    semdom.QuestionsOS[i].ExampleSentences.set_String(wsId, qStruct.ExampleSentences ?? string.Empty);
                    semdom.QuestionsOS[i].ExampleWords.set_String(wsId, qStruct.ExampleWords ?? string.Empty);
                    i++;
                }
            }
        }
Exemplo n.º 23
0
        public void Equality()
        {
            // Setup test values
            Cache.LangProject.PeopleOA = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create();
            ICmPossibility person1 = Cache.ServiceLocator.GetInstance <ICmPersonFactory>().Create();

            Cache.LangProject.PeopleOA.PossibilitiesOS.Add(person1);
            person1.ForeColor = 4;
            ICmPossibility person2 = Cache.ServiceLocator.GetInstance <ICmPersonFactory>().Create();

            Cache.LangProject.PeopleOA.PossibilitiesOS.Add(person2);
            person2.ForeColor = 5;
            ICmPossibility person3 = Cache.ServiceLocator.GetInstance <ICmPersonFactory>().Create();

            Cache.LangProject.PeopleOA.PossibilitiesOS.Add(person3);
            person3.ForeColor = 10;

            // Setup filter
            ILcmOwningCollection <ICmFilter> filtersCol = Cache.LangProject.FiltersOC;
            ICmFilter filter = Cache.ServiceLocator.GetInstance <ICmFilterFactory>().Create();

            filtersCol.Add(filter);
            filter.ColumnInfo = CmPossibilityTags.kClassId + "," + CmPossibilityTags.kflidForeColor;
            ICmRow row = Cache.ServiceLocator.GetInstance <ICmRowFactory>().Create();

            filter.RowsOS.Add(row);
            ICmCell cell1 = Cache.ServiceLocator.GetInstance <ICmCellFactory>().Create();

            row.CellsOS.Add(cell1);
            cell1.Contents = MakeString("= 5");

            // Check the result
            filter.InitCriteria();
            Assert.IsFalse(filter.MatchesCriteria(person1.Hvo));
            Assert.IsTrue(filter.MatchesCriteria(person2.Hvo));
            Assert.IsFalse(filter.MatchesCriteria(person3.Hvo));
        }
Exemplo n.º 24
0
        private ICmPossibility FindPossibilityAndSetName(XmlReader xrdr, string ownerPath,
                                                         Dictionary <string, ICmPossibility> mapNameToPoss)
        {
            if (xrdr.IsEmptyElement)
            {
                xrdr.Read();
                return(null);
            }
            ICmPossibility poss = null;

            if (xrdr.ReadToDescendant("AUni"))
            {
                Dictionary <int, string> mapWsName = new Dictionary <int, string>();
                do
                {
                    string sWs  = xrdr.GetAttribute("ws");
                    string sVal = xrdr.ReadString();
                    if (sWs == "en")
                    {
                        // Use the English name to look up the possibility.
                        mapNameToPoss.TryGetValue(String.Format("{0}:{1}", ownerPath, sVal), out poss);
                        continue;                                       // don't overwrite the English string
                    }
                    int ws = GetWsFromStr(sWs);
                    mapWsName.Add(ws, sVal);
                } while (xrdr.ReadToNextSibling("AUni"));
                if (poss != null)
                {
                    foreach (int ws in mapWsName.Keys)
                    {
                        poss.Name.set_String(ws, mapWsName[ws]);
                    }
                }
            }
            xrdr.Read();                // read the end tag.
            return(poss);
        }
Exemplo n.º 25
0
        private void ReadPossibilitiesFromXml(XmlReader xrdr, ICmPossibilityList list, string sItemClass,
                                              string ownerPath, Dictionary <string, ICmPossibility> mapNameToPoss = null)
        {
            var listElementName = xrdr.Name;

            do
            {
                xrdr.Read();
                if (xrdr.NodeType == XmlNodeType.Element &&
                    (xrdr.Name == sItemClass || m_itemClassNames.Contains(xrdr.Name)))
                {
                    if (mapNameToPoss == null)
                    {
                        mapNameToPoss = GetMappingForList(list);
                    }
                    string sGuid = xrdr.GetAttribute("guid");
                    xrdr.MoveToElement();
                    Guid           guid = Guid.Empty;
                    ICmPossibility poss = null;
                    if (!String.IsNullOrEmpty(sGuid))
                    {
                        guid = new Guid(sGuid);
                        PossibilityRepository.TryGetObject(guid, out poss);
                    }
                    using (var inner = xrdr.ReadSubtree())
                    {
                        ReadPossItem(inner, poss, sItemClass, ownerPath, mapNameToPoss);
                        inner.Close();
                    }
                }
                else if (xrdr.NodeType == XmlNodeType.EndElement && xrdr.Name == listElementName)
                {
                    xrdr.ReadEndElement();
                    return;
                }
            } while (!xrdr.EOF);
        }
Exemplo n.º 26
0
        public void FindOrCreateAnnotationCategory_AbsentCategory_ThirdLevel()
        {
            Assert.AreEqual(1, m_possList.PossibilitiesOS[1].SubPossibilitiesOS[1].SubPossibilitiesOS.Count);

            ICmPossibility newCategory = m_scr.NoteCategoriesOA.FindOrCreatePossibility(
                "Level 1a" + StringUtils.kChObject + "New Level 2 Category" + StringUtils.kChObject +
                "New Level 3 Category", m_wsSpanish);

            // Confirm that a new third-level node was created.
            Assert.AreEqual("New Level 3 Category", newCategory.Name.get_String(m_wsSpanish).Text);
            // Confirm that a new parent node for the third-level node was created on the second level.
            Assert.AreEqual(1, m_possList.PossibilitiesOS[0].SubPossibilitiesOS.Count,
                            "Another category CmPossibility should have been created on second level under Level 1a.");
            Assert.AreEqual(1, m_possList.PossibilitiesOS[0].SubPossibilitiesOS[0].SubPossibilitiesOS.Count);

            Assert.IsTrue(newCategory.Owner is ICmPossibility,
                          "Category should have been created under another category CmPossibility");
            Assert.AreEqual("New Level 2 Category",
                            ((ICmPossibility)newCategory.Owner).Name.get_String(m_wsSpanish).Text);
            Assert.IsTrue(((ICmPossibility)newCategory.Owner).Owner is ICmPossibility);
            ICmPossibility level1Possibility = (ICmPossibility)newCategory.Owner.Owner;

            Assert.AreEqual("Level 1a", level1Possibility.Name.get_String(m_wsSpanish).Text);
        }
        private void HandlePossibilitySelected(object sender, EventArgs e)
        {
            ICmPossibility poss   = m_autoComplete.SelectedPossibility;
            ICmObject      curObj = m_vectorRefView.SelectedObject;

            if (curObj == null)
            {
                AddItem(poss);
            }
            else if (poss != curObj)
            {
                var newTargets = new List <ICmObject>();
                foreach (ICmObject target in Targets)
                {
                    newTargets.Add(target == curObj ? poss : target);
                }
                SetItems(newTargets);
            }
            else
            {
                UpdateDisplayFromDatabase();
            }
            m_vectorRefView.SelectedObject = poss;
        }
 /// <summary>
 /// Create one. The SDA passed MAY be the DomainDataByFlid of the cache, but it is usually another
 /// decorator.
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="domainDataByFlid"></param>
 public DictionaryPublicationDecorator(FdoCache cache, ISilDataAccessManaged domainDataByFlid, int mainFlid, ICmPossibility publication)
     : base(domainDataByFlid)
 {
     Cache = cache;
     m_entryRepo = Cache.ServiceLocator.GetInstance<ILexEntryRepository>();
     m_lexRefRepo = Cache.ServiceLocator.GetInstance<ILexReferenceRepository>();
     m_senseRepo = Cache.ServiceLocator.GetInstance<ILexSenseRepository>();
     m_lerRepo = Cache.ServiceLocator.GetInstance<ILexEntryRefRepository>();
     m_LexDbEntriesFlid = mainFlid;
     m_headwordFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "HeadWord", false);
     m_mlHeadwordFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "MLHeadWord", false);
     m_picsOfSensesFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "PicturesOfSenses", false);
     m_senseOutlineFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexSenseTags.kClassId, "LexSenseOutline", false);
     m_mlOwnerOutlineFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexSenseTags.kClassId, "MLOwnerOutlineName", false);
     m_publishAsMinorEntryFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "PublishAsMinorEntry", false);
     m_doNotShowMainEntryInFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "DoNotShowMainEntryIn", false);
     m_headwordRefFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "HeadWordRef", false);
     m_headwordReversalFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexEntryTags.kClassId, "HeadWordReversal", false);
     m_reversalNameFlid = Cache.MetaDataCacheAccessor.GetFieldId2(LexSenseTags.kClassId, "ReversalName", false);
     Publication = publication;
     BuildExcludedObjects();
     BuildFieldsToFilter();
     BuildHomographInfo();
 }
Exemplo n.º 29
0
		/// <summary>
		/// Verify that the parameter tag points to the right possibility marker
		/// and that it refers to the correct begin and end points in the text.
		/// </summary>
		/// <param name="ttag"></param>
		/// <param name="poss"></param>
		/// <param name="point1"></param>
		/// <param name="point2"></param>
		private static void VerifyTextTag(ITextTag ttag, ICmPossibility poss,
										  AnalysisOccurrence point1, AnalysisOccurrence point2)
		{
			Assert.IsNotNull(ttag, "There should be a TextTag object.");
			Assert.AreEqual(poss.Hvo, ttag.TagRA.Hvo, "Text Tag has wrong possibility Hvo.");
			Assert.AreEqual(point1.Segment.Hvo, ttag.BeginSegmentRA.Hvo, "Tag has wrong BeginSegment");
			Assert.AreEqual(point1.Index, ttag.BeginAnalysisIndex, "Tag has wrong BeginAnalysisIndex");
			Assert.AreEqual(point2.Segment.Hvo, ttag.EndSegmentRA.Hvo, "Tag has wrong EndSegment");
			Assert.AreEqual(point2.Index, ttag.EndAnalysisIndex, "Tag has wrong EndAnalysisIndex");
		}
Exemplo n.º 30
0
 /// ------------------------------------------------------------------------------------
 internal static PaCmPossibility Create(ICmPossibility poss)
 {
     return(poss == null ? null : new PaCmPossibility(poss));
 }
Exemplo n.º 31
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="cache">FDO Cache object.</param>
 /// <param name="pos">The possibility.</param>
 /// <param name="displayNameProperty">property name to display</param>
 public CmPossibilityLabel(FdoCache cache, ICmPossibility pos, string displayNameProperty)
     : base(cache, pos, displayNameProperty)
 {
 }
Exemplo n.º 32
0
		/// <summary>
		/// Verify that there is a row with the specified index that has a cell with the specified
		/// index which belongs to the specified column and covers the specified words.
		/// </summary>
		/// <param name="irow"></param>
		/// <param name="icellPart"></param>
		/// <param name="column"></param>
		/// <param name="marker"></param>
		void VerifyTag(int irow, int icellPart, ICmPossibility column, ICmPossibility marker)
		{
			m_helper.VerifyMarkerCellPart(irow, icellPart, column, marker);
		}
Exemplo n.º 33
0
		/// <summary>
		/// Verify that there is a row with the specified index that has a ConstChartClauseMarker
		/// with the specified index which belongs to the specified column and points to the
		/// specified array of ConstChartRows.
		/// </summary>
		/// <param name="irow"></param>
		/// <param name="icellPart"></param>
		/// <param name="column"></param>
		/// <param name="depClauses"></param>
		void VerifyDependentClauseMarker(int irow, int icellPart, ICmPossibility column,
			IConstChartRow[] depClauses)
		{
			m_helper.VerifyDependentClauseMarker(irow, icellPart, column, depClauses);
		}
Exemplo n.º 34
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Populate the node with the children of the possibility. (recursive)
		/// </summary>
		/// <param name="node">given node</param>
		/// <param name="possibility">The possibility whose subpossibilities will be added as
		/// the child nodes</param>
		/// ------------------------------------------------------------------------------------
		protected virtual void PopulateChildNodes(TreeNode node, ICmPossibility possibility)
		{
			foreach (ICmPossibility subPossibility in possibility.SubPossibilitiesOS)
				node.Nodes.Add(CreateNode(subPossibility));
		}
		private static ICmAnnotationDefn AddAnnotationDefn(ICmPossibility owner, Guid guid)
		{
			var cache = owner.Cache;
			var servLoc = cache.ServiceLocator;
			var dataReader = (IDataReader)servLoc.GetInstance<IDataSetup>();
			var posFactory = servLoc.GetInstance<ICmAnnotationDefnFactory>() as ICmAnnotationDefnFactoryInternal;
			return posFactory.Create(
				guid,
				dataReader.GetNextRealHvo(),
				owner,
				owner.SubPossibilitiesOS.Count);
		}
Exemplo n.º 36
0
		private static void InitItem(XmlNode item, ICmPossibility poss)
		{
			poss.Name.AnalysisDefaultWritingSystem = XmlUtils.GetManditoryAttributeValue(item, "name");
			string abbr = XmlUtils.GetOptionalAttributeValue(item, "abbr");
			if (String.IsNullOrEmpty(abbr))
				abbr = poss.Name.AnalysisDefaultWritingSystem;
			poss.Abbreviation.AnalysisDefaultWritingSystem = abbr;
			foreach (XmlNode subItem in item.ChildNodes)
			{
				ICmPossibility poss2 = poss.SubPossibilitiesOS.Append(new CmPossibility());
				InitItem(subItem, poss2);
			}
		}
Exemplo n.º 37
0
		/// <summary>
		/// Verify that there is a row with the specified index that has a cell part
		/// (subclass ConstChartMovedTextMarker) with the specified index which belongs to the
		/// specified column and points to the specified WordGroup object in the right direction.
		/// </summary>
		/// <param name="irow"></param>
		/// <param name="icellPart"></param>
		/// <param name="column"></param>
		/// <param name="wordGrp"></param>
		/// <param name="fPrepose"></param>
		void VerifyMovedText(int irow, int icellPart, ICmPossibility column, IConstChartWordGroup wordGrp, bool fPrepose)
		{
			m_helper.VerifyMovedTextMarker(irow, icellPart, column, wordGrp, fPrepose);
		}
Exemplo n.º 38
0
		private void VerifyInsertMarker(ICmPossibility marker)
		{
			VerifyRow(0, "1a", 2);
			VerifyTag(0, 1, m_allColumns[1], marker);
		}
Exemplo n.º 39
0
		private static void VerifyChangeColumn(IEnumerable<IConstituentChartCellPart> cellPartsToMove, ICmPossibility column, string message)
		{
			foreach (var cellPart in cellPartsToMove)
				Assert.AreEqual(column, cellPart.ColumnRA, message);
		}
Exemplo n.º 40
0
		/// <summary>
		/// Generate a key by appending the name of this CmPossibility to the names of
		/// each of its owning CmPossibilities (if the owner is a CmPossibility).  The
		/// result is a rooted path of English CmPossibility names separated by colons,
		/// with a leading colon preceding the CmPossibility at the top level of the list.
		/// This allows items at lower levels of the list to have the same name without
		/// being confused.
		/// </summary>
		private string GetKeyForPossibility(ICmPossibility item)
		{
			ITsString tss = item.Name.get_String(m_wsEn);
			if (tss == null)
				return String.Empty;
			string name = tss.Text;
			if (String.IsNullOrEmpty(name))
				return String.Empty;
			var ownerPath = String.Empty;
			if (item.Owner is ICmPossibility)
				ownerPath = GetKeyForPossibility(item.Owner as ICmPossibility);
			return String.Format("{0}:{1}", ownerPath, name);
		}
Exemplo n.º 41
0
 /// <summary>
 /// Verify that there is a row with the specified index that has a cell with the specified
 /// index which belongs to the specified column possibility and contains cells
 /// with the specified words.
 /// </summary>
 /// <param name="irow"></param>
 /// <param name="icellPart"></param>
 /// <param name="column"></param>
 /// <param name="words"></param>
 void VerifyWordGroup(int irow, int icellPart, ICmPossibility column, List <AnalysisOccurrence> words)
 {
     m_helper.VerifyWordGroup(irow, icellPart, column, words);
 }
Exemplo n.º 42
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the text representing the possibility.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual string GetPossibilityText(ICmPossibility possibility)
		{
			return possibility.Name.BestAnalysisAlternative.Text;
		}
Exemplo n.º 43
0
 // Special case: LF sense Status field is a StringArray, but FDO sense status is single possibility
 private LfStringArrayField ToStringArrayField(string listCode, ICmPossibility fdoPoss)
 {
     return(LfStringArrayField.FromSingleString(ListConverters[listCode].LfItemKeyString(fdoPoss, _wsEn)));
 }
		/// <summary>
		/// N.B. If actually using columns in tests, you must add the following line after creating the chart.
		/// m_ccl.Chart.TemplateRA = m_template;
		/// </summary>
		/// <returns></returns>
		public ICmPossibility MakeTemplate()
		{
			// The exact organization of columns is not of great
			// importance for the current tests (still less the names), but we do want there
			// to be a hierarchy, since that is a common problem, and naming them conventionally
			// may make debugging easier.
			m_template = m_fdoCache.LangProject.GetDefaultChartTemplate();
			return m_template;
		}
Exemplo n.º 45
0
        private void ReadPossItem(XmlReader xrdrSub, ICmPossibility poss, string sItemClassName, string ownerPath,
                                  Dictionary <string, ICmPossibility> mapNameToPoss)
        {
            xrdrSub.Read();
            Debug.Assert(xrdrSub.Name == sItemClassName || m_itemClassNames.Contains(xrdrSub.Name));
            try
            {
                string abbrXml      = null;
                string descXml      = null;
                string aliasXml     = null;
                string revabbrXml   = null;
                string revabbrevXml = null;
                string revnameXml   = null;
                string questionsXml = null;
                while (xrdrSub.Read())
                {
                    if (xrdrSub.NodeType == XmlNodeType.Element)
                    {
                        switch (xrdrSub.Name)
                        {
                        case "Abbreviation":
                            if (poss != null)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, poss.Abbreviation);
                            }
                            else
                            {
                                abbrXml = GetXmlOfElement(xrdrSub);
                            }
                            break;

                        case "Description":
                            if (poss != null)
                            {
                                SetMultiStringFromXml(xrdrSub, poss.Description);
                            }
                            else
                            {
                                descXml = GetXmlOfElement(xrdrSub);
                            }
                            break;

                        case "Name":
                            if (poss != null)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, poss.Name);
                            }
                            else
                            {
                                poss = FindPossibilityAndSetName(xrdrSub, ownerPath, mapNameToPoss);
                                if (poss != null)
                                {
                                    if (abbrXml != null)
                                    {
                                        using (var srdr = new StringReader(abbrXml))
                                        {
                                            using (var xrdrAbbr = XmlReader.Create(srdr))
                                            {
                                                SetMultiUnicodeFromXml(xrdrAbbr, poss.Abbreviation);
                                                xrdrAbbr.Close();
                                                abbrXml = null;
                                            }
                                        }
                                    }
                                    if (descXml != null)
                                    {
                                        using (var srdr = new StringReader(descXml))
                                        {
                                            using (var xrdrDesc = XmlReader.Create(srdr))
                                            {
                                                SetMultiStringFromXml(xrdrDesc, poss.Description);
                                                xrdrDesc.Close();
                                                descXml = null;
                                            }
                                        }
                                    }
                                    if (aliasXml != null)
                                    {
                                        if (poss is ICmPerson)
                                        {
                                            using (var srdr = new StringReader(aliasXml))
                                            {
                                                using (var xrdrT = XmlReader.Create(srdr))
                                                {
                                                    SetMultiUnicodeFromXml(xrdrT, (poss as ICmPerson).Alias);
                                                    xrdrT.Close();
                                                }
                                            }
                                        }
                                        else if (poss is ICmLocation)
                                        {
                                            using (var srdr = new StringReader(aliasXml))
                                            {
                                                using (var xrdrT = XmlReader.Create(srdr))
                                                {
                                                    SetMultiUnicodeFromXml(xrdrT, (poss as ICmLocation).Alias);
                                                    xrdrT.Close();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ReportUnexpectedElement(sItemClassName, "Alias");
                                        }
                                        aliasXml = null;
                                    }
                                    if (revabbrXml != null)
                                    {
                                        if (poss is ILexEntryType)
                                        {
                                            using (var srdr = new StringReader(revabbrXml))
                                            {
                                                using (var xrdrT = XmlReader.Create(srdr))
                                                {
                                                    SetMultiUnicodeFromXml(xrdrT, (poss as ILexEntryType).ReverseAbbr);
                                                    xrdrT.Close();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ReportUnexpectedElement(sItemClassName, "ReverseAbbr");
                                        }
                                        revabbrXml = null;
                                    }
                                    if (revabbrevXml != null)
                                    {
                                        if (poss is ILexRefType)
                                        {
                                            using (var srdr = new StringReader(revabbrXml))
                                            {
                                                using (var xrdrT = XmlReader.Create(srdr))
                                                {
                                                    SetMultiUnicodeFromXml(xrdrT, (poss as ILexRefType).ReverseAbbreviation);
                                                    xrdrT.Close();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ReportUnexpectedElement(sItemClassName, "ReverseAbbreviation");
                                        }
                                        revabbrevXml = null;
                                    }
                                    if (revnameXml != null)
                                    {
                                        if (poss is ILexRefType)
                                        {
                                            using (var srdr = new StringReader(revnameXml))
                                            {
                                                using (var xrdrT = XmlReader.Create(srdr))
                                                {
                                                    SetMultiUnicodeFromXml(xrdrT, (poss as ILexRefType).ReverseName);
                                                    xrdrT.Close();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ReportUnexpectedElement(sItemClassName, "ReverseName");
                                        }
                                        revnameXml = null;
                                    }
                                    if (questionsXml != null)
                                    {
                                        if (poss is ICmSemanticDomain)
                                        {
                                            using (var srdr = new StringReader(revnameXml))
                                            {
                                                using (var xrdrT = XmlReader.Create(srdr))
                                                {
                                                    ReadQuestionsFromXml(xrdrT, poss as ICmSemanticDomain);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            ReportUnexpectedElement(sItemClassName, "Questions");
                                        }
                                        questionsXml = null;
                                    }
                                }
                            }
                            break;

                        case "SubPossibilities":
                            // we have the map, but we don't know the list at this level.
                            var myName = String.Empty;
                            if (poss != null && poss.Name != null)
                            {
                                var tss = poss.Name.get_String(m_wsEn);
                                if (tss != null && tss.Text != null)
                                {
                                    myName = tss.Text;
                                }
                            }
                            ReadPossibilitiesFromXml(xrdrSub, null, sItemClassName, String.Format("{0}:{1}", ownerPath, myName), mapNameToPoss);
                            break;

                        // Additional Subclass fields.

                        case "Questions":
                            if (poss is ICmSemanticDomain)
                            {
                                ReadQuestionsFromXml(xrdrSub.ReadSubtree(), poss as ICmSemanticDomain);
                            }
                            else if (poss == null)
                            {
                                questionsXml = GetXmlOfElement(xrdrSub);
                            }
                            else
                            {
                                StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
                            }
                            break;

                        case "Alias":
                            if (poss is ICmPerson)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, (poss as ICmPerson).Alias);
                            }
                            else if (poss is ICmLocation)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, (poss as ICmLocation).Alias);
                            }
                            else if (poss == null)
                            {
                                aliasXml = GetXmlOfElement(xrdrSub);
                            }
                            else
                            {
                                StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
                            }
                            break;

                        case "ReverseAbbr":
                            if (poss is ILexEntryType)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, (poss as ILexEntryType).ReverseAbbr);
                            }
                            else if (poss == null)
                            {
                                revabbrXml = GetXmlOfElement(xrdrSub);
                            }
                            else
                            {
                                StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
                            }
                            break;

                        case "ReverseAbbreviation":
                            if (poss is ILexRefType)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, (poss as ILexRefType).ReverseAbbreviation);
                            }
                            else if (poss == null)
                            {
                                revabbrevXml = GetXmlOfElement(xrdrSub);
                            }
                            else
                            {
                                StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
                            }
                            break;

                        case "ReverseName":
                            if (poss is ILexRefType)
                            {
                                SetMultiUnicodeFromXml(xrdrSub, (poss as ILexRefType).ReverseName);
                            }
                            else if (poss == null)
                            {
                                revnameXml = GetXmlOfElement(xrdrSub);
                            }
                            else
                            {
                                StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
                            }
                            break;

                        default:
                            StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
                            break;
                        }
                    }
                }
            }
            finally
            {
                xrdrSub.Close();
                if (m_progress != null)
                {
                    m_progress.Step(1);
                }
            }
        }
Exemplo n.º 46
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shows the Chooser dialog to allow the user to select a single possibility.
		/// </summary>
		/// <remarks>Used for filtering</remarks>
		/// <param name="list">The possibility list used to populate the tree</param>
		/// <param name="initialSelected">The possibility to check initially, or null to
		/// show with no initial selection</param>
		/// <returns>A single chosen CmPossibility, or null if user cancels or chooses
		/// nothing.</returns>
		/// ------------------------------------------------------------------------------------
		public ICmPossibility GetPossibility(ICmPossibilityList list, ICmPossibility initialSelected)
		{
			//CheckDisposed();

			//m_initiallySelectedHvos = new List<int>(1);
			//m_initiallySelectedHvos.Add(hvoPoss);

			//if (list != (CmPossibilityList)m_list)
			//{
			//    m_list = list;
			//    SetTitle();
			//}

			//tvPossibilities.Load(m_list, m_initiallySelectedHvos);
			//if (ShowDialog() != DialogResult.OK)
			//    return 0;

			//List<int> newHvos = tvPossibilities.SelectedHvos;
			//return (newHvos != null && newHvos.Count > 0 ? newHvos[0] : 0);

			// REVIEW: Currently, the chooser tree doesn't allow the user to select
			// only one possibility. If this method and single node selection is ever
			// necessary, then this method will need to be rewritten.
			return null;
		}
Exemplo n.º 47
0
		private void AddListToMenu(ToolStrip menu, ICmPossibility tagList)
		{
			Debug.Assert(tagList.SubPossibilitiesOS.Count > 0, "There should be sub-possibilities here!");

			// Add the main entry first
			ToolStripMenuItem tagSubmenu = new ToolStripMenuItem(tagList.Name.BestAnalysisAlternative.Text);
			menu.Items.Add(tagSubmenu);

			foreach (ICmPossibility poss in tagList.SubPossibilitiesOS)
			{
				// Add 'tag' BestDefaultAnalWS Name to menu
				TagPossibilityMenuItem tagItem = new TagPossibilityMenuItem(poss.Hvo);
				tagItem.Click += new EventHandler(Tag_Item_Click);
				tagItem.Text = poss.Name.BestAnalysisAlternative.Text;
				tagItem.Checked = DoSelectedXficsHaveTag(poss.Hvo);
				tagSubmenu.DropDownItems.Add(tagItem);
			}
		}
Exemplo n.º 48
0
		private void ReadPossItem(XmlReader xrdrSub, ICmPossibility poss, string sItemClassName)
		{
			xrdrSub.Read();
			Debug.Assert(xrdrSub.Name == sItemClassName);
			try
			{
				while (xrdrSub.Read())
				{
					if (xrdrSub.NodeType == XmlNodeType.Element)
					{
						switch (xrdrSub.Name)
						{
							case "Abbreviation":
								SetMultiUnicodeFromXml(xrdrSub, poss.Abbreviation);
								break;
							case "BackColor":
								poss.BackColor = ReadIntFromXml(xrdrSub);
								break;
							case "Description":
								SetMultiStringFromXml(xrdrSub, poss.Description);
								break;
							case "ForeColor":
								poss.ForeColor = ReadIntFromXml(xrdrSub);
								break;
							case "HelpId":
								poss.HelpId = ReadUnicodeFromXml(xrdrSub);
								break;
							case "Hidden":
								poss.Hidden = ReadBoolFromXml(xrdrSub);
								break;
							case "IsProtected":
								poss.IsProtected = ReadBoolFromXml(xrdrSub);
								break;
							case "Name":
								SetMultiUnicodeFromXml(xrdrSub, poss.Name);
								break;
							case "SortSpec":
								poss.SortSpec = ReadIntFromXml(xrdrSub);
								break;
							case "SubPossibilities":
								LoadSubPossibilitiesFromXml(xrdrSub, poss, sItemClassName);
								break;
							case "UnderColor":
								poss.UnderColor = ReadIntFromXml(xrdrSub);
								break;
							case "UnderStyle":
								poss.UnderStyle = ReadIntFromXml(xrdrSub);
								break;

							// Additional CmSemanticDomain fields.
							case "LouwNidaCodes":
								if (poss is ICmSemanticDomain)
									(poss as ICmSemanticDomain).LouwNidaCodes = ReadUnicodeFromXml(xrdrSub);
								else
									SkipAndReportUnexpectedElement(xrdrSub);
								break;
							case "OcmCodes":
								if (poss is ICmSemanticDomain)
									(poss as ICmSemanticDomain).OcmCodes = ReadUnicodeFromXml(xrdrSub);
								else
									SkipAndReportUnexpectedElement(xrdrSub);
								break;
							case "Questions":
								if (poss is ICmSemanticDomain)
									LoadQuestionsFromXml(xrdrSub, poss as ICmSemanticDomain);
								else
									SkipAndReportUnexpectedElement(xrdrSub);
								break;
							case "RelatedDomains":
								if (poss is ICmSemanticDomain)
									LoadRelatedDomainsFromXml(xrdrSub, poss as ICmSemanticDomain);
								else
									SkipAndReportUnexpectedElement(xrdrSub);
								break;

							// Additional PartOfSpeech fields.
							case "CatalogSourceId":
								if (poss is IPartOfSpeech)
									(poss as IPartOfSpeech).CatalogSourceId = ReadUnicodeFromXml(xrdrSub);
								else
									SkipAndReportUnexpectedElement(xrdrSub);
								break;

							default:
								SkipAndReportUnexpectedElement(xrdrSub);
								break;
						}
					}
				}
			}
			finally
			{
				xrdrSub.Close();
				if (m_progress != null)
					m_progress.Step(1);
			}
		}
Exemplo n.º 49
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a node for a possibility (including populating its child nodes)
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual TreeNode CreateNode(ICmPossibility possibility)
		{
			string text = TsStringUtils.NormalizeToNFC(GetPossibilityText(possibility));
			TreeNode node = new TreeNode(text);
			node.Tag = possibility;
			PopulateChildNodes(node, possibility);

			if (m_initiallySelectedHvos.Contains(possibility.Hvo))
				m_initiallyCheckedNodes.Add(node);

			return node;
		}
Exemplo n.º 50
0
		private void LoadSubPossibilitiesFromXml(XmlReader xrdr, ICmPossibility owner, string sItemClassName)
		{
			Debug.Assert(owner != null);
			if (xrdr.ReadToDescendant(sItemClassName))
			{
				do
				{
					string sGuid = xrdr.GetAttribute("guid");
					xrdr.MoveToElement();
					Guid guid = Guid.Empty;
					if (!String.IsNullOrEmpty(sGuid))
						guid = new Guid(sGuid);
					ICmPossibility poss = null;
					switch (sItemClassName)
					{
						case "CmPossibility":
							poss = m_factPoss.Create(EnsureGuid(guid), owner);
							break;
						case "CmAnthroItem":
							Debug.Assert(owner is ICmAnthroItem);
							poss = m_factAnthro.Create(EnsureGuid(guid), owner as ICmAnthroItem) as ICmPossibility;
							break;
						case "CmSemanticDomain":
							Debug.Assert(owner is ICmSemanticDomain);
							poss = m_factSemDom.Create(EnsureGuid(guid), owner as ICmSemanticDomain) as ICmPossibility;
							break;
						case "PartOfSpeech":
							Debug.Assert(owner is IPartOfSpeech);
							poss = m_factPOS.Create(guid, (IPartOfSpeech)owner);
							break;
						default:
							// TODO: implement the other subclasses of CmPossibility?
							break;
					}
					Debug.Assert(poss != null);
					ReadPossItem(xrdr.ReadSubtree(), poss, sItemClassName);
				} while (xrdr.ReadToNextSibling(sItemClassName));
			}
			xrdr.Read();	// reads end element.
		}
Exemplo n.º 51
0
 /// <summary>
 /// Verify that there is a row with the specified index that has a cell part
 /// (subclass ConstChartMovedTextMarker) with the specified index which belongs to the
 /// specified column and points to the specified WordGroup object in the right direction.
 /// </summary>
 /// <param name="irow"></param>
 /// <param name="icellPart"></param>
 /// <param name="column"></param>
 /// <param name="wordGrp"></param>
 /// <param name="fPrepose"></param>
 void VerifyMovedText(int irow, int icellPart, ICmPossibility column, IConstChartWordGroup wordGrp, bool fPrepose)
 {
     m_helper.VerifyMovedTextMarker(irow, icellPart, column, wordGrp, fPrepose);
 }
Exemplo n.º 52
0
 /// <summary>
 /// Verify that there is a row with the specified index that has a cell part
 /// (subclass ConstChartClauseMarker) with the specified index which belongs to the
 /// specified column and points to the specified array of ConstChartRows.
 /// </summary>
 /// <param name="irow"></param>
 /// <param name="icellPart"></param>
 /// <param name="column"></param>
 /// <param name="depClauses"></param>
 void VerifyDependentClause(int irow, int icellPart, ICmPossibility column, IConstChartRow[] depClauses)
 {
     m_helper.VerifyDependentClauseMarker(irow, icellPart, column, depClauses);
 }
Exemplo n.º 53
0
		/// <summary>
		/// Verify that there is a row with the specified index that has a cell with the specified
		/// index which belongs to the specified column and covers the specified words.
		/// </summary>
		/// <param name="irow"></param>
		/// <param name="icellPart"></param>
		/// <param name="column"></param>
		/// <param name="words"></param>
		void VerifyWordGroup(int irow, int icellPart, ICmPossibility column, List<AnalysisOccurrence> words)
		{
			m_helper.VerifyWordGroup(irow, icellPart, column, words);
		}
Exemplo n.º 54
0
 /// <summary>
 /// Verify that there is a row with the specified index that has a cell with the specified
 /// index which belongs to the specified column and has a ConstChartTag
 /// of the specified possibility.
 /// </summary>
 /// <param name="irow"></param>
 /// <param name="icellPart"></param>
 /// <param name="column"></param>
 /// <param name="tagPoss"></param>
 void VerifyTag(int irow, int icellPart, ICmPossibility column, ICmPossibility tagPoss)
 {
     m_helper.VerifyMarkerCellPart(irow, icellPart, column, tagPoss);
 }
Exemplo n.º 55
0
		/// <summary>
		/// Verify that there is a row with the specified index that has a ConstChartTag
		/// with the specified index which belongs to the specified column and has a null Tag.
		/// </summary>
		/// <param name="irow"></param>
		/// <param name="icellPart"></param>
		/// <param name="column"></param>
		void VerifyMissingMarker(int irow, int icellPart, ICmPossibility column)
		{
			m_helper.VerifyMissingMarker(irow, icellPart, column);
		}
Exemplo n.º 56
0
 private void VerifyInsertMarker(ICmPossibility marker)
 {
     VerifyRow(0, "1a", 2);
     VerifyTag(0, 1, m_allColumns[1], marker);
 }
Exemplo n.º 57
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Get the text representing the possibility.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected virtual string GetPossibilityText(ICmPossibility possibility)
 {
     return(possibility.Name.BestAnalysisAlternative.Text);
 }
Exemplo n.º 58
0
 private static void VerifyChangeColumn(IEnumerable <IConstituentChartCellPart> cellPartsToMove, ICmPossibility column, string message)
 {
     foreach (var cellPart in cellPartsToMove)
     {
         Assert.AreEqual(column, cellPart.ColumnRA, message);
     }
 }
Exemplo n.º 59
0
		private void ReadPossItem(XmlReader xrdrSub, ICmPossibility poss, string sItemClassName, string ownerPath,
			Dictionary<string, ICmPossibility> mapNameToPoss)
		{
			xrdrSub.Read();
			Debug.Assert(xrdrSub.Name == sItemClassName || m_itemClassNames.Contains(xrdrSub.Name));
			try
			{
				string abbrXml = null;
				string descXml = null;
				string aliasXml = null;
				string revabbrXml = null;
				string revabbrevXml = null;
				string revnameXml = null;
				string questionsXml = null;
				while (xrdrSub.Read())
				{
					if (xrdrSub.NodeType == XmlNodeType.Element)
					{
						switch (xrdrSub.Name)
						{
							case "Abbreviation":
								if (poss != null)
									SetMultiUnicodeFromXml(xrdrSub, poss.Abbreviation);
								else
									abbrXml = GetXmlOfElement(xrdrSub);
								break;
							case "Description":
								if (poss != null)
									SetMultiStringFromXml(xrdrSub, poss.Description);
								else
									descXml = GetXmlOfElement(xrdrSub);
								break;
							case "Name":
								if (poss != null)
								{
									SetMultiUnicodeFromXml(xrdrSub, poss.Name);
								}
								else
								{
									poss = FindPossibilityAndSetName(xrdrSub, ownerPath, mapNameToPoss);
									if (poss != null)
									{
										if (abbrXml != null)
										{
											using (var srdr = new StringReader(abbrXml))
											{
												using (var xrdrAbbr = XmlReader.Create(srdr))
												{
											SetMultiUnicodeFromXml(xrdrAbbr, poss.Abbreviation);
											xrdrAbbr.Close();
											abbrXml = null;
										}
											}
										}
										if (descXml != null)
										{
											using (var srdr = new StringReader(descXml))
											{
												using (var xrdrDesc = XmlReader.Create(srdr))
												{
											SetMultiStringFromXml(xrdrDesc, poss.Description);
											xrdrDesc.Close();
											descXml = null;
										}
											}
										}
										if (aliasXml != null)
										{
											if (poss is ICmPerson)
											{
												using (var srdr = new StringReader(aliasXml))
												{
													using (var xrdrT = XmlReader.Create(srdr))
													{
												SetMultiUnicodeFromXml(xrdrT, (poss as ICmPerson).Alias);
												xrdrT.Close();
											}
												}
											}
											else if (poss is ICmLocation)
											{
												using (var srdr = new StringReader(aliasXml))
												{
													using (var xrdrT = XmlReader.Create(srdr))
													{
												SetMultiUnicodeFromXml(xrdrT, (poss as ICmLocation).Alias);
												xrdrT.Close();
											}
												}
											}
											else
											{
												ReportUnexpectedElement(sItemClassName, "Alias");
											}
											aliasXml = null;
										}
										if (revabbrXml != null)
										{
											if (poss is ILexEntryType)
											{
												using (var srdr = new StringReader(revabbrXml))
												{
													using (var xrdrT = XmlReader.Create(srdr))
													{
												SetMultiUnicodeFromXml(xrdrT, (poss as ILexEntryType).ReverseAbbr);
												xrdrT.Close();
											}
												}
											}
											else
											{
												ReportUnexpectedElement(sItemClassName, "ReverseAbbr");
											}
											revabbrXml = null;
										}
										if (revabbrevXml != null)
										{
											if (poss is ILexRefType)
											{
												using (var srdr = new StringReader(revabbrXml))
												{
													using (var xrdrT = XmlReader.Create(srdr))
													{
												SetMultiUnicodeFromXml(xrdrT, (poss as ILexRefType).ReverseAbbreviation);
												xrdrT.Close();
											}
												}
											}
											else
											{
												ReportUnexpectedElement(sItemClassName, "ReverseAbbreviation");
											}
											revabbrevXml = null;
										}
										if (revnameXml != null)
										{
											if (poss is ILexRefType)
											{
												using (var srdr = new StringReader(revnameXml))
												{
													using (var xrdrT = XmlReader.Create(srdr))
													{
												SetMultiUnicodeFromXml(xrdrT, (poss as ILexRefType).ReverseName);
												xrdrT.Close();
											}
												}
											}
											else
											{
												ReportUnexpectedElement(sItemClassName, "ReverseName");
											}
											revnameXml = null;
										}
										if (questionsXml != null)
										{
											if (poss is ICmSemanticDomain)
											{
												using (var srdr = new StringReader(revnameXml))
												{
													using (var xrdrT = XmlReader.Create(srdr))
													{
												ReadQuestionsFromXml(xrdrT, poss as ICmSemanticDomain);
											}
												}
											}
											else
											{
												ReportUnexpectedElement(sItemClassName, "Questions");
											}
											questionsXml = null;
										}
									}
								}
								break;
							case "SubPossibilities":
								// we have the map, but we don't know the list at this level.
								var myName = String.Empty;
								if (poss != null && poss.Name != null)
								{
									var tss = poss.Name.get_String(m_wsEn);
									if (tss != null && tss.Text != null)
										myName = tss.Text;
								}
								ReadPossibilitiesFromXml(xrdrSub, null, sItemClassName, String.Format("{0}:{1}", ownerPath, myName), mapNameToPoss);
								break;

							// Additional Subclass fields.

							case "Questions":
								if (poss is ICmSemanticDomain)
									ReadQuestionsFromXml(xrdrSub.ReadSubtree(), poss as ICmSemanticDomain);
								else if (poss == null)
									questionsXml = GetXmlOfElement(xrdrSub);
								else
									StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
								break;

							case "Alias":
								if (poss is ICmPerson)
									SetMultiUnicodeFromXml(xrdrSub, (poss as ICmPerson).Alias);
								else if (poss is ICmLocation)
									SetMultiUnicodeFromXml(xrdrSub, (poss as ICmLocation).Alias);
								else if (poss == null)
									aliasXml = GetXmlOfElement(xrdrSub);
								else
									StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
								break;

							case "ReverseAbbr":
								if (poss is ILexEntryType)
									SetMultiUnicodeFromXml(xrdrSub, (poss as ILexEntryType).ReverseAbbr);
								else if (poss == null)
									revabbrXml = GetXmlOfElement(xrdrSub);
								else
									StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
								break;

							case "ReverseAbbreviation":
								if (poss is ILexRefType)
									SetMultiUnicodeFromXml(xrdrSub, (poss as ILexRefType).ReverseAbbreviation);
								else if (poss == null)
									revabbrevXml = GetXmlOfElement(xrdrSub);
								else
									StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
								break;

							case "ReverseName":
								if (poss is ILexRefType)
									SetMultiUnicodeFromXml(xrdrSub, (poss as ILexRefType).ReverseName);
								else if (poss == null)
									revnameXml = GetXmlOfElement(xrdrSub);
								else
									StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
								break;

							default:
								StoreOrReportUnexpectedElement(poss, xrdrSub, sItemClassName);
								break;
						}
					}
				}
			}
			finally
			{
				xrdrSub.Close();
				if (m_progress != null)
					m_progress.Step(1);
			}
		}
 protected override void PopulatePossibilityFromExtraData(ICmPossibility poss)
 {
     // IPartOfSpeech instances don't need anything from ExtraData
 }