Ejemplo n.º 1
0
        public bool OnPromoteReversalSubPOS(object cmd)
        {
            Slice slice = m_dataEntryForm.CurrentSlice;

            Debug.Assert(slice != null, "No slice was current");
            if (slice != null)
            {
                FdoCache       cache       = m_dataEntryForm.Cache;
                ICmPossibility sliceObj    = slice.Object as ICmPossibility;
                int            hvoNewOwner = cache.GetOwnerOfObject(sliceObj.OwnerHVO);
                switch (cache.GetClassOfObject(hvoNewOwner))
                {
                default:
                    throw new ArgumentException("Illegal class.");

                case PartOfSpeech.kclsidPartOfSpeech:
                {
                    IPartOfSpeech pos = PartOfSpeech.CreateFromDBObject(cache, hvoNewOwner);
                    pos.SubPossibilitiesOS.Append(sliceObj);
                    break;
                }

                case CmPossibilityList.kclsidCmPossibilityList:
                {
                    ICmPossibilityList posList = CmPossibilityList.CreateFromDBObject(cache, hvoNewOwner);
                    posList.PossibilitiesOS.Append(sliceObj);
                    break;
                }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
            internal FindPossibilityComboFiller(ICmPossibilityList list)
                : base()
            {
                Debug.Assert(list != null);

                m_possibilityList = list;
            }
Ejemplo n.º 3
0
        protected override FdoObjectSet <ICmObject> GetObjectSet()
        {
            ICmPossibilityList list = m_owningObject as ICmPossibilityList;

            int[] items = list.PossibilitiesOS.HvoArray;
            return(new FdoObjectSet <ICmObject>(m_cache, items, true));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Will find a grammatical category (if one exists) with the given (analysis ws) name.
        /// If not found, will create a grammatical category either as a possibility of a list,
        /// or as a subpossibility of a category.
        /// </summary>
        /// <param name="catName"></param>
        /// <param name="owningList"></param>
        /// <param name="owningCategory"></param>
        /// <returns></returns>
        protected IPartOfSpeech GetGrammaticalCategoryOrCreateOne(string catName, ICmPossibilityList owningList,
                                                                  IPartOfSpeech owningCategory)
        {
            Assert.True(m_posFact != null, "Fixture Initialization is not complete.");
            Assert.True(m_window != null, "No window.");
            var category = m_posRepo.AllInstances().Where(
                someposs => someposs.Name.AnalysisDefaultWritingSystem.Text == catName).FirstOrDefault();

            if (category != null)
            {
                return(category);
            }
            var ws = Cache.DefaultAnalWs;

            if (owningList == null)
            {
                if (owningCategory == null)
                {
                    throw new ArgumentException(
                              "Grammatical category not found and insufficient information given to create one.");
                }
                category = m_posFact.Create(new Guid(), owningCategory);
            }
            else
            {
                category = m_posFact.Create(new Guid(), owningList);
            }
            category.Name.set_String(ws, catName);
            return(category);
        }
Ejemplo n.º 5
0
        private static XmlNode CreateCustomClerkNode(ICmPossibilityList curList)
        {
            var    clerk       = GetCustomListClerkName(curList);
            var    hierarchy   = curList.Depth > 1 ? "true" : "false";
            var    includeAbbr = curList.DisplayOption == (int)PossNameType.kpntName ? false : true;
            string ws          = curList.GetWsString();
            var    xmlString   =
                "<clerk id=\"" + XmlUtils.MakeSafeXmlAttribute(clerk) + "\">"
                + "<recordList owner=\"unowned\" property=\"" + curList.Guid + "\">"
                + "<dynamicloaderinfo assemblyPath=\"xWorks.dll\" class=\"SIL.FieldWorks.XWorks.PossibilityRecordList\"/>"
                + "</recordList>";

            xmlString +=
                "<treeBarHandler assemblyPath=\"xWorks.dll\" expand=\"false\" hierarchical=\"" + hierarchy
                + "\" includeAbbr=\"" + includeAbbr + "\" ws=\"" + ws + "\" "
                + "class=\"SIL.FieldWorks.XWorks.PossibilityTreeBarHandler\"/>"
                + "<filters/>";
            if (curList.IsSorted)
            {
                xmlString +=
                    "<sortMethods>"
                    + "<sortMethod label=\"Default\" assemblyPath=\"Filters.dll\""
                    + " class=\"SIL.FieldWorks.Filters.PropertyRecordSorter\" sortProperty=\"ShortName\"/>"
                    + "</sortMethods>";
            }
            else
            {
                xmlString += "<sortMethods/>";
            }
            xmlString += "</clerk>";
            var doc = new XmlDocument();

            doc.LoadXml(xmlString);
            return(doc.DocumentElement);
        }
Ejemplo n.º 6
0
 private void Init(LcmCache cache, Mediator mediator, XCore.PropertyTable propertyTable, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
 {
     m_mediator      = mediator;
     m_propertyTable = propertyTable;
     if (parent == null)
     {
         if (m_propertyTable != null)
         {
             IApp app = m_propertyTable.GetValue <IApp>("App");
             if (app != null)
             {
                 parent = app.ActiveMainWindow;
             }
             if (parent == null)
             {
                 parent = m_propertyTable.GetValue <Form>("window");
             }
         }
         if (parent == null)
         {
             parent = Form.ActiveForm;                     // desperate for something...
         }
     }
     m_cache   = cache;
     m_useAbbr = useAbbr;
     m_parent  = parent;
     m_list    = list;
     m_ws      = ws;
 }
Ejemplo n.º 7
0
        protected override ClassAndPropInfo GetMatchingClass(string className)
        {
            if (className != "PartOfSpeech")
            {
                return(null);
            }

            // A possibility list only allows one type of possibility to be owned in the list.
            ICmPossibilityList pssl = (ICmPossibilityList)m_owningObject;
            int    possClass        = pssl.ItemClsid;
            string sPossClass       = m_cache.DomainDataByFlid.MetaDataCache.GetClassName((int)possClass);

            if (sPossClass != className)
            {
                return(null);
            }
            foreach (ClassAndPropInfo cpi in m_insertableClasses)
            {
                if (cpi.signatureClassName == className)
                {
                    return(cpi);
                }
            }
            return(null);
        }
        public void AtomicOwningPropertyAccessorTest_SetAndChange()
        {
            // GJM -- 22 June 2010:
            // In order to implement FWR-133 Allow Custom Lists, ICmPossibilityListFactory needs
            // to be able to create unowned lists. Hence the 2 lines commented out below.
            ICmPossibilityListFactory possListFactory = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>();
            ICmPossibilityList        possList1       = possListFactory.Create();

            //Assert.AreEqual((int)SpecialHVOValues.kHvoUninitializedObject, possList1.Hvo);

            Cache.LanguageProject.LocationsOA = possList1;
            Assert.AreEqual(possList1, Cache.LanguageProject.LocationsOA);
            Assert.AreNotEqual((int)SpecialHVOValues.kHvoObjectDeleted, possList1.Hvo);
            Assert.AreNotEqual((int)SpecialHVOValues.kHvoUninitializedObject, possList1.Hvo);
            Assert.AreEqual(Cache.LanguageProject, possList1.Owner);
            Assert.AreEqual(LangProjectTags.kflidLocations, possList1.OwningFlid);

            ICmPossibilityList possList2 = possListFactory.Create();

            //Assert.AreEqual((int)SpecialHVOValues.kHvoUninitializedObject, possList2.Hvo);
            Cache.LanguageProject.LocationsOA = possList2;
            Assert.AreEqual(possList2, Cache.LanguageProject.LocationsOA);
            Assert.AreNotEqual((int)SpecialHVOValues.kHvoObjectDeleted, possList2.Hvo);
            Assert.AreNotEqual((int)SpecialHVOValues.kHvoUninitializedObject, possList2.Hvo);
            Assert.AreEqual((int)SpecialHVOValues.kHvoObjectDeleted, possList1.Hvo);

            Cache.LanguageProject.LocationsOA = null;
            Assert.IsNull(Cache.LanguageProject.LocationsOA);
            Assert.AreEqual((int)SpecialHVOValues.kHvoObjectDeleted, possList2.Hvo);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                foreach (TreeNode tn in m_nodes)
                {
                    MasterCategory mc = tn.Tag as MasterCategory;
                    tn.Tag = null;
                    mc.Dispose();
                }
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_nodes != null)
                {
                    m_nodes.Clear();
                }
            }
            m_posList  = null;
            m_mediator = null;
            m_cache    = null;
            m_selPOS   = null;
            m_nodes    = null;

            base.Dispose(disposing);
        }
Ejemplo n.º 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shows the Chooser dialog to allow the user to select a single possibility.
        /// </summary>
        /// <remarks>Used for filtering</remarks>
        /// <param name="list">The possibility list used to populate the tree</param>
        /// <param name="initialSelected">The possibility to check initially, or null to
        /// show with no initial selection</param>
        /// <returns>A single chosen CmPossibility, or null if user cancels or chooses
        /// nothing.</returns>
        /// ------------------------------------------------------------------------------------
        public ICmPossibility GetPossibility(ICmPossibilityList list, ICmPossibility initialSelected)
        {
            //CheckDisposed();

            //m_initiallySelectedHvos = new List<int>(1);
            //m_initiallySelectedHvos.Add(hvoPoss);

            //if (list != (CmPossibilityList)m_list)
            //{
            //    m_list = list;
            //    SetTitle();
            //}

            //tvPossibilities.Load(m_list, m_initiallySelectedHvos);
            //if (ShowDialog() != DialogResult.OK)
            //    return 0;

            //List<int> newHvos = tvPossibilities.SelectedHvos;
            //return (newHvos != null && newHvos.Count > 0 ? newHvos[0] : 0);

            // REVIEW: Currently, the chooser tree doesn't allow the user to select
            // only one possibility. If this method and single node selection is ever
            // necessary, then this method will need to be rewritten.
            return(null);
        }
Ejemplo n.º 11
0
		private void MakeAnnDefn(ICmPossibilityList defns, string guid)
		{
			CmAnnotationDefn defn = new CmAnnotationDefn();
			defns.PossibilitiesOS.Append(defn);
			Cache.VwCacheDaAccessor.CacheGuidProp(defn.Hvo, (int)CmObjectFields.kflidCmObject_Guid,
				new Guid(guid));
		}
Ejemplo n.º 12
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + ". ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                if (m_nodes != null)
                {
                    m_nodes.Clear();
                }
            }
            m_posList  = null;
            m_mediator = null;
            m_cache    = null;
            m_selPOS   = null;
            m_nodes    = null;

            base.Dispose(disposing);
        }
Ejemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="output"></param>
        /// <param name="labelName"></param>
        /// <param name="fieldName"></param>
        /// <param name="customFieldId"></param>
        /// <param name="className"></param>
        protected void ReplaceParamsInAttributes(XmlNode output, string labelName, string fieldName, int customFieldId, string className)
        {
            SetupWsParams(output, customFieldId);
            ReplaceSubstringInAttr visitorFn = new ReplaceSubstringInAttr("$fieldName", fieldName);

            XmlUtils.VisitAttributes(output, visitorFn);
            AppendClassAttribute(output, fieldName, className);
            ReplaceSubstringInAttr visitorLab = new ReplaceSubstringInAttr("$label", labelName);

            XmlUtils.VisitAttributes(output, visitorLab);
            if (customFieldId != 0 && m_mdc is IFwMetaDataCacheManaged)
            {
                IFwMetaDataCacheManaged mdc = m_mdc as IFwMetaDataCacheManaged;
                if (mdc.IsCustom(customFieldId) && mdc.GetDstClsId(customFieldId) != 0)
                {
                    Guid guidList = (m_mdc as IFwMetaDataCacheManaged).GetFieldListRoot(customFieldId);
                    if (guidList != Guid.Empty)
                    {
                        string             targetList;
                        ICmPossibilityList list = m_cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>().GetObject(guidList);
                        if (list.Owner != null)
                        {
                            targetList = String.Format("{0}.{1}", list.Owner.ClassName, mdc.GetFieldName(list.OwningFlid));
                        }
                        else
                        {
                            targetList = String.Format("unowned.{0}", guidList.ToString());
                        }
                        ReplaceSubstringInAttr visitorTarg = new ReplaceSubstringInAttr("$targetList", targetList);
                        XmlUtils.VisitAttributes(output, visitorTarg);
                    }
                }
            }
        }
Ejemplo n.º 14
0
		public PossibilityAutoComplete(FdoCache cache, Mediator mediator, ICmPossibilityList list, Control control,
			string displayNameProperty, string displayWs)
		{
			m_cache = cache;
			m_mediator = mediator;
			m_control = control;
			m_displayNameProperty = displayNameProperty;
			m_displayWs = displayWs;

			m_listBox = new ComboListBox {DropDownStyle = ComboBoxStyle.DropDownList, ActivateOnShow = false};
			m_listBox.SelectedIndexChanged += HandleSelectedIndexChanged;
			m_listBox.SameItemSelected += HandleSameItemSelected;
			m_listBox.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			m_listBox.WritingSystemFactory = cache.WritingSystemFactory;
			m_searcher = new StringSearcher<ICmPossibility>(SearchType.Prefix, cache.ServiceLocator.WritingSystemManager);
			m_possibilities = new List<ICmPossibility>();
			var stack = new Stack<ICmPossibility>(list.PossibilitiesOS);
			while (stack.Count > 0)
			{
				ICmPossibility poss = stack.Pop();
				m_possibilities.Add(poss);
				foreach (ICmPossibility child in poss.SubPossibilitiesOS)
					stack.Push(child);
			}

			m_control.KeyDown += HandleKeyDown;
			m_control.KeyPress += HandleKeyPress;
		}
Ejemplo n.º 15
0
        public void AddToDatabase(LcmCache cache, ICmPossibilityList posList, MasterCategory parent, IPartOfSpeech subItemOwner)
        {
            // It's already in the database, so nothing more can be done.
            if (InDatabase)
            {
                return;
            }

            UndoableUnitOfWorkHelper.Do(LexTextControls.ksUndoCreateCategory, LexTextControls.ksRedoCreateCategory,
                                        cache.ServiceLocator.GetInstance <IActionHandler>(), () =>
            {
                DeterminePOSLocationInfo(cache, subItemOwner, parent, posList, out _, out _);
                Debug.Assert(POS != null);
                if (m_node == null)
                {
                    // should not happen, but just in case... we still get something useful
                    var wsf      = cache.WritingSystemFactory;
                    var termWs   = wsf.GetWsFromStr(m_termWs);
                    var abbrevWs = wsf.GetWsFromStr(m_abbrevWs);
                    var defWs    = wsf.GetWsFromStr(m_defWs);
                    POS.Name.set_String(termWs, TsStringUtils.MakeString(m_term, termWs));
                    POS.Abbreviation.set_String(abbrevWs, TsStringUtils.MakeString(m_abbrev, abbrevWs));
                    POS.Description.set_String(defWs, TsStringUtils.MakeString(m_def, defWs));
                }
                else
                {
                    UpdatePOSStrings(cache, m_node, POS);
                }

                POS.CatalogSourceId = m_id;
            });
        }
Ejemplo n.º 16
0
        /// ----------------------------------------------------------------------------------------
        /// <summary>
        /// Main entry point for deleting Custom Lists.
        /// Needs to:
        /// 1 - Make sure the given list really is a Custom List
        /// 2 - Let the user know if any of the possibilities of this list are being referenced.
        /// 3 - Delete the list (and its possibilities and subpossibilities) and, consequently,
        ///     any references to those possibilities.
        /// </summary>
        /// ----------------------------------------------------------------------------------------
        public void Run(ICmPossibilityList curList)
        {
            m_listToDelete = curList;

            // Make sure list is a CUSTOM list!
            var owner = m_listToDelete.Owner;             // Custom lists are unowned!

            if (owner != null)
            {
                return;                 // Not a Custom list!
            }
            // Make sure user knows if any possibilities owned by this list are referenced
            // by anything else!
            GetCustomFieldsReferencingList(m_listToDelete.Guid);
            ICmPossibility poss;

            if (HasPossibilityReferences(out poss) > 0)
            {
                var name = poss.Name.BestAnalysisVernacularAlternative.Text;
                // Warn user that possibilities in this list are in use.
                if (CheckWithUser(name) != DialogResult.Yes)
                {
                    return;
                }
            }
            DeleteList(m_listToDelete);
        }
Ejemplo n.º 17
0
 private void DeleteList(ICmPossibilityList listToDelete)
 {
     // Delete any custom fields that reference this list
     DeleteCustomFieldsReferencingList();
     // Delete the Custom list
     m_ddbf.DeleteObj(listToDelete.Hvo);
 }
Ejemplo n.º 18
0
        private void DeterminePOSLocationInfo(LcmCache cache, IPartOfSpeech subItemOwner,
                                              MasterCategory parent, ICmPossibilityList posList,
                                              out int newOwningFlid, out int insertLocation)
        {
            // The XML node is from a file shipped with FieldWorks. It is quite likely multiple users
            // of a project could independently add the same items, so we create them with fixed guids
            // so merge will recognize them as the same objects.
            //// LT-14511 However, if the partOfSpeech is being added to a reversal index, a different guid needs to be used
            //// than the ones in the file shipped with FieldWorks. In this case if two users add the same POS to the
            //// reversal index at the same time and then do a Send/Receive operation, then a merge conflict report
            //// will probably be created for this. This scenario is not likely to occur very often at all so having
            //// a conflict report created for when this happens is something we can live with.
            var guid = posList.Owner is IReversalIndex?Guid.NewGuid() : new Guid(XmlUtils.GetAttributeValue(m_node, "guid"));

            var posFactory = cache.ServiceLocator.GetInstance <IPartOfSpeechFactory>();

            if (subItemOwner != null)
            {
                newOwningFlid  = CmPossibilityTags.kflidSubPossibilities;
                insertLocation = subItemOwner.SubPossibilitiesOS.Count;
                POS            = posFactory.Create(guid, subItemOwner);
            }
            else if (parent?.POS != null)
            {
                newOwningFlid  = CmPossibilityTags.kflidSubPossibilities;
                insertLocation = parent.POS.SubPossibilitiesOS.Count;
                POS            = posFactory.Create(guid, parent.POS);
            }
            else
            {
                newOwningFlid  = CmPossibilityListTags.kflidPossibilities;
                insertLocation = posList.PossibilitiesOS.Count;
                POS            = posFactory.Create(guid, posList);     // automatically adds to parent.
            }
        }
Ejemplo n.º 19
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public MSAPopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list,
			int ws, bool useAbbr, Mediator mediator, Form parent)
			: base(popupTree,  cache, list, ws, useAbbr, parent)
		{
			m_mediator = mediator;
			LoadStrings();
		}
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="posList"></param>
        /// <param name="mediator"></param>
        /// <param name="launchedFromInsertMenu"></param>
        /// <param name="subItemOwner"></param>
        public void SetDlginfo(ICmPossibilityList posList, Mediator mediator, bool launchedFromInsertMenu, IPartOfSpeech subItemOwner)
        {
            CheckDisposed();

            m_subItemOwner           = subItemOwner;   // May be null, which is fine.
            m_posList                = posList;
            m_launchedFromInsertMenu = launchedFromInsertMenu;
            m_mediator               = mediator;
            if (mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue("masterCatListDlgLocation");
                object szWnd  = m_mediator.PropertyTable.GetValue("masterCatListDlgSize");
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }
            Debug.Assert(posList != null);
            m_cache = posList.Cache;
            LoadMasterCategories(posList.ReallyReallyAllPossibilities);
        }
