コード例 #1
0
        private static string FindMatchingPossibilityListUIName(XmlNode toolNode,
                                                                ICmPossibilityListRepository possRepo, FdoCache cache)
        {
            var recordListNode = GetClerkRecordListNodeFromToolNode(toolNode);

            if (recordListNode == null)
            {
                return(null);
            }
            var ownerAttr    = XmlUtils.GetAttributeValue(recordListNode, "owner");
            var propertyAttr = XmlUtils.GetAttributeValue(recordListNode, "property");
            ICmPossibilityList possList;

            if (ownerAttr == "unowned")
            {
                // If its owner is "unowned" then the property is the list's guid
                possList = GetListByGuid(possRepo, propertyAttr);
            }
            else
            {
                // If it has an owner and property, get the right list's hvo via SDA
                possList = GetListBySda(cache, ownerAttr, propertyAttr);
            }
            return(possList == null ? null : possList.Name.UserDefaultWritingSystem.Text);
        }
コード例 #2
0
        protected override void CreateTestData()
        {
            base.CreateTestData();

            var servLoc = Cache.ServiceLocator;

            m_listRepo = servLoc.GetInstance <ICmPossibilityListRepository>();
            m_possFact = servLoc.GetInstance <ICmPossibilityFactory>();
            m_userWs   = Cache.DefaultUserWs;

            CreateCustomList();
            m_helper = new DeleteListHelper(Cache);
        }
コード例 #3
0
ファイル: LiftExporter.cs プロジェクト: bbriggs/FieldWorks
		public LiftExporter(FdoCache cache)
		{
			m_cache = cache;
			m_mdc = cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged;
			Debug.Assert(m_mdc != null);
			m_sda = m_cache.DomainDataByFlid as ISilDataAccessManaged;
			Debug.Assert(m_sda != null);
			m_repoCmPossibilityLists = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>();

			m_wsEn = cache.WritingSystemFactory.GetWsFromStr("en");
			if (m_wsEn == 0)
				m_wsEn = cache.DefaultUserWs;
			m_wsManager = cache.ServiceLocator.WritingSystemManager;
			m_wsBestAnalVern = (int)SpecialWritingSystemCodes.BestAnalysisOrVernacular;
		}
コード例 #4
0
        private static void AddToolNodeToDisplay(ICmPossibilityListRepository possRepo, FdoCache cache,
                                                 UIListDisplayProperties display, StringTable tbl, XmlNode node)
        {
            // Modified how this works, so it uses the current UI version of the PossibilityList Name,
            // if possible.
            var localizedLabel = FindMatchingPossibilityListUIName(node, possRepo, cache);

            if (localizedLabel == null)
            {
                localizedLabel = XmlUtils.GetLocalizedAttributeValue(tbl, node, "label", "???");
            }
            var value          = XmlUtils.GetAttributeValue(node, "value", "???");
            var imageName      = XmlUtils.GetAttributeValue(node, "icon");        //can be null
            var controlElement = node.SelectSingleNode("control");

            display.List.Add(localizedLabel, value, imageName, controlElement);
        }
コード例 #5
0
        private void FillInLists()
        {
            ICmPossibilityListRepository repo = m_cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>();

            foreach (var list in repo.AllInstances())
            {
                if (list.Owner != null &&
                    list.Owner != m_cache.LangProject.TranslatedScriptureOA &&
                    !m_excludedListFlids.ContainsKey(list.OwningFlid))
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = list.Name.UserDefaultWritingSystem.Text;
                    if (String.IsNullOrEmpty(lvi.Text) || lvi.Text == list.Name.NotFoundTss.Text)
                    {
                        lvi.Text = list.Name.BestAnalysisVernacularAlternative.Text;
                    }
                    lvi.Tag = list;
                    m_lvLists.Items.Add(lvi);
                }
            }
            m_lvLists.Sort();
        }
コード例 #6
0
ファイル: AreaListener.cs プロジェクト: bbriggs/FieldWorks
		private static ICmPossibilityList GetListByGuid(ICmPossibilityListRepository possRepo, string listGuid)
		{
			return possRepo.GetObject(new Guid(listGuid));
		}
