Exemplo n.º 1
0
 /// <summary>
 /// Checks that the chart contains the ChartRows specified.
 /// </summary>
 /// <param name="chart"></param>
 /// <param name="chartRows"></param>
 public void VerifyChartRows(IDsConstChart chart, IConstChartRow[] chartRows)
 {
     Assert.AreEqual(chart.RowsOS.Count, chartRows.Length, "Chart has wrong number of rows");
     for (var i = 0; i < chartRows.Length; i++)
     {
         Assert.AreEqual(chartRows[i].Hvo, chart.RowsOS[i].Hvo,
                         string.Format("Chart has unexpected ChartRow object at index = {0}", i));
     }
 }
Exemplo n.º 2
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_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = m_helper.SetupAChart();
		}
Exemplo n.º 3
0
		int m_wsLineNumber; // ws to use for line numbers.

		public DiscourseExporter(FdoCache cache, XmlWriter writer, int hvoRoot, IVwViewConstructor vc,
			int wsLineNumber)
			: base(null, cache.MainCacheAccessor, hvoRoot)
		{
			m_cache = cache;
			m_writer = writer;
			m_vc = vc;
			m_wsLineNumber = wsLineNumber;
			m_chart = DsConstChart.CreateFromDBObject(cache, hvoRoot);
		}
Exemplo n.º 4
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_helper.MakeTemplate(out m_allColumns);
     // Note: do this AFTER creating the template, which may also create the DiscourseData object.
     m_chart = m_helper.SetupAChart();
 }
Exemplo n.º 5
0
        int m_wsLineNumber;         // ws to use for line numbers.

        public DiscourseExporter(FdoCache cache, XmlWriter writer, int hvoRoot, IVwViewConstructor vc,
                                 int wsLineNumber)
            : base(null, cache.MainCacheAccessor, hvoRoot)
        {
            m_cache        = cache;
            m_writer       = writer;
            m_vc           = vc;
            m_wsLineNumber = wsLineNumber;
            m_chart        = DsConstChart.CreateFromDBObject(cache, hvoRoot);
        }
Exemplo n.º 6
0
        private readonly int m_wsLineNumber;         // ws to use for line numbers.

        public DiscourseExporter(FdoCache cache, XmlWriter writer, int hvoRoot, IVwViewConstructor vc,
                                 int wsLineNumber)
            : base(null, cache.MainCacheAccessor, hvoRoot)
        {
            m_cache        = cache;
            m_writer       = writer;
            m_vc           = vc;
            m_wsLineNumber = wsLineNumber;
            m_chart        = m_cache.ServiceLocator.GetInstance <IDsConstChartRepository>().GetObject(hvoRoot);
            m_rowRepo      = m_cache.ServiceLocator.GetInstance <IConstChartRowRepository>();
        }
Exemplo n.º 7
0
		private readonly int m_wsLineNumber; // ws to use for line numbers.

		public DiscourseExporter(FdoCache cache, XmlWriter writer, int hvoRoot, IVwViewConstructor vc,
			int wsLineNumber)
			: base(null, cache.MainCacheAccessor, hvoRoot)
		{
			m_cache = cache;
			m_writer = writer;
			m_vc = vc;
			m_wsLineNumber = wsLineNumber;
			m_chart = m_cache.ServiceLocator.GetInstance<IDsConstChartRepository>().GetObject(hvoRoot);
			m_rowRepo = m_cache.ServiceLocator.GetInstance<IConstChartRowRepository>();
		}
		protected override void CreateTestData()
		{
			base.CreateTestData();
			//m_firstParaOccurrences = m_helper.m_allOccurrences[m_firstPara];
			m_ccl = new TestCCLogic(Cache, m_chart, m_stText);
			m_helper.Logic = m_ccl;
			m_ccl.Ribbon = new MockRibbon(Cache, m_stText.Hvo);
			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();
			// Tests in this file want to limit text to known quantities, so delete the default paragraph.
			m_stText.ParagraphsOS.RemoveAt(0);
		}
