public void GenerateSeqItems()
        {
            ArrayList list   = new ArrayList();
            XmlNode   column = m_columnList[3];           // Glosses

            XmlViewsUtils.CollectBrowseItems(1, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one items for glosses obj 1");
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(4, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for glosses obj 4");
            IManyOnePathSortItem bv = list[0] as IManyOnePathSortItem;

            Assert.AreEqual(5, bv.KeyObject);
            Assert.AreEqual(1, bv.PathLength);
            Assert.AreEqual(4, bv.PathObject(0));
            Assert.AreEqual(2010, bv.PathFlid(0));
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(6, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(3, list.Count, "got three items for glosses obj 6");
            int[] keys = new int[] { 7, 8, 9 };
            for (int i = 0; i < keys.Length; i++)
            {
                bv = list[i] as IManyOnePathSortItem;
                Assert.AreEqual(keys[i], bv.KeyObject);
                Assert.AreEqual(1, bv.PathLength);
                Assert.AreEqual(6, bv.PathObject(0));
                Assert.AreEqual(2010, bv.PathFlid(0));
            }
        }
Beispiel #2
0
        public void AlphaCompNumberString()
        {
            string      zero    = XmlViewsUtils.AlphaCompNumberString(0);
            string      one     = XmlViewsUtils.AlphaCompNumberString(1);
            string      two     = XmlViewsUtils.AlphaCompNumberString(2);
            string      ten     = XmlViewsUtils.AlphaCompNumberString(10);
            string      eleven  = XmlViewsUtils.AlphaCompNumberString(11);
            string      hundred = XmlViewsUtils.AlphaCompNumberString(100);
            string      minus1  = XmlViewsUtils.AlphaCompNumberString(-1);
            string      minus2  = XmlViewsUtils.AlphaCompNumberString(-2);
            string      minus10 = XmlViewsUtils.AlphaCompNumberString(-10);
            string      max     = XmlViewsUtils.AlphaCompNumberString(Int32.MaxValue);
            string      min     = XmlViewsUtils.AlphaCompNumberString(Int32.MinValue);
            IcuComparer comp    = new IcuComparer("en");

            comp.OpenCollatingEngine();
            Assert.IsTrue(comp.Compare(zero, one) < 0);
            Assert.IsTrue(comp.Compare(one, two) < 0);
            Assert.IsTrue(comp.Compare(two, ten) < 0);
            Assert.IsTrue(comp.Compare(ten, eleven) < 0);
            Assert.IsTrue(comp.Compare(eleven, hundred) < 0);
            Assert.IsTrue(comp.Compare(minus1, zero) < 0);
            Assert.IsTrue(comp.Compare(minus2, minus1) < 0);
            Assert.IsTrue(comp.Compare(minus10, minus2) < 0);
            Assert.IsTrue(comp.Compare(hundred, max) < 0);
            Assert.IsTrue(comp.Compare(min, minus10) < 0);

            Assert.IsTrue(comp.Compare(ten, zero) > 0);
            Assert.IsTrue(comp.Compare(ten, minus1) > 0);
            Assert.IsTrue(comp.Compare(hundred, minus10) > 0);
            Assert.IsTrue(comp.Compare(one, one) == 0);
            Assert.IsTrue(comp.Compare(ten, ten) == 0);
            Assert.IsTrue(comp.Compare(minus1, minus1) == 0);
            comp.CloseCollatingEngine();
        }
        public void GenerateDoubleSeqItems()
        {
            ArrayList            list = new ArrayList();
            IManyOnePathSortItem bv;
            XmlNode column = m_columnList[5];             // Semantic domains

            XmlViewsUtils.CollectBrowseItems(1, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for SD obj 1");             // no senses!
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(4, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for SD obj 4");             // sense 5 has no SDs
            list.Clear();
            // Senses 7, 8, 9, having SDs 7->30, 8->31, and 9->30, 31, 32
            XmlViewsUtils.CollectBrowseItems(6, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(5, list.Count, "got five items for SD obj 6");
            int[] keys  = new int[] { 30, 31, 30, 31, 32 };
            int[] keys2 = new int[] { 7, 8, 9, 9, 9 };
            for (int i = 0; i < keys.Length; i++)
            {
                bv = list[i] as IManyOnePathSortItem;
                Assert.AreEqual(keys[i], bv.KeyObject);
                Assert.AreEqual(2, bv.PathLength);
                Assert.AreEqual(6, bv.PathObject(0));
                Assert.AreEqual(2010, bv.PathFlid(0));                 // LexEntry.Senses
                Assert.AreEqual(keys2[i], bv.PathObject(1));
                Assert.AreEqual(21016, bv.PathFlid(1));                // LexSense.SemanticDomain
            }
        }
Beispiel #4
0
        /// <summary>
        /// Sets the title string to an appropriate default when nothing is specified in the xml configuration for the view
        /// </summary>
        protected virtual void SetInfoBarText()
        {
            if (m_informationBar == null)
            {
                return;
            }
            string className = StringTable.Table.GetString("No Record", "Misc");

            if (Clerk.CurrentObject != null)
            {
                using (var uiObj = CmObjectUi.MakeUi(Clerk.CurrentObject))
                    className = uiObj.DisplayNameOfClass;
            }
            else
            {
                string emptyTitleId = XmlUtils.GetAttributeValue(m_configurationParameters, "emptyTitleId");
                if (!String.IsNullOrEmpty(emptyTitleId))
                {
                    string titleStr;
                    XmlViewsUtils.TryFindString("EmptyTitles", emptyTitleId, out titleStr);
                    if (titleStr != "*" + emptyTitleId + "*")
                    {
                        className = titleStr;
                    }
                    Clerk.UpdateStatusBarRecordNumber(titleStr);
                }
            }
            // This code:  ((IPaneBar)m_informationBar).Text = className;
            // causes about 47 of the following exceptions when executed in Flex.
            // First-chance exception at 0x4ed9b280 in Flex.exe: 0xC0000005: Access violation writing location 0x00f90004.
            // The following code doesn't cause the exception, but neither one actually sets the Text to className,
            // so something needs to be changed somewhere. It doesn't enter "override string Text" in PaneBar.cs
            ((IPaneBar)m_informationBar).Text = className;
        }
        private int getWsFromId(string id)
        {
            // special case, the only few we support so far (and only for a few fields).
            if (id == "best analysis")
            {
                return(WritingSystemServices.kwsFirstAnal);               //LangProject.kwsFirstAnal;
            }
            else if (id == "vern in para")
            {
                return(WritingSystemServices.kwsVernInParagraph);
            }
            Debug.Assert(!XmlViewsUtils.GetWsRequiresObject(id), "Writing system is magic.  These should never be used in the Interlinear area.");

            int ws = -50;

            try
            {
                if (!XmlViewsUtils.GetWsRequiresObject(id))
                {
                    // Try to convert the ws parameter into an int.  Sometimes the parameter
                    // cannot be interpreted without an object, such as when the ws is a magic
                    // string that will change the actual ws depending on the contents of the
                    // object.  In these cases, we give -50 as a known constant to check for.
                    // This can possibly throw an exception, so we'll enclose it in a try block.
                    ws = WritingSystemServices.InterpretWsLabel(m_cache, id, null, 0, 0, null);
                }
            }
            catch
            {
                Debug.Assert(ws != -50, "InterpretWsLabel was not able to interpret the Ws Label.  The most likely cause for this is that a magic ws was passed in.");
            }
            return(ws);
        }
Beispiel #6
0
        public void CopyWithParamDefaults()
        {
            XmlDocument docSrc = new XmlDocument();

            docSrc.LoadXml(
                "<column label=\"Gloss\"> "
                + "<seq field=\"Senses\" sep=\"$delimiter=commaSpace\"> "
                + "<string field=\"Gloss\" ws=\"$ws=analysis\"/> "
                + "</seq> "
                + "</column>");

            XmlNode source = GetRootNode(docSrc, "column");

            Assert.IsNotNull(source);

            XmlNode output = XmlViewsUtils.CopyWithParamDefaults(source);

            Assert.IsNotNull(output);
            Assert.IsFalse(source == output);

            XmlDocument docExpected = new XmlDocument();

            docExpected.LoadXml(
                "<column label=\"Gloss\"> "
                + "<seq field=\"Senses\" sep=\"commaSpace\"> "
                + "<string field=\"Gloss\" ws=\"analysis\"/> "
                + "</seq> "
                + "</column>");
            XmlNode expected = GetRootNode(docExpected, "column");

            Assert.IsTrue(NodesMatch(output, expected));
        }
        public void GenerateAtomicItems()
        {
            ArrayList list   = new ArrayList();
            XmlNode   column = m_columnList[1];           // Etymology

            XmlViewsUtils.CollectBrowseItems(1, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for etymology obj 1");
            IManyOnePathSortItem bv = list[0] as IManyOnePathSortItem;

            Assert.AreEqual(60, bv.KeyObject);
            Assert.AreEqual(1, bv.PathLength);
            Assert.AreEqual(1, bv.PathObject(0));
            Assert.AreEqual(2011, bv.PathFlid(0));
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(4, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for etymology obj 4");
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(6, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for etymology obj 6");
            bv = list[0] as IManyOnePathSortItem;
            Assert.AreEqual(61, bv.KeyObject);
            Assert.AreEqual(1, bv.PathLength);
            Assert.AreEqual(6, bv.PathObject(0));
            Assert.AreEqual(2011, bv.PathFlid(0));
        }
Beispiel #8
0
        /// <summary>
        /// Add to collector the ManyOnePathSortItems which this sorter derives from
        /// the specified object. This implementation follows object and sequence properties,
        /// if there is only one in a given structure, and makes an item for each thing
        /// found.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="collector"></param>
        public void CollectItems(ICmObject obj, ArrayList collector)
        {
            CheckDisposed();

            int start = collector.Count;

            XmlViewsUtils.CollectBrowseItems(obj.Hvo, m_colSpec, collector, m_mdc, m_sda, m_layouts);
            for (int i = start; i < collector.Count; i++)
            {
                (collector[i] as ManyOnePathSortItem).RootObject = obj;
            }
        }
        public void DisplayAtomicPathObject()
        {
            ArrayList list   = new ArrayList();
            XmlNode   column = m_columnList[1];

            XmlViewsUtils.CollectBrowseItems(1, column, list, m_mdc, m_sda, m_layouts);
            IManyOnePathSortItem bvi = list[0] as IManyOnePathSortItem;

            // Try on first column. Nothing in the path matches, but we still dig inside
            // the span.
            int            useHvo;
            List <XmlNode> collectStructNodes = new List <XmlNode>();
            XmlNode        useNode            = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[0],
                                                                                    m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);

            Assert.AreEqual(1, useHvo);
            CheckDebugId(useNode, "LexemeCf");
            Assert.AreEqual(1, collectStructNodes.Count);
            CheckDebugId(collectStructNodes[0], "LexemeSpan");

            // Try on matching column.
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[1],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(bvi.KeyObject, useHvo);
            CheckDebugId(useNode, "EtymologyComment");
            Assert.AreEqual(1, collectStructNodes.Count);
            XmlNode structNode1 = collectStructNodes[0];

            CheckDebugId(structNode1, "EtymologySpan");

            // Try on a column involving a lookup. This affects the node output.
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[2],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(1, useHvo);
            CheckDebugId(useNode, "EntryMsaSeq");
            Assert.AreEqual(1, collectStructNodes.Count);
            structNode1 = collectStructNodes[0];
            CheckDebugId(structNode1, "EntryMsasDiv");

            // On a different view of the Etymology, we should still get the Etymology object.
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[6],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(bvi.KeyObject, useHvo);
            CheckDebugId(useNode, "EtymologyComment2");
            // But this column has no structural nodes.
            Assert.AreEqual(0, collectStructNodes.Count);
        }
Beispiel #10
0
        public void StringsFor()
        {
            var entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create();

            entry.CitationForm.VernacularDefaultWritingSystem = Cache.TsStrFactory.MakeString("kick", Cache.DefaultVernWs);
            var doc = new XmlDocument();

            doc.LoadXml(@"<string class='LexEntry' field='CitationForm'/>");
            var node    = doc.DocumentElement;
            var strings = XmlViewsUtils.StringsFor(Cache, Cache.DomainDataByFlid, node, entry.Hvo, null, null, null,
                                                   (int)WritingSystemServices.kwsVern);

            Assert.That(strings, Has.Length.EqualTo(1));
            Assert.That(strings, Has.Member("kick"));
        }
Beispiel #11
0
        protected virtual void SetInfoBarText()
        {
            if (m_informationBar == null)
            {
                return;
            }
            string className = StringTbl.GetString("No Record", "Misc");

            if (Clerk.CurrentObject != null)
            {
                string typeName = Clerk.CurrentObject.GetType().Name;
                if (Clerk.CurrentObject is ICmPossibility)
                {
                    var possibility = Clerk.CurrentObject as ICmPossibility;
                    className = possibility.ItemTypeName(StringTbl);
                }
                else
                {
                    className = StringTbl.GetString(typeName, "ClassNames");
                }
                if (className == "*" + typeName + "*")
                {
                    className = typeName;
                }
            }
            else
            {
                string emptyTitleId = XmlUtils.GetAttributeValue(m_configurationParameters, "emptyTitleId");
                if (!String.IsNullOrEmpty(emptyTitleId))
                {
                    string titleStr;
                    XmlViewsUtils.TryFindString(StringTbl, "EmptyTitles", emptyTitleId, out titleStr);
                    if (titleStr != "*" + emptyTitleId + "*")
                    {
                        className = titleStr;
                    }
                    Clerk.UpdateStatusBarRecordNumber(titleStr);
                }
            }
            // This code:  ((IPaneBar)m_informationBar).Text = className;
            // causes about 47 of the following exceptions when executed in Flex.
            // First-chance exception at 0x4ed9b280 in Flex.exe: 0xC0000005: Access violation writing location 0x00f90004.
            // The following code doesn't cause the exception, but neither one actually sets the Text to className,
            // so something needs to be changed somewhere. It doesn't enter "override string Text" in PaneBar.cs
            (m_informationBar as IPaneBar).Text = className;
        }
Beispiel #12
0
        public static DictionaryNodeOptions GetFullyEnabledListOptions(LcmCache cache, DictionaryNodeListOptions.ListIds listName)
        {
            List <DictionaryNodeListOptions.DictionaryNodeOption> dnoList;
            var useParaOptions = false;

            switch (listName)
            {
            case DictionaryNodeListOptions.ListIds.Minor:
                dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedVariantType(), XmlViewsUtils.GetGuidForUnspecifiedComplexFormType() }
                    .Select(guid => guid.ToString())
                    .Union(cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS
                           .Union(cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS).Select(item => item.Guid.ToString())));
                break;

            case DictionaryNodeListOptions.ListIds.Variant:
                dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedVariantType().ToString() }
                    .Union(cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString())));
                break;

            case DictionaryNodeListOptions.ListIds.Complex:
                useParaOptions = true;
                dnoList        = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedComplexFormType().ToString() }
                    .Union(cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString())));
                break;

            case DictionaryNodeListOptions.ListIds.Note:
                useParaOptions = true;
                dnoList        = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(
                    new[] { XmlViewsUtils.GetGuidForUnspecifiedExtendedNoteType().ToString() }
                    .Union(cache.LangProject.LexDbOA.ExtendedNoteTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString())));
                break;

            default:
                throw new NotImplementedException(string.Format("Unknown list id {0}", listName));
            }

            DictionaryNodeListOptions listOptions = useParaOptions ? new DictionaryNodeListAndParaOptions() : new DictionaryNodeListOptions();

            listOptions.ListId  = listName;
            listOptions.Options = dnoList;
            return(listOptions);
        }