コード例 #7
0
ファイル: AreaListener.cs プロジェクト: bbriggs/FieldWorks
		private static string FindMatchingPossibilityListUIName(XmlNode toolNode,
																ICmPossibilityListRepository possRepo, FdoCache cache)
		{
			var recordListNode = GetClerkRecordListNodeFromToolNode(toolNode);
			if (recordListNode == null)
				return null;
			var ownerAttr = XmlUtils.GetAttributeValue(recordListNode, "owner");
			var propertyAttr = XmlUtils.GetAttributeValue(recordListNode, "property");
			ICmPossibilityList possList;
			if (ownerAttr == "unowned")
			{
				// If its owner is "unowned" then the property is the list's guid
				possList = GetListByGuid(possRepo, propertyAttr);
			}
			else
			{
				// If it has an owner and property, get the right list's hvo via SDA
				possList = GetListBySda(cache, ownerAttr, propertyAttr);
			}
			return possList == null ? null : possList.Name.UserDefaultWritingSystem.Text;
		}
コード例 #8
0
ファイル: AreaListener.cs プロジェクト: bbriggs/FieldWorks
		private static void AddToolNodeToDisplay(ICmPossibilityListRepository possRepo, FdoCache cache,
												 UIListDisplayProperties display, StringTable tbl, XmlNode node)
		{
			// Modified how this works, so it uses the current UI version of the PossibilityList Name,
			// if possible.
			var localizedLabel = FindMatchingPossibilityListUIName(node, possRepo, cache);
			if (localizedLabel == null)
				localizedLabel = XmlUtils.GetLocalizedAttributeValue(tbl, node, "label", "???");
			var value = XmlUtils.GetAttributeValue(node, "value", "???");
			var imageName = XmlUtils.GetAttributeValue(node, "icon"); //can be null
			var controlElement = node.SelectSingleNode("control");
			display.List.Add(localizedLabel, value, imageName, controlElement);
		}
