This class publishes a list of objects through the ISilDataAccess interface. It defines a virtual property which contains a list of objects, and supports notifying changes to it. Other requests are passed through. This can be used to publish a list of objects for a BrowseViewer. In addition, it can implement the 'owning' property on which the virtual one is based. This is used for properties like "all wordforms" that don't have any logical object to be a virtual property of.
Inheritance: SIL.FieldWorks.FDO.Application.DomainDataByFlidDecoratorBase, IClearValues
Exemplo n.º 1
0
		private void VerifyCurrentValue(int hvoRoot, ObjectListPublisher publisher, int[] values, string label)
		{
			int[] newValues = publisher.VecProp(hvoRoot, ObjectListFlid);
			Assert.AreEqual(values.Length, newValues.Length, label + "length from VecProp");
			for (int i = 0; i < values.Length; i++)
				Assert.AreEqual(values[i], newValues[i], label + " item " + i +" from VecProp");
		}
Exemplo n.º 2
0
        /// <summary>
        /// Create and initialize the browse view, storing the data it will display.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="stylesheet">The stylesheet.</param>
        /// <param name="mediator">The mediator.</param>
        /// <param name="xnConfig">The config node.</param>
        /// <param name="objs">The objs.</param>
        public void Initialize(FdoCache cache, IVwStylesheet stylesheet, Mediator mediator,
                               XmlNode xnConfig, IEnumerable <ICmObject> objs)
        {
            CheckDisposed();
            m_cache      = cache;
            m_stylesheet = stylesheet;
            m_mediator   = mediator;
            m_configNode = xnConfig;
            SuspendLayout();
            m_listPublisher = new ObjectListPublisher(cache.DomainDataByFlid as ISilDataAccessManaged, ObjectListFlid);

            StoreData(objs);
            m_bvList = new BrowseViewer(m_configNode, m_cache.LanguageProject.Hvo, ObjectListFlid, m_cache, m_mediator,
                                        null, m_listPublisher);
            m_bvList.Location = new Point(0, 0);
            m_bvList.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom |
                                AnchorStyles.Right;
            m_bvList.Name              = "m_bvList";
            m_bvList.Sorter            = null;
            m_bvList.TabStop           = true;
            m_bvList.StyleSheet        = m_stylesheet;
            m_bvList.Dock              = DockStyle.Fill;
            m_bvList.SelectionChanged += m_bvList_SelectionChanged;
            Controls.Add(m_bvList);
            ResumeLayout(false);
        }
Exemplo n.º 3
0
		/// <summary>
		/// Create and initialize the browse view, storing the data it will display.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="stylesheet">The stylesheet.</param>
		/// <param name="mediator">The mediator.</param>
		/// <param name="xnConfig">The config node.</param>
		/// <param name="objs">The objs.</param>
		public void Initialize(FdoCache cache, IVwStylesheet stylesheet, Mediator mediator,
			XmlNode xnConfig, IEnumerable<ICmObject> objs)
		{
			CheckDisposed();
			m_cache = cache;
			m_stylesheet = stylesheet;
			m_mediator = mediator;
			m_configNode = xnConfig;
			SuspendLayout();
			m_listPublisher = new ObjectListPublisher(cache.DomainDataByFlid as ISilDataAccessManaged, ObjectListFlid);

			StoreData(objs);
			m_bvList = new BrowseViewer(m_configNode, m_cache.LanguageProject.Hvo, ObjectListFlid, m_cache, m_mediator,
				null, m_listPublisher);
			m_bvList.Location = new Point(0, 0);
			m_bvList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom |
				AnchorStyles.Right;
			m_bvList.Name = "m_bvList";
			m_bvList.Sorter = null;
			m_bvList.TabStop = true;
			m_bvList.StyleSheet = m_stylesheet;
			m_bvList.Dock = DockStyle.Fill;
			m_bvList.SelectionChanged += m_bvList_SelectionChanged;
			Controls.Add(m_bvList);
			ResumeLayout(false);
		}
Exemplo n.º 4
0
        ///<summary>
        /// Decorate an ISilDataAccessManaged object with another layer limiting objects to print.
        ///</summary>
        ///<param name="oldSda"></param>
        ///<param name="rootHvo"></param>
        ///<param name="mainFlid"></param>
        ///<param name="selectedObjects"></param>
        ///<returns></returns>
        public static ISilDataAccessManaged CachePrintDecorator(ISilDataAccessManaged oldSda,
                                                                int rootHvo, int mainFlid, int[] selectedObjects)
        {
            var printDecorator = new ObjectListPublisher(oldSda, mainFlid);

            printDecorator.CacheVecProp(rootHvo, selectedObjects);
            return(printDecorator);
        }