Ejemplo n.º 21
0
        public void FindNextMatch_RequireNormalization()
        {
            IWritingSystem ws;

            Cache.ServiceLocator.WritingSystemManager.GetOrSet("grc", out ws);

            int wsGreek = ws.Handle;

            TreeNode catNode = new TreeNode("Proper Names");

            m_treeView.Nodes.Add(catNode);
            TreeNode           chkTermNode = new TreeNode("Abraham");
            ICmPossibilityList list        = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create();

            Cache.LanguageProject.CheckListsOC.Add(list);
            IChkTerm term = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create();

            list.PossibilitiesOS.Add(term);
            ITsString    tssName    = Cache.TsStrFactory.MakeString("Abraham".Normalize(NormalizationForm.FormD), Cache.DefaultUserWs);
            const string abrahamGrk = "\u1F08\u03B2\u03C1\u03B1\u1F71\u03BC";
            ITsString    tssDesc    = Cache.TsStrFactory.MakeString(abrahamGrk.Normalize(NormalizationForm.FormD), wsGreek);
            ITsString    tssSeeAlso = Cache.TsStrFactory.MakeString("", Cache.DefaultUserWs);

            term.Name.set_String(Cache.DefaultUserWs, tssName);
            term.Description.set_String(wsGreek, tssDesc);
            term.SeeAlso.set_String(Cache.DefaultUserWs, tssName);
            chkTermNode.Tag = term;
            catNode.Nodes.Add(chkTermNode);
            m_treeView.SelectedNode = catNode;
            Assert.AreEqual(KeyTermsTree.FindResult.MatchFound, m_treeView.CallFindNextMatch(abrahamGrk.Normalize(NormalizationForm.FormC)));
            Assert.AreEqual("Abraham", m_treeView.SelectedNode.Text);
        }
        public PossibilityAutoComplete(FdoCache cache, Mediator mediator, ICmPossibilityList list, Control control,
                                       string displayNameProperty, string displayWs)
        {
            m_cache               = cache;
            m_mediator            = mediator;
            m_control             = control;
            m_displayNameProperty = displayNameProperty;
            m_displayWs           = displayWs;

            m_listBox = new ComboListBox {
                DropDownStyle = ComboBoxStyle.DropDownList, ActivateOnShow = false
            };
            m_listBox.SelectedIndexChanged += HandleSelectedIndexChanged;
            m_listBox.SameItemSelected     += HandleSameItemSelected;
            m_listBox.StyleSheet            = FontHeightAdjuster.StyleSheetFromMediator(mediator);
            m_listBox.WritingSystemFactory  = cache.WritingSystemFactory;
            m_searcher      = new StringSearcher <ICmPossibility>(SearchType.Prefix, cache.ServiceLocator.WritingSystemManager);
            m_possibilities = new List <ICmPossibility>();
            var stack = new Stack <ICmPossibility>(list.PossibilitiesOS);

            while (stack.Count > 0)
            {
                ICmPossibility poss = stack.Pop();
                m_possibilities.Add(poss);
                foreach (ICmPossibility child in poss.SubPossibilitiesOS)
                {
                    stack.Push(child);
                }
            }

            m_control.KeyDown  += HandleKeyDown;
            m_control.KeyPress += HandleKeyPress;
        }
        public void ReferencesToDeletedWordformsShouldSwitch()
        {
            var wf1  = MakeWordform("wordXX");
            var wf2  = MakeWordform("wordXX");
            var wf3  = MakeWordform("wordXX");
            var text = Cache.ServiceLocator.GetInstance <ITextFactory>().Create();
            //Cache.LangProject.TextsOC.Add(text);
            var stText = Cache.ServiceLocator.GetInstance <IStTextFactory>().Create();

            text.ContentsOA = stText;
            var para = Cache.ServiceLocator.GetInstance <IStTxtParaFactory>().Create();

            stText.ParagraphsOS.Add(para);
            var seg = Cache.ServiceLocator.GetInstance <ISegmentFactory>().Create();

            para.SegmentsOS.Add(seg);
            seg.AnalysesRS.Add(wf1);
            seg.AnalysesRS.Add(wf2);
            seg.AnalysesRS.Add(wf3);
            seg.AnalysesRS.Add(wf2);
            seg.AnalysesRS.Add(wf3);

            var wordset = Cache.ServiceLocator.GetInstance <IWfiWordSetFactory>().Create();

            Cache.LangProject.MorphologicalDataOA.TestSetsOC.Add(wordset);
            wordset.CasesRC.Add(wf2);

            ICmPossibilityList list = Cache.LangProject.KeyTermsList;
            var term = Cache.ServiceLocator.GetInstance <IChkTermFactory>().Create();

            list.PossibilitiesOS.Add(term);
            var rendering = Cache.ServiceLocator.GetInstance <IChkRenderingFactory>().Create();

            term.RenderingsOC.Add(rendering);
            rendering.SurfaceFormRA = wf2;
            var chkRef = Cache.ServiceLocator.GetInstance <IChkRefFactory>().Create();

            term.OccurrencesOS.Add(chkRef);
            chkRef.RenderingRA = wf2;

            WfiWordformServices.FixDuplicates(Cache, m_progress);
            // One but only one should survive.
            var wf = Survivor(wf1, wf2, wf3);

            Assert.That(seg.AnalysesRS.Count, Is.EqualTo(5));
            Assert.That(seg.AnalysesRS[0], Is.EqualTo(wf));
            Assert.That(seg.AnalysesRS[1], Is.EqualTo(wf));
            Assert.That(seg.AnalysesRS[2], Is.EqualTo(wf));
            Assert.That(seg.AnalysesRS[3], Is.EqualTo(wf));
            Assert.That(seg.AnalysesRS[4], Is.EqualTo(wf));

            // for several tests to prove anything, the wordform that survives must NOT be the
            // one that was there already.
            Assert.That(wf, Is.Not.EqualTo(wf2));

            Assert.That(wordset.CasesRC, Has.Member(wf));
            Assert.That(rendering.SurfaceFormRA, Is.EqualTo(wf));
            Assert.That(chkRef.RenderingRA, Is.EqualTo(wf));
        }
