Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FwModelBrowser"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public FwModelBrowser()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

#if USINGCPP
            m_ode = OleDbEncapClass.Create();
            m_ode.Init(SystemInformation.ComputerName + "\\SILFW", "TestLangProj", null,
                       FwKernelLib.OdeLockTimeoutMode.koltReturnError,
                       (int)FwKernelLib.OdeLockTimeoutValue.koltvFwDefault);
            m_mdc = FwMetaDataCacheClass.Create();
            m_mdc.Init(m_ode);
#else
            string modelDir = DirectoryFinder.FwSourceDirectory;
            modelDir = modelDir.Substring(0, modelDir.LastIndexOf('\\'));
            modelDir = Path.Combine(modelDir, @"Output\XMI");
            m_mdc    = MetaDataCache.CreateMetaDataCache(Path.Combine(modelDir, "xmi2cellar3.xml"));
#endif

            uint   clid      = 0;
            string classname = m_mdc.GetClassName(clid);
            m_tvClasses.SuspendLayout();
            AddNode(m_tvClasses.Nodes, classname, clid);
            m_tvClasses.Nodes[0].Expand();
            m_tvClasses.ResumeLayout(false);
        }
Exemple #2
0
        public void GenerateMlCustomString()
        {
            IFwMetaDataCache mdc         = FwMetaDataCacheClass.Create();
            string           m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                                        @"DbAccess\Test\SampleCm.xml");

            mdc.InitXml(m_sTestPath, true);

            XmlDocument docSrc = new XmlDocument();

            docSrc.LoadXml(
                "<generate class=\"LexEntry\" fieldType=\"mlstring\" restrictions=\"customOnly\"> "
                + "<column label=\"$label\"> "
                + "<seq field=\"Senses\" sep=\"$delimiter:commaSpace\"> "
                + "<string field=\"$fieldName\" ws=\"$ws:analysis\" class=\"LexEntry\"/> "
                + "</seq> "
                + "</column> "
                + "</generate>");
            XmlNode source = TestXmlViewsUtils.GetRootNode(docSrc, "generate");

            Assert.IsNotNull(source);

            PartGenerator generator = new PartGenerator(mdc, source);

            string[] fields = generator.FieldNames;
            Assert.AreEqual(1, fields.Length);
            Assert.IsTrue(StringArrayIncludes(fields, "custom"));

            XmlNode[] results = generator.Generate();

            // SampleCm.xml has three ML attrs on LexEntry
            Assert.AreEqual(1, results.Length);

            XmlDocument docExpected3 = new XmlDocument();

            docExpected3.LoadXml(
                "<column label=\"Restrictions\" originalLabel=\"Restrictions\" > "
                + "<seq field=\"Senses\" sep=\"$delimiter:commaSpace\"> "
                + "<string field=\"custom\" ws=\"$ws:analysis\" class=\"LexEntry\"/> "
                + "</seq> "
                + "</column>");
            XmlNode expected3 = TestXmlViewsUtils.GetRootNode(docExpected3, "column");

            Assert.IsTrue(SomeNodeMatches(results, expected3));
        }
Exemple #3
0
        public void GenerateParts()
        {
            IFwMetaDataCache mdc         = FwMetaDataCacheClass.Create();
            string           m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                                        @"DbAccess\Test\SampleCm.xml");

            mdc.InitXml(m_sTestPath, true);

            XmlDocument docSrc = new XmlDocument();

            docSrc.LoadXml(
                "<root> "
                + "<dummy1/> "
                + "<generate class=\"LexEntry\" fieldType=\"mlstring\" restrictions=\"none\"> "
                + "<column label=\"$fieldName\"> "
                + "<seq field=\"Senses\" sep=\"$delimiter:commaSpace\"> "
                + "<string field=\"$fieldName\" ws=\"$ws:analysis\"/> "
                + "</seq> "
                + "</column> "
                + "</generate> "
                + "<dummy2/> "
                + "<generate class=\"LexEntry\" fieldType=\"mlstring\" restrictions=\"none\"> "
                + "<dummyG label=\"$fieldName\"/> "
                + "</generate> "
                + "<dummy3/> "
                + "<dummy4/> "
                + "</root>");
            XmlNode source = TestXmlViewsUtils.GetRootNode(docSrc, "root");

            Assert.IsNotNull(source);

            List <XmlNode> nodes = PartGenerator.GetGeneratedChildren(source, mdc);

            Assert.AreEqual(1 + 3 + 1 + 3 + 2, nodes.Count);
            Assert.AreEqual("dummy1", nodes[0].Name);
            Assert.AreEqual("dummy2", nodes[4].Name);
            Assert.AreEqual("dummy3", nodes[8].Name);
            Assert.AreEqual("dummy4", nodes[9].Name);
            Assert.IsTrue(NameAndLabelOccur(nodes, 1, 4, "column", "CitationForm"));
            Assert.IsTrue(NameAndLabelOccur(nodes, 1, 4, "column", "Bibliography"));
            Assert.IsTrue(NameAndLabelOccur(nodes, 5, 8, "dummyG", "CitationForm"));
            Assert.IsTrue(NameAndLabelOccur(nodes, 5, 8, "dummyG", "custom"));
        }