Exemplo n.º 9
0
        /// <summary>
        /// Creates a chart, adds it to the LangProject, sets a template, and adds it to the logic
        /// </summary>
        internal IDsConstChart SetupAChart()
        {
            // Note: do this AFTER creating the template, which may also create the DiscourseData object.
            Assert.IsNotNull(Cache.LangProject, "No LangProject in the cache!");
            var data = Cache.LangProject.DiscourseDataOA;

            Assert.IsNotNull(data, "No DiscourseData object!");
            m_chart = Cache.ServiceLocator.GetInstance <IDsConstChartFactory>().Create(
                data, m_stText, m_template);
            Logic.Chart = m_chart;
            m_logic.Ribbon.CacheRibbonItems(new List <AnalysisOccurrence>());
            Cache.LangProject.GetDefaultChartMarkers();
            return(m_chart);
        }
Exemplo n.º 10
0
        protected override void CreateTestData()
        {
            base.CreateTestData();
            m_logic        = new TestCCLogic(Cache, m_chart, m_stText);      // m_chart is still null!
            m_helper.Logic = m_logic;
            m_logic.Ribbon = new MockRibbon(Cache, m_stText.Hvo);
            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_constChart = new ConstituentChart(Cache, m_logic);
            m_constChart.Init(null, null, null);
            m_chartBody       = m_constChart.Body;
            m_chartBody.Cache = Cache;             // don't know why constructor doesn't do this, but it doesn't.

            m_chartBody.SetRoot(m_chart, m_allColumns.ToArray());
        }
Exemplo n.º 11
0
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_logic = new TestCCLogic(Cache, m_chart, m_stText); // m_chart is still null!
			m_helper.Logic = m_logic;
			m_logic.Ribbon = new MockRibbon(Cache, m_stText.Hvo);
			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_constChart = new ConstituentChart(Cache, m_logic);
			m_constChart.Init(null, null);
			m_chartBody = m_constChart.Body;
			m_chartBody.Cache = Cache; // don't know why constructor doesn't do this, but it doesn't.

			m_chartBody.SetRoot(m_chart, m_allColumns.ToArray());
		}
Exemplo n.º 12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds an empty chart on the specified text.
        /// </summary>
        /// <param name="name">Chart name.</param>
        /// <param name="stText">Chart is BasedOn this text.</param>
        /// ------------------------------------------------------------------------------------
        private IDsConstChart AddChartToLangProj(string name, IStText stText)
        {
            ILcmServiceLocator servloc = Cache.ServiceLocator;
            IDsConstChart      chart   = servloc.GetInstance <IDsConstChartFactory>().Create();

            if (Cache.LangProject.DiscourseDataOA == null)
            {
                Cache.LangProject.DiscourseDataOA = servloc.GetInstance <IDsDiscourseDataFactory>().Create();
            }

            Cache.LangProject.DiscourseDataOA.ChartsOC.Add(chart);

            // Setup the new chart
            chart.Name.AnalysisDefaultWritingSystem = TsStringUtils.MakeString(name, Cache.DefaultAnalWs);
            chart.BasedOnRA = stText;

            return(chart);            // This chart has no template or rows, so far!!
        }