Ejemplo n.º 24
0
        private ICmCustomItem CreateCustomItemAddToList(ICmPossibilityList owningList, string itemName)
        {
            var item = Cache.ServiceLocator.GetInstance <ICmCustomItemFactory>().Create();

            owningList.PossibilitiesOS.Add(item);
            item.Name.set_String(m_userWs, m_tsFact.MakeString(itemName, m_userWs));
            return(item);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Add a CmPossibilityList to the collection.
        /// </summary>
        /// <param name="pl">The CmPossibilityList to add.</param>
        public ICmPossibilityList Add(ICmPossibilityList pl)
        {
            Debug.Assert(pl != null);
            ICmPossibilityList plAdd = (ICmPossibilityList)ValidateObject(pl);

            List.Add(plAdd);
            return(plAdd);
        }
Ejemplo n.º 26
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ConfigureListDlg"/> class.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ConfigureListDlg(Mediator mediator, ICmPossibilityList possList) :
     base(mediator)
 {
     m_curList      = possList;
     m_fchangesMade = false;
     Text           = xWorksStrings.ksConfigureList;
     s_helpTopic    = "khtpConfigureList";
 }
Ejemplo n.º 27
0
        public override void TestSetup()
        {
            base.TestSetup();
            ICmPossibilityList dummyList = MockRepository.GenerateMock <ICmPossibilityList>();

            dummyList.Stub(l => l.Cache).Return(Cache);
            m_treeView = new DummyKeyTermsTree(dummyList);
        }
Ejemplo n.º 28
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public PopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
		{
			m_popupTree = popupTree;
			Init(cache, list, ws, useAbbr, parent);
			popupTree.BeforeSelect += new TreeViewCancelEventHandler(m_treeCombo_BeforeSelect);
			popupTree.AfterSelect += new TreeViewEventHandler(m_treeCombo_AfterSelect);
			popupTree.PopupTreeClosed += new TreeViewEventHandler(popupTree_PopupTreeClosed);
		}
Ejemplo n.º 29
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public PopupTreeManager(PopupTree popupTree, FdoCache cache, Mediator mediator, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
		{
			m_popupTree = popupTree;
			Init(cache, mediator, list, ws, useAbbr, parent);
			popupTree.BeforeSelect += m_treeCombo_BeforeSelect;
			popupTree.AfterSelect += m_treeCombo_AfterSelect;
			popupTree.PopupTreeClosed += popupTree_PopupTreeClosed;
		}
Ejemplo n.º 30
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public PopupTreeManager(PopupTree popupTree, FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
 {
     m_popupTree = popupTree;
     Init(cache, list, ws, useAbbr, parent);
     popupTree.BeforeSelect    += new TreeViewCancelEventHandler(m_treeCombo_BeforeSelect);
     popupTree.AfterSelect     += new TreeViewEventHandler(m_treeCombo_AfterSelect);
     popupTree.PopupTreeClosed += new TreeViewEventHandler(popupTree_PopupTreeClosed);
 }
Ejemplo n.º 31
0
 private void MakeListXml(ICmPossibilityList list, XmlElement root)
 {
     foreach (XmlNode item in root)
     {
         ICmPossibility poss = list.PossibilitiesOS.Append(new CmPossibility());
         InitItem(item, poss);
     }
 }
Ejemplo n.º 32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Call the base class method
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void CallLoadKeyTerms(ICmPossibilityList oldKeyTermsList,
			ICmPossibilityList newKeyTermsList, BiblicalTermsList terms,
			List<BiblicalTermsLocalization> localizations)
		{
			IScripture scr = newKeyTermsList.Cache.LangProject.TranslatedScriptureOA;
			new DummyTeKeyTermsInit(scr).LoadKeyTerms(null, oldKeyTermsList, newKeyTermsList,
				terms, localizations);
		}
Ejemplo n.º 33
0
        private void MakeAnnDefn(ICmPossibilityList defns, string guid)
        {
            CmAnnotationDefn defn = new CmAnnotationDefn();

            defns.PossibilitiesOS.Append(defn);
            Cache.VwCacheDaAccessor.CacheGuidProp(defn.Hvo, (int)CmObjectFields.kflidCmObject_Guid,
                                                  new Guid(guid));
        }
Ejemplo n.º 34
0
        private ICmPossibility MakePossibility(ICmPossibilityList list, string name)
        {
            var result = Cache.ServiceLocator.GetInstance <ICmPossibilityFactory>().Create();

            list.PossibilitiesOS.Add(result);
            result.Name.AnalysisDefaultWritingSystem = AnalysisTss(name);
            return(result);
        }
Ejemplo n.º 35
0
 public ConvertFdoToMongoOptionList ConvertOptionListFromFdo(ILfProject project, string listCode, ICmPossibilityList fdoOptionList, bool updateMongoList = true)
 {
     LfOptionList lfExistingOptionList = _conn.GetLfOptionListByCode(project, listCode);
     var converter = new ConvertFdoToMongoOptionList(lfExistingOptionList, _wsEn, listCode, _env.Logger, _cache.WritingSystemFactory);
     LfOptionList lfChangedOptionList = converter.PrepareOptionListUpdate(fdoOptionList);
     if (updateMongoList)
         _conn.UpdateRecord(project, lfChangedOptionList, listCode);
     return new ConvertFdoToMongoOptionList(lfChangedOptionList, _wsEn, listCode, _env.Logger, _cache.WritingSystemFactory);
 }
Ejemplo n.º 36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// create test data
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			base.CreateTestData();

			m_xmlNote = new XmlNoteCategory();

			// Initialize the annotation category possibility list.
			m_possList = CreateCategories(Cache, m_wsSpanish);
		}
		private void CreateKnownPossibilityList()
		{
			// this list exists empty in the FdoTestBase.
			m_testList = Cache.LangProject.ConfidenceLevelsOA;
			Assert.AreEqual(0, m_testList.PossibilitiesOS.Count);
			Assert.AreEqual("Possibilities", Cache.MetaDataCache.GetFieldName(possibilitiesFlid));

			AppendTestItemToList("First"); // So tests automatically have one item.
		}
Ejemplo n.º 38
0
        private void Import(XmlReader xrdr)
        {
            xrdr.MoveToContent();
            if (xrdr.Name != "Lists")
            {
                throw new Exception(String.Format("Unexpected outer element (expected <Lists>): {0}", xrdr.Name));
            }
            DateTime dateOfTranslation = ReadDateAttribute(xrdr);

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

            while (xrdr.Name == "List")
            {
                ICmPossibilityList list = GetListFromAttributes(xrdr);
                xrdr.MoveToElement();
                string sItemClass;
                int    clid;
                GetItemClassFromAttributes(xrdr, out sItemClass, out clid);
                xrdr.MoveToElement();
                xrdr.Read();
                while (xrdr.Depth == 2)
                {
                    xrdr.MoveToContent();
                    if (xrdr.Depth < 2)
                    {
                        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 "Possibilities":
                        // we know the list, but we don't have the map yet at this level.
                        ReadPossibilitiesFromXml(xrdr, list, sItemClass, "");
                        break;

                    default:
                        throw new Exception(String.Format("Unknown field element in <List>: {0}", xrdr.Name));
                    }
                }
                xrdr.ReadEndElement();
                xrdr.MoveToContent();                   // skip any trailing whitespace
            }
        }
Ejemplo n.º 39
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="KeyTermsTree"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public KeyTermsTree(ICmPossibilityList keyTermsList)
		{
			BorderStyle = BorderStyle.None;
			HideSelection = false;
			m_keyTermsList = keyTermsList;
			m_cache = m_keyTermsList.Cache;
			m_wsDefault = m_cache.DefaultUserWs;

			GetFontForWs = (ws => Font); // By default, just use the control's font (from Designer)
		}
Ejemplo n.º 40
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads the tree with the specified list of possibilities.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public virtual void Load(ICmPossibilityList list, List<int> initiallySelectedHvos,
			Label lblSelectedCategories)
		{
			m_lblSelectedCategories = lblSelectedCategories;

			Nodes.Clear();
			m_initiallySelectedHvos = (initiallySelectedHvos ?? new List<int>());

			if (list != null)
			{
				foreach (ICmPossibility possibility in list.PossibilitiesOS)
					Nodes.Add(CreateNode(possibility));
			}
		}
Ejemplo n.º 41
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads the tree with the specified list of possibilities.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public virtual void Load(ICmPossibilityList list, List<int> initiallySelectedHvos,
			Label lblSelectedCategories)
		{
			m_lblSelectedCategories = lblSelectedCategories;

			Nodes.Clear();
			StringUtils.InitIcuDataDir();	// used for normalizing strings to NFC
			m_initiallySelectedHvos = (initiallySelectedHvos ?? new List<int>());

			if (list != null)
			{
				foreach (ICmPossibility possibility in list.PossibilitiesOS)
					Nodes.Add(CreateNode(possibility));
			}
		}
Ejemplo n.º 42
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();

			m_xmlNote = new XmlNoteCategory();

			m_scrInMemoryCache.InitializeWritingSystemEncodings();
			m_scrInMemoryCache.InitializeScripture();
			m_scrInMemoryCache.SetupScriptureAnnotationCategories();

			// Initialize the annotation category possibility list.
			m_wsSpanish = InMemoryFdoCache.s_wsHvos.Es;
			m_possList = CreateCategories(m_scrInMemoryCache.Cache, m_possList, m_wsSpanish);
		}
Ejemplo n.º 43
0
		private void Init(FdoCache cache, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
		{
			if (m_parent == null)
			{
				if (SIL.FieldWorks.Common.Framework.FwApp.App != null)
					m_parent = SIL.FieldWorks.Common.Framework.FwApp.App.ActiveMainWindow;
				if (m_parent == null)
					m_parent = Form.ActiveForm; // desperate for something...
			}
			m_cache = cache;
			m_useAbbr = useAbbr;
			m_parent = parent;
			m_list = list;
			m_ws = ws;

		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a text for testing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void CreateTestText()
		{
			m_txt = m_servLoc.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_txt);
			m_possTagList = Cache.LangProject.GetDefaultTextTagList();
			m_stTxt = m_servLoc.GetInstance<IStTextFactory>().Create();
			m_txt.ContentsOA = m_stTxt;
			m_txtPara = m_txt.ContentsOA.AddNewTextPara(null);

			// 0    1  2 3    4      5   6                        7    8
			// This is a test string for ReferenceAdjusterService tests.

			var hvoVernWs = Cache.DefaultVernWs;
			m_txtPara.Contents = TsStringUtils.MakeTss("This is a test string for ReferenceAdjusterService tests.", hvoVernWs);
			ParseText();
		}
Ejemplo n.º 45
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });

			// Try moving this up to Fixture Setup, since we don't plan on changing the text here.
			m_text1 = LoadTestText(@"LexText\Interlinear\ITextDllTests\ParagraphParserTestTexts.xml", 1, m_textsDefn);
			m_hvoPara = m_text1.ContentsOA.ParagraphsOS[1].Hvo; // First paragraph contains no text!
			ParseTestText();

			m_tagChild = new TestTaggingChild(Cache);

			// This could change, but at least it gives a reasonably stable list to test from.
			m_textMarkupTags = m_tagChild.CreateDefaultListFromXML();
			LoadTagListHvos();
		}