コード例 #9
0
        /// <summary>
        /// Load the list (given by owner and sFieldName) from the given TextReader.
        /// </summary>
        public void ImportList(ICmObject owner, string sFieldName, TextReader reader, IProgress progress)
        {
            m_cache    = owner.Cache;
            m_mdc      = m_cache.MetaDataCache;
            m_wsf      = m_cache.WritingSystemFactory;
            m_progress = progress;

            NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(m_cache.ActionHandlerAccessor, () =>
            {
                int flidList = m_mdc.GetFieldId(owner.ClassName, sFieldName, true);
                if (flidList == 0)
                {
                    throw new Exception(String.Format("Invalid list fieldname (programming error): {0}", sFieldName));
                }
                using (var xrdr = XmlReader.Create(reader))
                {
                    xrdr.MoveToContent();
                    if (xrdr.Name != owner.ClassName)
                    {
                        throw new Exception(String.Format("Unexpected outer element: {0}", xrdr.Name));
                    }

                    if (!xrdr.ReadToDescendant(sFieldName))
                    {
                        throw new Exception(String.Format("Unexpected second element: {0}", xrdr.Name));
                    }

                    if (!xrdr.ReadToDescendant("CmPossibilityList"))
                    {
                        throw new Exception(String.Format("Unexpected third element: {0}", xrdr.Name));
                    }

                    ICmPossibilityList list;
                    int hvo = m_cache.MainCacheAccessor.get_ObjectProp(owner.Hvo, flidList);
                    if (hvo == 0)
                    {
                        hvo = m_cache.MainCacheAccessor.MakeNewObject(CmPossibilityListTags.kClassId, owner.Hvo, flidList, -2);
                    }
                    ICmPossibilityListRepository repo = m_cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>();
                    list = repo.GetObject(hvo);
                    string sItemClassName = "CmPossibility";
                    xrdr.Read();
                    while (xrdr.Depth == 3)
                    {
                        xrdr.MoveToContent();
                        if (xrdr.Depth < 3)
                        {
                            break;
                        }
                        switch (xrdr.Name)
                        {
                        case "Description":
                            SetMultiStringFromXml(xrdr, list.Description);
                            break;

                        case "Name":
                            SetMultiUnicodeFromXml(xrdr, list.Name);
                            break;

                        case "Abbreviation":
                            SetMultiUnicodeFromXml(xrdr, list.Abbreviation);
                            break;

                        case "Depth":
                            list.Depth = ReadIntFromXml(xrdr);
                            break;

                        case "DisplayOption":
                            list.DisplayOption = ReadIntFromXml(xrdr);
                            break;

                        case "HelpFile":
                            list.HelpFile = ReadUnicodeFromXml(xrdr);
                            break;

                        case "IsClosed":
                            list.IsClosed = ReadBoolFromXml(xrdr);
                            break;

                        case "IsSorted":
                            list.IsSorted = ReadBoolFromXml(xrdr);
                            break;

                        case "IsVernacular":
                            list.IsVernacular = ReadBoolFromXml(xrdr);
                            break;

                        case "ItemClsid":
                            list.ItemClsid = ReadIntFromXml(xrdr);
                            sItemClassName = m_mdc.GetClassName(list.ItemClsid);
                            break;

                        case "ListVersion":
                            list.ListVersion = ReadGuidFromXml(xrdr);
                            break;

                        case "PreventChoiceAboveLevel":
                            list.PreventChoiceAboveLevel = ReadIntFromXml(xrdr);
                            break;

                        case "PreventDuplicates":
                            list.PreventDuplicates = ReadBoolFromXml(xrdr);
                            break;

                        case "PreventNodeChoices":
                            list.PreventNodeChoices = ReadBoolFromXml(xrdr);
                            break;

                        case "UseExtendedFields":
                            list.UseExtendedFields = ReadBoolFromXml(xrdr);
                            break;

                        case "WsSelector":
                            list.WsSelector = ReadIntFromXml(xrdr);
                            break;

                        case "Possibilities":
                            LoadPossibilitiesFromXml(xrdr, list, sItemClassName);
                            break;

                        case "HeaderFooterSets":
                            throw new Exception("We don't (yet?) handle HeaderFooterSets for CmPossibilityList (programming issue)");

                        case "Publications":
                            throw new Exception("We don't (yet?) handle Publications for CmPossibilityList (programming issue)");

                        default:
                            throw new Exception(String.Format("Unknown field element in CmPossibilityList: {0}", xrdr.Name));
                        }
                    }
                    xrdr.Close();
                    if (m_mapRelatedDomains.Count > 0)
                    {
                        SetRelatedDomainsLinks();
                    }
                }
            });
        }
コード例 #10
0
 private static ICmPossibilityList GetListByGuid(ICmPossibilityListRepository possRepo, string listGuid)
 {
     return(possRepo.GetObject(new Guid(listGuid)));
 }
コード例 #11
0
        private bool FillListAreaList(UIListDisplayProperties display)
        {
            var customLists    = GetListOfOwnerlessLists();
            var fcustomChanged = customLists.Count != m_ccustomLists;

            // Since we're in the 'Lists' area, don't bother refreshing this
            // list, unless the number of Custom lists has changed. This happens
            // whenever someone adds one.
            if (display.List.Count > 0 && !fcustomChanged)
            {
                return(true);
            }

            // We can get here in the following cases:
            // Case 1: display.List is empty and m_ctotalLists == 0
            //       Load 'windowConfiguration' with all Custom lists,
            //       Update both list counts,
            //       Load 'display' with ALL lists.
            // Case 2: display.List is empty, but m_ctotalLists > 0
            //       We MAY have a recent Custom list addition to add.
            //       If 'fcustomChanged', load the new Custom list into 'windowConfiguration',
            //          and update both list counts,
            //       Load 'display' with ALL lists.
            // Case 3: display.List is loaded, but we have a recent Custom list addition to add.
            //       Load the new Custom list into 'windowConfiguration',
            //       Update both list counts,
            //       Only update 'display' with new Custom list.
            // N.B. This may need changing if we allow the user to DELETE Custom lists someday.
            var windowConfiguration = (XmlNode)m_mediator.PropertyTable.GetValue("WindowConfiguration");

            UpdateWinConfig(fcustomChanged, customLists, windowConfiguration);

            // Now update 'display'
            StringTable tbl   = null;
            FdoCache    cache = null;
            ICmPossibilityListRepository possRepo = null;

            if (m_mediator != null && m_mediator.HasStringTable)
            {
                tbl = m_mediator.StringTbl;
            }
            if (m_mediator != null)
            {
                cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            }
            if (cache != null)
            {
                possRepo = cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>();
            }
            if (display.List.Count > 0)
            {
                var node = windowConfiguration.SelectSingleNode(GetListToolsXPath()).LastChild;
                if (node != null)
                {
                    AddToolNodeToDisplay(possRepo, cache, display, tbl, node);
                }
            }
            else
            {
                var nodes = windowConfiguration.SelectNodes(GetToolXPath("lists"));
                if (nodes != null)
                {
                    foreach (XmlNode node in nodes)
                    {
                        if ((!FwUtils.IsTEInstalled) && XmlUtils.GetOptionalBooleanAttributeValue(node, "bteOnly", false))
                        {
                            continue;
                        }
                        AddToolNodeToDisplay(possRepo, cache, display, tbl, node);
                    }
                }
            }
            return(true);
        }