Exemplo n.º 13
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()
		{
			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.º 15
0
		/// <summary>
		/// Set the root object.
		/// </summary>
		public void SetRoot(int hvo)
		{
			int oldTemplateHvo = 0;
			if (m_template != null)
				oldTemplateHvo = m_template.Hvo;
			// does it already have a chart? If not make one.
			m_chart = null;
			// in case of previous call.
			if (m_cache.LangProject.DiscourseDataOA == null)
			{
				NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => { m_template = m_cache.LangProject.GetDefaultChartTemplate(); });
			}
			m_hvoRoot = hvo;
			if (m_hvoRoot == 0)
				RootStText = null;
			else
				RootStText = (IStText)m_cache.ServiceLocator.ObjectRepository.GetObject(hvo);
			if (m_hvoRoot > 0)
			{
				DetectAndReportTemplateProblem();

				// Make sure text is parsed!
				if (InterlinMaster.HasParagraphNeedingParse(RootStText))
				{
					NonUndoableUnitOfWorkHelper.Do(
						RootStText.Cache.ActionHandlerAccessor,
						() => InterlinMaster.LoadParagraphAnnotationsAndGenerateEntryGuessesIfNeeded(RootStText, false));
				}

				// We need to make or set the chart before calling NextUnusedInput.
				FindAndCleanUpMyChart(m_hvoRoot);
				// Sets m_chart if it finds one for hvoStText
				if (m_chart == null)
				{
					CreateChartInNonUndoableUOW();
				}
				m_logic.Chart = m_chart;
				var unchartedWordforms = m_logic.NextUnchartedInput(RootStText, kmaxWordforms).ToList();
				m_ribbon.CacheRibbonItems(unchartedWordforms);
				// Don't need PropChanged here, CacheRibbonItems handles it.
				if (m_logic.StTextHvo != 0 && m_hvoRoot != m_logic.StTextHvo)
				{
					EnableAllContextButtons();
					EnableAllMoveHereButtons();
					m_logic.ResetRibbonLimits();
					m_logic.CurrHighlightCells = null;
					// Should reset highlighting (w/PropChanged)
				}
				// Tell the ribbon whether it needs to display and select words Right to Left or not
				m_ribbon.SetRoot(m_hvoRoot);
				if (m_chart.TemplateRA == null)
					// LT-8700: if original template is deleted we might need this
					m_chart.TemplateRA = m_cache.LangProject.GetDefaultChartTemplate();
				m_template = m_chart.TemplateRA;
				m_logic.StTextHvo = m_hvoRoot;
				m_allColumns = m_logic.AllColumns(m_chart.TemplateRA).ToArray();
			}
			else
			{
				// no text, so no chart
				m_ribbon.SetRoot(0);
				m_logic.Chart = null;
				m_logic.StTextHvo = 0;
				m_allColumns = new ICmPossibility[0];
			}
			if (m_template != null && m_template.Hvo != oldTemplateHvo)
			{
				m_fInColWidthChanged = true;
				try
				{
					m_logic.MakeMainHeaderCols(m_headerMainCols);
					if (m_allColumns == new ICmPossibility[0])
						return;
					int ccolsWanted = m_allColumns.Length + ConstituentChartLogic.NumberOfExtraColumns;
					m_columnWidths = new int[ccolsWanted];
					m_columnPositions = new int[ccolsWanted + 1];
					// one extra for after the last column
					if (!RestoreColumnWidths())
					{
						SetDefaultColumnWidths();
					}
				}
				finally
				{
					m_fInColWidthChanged = false;
				}
			}
			if (m_chart != null)
			{
				m_body.SetRoot(m_chart.Hvo, m_allColumns, ChartIsRtL);

				GetAndScrollToBookmark();
			}

			else
				m_body.SetRoot(0, null, false);

			// If necessary adjust number of buttons
			if (m_MoveHereButtons.Count != m_allColumns.Length && hvo > 0)
			{
				SetupMoveHereButtonsToMatchTemplate();
			}
			SetHeaderColAndButtonWidths();
		}
Exemplo n.º 16
0
		/// <summary>
		/// Checks that the chart contains the rows specified.
		/// </summary>
		/// <param name="chart"></param>
		/// <param name="rows"></param>
		private void VerifyChartRows(IDsConstChart chart, IConstChartRow[] rows)
		{
			m_helper.VerifyChartRows(chart, rows);
		}
Exemplo n.º 17
0
		private bool m_isRtL; // set true to test RTL context menus, etc.

		internal TestCCLogic(FdoCache cache, IDsConstChart chart, IStText stText)
			: base(cache, chart, stText.Hvo)
		{
		}