Beispiel #13
0
        private void SetInfoBarText(XmlNode handlerNode, PaneBar infoBar)
        {
            var titleStr = string.Empty;
            // See if we have an AlternativeTitle string table id for an alternate title.
            var titleId = XmlUtils.GetAttributeValue(handlerNode, "altTitleId");

            if (titleId != null)
            {
                XmlViewsUtils.TryFindString("AlternativeTitles", titleId, out titleStr);
                // if they specified an altTitleId, but it wasn't found, they need to do something,
                // so just return *titleId*
                if (titleStr == null)
                {
                    titleStr = titleId;
                }
            }
            infoBar.Text = titleStr;
        }
Beispiel #14
0
        public void TrivialCopyWithParamDefaults()
        {
            XmlDocument docSrc = new XmlDocument();

            docSrc.LoadXml(
                "<column label=\"Gloss\"> "
                + "<seq field=\"Senses\" sep=\"commaSpace\"> "
                + "<string field=\"Gloss\" ws=\"analysis\"/> "
                + "</seq> "
                + "</column>");

            XmlNode source = GetRootNode(docSrc, "column");

            Assert.IsNotNull(source);
            XmlNode output = XmlViewsUtils.CopyWithParamDefaults(source);

            Assert.IsTrue(source == output);
        }