Ejemplo n.º 46
0
		public void Setup()
		{
			CheckDisposed();
			base.Initialize();

			m_scrInMemoryCache.InitializeWritingSystemEncodings();
			m_scrInMemoryCache.InitializeAnnotationCategories();
			m_scrInMemoryCache.InitializeAnnotationDefs();
			m_scrInMemoryCache.SetupScriptureAnnotationCategories();

			m_wsSpanish = InMemoryFdoCache.s_wsHvos.Es;

			// Initialize the annotation category possibility list.
			m_possList = XmlNoteCategoryTests.CreateCategories(m_scrInMemoryCache.Cache,
				m_possList, m_wsSpanish);

			ScrNoteImportManager.Initialize(m_scr, 1);
		}
Ejemplo n.º 47
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates the categories.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="list">The possibility (category) list.</param>
		/// <param name="ws">The writing system for setting the category names.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		internal static ICmPossibilityList CreateCategories(FdoCache cache,
			ICmPossibilityList list, int ws)
		{
			list = cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA;

			// Initialize text.
			ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
			ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
									 (int)FwTextPropVar.ktpvDefault, ws);
			ITsStrBldr tsStrBldr = TsStrBldrClass.Create();

			// Set possibilities on top level--"Level 1a"
			CmPossibility possibility1a = new CmPossibility();
			list.PossibilitiesOS.Append(possibility1a);
			tsStrBldr.ReplaceRgch(0, 0, "Level 1a", 8, ttpBldr.GetTextProps());
			possibility1a.Name.SetAlternative(tsStrBldr.GetString(), ws);

			// Add another on top level--"Level 1b"
			CmPossibility possibility1b = new CmPossibility();
			list.PossibilitiesOS.Append(possibility1b);
			tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 1b", 8, ttpBldr.GetTextProps());
			possibility1b.Name.SetAlternative(tsStrBldr.GetString(), ws);

			// Add possibilities on second level under "Level 1b"--"Level 2a"
			CmPossibility subPossibility2a = new CmPossibility();
			possibility1b.SubPossibilitiesOS.Append(subPossibility2a);
			tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 2a, parent is 1b", 22, ttpBldr.GetTextProps());
			subPossibility2a.Name.SetAlternative(tsStrBldr.GetString(), ws);

			// Add "Level 2b" under "Level 1b"
			CmPossibility subPossibility2b = new CmPossibility();
			possibility1b.SubPossibilitiesOS.Append(subPossibility2b);
			tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 2b, parent is 1b", 22, ttpBldr.GetTextProps());
			subPossibility2b.Name.SetAlternative(tsStrBldr.GetString(), ws);

			// Add "Level 3" under "Level 2b"
			CmPossibility subSubPossibility3 = new CmPossibility();
			subPossibility2b.SubPossibilitiesOS.Append(subSubPossibility3);
			tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 3, parent is 2b", 21, ttpBldr.GetTextProps());
			subSubPossibility3.Name.SetAlternative(tsStrBldr.GetString(), ws);

			return list;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize this test fixture.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			IWritingSystem wsEs;
			Cache.ServiceLocator.WritingSystemManager.GetOrSet("es", out wsEs);
			m_wsSpanish = wsEs.Handle;

			NonUndoableUnitOfWorkHelper.Do(Cache.ActionHandlerAccessor, () =>
			{
				Cache.ServiceLocator.WritingSystems.AnalysisWritingSystems.Add(wsEs);

				// Initialize the annotation category possibility list.
				m_possList = XmlNoteCategoryTests.CreateCategories(Cache, m_wsSpanish);

				ScrNoteImportManager.Initialize(m_scr, 1);
			});

		}