Exemplo n.º 5
0
		public void SetAndAccessDummyList()
		{
			ILexDb lexDb = Cache.LangProject.LexDbOA;
			ILexEntry entry1 = null;
			ICmResource res1 = null;
			NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () =>
			{
				var leFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
				entry1 = leFactory.Create();
				ILexEntry entry2 = leFactory.Create();
				res1 = Cache.ServiceLocator.GetInstance<ICmResourceFactory>().Create();
				lexDb.ResourcesOC.Add(res1);
			});

			int hvoRoot = 10578;
			ObjectListPublisher publisher = new ObjectListPublisher(Cache.MainCacheAccessor as ISilDataAccessManaged, ObjectListFlid);
			var values = new int[] {23, 56, 2048};
			Notifiee recorder = new Notifiee();
			publisher.AddNotification(recorder);
			publisher.CacheVecProp(hvoRoot, values);
			Assert.AreEqual(values.Length, publisher.get_VecSize(hvoRoot, ObjectListFlid), "override of vec size");
			//Assert.AreEqual(Cache.LangProject.Texts.Count, publisher.get_VecSize(Cache.LangProject.Hvo, LangProjectTags.kflidTexts), "base vec size");

			Assert.AreEqual(23, publisher.get_VecItem(hvoRoot, ObjectListFlid, 0), "override of vec item");
			Assert.AreEqual(res1.Hvo, publisher.get_VecItem(lexDb.Hvo, LexDbTags.kflidResources, 0), "base vec item");
			Assert.AreEqual(56, publisher.get_VecItem(hvoRoot, ObjectListFlid, 1), "override of vec item, non-zero index");

			VerifyCurrentValue(hvoRoot, publisher, values, "original value");
			Assert.AreEqual(lexDb.ResourcesOC.Count(), publisher.VecProp(lexDb.Hvo, LexDbTags.kflidResources).Length, "base VecProp");

			recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 0, values.Length, 0) },
				"expected PropChanged from caching HVOs");
			publisher.RemoveNotification(recorder);

			recorder = new Notifiee();
			publisher.AddNotification(recorder);
			publisher.Replace(hvoRoot, 1, new int[] {97, 98}, 0);
			VerifyCurrentValue(hvoRoot, publisher, new int[] {23, 97, 98, 56, 2048}, "after inserting 97, 98" );
			recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 1, 2, 0) },
				"expected PropChanged from caching HVOs");
			publisher.RemoveNotification(recorder);

			recorder = new Notifiee();
			publisher.AddNotification(recorder);
			publisher.Replace(hvoRoot, 1, new int[0] , 2);
			VerifyCurrentValue(hvoRoot, publisher, new int[] { 23, 56, 2048 }, "after deleting 97, 98");
			recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 1, 0, 2) },
				"expected PropChanged from caching HVOs");
			publisher.RemoveNotification(recorder);
		}
Exemplo n.º 6
0
 private void CreateBrowseViewer(XmlNode configNode, IWritingSystem reversalWs)
 {
     m_listPublisher = new ObjectListPublisher(m_cache.DomainDataByFlid as ISilDataAccessManaged, ListFlid);
     m_bvMatches     = new BrowseViewer(configNode, m_cache.LanguageProject.LexDbOA.Hvo, ListFlid, m_cache, m_mediator,
                                        null, m_listPublisher);
     m_bvMatches.SuspendLayout();
     m_bvMatches.Location   = new Point(0, 0);
     m_bvMatches.Anchor     = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
     m_bvMatches.Name       = "m_bvMatches";
     m_bvMatches.Sorter     = null;
     m_bvMatches.TabStop    = false;
     m_bvMatches.StyleSheet = m_stylesheet;
     m_bvMatches.Dock       = DockStyle.Fill;
     if (reversalWs != null)
     {
         m_bvMatches.BrowseView.Vc.ReversalWs = reversalWs.Handle;
     }
     m_bvMatches.SelectionChanged += m_bvMatches_SelectionChanged;
     m_bvMatches.SelectionMade    += m_bvMatches_SelectionMade;
     Controls.Add(m_bvMatches);
     m_bvMatches.ResumeLayout();
 }
Exemplo n.º 7
0
 public ObjectListPublisherMdc(IFwMetaDataCacheManaged metaDataCache, ObjectListPublisher publisher)
     : base(metaDataCache)
 {
     m_publisher = publisher;
 }
Exemplo n.º 8
0
			public ObjectListPublisherMdc(IFwMetaDataCacheManaged metaDataCache, ObjectListPublisher publisher)
				: base(metaDataCache)
			{
				m_publisher = publisher;
			}
