Пример #1
0
        public void ParseObjectMatchCriteria_MatchWithoutSubItemsNoDefault()
        {
            // Set the matching criteria for this filter cell
            m_cell.Contents = TsStringUtils.MakeString("Matches ", Cache.DefaultUserWs);

            m_cell.ParseObjectMatchCriteria();

            Assert.AreEqual(ComparisonTypes.kMatches, m_cell.ComparisonType);
            Assert.AreEqual(0, m_cell.MatchValue);
            Assert.IsFalse((bool)ReflectionHelper.GetField(m_cell, "m_matchSubitems"));
            Assert.IsFalse((bool)ReflectionHelper.GetField(m_cell, "m_matchEmpty"));
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialize the filter so it can check for matches in reference collections.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void InitReferenceCriteria(ICmCell cell, int filteredFlid)
        {
            cell.ParseObjectMatchCriteria();

            if (cell is CmCell && ((CmCell)cell).MatchOnlyEmptyRefCollection)
            {
                return;
            }

            // Do we need to prompt the user for the value he wants to match?
            if (cell.MatchValue == 0 || ShowPrompt == 1)
            {
                throw new NotImplementedException("Need to implement prompting the user for filter information");
                // Prompt the user for a possibility.
                //Debug.Assert(m_possSupplier != null);
                //int hvoPossList = m_userView.GetPossibilityListForProperty(filteredFlid);
                //if (hvoPossList == 0)
                //    throw new Exception("Couldn't find appropriate Possibility List to prompt for filter criteria");

                //// The possibility supplier actually displays the Chooser dialog to prompt the user.
                //ICmPossibility pss = m_possSupplier.GetPossibility((CmPossibilityList)Services.GetObject(hvoPossList),
                //    (CmPossibility)Services.GetObject(cell.MatchValue));
                //if (pss == null)
                //    throw new Exception("User cancelled Filter");

                //cell.MatchValue = pss.Hvo;
            }
        }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialize the filter so it can check for matches in reference collections.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void InitReferenceCriteria(ICmCell cell, int filteredFlid)
        {
            cell.ParseObjectMatchCriteria();

            if (cell is CmCell && ((CmCell)cell).MatchOnlyEmptyRefCollection)
            {
                return;
            }

            // Do we need to prompt the user for the value he wants to match?
            if (cell.MatchValue == 0 || ShowPrompt == 1)
            {
                // Prompt the user for a possibility.
                Debug.Assert(m_userView != null);
                Debug.Assert(m_possSupplier != null);
                int hvoPossList = m_userView.GetPossibilityListForProperty(filteredFlid);
                if (hvoPossList == 0)
                {
                    throw new Exception("Couldn't find appropriate Possibility List to prompt for filter criteria");
                }

                // The possibility supplier actually displays the Chooser dialog to prompt the user.
                int hvoPoss = m_possSupplier.GetPossibility(
                    new CmPossibilityList(m_cache, hvoPossList), cell.MatchValue);

                if (hvoPoss == 0)
                {
                    throw new Exception("User cancelled Filter");
                }

                cell.MatchValue = hvoPoss;
            }
        }
Пример #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes the list of categories based on categories in the specified filter.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private bool InitializeFromFilter(FdoCache cache, ICmFilter filter,
                                          out List <int> initiallySelectedList)
        {
            initiallySelectedList = new List <int>();

            if (filter == null || filter.RowsOS.Count == 0 || filter.RowsOS[0].CellsOS.Count == 0)
            {
                return(false);
            }

            bool fFilterContainsCategories = false;

            // Get the pairs of class ids and flids.
            string[] pairs = filter.ColumnInfo.Split('|');
            Debug.Assert(filter.RowsOS[0].CellsOS.Count == pairs.Length);

            for (int i = 0; i < pairs.Length; i++)
            {
                ICmCell cell = filter.RowsOS[0].CellsOS[i];
                Guid    guid;

                // Get the flid for this cell.
                string[] pair = pairs[i].Split(',');
                int      flid = 0;
                int.TryParse(pair[1], out flid);

                if (flid == ScrScriptureNoteTags.kflidCategories)
                {
                    fFilterContainsCategories = true;
                    cell.ParseObjectMatchCriteria();
                    if (cell.Contents.RunCount > 1)
                    {
                        guid = TsStringUtils.GetGuidFromRun(cell.Contents, 1);
                        int hvo = cache.ServiceLocator.GetInstance <ICmObjectRepository>().GetObject(guid).Hvo;
                        initiallySelectedList.Add(hvo);
                    }
                }
            }

            return(fFilterContainsCategories);
        }