Ejemplo n.º 49
0
		private void Init(FdoCache cache, Mediator mediator, ICmPossibilityList list, int ws, bool useAbbr, Form parent)
		{
			m_mediator = mediator;
			if (parent == null)
			{
				if (mediator != null)
				{
					IApp app = (IApp)mediator.PropertyTable.GetValue("App");
					if (app != null)
						parent = app.ActiveMainWindow;
				}
				if (parent == null)
					parent = Form.ActiveForm; // desperate for something...
			}
			m_cache = cache;
			m_useAbbr = useAbbr;
			m_parent = parent;
			m_list = list;
			m_ws = ws;

		}
Ejemplo n.º 50
0
		/// ----------------------------------------------------------------------------------------
		/// <summary>
		/// Main entry point for deleting Custom Lists.
		/// Needs to:
		/// 1 - Make sure the given list really is a Custom List
		/// 2 - Let the user know if any of the possibilities of this list are being referenced.
		/// 3 - Delete the list (and its possibilities and subpossibilities) and, consequently,
		///     any references to those possibilities.
		/// </summary>
		/// ----------------------------------------------------------------------------------------
		public void Run(ICmPossibilityList curList)
		{
			m_listToDelete = curList;

			// Make sure list is a CUSTOM list!
			var owner = m_listToDelete.Owner; // Custom lists are unowned!
			if (owner != null)
				return; // Not a Custom list!

			// Make sure user knows if any possibilities owned by this list are referenced
			// by anything else!
			GetCustomFieldsReferencingList(m_listToDelete.Guid);
			ICmPossibility poss;
			if (HasPossibilityReferences(out poss) > 0)
			{
				var name = poss.Name.BestAnalysisVernacularAlternative.Text;
				// Warn user that possibilities in this list are in use.
				if (CheckWithUser(name) != DialogResult.Yes)
					return;
			}
			DeleteList(m_listToDelete);
		}