Exemplo n.º 9
0
		private void CreateBrowseViewer(XmlNode configNode, IWritingSystem reversalWs)
		{
			m_listPublisher = new ObjectListPublisher(m_cache.DomainDataByFlid as ISilDataAccessManaged, ListFlid);
			m_bvMatches = new BrowseViewer(configNode, m_cache.LanguageProject.LexDbOA.Hvo, ListFlid, m_cache, m_mediator,
				null, m_listPublisher);
			m_bvMatches.SuspendLayout();
			m_bvMatches.Location = new Point(0, 0);
			m_bvMatches.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
			m_bvMatches.Name = "m_bvMatches";
			m_bvMatches.Sorter = null;
			m_bvMatches.TabStop = false;
			m_bvMatches.StyleSheet = m_stylesheet;
			m_bvMatches.Dock = DockStyle.Fill;
			if (reversalWs != null)
				m_bvMatches.BrowseView.Vc.ReversalWs = reversalWs.Handle;
			m_bvMatches.SelectionChanged += m_bvMatches_SelectionChanged;
			m_bvMatches.SelectionMade += m_bvMatches_SelectionMade;
			UpdateVisibleColumns();
			Controls.Add(m_bvMatches);
			m_bvMatches.ResumeLayout();
			m_bvMatches.ColumnsChanged += m_bvMatches_ColumnsChanged;
		}
Exemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a view with multiple LexEntry objects.
		/// </summary>
		/// <param name="rghvoEntries"></param>
		/// <param name="cache"></param>
		/// <param name="styleSheet"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private XmlView CreateSummaryView(List<int> rghvoEntries, FdoCache cache, IVwStylesheet styleSheet)
		{
			// Make a decorator to publish the list of entries as a fake property of the LexDb.
			int kflidEntriesFound = 8999950; // some arbitrary number not conflicting with real flids.
			var sda = new ObjectListPublisher(cache.DomainDataByFlid as ISilDataAccessManaged, kflidEntriesFound);
			int hvoRoot = RootHvo;
			sda.CacheVecProp(hvoRoot, rghvoEntries.ToArray());
			//TODO: Make this method return a GeckoBrowser control, and generate the content here.
			// The name of this property must match the property used by the publishFound layout.
			sda.SetOwningPropInfo(LexDbTags.kflidClass, "LexDb", "EntriesFound");

			// Make an XmlView which displays that object using the specified layout.
			XmlView xv = new XmlView(hvoRoot, "publishFound", null, false, sda);
			xv.Cache = cache;
			xv.Mediator = m_mediator;
			xv.StyleSheet = styleSheet;
			return xv;
		}
Exemplo n.º 11
0
		private void InitBrowseView(string guiControl, List<DummyCmObject> mergeCandidates)
		{
			XmlNode configurationParameters = (XmlNode)m_mediator.PropertyTable.GetValue("WindowConfiguration");
			XmlNode toolNode = configurationParameters.SelectSingleNode("controls/parameters/guicontrol[@id='" + guiControl + "']/parameters");

			const int kfakeFlid = 8999958;
			ObjectListPublisher sda = new ObjectListPublisher((ISilDataAccessManaged)m_cache.DomainDataByFlid , kfakeFlid);

			int[] hvos = (from obj in mergeCandidates select obj.Hvo).ToArray();
			for (int i = 0; i < mergeCandidates.Count; i++)
				m_candidates[mergeCandidates[i].Hvo] = mergeCandidates[i];
			sda.SetOwningPropInfo(WfiWordformTags.kClassId, "LangProject", "Options");
			sda.SetOwningPropValue(hvos);

			m_bvMergeOptions = new BrowseViewer(toolNode, m_cache.LangProject.Hvo, ObjectListPublisher.OwningFlid, m_cache, m_mediator, null, sda);
			m_bvMergeOptions.StyleSheet = Common.Widgets.FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
			m_bvMergeOptions.SelectedIndexChanged += m_bvMergeOptions_SelectedIndexChanged;
			m_bvMergeOptions.Dock = DockStyle.Fill;
			m_bvPanel.Controls.Add(m_bvMergeOptions);
		}
Exemplo n.º 12
0
		///<summary>
		/// Decorate an ISilDataAccessManaged object with another layer limiting objects to print.
		///</summary>
		///<param name="oldSda"></param>
		///<param name="rootHvo"></param>
		///<param name="mainFlid"></param>
		///<param name="selectedObjects"></param>
		///<returns></returns>
		public static ISilDataAccessManaged CachePrintDecorator(ISilDataAccessManaged oldSda,
			int rootHvo, int mainFlid, int[] selectedObjects)
		{
			var printDecorator = new ObjectListPublisher(oldSda, mainFlid);
			printDecorator.CacheVecProp(rootHvo, selectedObjects);
			return printDecorator;
		}