コード例 #12
0
		/// <summary>
		/// Store the data for a field that contains one or more references to a possibility
		/// list.
		/// </summary>
		private void SetListReference(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			ReconvertEncodedDataIfNeeded(field, rsf.m_tlo.m_wsId);
			string sData = field.Data;
			if (sData == null)
				sData = String.Empty;
			sData = ApplyChanges(rsf, sData);
			sData = sData.Trim();
			List<string> rgsData = null;
			if (sData.Length > 0)
			{
				if (rsf.m_tlo.m_fHaveMulti)
				{
					rgsData = SplitString(sData, rsf.m_tlo.m_rgsDelimMulti);
					rgsData = PruneEmptyStrings(rgsData);
				}
				else
				{
					rgsData = new List<string> {sData};
				}
			}
			if ((rgsData == null || rgsData.Count == 0) && rsf.m_tlo.m_default == null)
			{
				return;
			}
			if (rgsData == null)
				rgsData = new List<string>();
			rgsData = ApplyBeforeAndBetween(rsf, rgsData);
			if (rgsData.Count == 0)
				rgsData.Add(String.Empty);
			foreach (var sItem in rgsData)
			{
				switch (rsf.m_flid)
				{
					case RnGenericRecTags.kflidAnthroCodes:
						if (!StoreAnthroCode(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidConfidence:
						if (!StoreConfidence(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidLocations:
						if (!StoreLocation(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidPhraseTags:
						if (!StorePhraseTag(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidResearchers:
						if (!StoreResearcher(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidRestrictions:
						if (!StoreRestriction(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidSources:
						if (!StoreSource(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidStatus:
						if (!StoreStatus(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidTimeOfEvent:
						if (!StoreTimeOfEvent(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidType:
						if (!StoreRecType(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidParticipants:
						if (!StoreParticipant(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					default:
						// must be a custom field.
						Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
						Guid guidList = m_mdc.GetFieldListRoot(rsf.m_flid);
						if (guidList != Guid.Empty)
						{
							if (m_repoList == null)
								m_repoList = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>();
							ICmPossibilityList list = m_repoList.GetObject(guidList);
							if (list != null)
							{
								if (!StoreCustomListRefItem(rec, rsf, sItem, list))
									LogCannotFindListItem(sItem, field);
								break;
							}
						}
						LogMessage(
							String.Format(LexTextControls.ksCannotFindPossibilityList, field.Marker),
							field.LineNumber);
						return;
				}
			}
		}
コード例 #13
0
        protected override void CreateTestData()
        {
            base.CreateTestData();

            var servLoc = Cache.ServiceLocator;
            m_listRepo = servLoc.GetInstance<ICmPossibilityListRepository>();
            m_possFact = servLoc.GetInstance<ICmPossibilityFactory>();
            m_tsFact = Cache.TsStrFactory;
            m_userWs = Cache.DefaultUserWs;

            CreateCustomList();
            m_helper = new DeleteListHelper(Cache);
        }