Ejemplo n.º 51
0
		public MasterCategoryListChooserLauncher(Form popupMgrParent, Mediator mediator,
			ICmPossibilityList possibilityList, string fieldName, ILexSense sense)
		{
			m_parentOfPopupMgr = popupMgrParent;
			m_mediator = mediator;
			CategoryList = possibilityList;
			m_sense = sense;
			FieldName = fieldName;
			Cache = m_sense.Cache;

			Application.Idle += new EventHandler(LaunchChooseFromMasterCategoryListOnIdle);
		}
Ejemplo n.º 52
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public MSAPopupTreeManager(TreeCombo treeCombo, FdoCache cache, ICmPossibilityList list,
			int ws, bool useAbbr, Mediator mediator, Form parent)
			: base(treeCombo, cache, mediator, list, ws, useAbbr, parent)
		{
			LoadStrings();
		}
Ejemplo n.º 53
0
		/// <summary>
		/// Return true if the specified list requires us to use a chooser dialog rather than putting a simple combo box
		/// in the bulk edit bar. Currently we do this if the list is (actually, not just potentially) hierarchical,
		/// or if it has more than 25 items.
		/// Note that at least one unit test will break if this method causes the default Locations list to be treated
		/// as hierarchical.
		/// </summary>
		/// <param name="list"></param>
		/// <returns></returns>
		private bool RequiresDialogChooser(ICmPossibilityList list)
		{
			if (list.PossibilitiesOS.Count > 25)
				return true;
			foreach (var item in list.PossibilitiesOS)
			{
				if (item.SubPossibilitiesOS.Count > 0)
					return true;
			}
			return false;
		}