Exemplo n.º 13
0
		private RespellUndoAction SetUpParaAndRespellUndoAction_MultiMorphemic(string sParaText,
			string sWordToReplace, string sNewWord, string[] morphsToCreate, int clidPara,
			out IStTxtPara para)
		{
			List<IParaFragment> paraFrags = new List<IParaFragment>();
			IStTxtPara paraT = null;
			IStText stText = null;
			UndoableUnitOfWorkHelper.Do("Undo create book", "Redo create book", m_actionHandler, () =>
			{
				var lp = Cache.LanguageProject;
				if (clidPara == ScrTxtParaTags.kClassId)
				{
					IScrBook book = Cache.ServiceLocator.GetInstance<IScrBookFactory>().Create(1, out stText);
					paraT = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(stText, "Monkey");
					paraT.Contents = TsStringUtils.MakeTss(sParaText, Cache.DefaultVernWs);
					object owner = ReflectionHelper.CreateObject("FDO.dll", "SIL.FieldWorks.FDO.Infrastructure.Impl.CmObjectId", BindingFlags.NonPublic,
						new object[] { book.Guid });
					ReflectionHelper.SetField(stText, "m_owner", owner);
				}
				else
				{
					var proj = Cache.LangProject;
					var text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
					stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
					text.ContentsOA = stText;
					paraT = Cache.ServiceLocator.GetInstance<IStTxtParaFactory>().Create();
					stText.ParagraphsOS.Add(paraT);
					paraT.Contents = TsStringUtils.MakeTss(sParaText, Cache.DefaultVernWs);
				}
				foreach (ISegment seg in paraT.SegmentsOS)
				{
					FdoTestHelper.CreateAnalyses(seg, paraT.Contents, seg.BeginOffset, seg.EndOffset, true);
					var thisSegParaFrags = GetParaFragmentsInSegmentForWord(seg, sWordToReplace);
					SetMultimorphemicAnalyses(thisSegParaFrags, morphsToCreate);
					paraFrags.AddRange(thisSegParaFrags);
				}
			});

			var rsda = new RespellingSda((ISilDataAccessManaged)Cache.MainCacheAccessor, null, Cache.ServiceLocator);
			InterestingTextList dummyTextList = MockRepository.GenerateStub<InterestingTextList>(null, Cache.ServiceLocator.GetInstance<ITextRepository>(),
			Cache.ServiceLocator.GetInstance<IStTextRepository>());
			if (clidPara == ScrTxtParaTags.kClassId)
				dummyTextList.Stub(tl => tl.InterestingTexts).Return(new IStText[0]);
			else
				dummyTextList.Stub(t1 => t1.InterestingTexts).Return(new IStText[1] { stText });
			ReflectionHelper.SetField(rsda, "m_interestingTexts", dummyTextList);
			rsda.SetCache(Cache);
			rsda.SetOccurrences(0, paraFrags);
			ObjectListPublisher publisher = new ObjectListPublisher(rsda, kObjectListFlid);
			XMLViewsDataCache xmlCache = MockRepository.GenerateStub<XMLViewsDataCache>(publisher, true, new Dictionary<int, int>());

			xmlCache.Stub(c => c.get_IntProp(paraT.Hvo, CmObjectTags.kflidClass)).Return(ScrTxtParaTags.kClassId);
			xmlCache.Stub(c => c.VecProp(Arg<int>.Is.Anything, Arg<int>.Is.Anything)).Do(new Func<int, int, int[]>(publisher.VecProp));
			xmlCache.MetaDataCache = new RespellingMdc((IFwMetaDataCacheManaged)Cache.MetaDataCacheAccessor);
			xmlCache.Stub(c => c.get_ObjectProp(Arg<int>.Is.Anything, Arg<int>.Is.Anything)).Do(new Func<int, int, int>(publisher.get_ObjectProp));
			xmlCache.Stub(c => c.get_IntProp(Arg<int>.Is.Anything, Arg<int>.Is.Anything)).Do(new Func<int, int, int>(publisher.get_IntProp));

			var respellUndoaction = new RespellUndoAction(xmlCache, Cache, Cache.DefaultVernWs, sWordToReplace, sNewWord);
			foreach (int hvoFake in rsda.VecProp(0, ConcDecorator.kflidConcOccurrences))
				respellUndoaction.AddOccurrence(hvoFake);

			para = paraT;
			return respellUndoaction;
		}