Exemple #4
0
        public void Setup()
        {
            // Create the following:
            // - part and layout inventories
            // - metadata cache
            // - DataAccess cache
            // - collection of columns to display.

            // We want a MetaDataCache that knows about
            // - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
            // - LexSense.SemanticDomains, SenseType, Status, gloss
            // - CmPossibility Name, abbr
            // - MoMorphSynAnalysis
            // - MoStemMsa
            // - MoDerivationalMsa
            m_mdc = FwMetaDataCacheClass.Create();
            string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                              @"Common\Controls\XmlViews\XmlViewsTests\SampleCm.xml");

            m_mdc.InitXml(m_sTestPath, true);

            // We want ISilDataAccess with:
            // - LexEntry (1) with no senses and one MSA (2)
            // - LexEntry (4) with one sense (5) and no MSA
            // - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
            // - sense(5) with no semantic domains
            // - senses with one SD (7->30, 8->31)
            // - sense with three SDs, one the same as the first (9->30, 31, 32)
            // - MoStemMsa (2, 11)
            // - MoDerivationalMsa (10)
            m_cda = VwCacheDaClass.Create();
            m_sda = m_cda as ISilDataAccess;
            m_wsf = LgWritingSystemFactoryClass.Create();
            m_sda.WritingSystemFactory = m_wsf;
            SimpleDataParser parser = new SimpleDataParser(m_mdc, m_cda);

            parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory,
                                      @"Common\Controls\XmlViews\XmlViewsTests\SampleData.xml"));
            int wsEn = m_wsf.GetWsFromStr("en");

            // These are mainly to check out the parser.
            Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
            Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
            Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
            Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
            Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");

            // Columns includes
            // - CitationForm (string inside span)
            // - Bibliography (string not in span)
            // - Sense glosses (string in para in seq, nested in column element)
            // - Semantic domains (pair of strings in para in seq in seq, using layout refs)
            // - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
            XmlDocument docColumns = new XmlDocument();

            docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory,
                                         @"Common\Controls\XmlViews\XmlViewsTests\TestColumns.xml"));
            m_columnList = docColumns.DocumentElement.ChildNodes;

            // Parts just has what those columns need.
            string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory,
                                                @"Common\Controls\XmlViews\XmlViewsTests");
            Dictionary <string, string[]> keyAttrs = new Dictionary <string, string[]>();

            keyAttrs["layout"] = new string[] { "class", "type", "name" };
            keyAttrs["group"]  = new string[] { "label" };
            keyAttrs["part"]   = new string[] { "ref" };


            // Currently there are no specialized layout files that match.
            m_layoutInventory = new Inventory(new string[] { partDirectory },
                                              "*Layouts.xml", "/LayoutInventory/*", keyAttrs);

            keyAttrs         = new Dictionary <string, string[]>();
            keyAttrs["part"] = new string[] { "id" };

            m_partInventory = new Inventory(new string[] { partDirectory },
                                            "TestParts.xml", "/PartInventory/bin/*", keyAttrs);
            if (m_layouts != null)
            {
                m_layouts.Dispose();
            }
            m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
        }