Ejemplo n.º 54
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_textsDefn = null;
			m_text1 = null;
			m_textMarkupTags = null;
			m_tagChild = null;
			m_possTagHvos = null;
			m_hvoWfics = null;

			base.Dispose(disposing);
		}
Ejemplo n.º 55
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Shows the Chooser dialog to allow the user to select a single possibility.
		/// </summary>
		/// <remarks>Used for filtering</remarks>
		/// <param name="list">The possibility list used to populate the tree</param>
		/// <param name="initialSelected">The possibility to check initially, or null to
		/// show with no initial selection</param>
		/// <returns>A single chosen CmPossibility, or null if user cancels or chooses
		/// nothing.</returns>
		/// ------------------------------------------------------------------------------------
		public ICmPossibility GetPossibility(ICmPossibilityList list, ICmPossibility initialSelected)
		{
			//CheckDisposed();

			//m_initiallySelectedHvos = new List<int>(1);
			//m_initiallySelectedHvos.Add(hvoPoss);

			//if (list != (CmPossibilityList)m_list)
			//{
			//    m_list = list;
			//    SetTitle();
			//}

			//tvPossibilities.Load(m_list, m_initiallySelectedHvos);
			//if (ShowDialog() != DialogResult.OK)
			//    return 0;

			//List<int> newHvos = tvPossibilities.SelectedHvos;
			//return (newHvos != null && newHvos.Count > 0 ? newHvos[0] : 0);

			// REVIEW: Currently, the chooser tree doesn't allow the user to select
			// only one possibility. If this method and single node selection is ever
			// necessary, then this method will need to be rewritten.
			return null;
		}