Пример #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize the filter so it can check for matches in reference collections.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitReferenceCriteria(ICmCell cell, int filteredFlid)
		{
			cell.ParseObjectMatchCriteria();

			if (cell is CmCell && ((CmCell)cell).MatchOnlyEmptyRefCollection)
				return;

			// Do we need to prompt the user for the value he wants to match?
			if (cell.MatchValue == 0 || ShowPrompt == 1)
			{
				throw new NotImplementedException("Need to implement prompting the user for filter information");
				// Prompt the user for a possibility.
				//Debug.Assert(m_possSupplier != null);
				//int hvoPossList = m_userView.GetPossibilityListForProperty(filteredFlid);
				//if (hvoPossList == 0)
				//    throw new Exception("Couldn't find appropriate Possibility List to prompt for filter criteria");

				//// The possibility supplier actually displays the Chooser dialog to prompt the user.
				//ICmPossibility pss = m_possSupplier.GetPossibility((CmPossibilityList)Services.GetObject(hvoPossList),
				//    (CmPossibility)Services.GetObject(cell.MatchValue));
				//if (pss == null)
				//    throw new Exception("User cancelled Filter");

				//cell.MatchValue = pss.Hvo;
			}
		}
Пример #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize the filter so it can check for matches in reference collections.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitReferenceCriteria(ICmCell cell, int filteredFlid)
		{
			cell.ParseObjectMatchCriteria();

			if (cell is CmCell && ((CmCell)cell).MatchOnlyEmptyRefCollection)
				return;

			// Do we need to prompt the user for the value he wants to match?
			if (cell.MatchValue == 0 || ShowPrompt == 1)
			{
				// Prompt the user for a possibility.
				Debug.Assert(m_userView != null);
				Debug.Assert(m_possSupplier != null);
				int hvoPossList = m_userView.GetPossibilityListForProperty(filteredFlid);
				if (hvoPossList == 0)
					throw new Exception("Couldn't find appropriate Possibility List to prompt for filter criteria");

				// The possibility supplier actually displays the Chooser dialog to prompt the user.
				int hvoPoss = m_possSupplier.GetPossibility(
					new CmPossibilityList(m_cache, hvoPossList), cell.MatchValue);

				if (hvoPoss == 0)
					throw new Exception("User cancelled Filter");

				cell.MatchValue = hvoPoss;
			}
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes the form's controls from the settings in the filter.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void InitializeFromFilter()
        {
            if (m_filter == null || m_filter.RowsOS.Count == 0 || m_filter.RowsOS[0].CellsOS.Count == 0)
            {
                return;
            }

            // Get the pairs of class ids and flids.
            string[] pairs = m_filter.ColumnInfo.Split('|');
            Debug.Assert(m_filter.RowsOS[0].CellsOS.Count == pairs.Length);

            for (int i = 0; i < pairs.Length; i++)
            {
                ICmCell cell = m_filter.RowsOS[0].CellsOS[i];

                // Get the flid for this cell.
                string[] pair = pairs[i].Split(',');
                int      flid = 0;
                int.TryParse(pair[1], out flid);

                switch (flid)
                {
                case ScrScriptureNoteTags.kflidResolutionStatus:
                    chkStatus.Checked = true;
                    cell.ParseIntegerMatchCriteria();
                    rbResolved.Checked   = (cell.MatchValue == 1);
                    rbUnresolved.Checked = (cell.MatchValue == 0);
                    break;

                case CmAnnotationTags.kflidAnnotationType:
                    chkType.Checked = true;
                    cell.ParseObjectMatchCriteria();
                    Guid guid = TsStringUtils.GetGuidFromRun(cell.Contents, 1);
                    rbConsultant.Checked = (guid == CmAnnotationDefnTags.kguidAnnConsultantNote);
                    rbTranslator.Checked = (guid == CmAnnotationDefnTags.kguidAnnTranslatorNote);
                    break;

                case CmBaseAnnotationTags.kflidBeginRef:
                    chkScrRange.Checked = true;
                    cell.ParseIntegerMatchCriteria();
                    ScrReference scrRef = new ScrReference(cell.MatchValue, m_scr.Versification);
                    // If the reference was adjusted to 0:0 to include notes in the title and
                    // introduction, adjust it back to 1:1 so we don't confuse the user.
                    if (scrRef.Chapter == 0)
                    {
                        scrRef.Chapter = 1;
                    }
                    if (scrRef.Verse == 0)
                    {
                        scrRef.Verse = 1;
                    }

                    if (cell.ComparisonType == ComparisonTypes.kGreaterThanEqual)
                    {
                        scrBookFrom.ScReference = scrRef;
                    }
                    else
                    {
                        scrBookTo.ScReference = scrRef;
                    }
                    break;
                }
            }
        }