Beispiel #15
0
        private bool IsItemEmpty(int hvo, int fragId)
        {
            // If it's not the kind of vector we know how to deal with, safest to assume the item
            // is not empty.
            MainCallerDisplayCommand command;

            if (!m_viewConstructor.CanGetMainCallerDisplayCommand(fragId, out command))
            {
                return(false);
            }

            string  layoutName;
            XmlNode node = command.GetNodeForChild(out layoutName, fragId, m_viewConstructor, hvo);
            var     keys = XmlViewsUtils.ChildKeys(m_cache, m_sda, node, hvo, Layouts,
                                                   command.Caller, m_stringTable, m_viewConstructor.WsForce);

            return(AreAllKeysEmpty(keys));
        }
        public void DisplayPathlessObject()
        {
            ArrayList list   = new ArrayList();
            XmlNode   column = m_columnList[0];

            XmlViewsUtils.CollectBrowseItems(1, column, list, m_mdc, m_sda, m_layouts);
            IManyOnePathSortItem bvi = list[0] as IManyOnePathSortItem;

            // Try on original column. We get original object since there's no path,
            // but we still dig inside the span
            int            useHvo;
            List <XmlNode> collectStructNodes = new List <XmlNode>();
            XmlNode        useNode            = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[0],
                                                                                    m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);

            Assert.AreEqual(1, useHvo);
            CheckDebugId(useNode, "LexemeCf");
            Assert.AreEqual(1, collectStructNodes.Count);
            CheckDebugId(collectStructNodes[0], "LexemeSpan");

            // Try on another column. Again we get original object, and dig inside span
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[1],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(1, useHvo);
            CheckDebugId(useNode, "EtymologyObj");
            Assert.AreEqual(1, collectStructNodes.Count);
            XmlNode structNode1 = collectStructNodes[0];

            CheckDebugId(structNode1, "EtymologySpan");

            // Try on a column involving a lookup. This affects the node output.
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[2],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(1, useHvo);
            CheckDebugId(useNode, "EntryMsaSeq");
            Assert.AreEqual(1, collectStructNodes.Count);
            structNode1 = collectStructNodes[0];
            CheckDebugId(structNode1, "EntryMsasDiv");
        }