Ejemplo n.º 56
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="FwChooserDlg"/> class.
		/// </summary>
		/// <param name="list">The possibility list used to populate the tree</param>
		/// <param name="initiallySelectedHvos">The sequence of HVOs of initially selected
		/// possibilities</param>
		/// <param name="helptopicProvider">object that knows how to serve up help topics</param>
		/// <param name="sHelpTopicKey">Topic to display if user clicks Help button (can be
		/// specific to the possibility list being displayed)</param>
		/// <param name="projSettingsKey">The project settings key.</param>
		/// ------------------------------------------------------------------------------------
		public FwChooserDlg(ICmPossibilityList list, int[] initiallySelectedHvos,
			IHelpTopicProvider helptopicProvider, string sHelpTopicKey,
			IProjectSpecificSettingsKeyProvider projSettingsKey) : this()
		{
			if (initiallySelectedHvos == null)
				throw new ArgumentNullException("initiallySelectedHvos");
			if (list == null)
				throw new ArgumentNullException("list");
			m_list = list;
			m_cache = m_list.Cache;
			m_initiallySelectedHvos = new List<int>(initiallySelectedHvos);
			m_helptopicProvider = helptopicProvider;
			m_helpTopicKey = sHelpTopicKey;
			m_projSettingsKey = projSettingsKey;

			SetTitle();
			tvPossibilities.Load(m_list, m_initiallySelectedHvos, SelectedPossibilitiesLabel);
		}
Ejemplo n.º 57
0
		private void LoadPossibilitiesFromXml(XmlReader xrdr, ICmPossibilityList owner, string sItemClassName)
		{
			if (xrdr.ReadToDescendant(sItemClassName))
			{
				EnsureFactoryForClass(sItemClassName);
				do
				{
					string sGuid = xrdr.GetAttribute("guid");
					xrdr.MoveToElement();
					Guid guid = Guid.Empty;
					if (!String.IsNullOrEmpty(sGuid))
						guid = new Guid(sGuid);
					ICmPossibility poss = null;
					switch (sItemClassName)
					{
						case "CmPossibility":
							poss = m_factPoss.Create(EnsureGuid(guid), owner);
							break;
						case "CmAnthroItem":
							poss = m_factAnthro.Create(EnsureGuid(guid), owner) as ICmPossibility;
							break;
						case "CmSemanticDomain":
							poss = m_factSemDom.Create(EnsureGuid(guid), owner) as ICmPossibility;
							break;
						case "PartOfSpeech":
							Debug.Assert(guid != Guid.Empty);
							poss = m_factPOS.Create(guid, owner);
							break;
						default:
							// TODO: implement other subclasses of CmPossibility?
							break;
					}
					Debug.Assert(poss != null);
					ReadPossItem(xrdr.ReadSubtree(), poss, sItemClassName);
				} while (xrdr.ReadToNextSibling(sItemClassName));
			}
			xrdr.Read();	// reads end element.
		}
Ejemplo n.º 58
0
		protected void MakeContextMenu_AvailableTags(ContextMenuStrip menu, ICmPossibilityList list)
		{
			foreach (ICmPossibility tagList in list.PossibilitiesOS)
			{
				if (tagList.SubPossibilitiesOS.Count > 0)
					AddListToMenu(menu, tagList);
			}
		}
Ejemplo n.º 59
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads the tree with the specified list of possibilities.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public virtual void Load(ICmPossibilityList list, List<int> initiallySelectedHvos)
		{
			Load(list, initiallySelectedHvos, null);
		}