Exemplo n.º 18
0
        /// <summary>
        /// The FDO factory now inserts the row in a particular spot in the chart.
        /// This method assumes you want to put it at the end.
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="lineNo"></param>
        /// <returns></returns>
        internal IConstChartRow MakeRow(IDsConstChart chart, string lineNo)
        {
            var label = m_tsf.MakeString(lineNo, Logic.WsLineNumber);

            return(m_rowFact.Create(chart, chart.RowsOS.Count, label));
        }
Exemplo n.º 19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a row in the given chart. Assumes append at end of chart.
		/// </summary>
		/// <param name="chart">The constiuent chart</param>
		/// <param name="rowNumber"></param>
		/// ------------------------------------------------------------------------------------
		private IConstChartRow CreateRow(IDsConstChart chart, string rowNumber)
		{
			var rowLabel = m_tssFact.MakeString(rowNumber, Cache.DefaultAnalWs);
			return m_rowFact.Create(chart, chart.RowsOS.Count, rowLabel);
		}
Exemplo n.º 20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a row in the given chart. Assumes append at end of chart.
        /// </summary>
        /// <param name="chart">The constiuent chart</param>
        /// <param name="rowNumber"></param>
        /// ------------------------------------------------------------------------------------
        private IConstChartRow CreateRow(IDsConstChart chart, string rowNumber)
        {
            var rowLabel = m_tssFact.MakeString(rowNumber, Cache.DefaultAnalWs);

            return(m_rowFact.Create(chart, chart.RowsOS.Count, rowLabel));
        }
Exemplo n.º 21
0
        private bool m_isRtL;                     // set true to test RTL context menus, etc.

        internal TestCCLogic(LcmCache cache, IDsConstChart chart, IStText stText)
            : base(cache, chart, stText.Hvo)
        {
        }
Exemplo n.º 22
0
		private void FindAndCleanUpMyChart(int hvoStText)
		{
			foreach (var chart in m_cache.LangProject.DiscourseDataOA.ChartsOC.Cast<IDsConstChart>().Where(chart => chart.BasedOnRA != null && chart.BasedOnRA.Hvo == hvoStText))
			{
				m_chart = chart;
				m_logic.Chart = m_chart;
				m_logic.CleanupInvalidChartCells();
				// Enhance GordonM: Eventually we may have to allow > 1 chart per text
				// Then we'll need to take out this break.
				break;
			}
		}
Exemplo n.º 23
0
		private void CreateChartInNonUndoableUOW()
		{
			NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () => { m_chart = m_serviceLocator.GetInstance<IDsConstChartFactory>().Create(m_cache.LangProject.DiscourseDataOA, RootStText, m_cache.LangProject.GetDefaultChartTemplate()); });
		}
Exemplo n.º 24
0
		/// <summary>
		/// Change the root chart. This version takes the actual chart object.
		/// </summary>
		/// <param name="chart"></param>
		/// <param name="allColumns"></param>
		public void SetRoot(IDsConstChart chart, ICmPossibility[] allColumns)
		{
			SetRoot(chart.Hvo, allColumns);
		}
Exemplo n.º 25
0
		/// <summary>
		/// Creates a new Chart Row with the specified row number/letter label
		/// at the specified location in the specified chart.
		/// </summary>
		/// <param name="chart"></param>
		/// <param name="insertAt"></param>
		/// <param name="rowLabel"></param>
		/// <returns></returns>
		public IConstChartRow Create(IDsConstChart chart, int insertAt, ITsString rowLabel)
		{
			if (chart == null)
				throw new ArgumentNullException("chart");
			if (rowLabel == null)
				throw new ArgumentNullException("rowLabel");
			if (insertAt < 0 || insertAt > chart.RowsOS.Count) // insertAt == Count will append
				throw new ArgumentOutOfRangeException("insertAt");
			var newby = Create();
			chart.RowsOS.Insert(insertAt, newby);
			newby.Label = rowLabel;
			newby.ClauseType = ClauseTypes.Normal;
			return newby;
		}