Beispiel #17
0
        public void FindDefaults()
        {
            XmlDocument docSrc = new XmlDocument();

            docSrc.LoadXml(
                "<column label=\"Gloss\"> "
                + "<seq field=\"Senses\" sep=\"$delimiter=commaSpace\"> "
                + "<string field=\"Gloss\" ws=\"$ws=analysis\"/> "
                + "</seq> "
                + "</column>");

            XmlNode source = GetRootNode(docSrc, "column");

            Assert.IsNotNull(source);
            Assert.IsTrue(XmlViewsUtils.HasParam(source));

            string[] paramList = XmlViewsUtils.FindParams(source);
            Assert.AreEqual(2, paramList.Length);
            Assert.AreEqual("$delimiter=commaSpace", paramList[0]);
            Assert.AreEqual("$ws=analysis", paramList[1]);
        }
        public void GeneratePathlessItems()
        {
            ArrayList list   = new ArrayList();
            XmlNode   column = m_columnList[0];

            XmlViewsUtils.CollectBrowseItems(1, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for lexeme obj 1");
            IManyOnePathSortItem bv = list[0] as IManyOnePathSortItem;

            Assert.AreEqual(1, bv.KeyObject);
            Assert.AreEqual(0, bv.PathLength);
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(4, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for lexeme obj 4");
            list.Clear();
            XmlViewsUtils.CollectBrowseItems(6, column, list, m_mdc, m_sda, m_layouts);
            Assert.AreEqual(1, list.Count, "got one item for lexeme obj 6");
            bv = list[0] as IManyOnePathSortItem;
            Assert.AreEqual(6, bv.KeyObject);
            Assert.AreEqual(0, bv.PathLength);
        }
Beispiel #19
0
        /// <summary>
        /// Add to collector the ManyOnePathSortItems which this sorter derives from
        /// the specified object. This implementation follows object and sequence properties,
        /// if there is only one in a given structure, and makes an item for each thing
        /// found.
        /// </summary>
        public void CollectItems(int hvo, ArrayList collector)
        {
            int start = collector.Count;

            XmlViewsUtils.CollectBrowseItems(hvo, m_colSpec, collector, m_mdc, m_sda, m_layouts);
        }
Beispiel #20
0
 private string[] StringsFor(int hvo, XmlNode layout, int wsForce)
 {
     return(XmlViewsUtils.StringsFor(m_cache, m_cache.DomainDataByFlid, layout, hvo, m_layouts, null, m_stringTbl, wsForce));
 }
Beispiel #21
0
        protected override void SetInfoBarText()
        {
            if (m_informationBar == null)
            {
                return;
            }

            string titleStr = "";
            // See if we have an AlternativeTitle string table id for an alternate title.
            string titleId = XmlUtils.GetAttributeValue(m_configurationParameters,
                                                        "altTitleId");

            if (titleId != null)
            {
                XmlViewsUtils.TryFindString("AlternativeTitles", titleId, out titleStr);
                // if they specified an altTitleId, but it wasn't found, they need to do something,
                // so just return *titleId*
                if (Clerk.OwningObject != null && titleId.StartsWith("Reversal") &&
                    XmlUtils.GetBooleanAttributeValue(m_configurationParameters, "ShowOwnerShortname"))
                {
                    // Originally this option was added to enable Bulk Edit Reversal Entries title bar to show
                    // which reversal index was being shown. If the 'titleId.StartsWith("Reversal")' in the 'if'
                    // above is removed then the Word List Concordance shows the word being concorded in the
                    // right pane title bar.
                    titleStr = string.Format(xWorksStrings.ksXReversalIndex, Clerk.OwningObject.ShortName, titleStr);
                }
            }
            else if (Clerk.OwningObject != null)
            {
                if (XmlUtils.GetBooleanAttributeValue(m_configurationParameters,
                                                      "ShowOwnerShortname"))
                {
                    titleStr = Clerk.OwningObject.ShortName;
                }
            }
            if (String.IsNullOrEmpty(titleStr))
            {
                XmlViewsUtils.TryFindPluralFormFromFlid(Clerk.VirtualListPublisher.MetaDataCache,
                                                        Clerk.OwningFlid, out titleStr);
            }

            bool fBaseCalled = false;

            if (String.IsNullOrEmpty(titleStr))
            {
                base.SetInfoBarText();
                fBaseCalled = true;
//				titleStr = ((IPaneBar)m_informationBar).Text;	// can't get to work.
                // (EricP) For some reason I can't provide an IPaneBar get-accessor to return
                // the new Text value. If it's desirable to allow TitleFormat to apply to
                // Clerk.CurrentObject, then we either have to duplicate what the
                // base.SetInfoBarText() does here, or get the string set by the base.
                // for now, let's just return.
                if (string.IsNullOrEmpty(titleStr))
                {
                    return;
                }
            }

            // If we have a format attribute, format the title accordingly.
            string sFmt = XmlUtils.GetAttributeValue(m_configurationParameters,
                                                     "TitleFormat");

            if (sFmt != null)
            {
                titleStr = String.Format(sFmt, titleStr);
            }

            // if we haven't already set the text through the base,
            // or if we had some formatting to do, then set the infoBar text.
            if (!fBaseCalled || sFmt != null)
            {
                ((IPaneBar)m_informationBar).Text = titleStr;
            }
        }
        public void DisplayDoubleSeqPathObject()
        {
            ArrayList list   = new ArrayList();
            XmlNode   column = m_columnList[5];

            XmlViewsUtils.CollectBrowseItems(6, column, list, m_mdc, m_sda, m_layouts);
            IManyOnePathSortItem bvi = list[0] as IManyOnePathSortItem;

            // Try on first column. Nothing in the path matches, but we still dig inside
            // the span.
            int            useHvo;
            List <XmlNode> collectStructNodes = new List <XmlNode>();
            XmlNode        useNode            = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[0],
                                                                                    m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);

            Assert.AreEqual(6, useHvo);
            CheckDebugId(useNode, "LexemeCf");
            Assert.AreEqual(1, collectStructNodes.Count);
            CheckDebugId(collectStructNodes[0], "LexemeSpan");

            // Try on etymology column. Has an <obj>, but doens't match
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[1],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(6, useHvo);
            CheckDebugId(useNode, "EtymologyObj");
            Assert.AreEqual(1, collectStructNodes.Count);
            XmlNode structNode1 = collectStructNodes[0];

            CheckDebugId(structNode1, "EtymologySpan");

            // Try on a column involving a lookup. This affects the node output.
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[2],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(6, useHvo);
            CheckDebugId(useNode, "EntryMsaSeq");
            Assert.AreEqual(1, collectStructNodes.Count);
            structNode1 = collectStructNodes[0];
            CheckDebugId(structNode1, "EntryMsasDiv");

            // On the matching column, we should get the leaf object
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[5],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(bvi.KeyObject, useHvo);
            CheckDebugId(useNode, "PACN_Para");
            Assert.AreEqual(1, collectStructNodes.Count);
            structNode1 = collectStructNodes[0];
            CheckDebugId(structNode1, "DosDiv");

            // On the gloss column, we get the sense.
            collectStructNodes.Clear();
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[3],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(7, useHvo);             // the first sense
            CheckDebugId(useNode, "SenseGloss");
            Assert.AreEqual(1, collectStructNodes.Count);
            structNode1 = collectStructNodes[0];
            CheckDebugId(structNode1, "SenseGlossPara");

            // Make sure that for later Bvis, we get later senses
            collectStructNodes.Clear();
            bvi     = list[3] as IManyOnePathSortItem;
            useNode = XmlViewsUtils.GetNodeToUseForColumn(bvi, m_columnList[3],
                                                          m_mdc, m_sda, m_layouts, out useHvo, collectStructNodes);
            Assert.AreEqual(9, useHvo);             // the third sense, in which context we display the 4th SD
        }
Beispiel #23
0
        protected override void SetInfoBarText()
        {
            if (m_informationBar == null)
            {
                return;
            }

            string titleStr = "";
            // See if we have an AlternativeTitle string table id for an alternate title.
            string titleId = XmlUtils.GetAttributeValue(m_configurationParameters,
                                                        "altTitleId");

            if (titleId != null)
            {
                XmlViewsUtils.TryFindString(StringTbl, "AlternativeTitles", titleId, out titleStr);
                // if they specified an altTitleId, but it wasn't found, they need to do something,
                // so just return *titleId*
            }
            else if (Clerk.OwningObject != null)
            {
                if (XmlUtils.GetBooleanAttributeValue(m_configurationParameters,
                                                      "ShowOwnerShortname"))
                {
                    titleStr = Clerk.OwningObject.ShortName;
                }
            }
            if (String.IsNullOrEmpty(titleStr))
            {
                XmlViewsUtils.TryFindPluralFormFromFlid(Cache, StringTbl, (uint)Clerk.OwningFlid, out titleStr);
            }

            bool fBaseCalled = false;

            if (titleStr == string.Empty)
            {
                base.SetInfoBarText();
                fBaseCalled = true;
//				titleStr = ((IPaneBar)m_informationBar).Text;	// can't get to work.
                // (EricP) For some reason I can't provide an IPaneBar get-accessor to return
                // the new Text value. If it's desirable to allow TitleFormat to apply to
                // Clerk.CurrentObject, then we either have to duplicate what the
                // base.SetInfoBarText() does here, or get the string set by the base.
                // for now, let's just return.
                if (titleStr == null || titleStr == string.Empty)
                {
                    return;
                }
            }

            // If we have a format attribute, format the title accordingly.
            string sFmt = XmlUtils.GetAttributeValue(m_configurationParameters,
                                                     "TitleFormat");

            if (sFmt != null)
            {
                titleStr = String.Format(sFmt, titleStr);
            }

            // if we haven't already set the text through the base,
            // or if we had some formatting to do, then set the infoBar text.
            if (!fBaseCalled || sFmt != null)
            {
                ((IPaneBar)m_informationBar).Text = titleStr;
            }
        }