Esempio n. 1
0
        public void Init(Mediator mediator, XmlNode configurationNode, ICmObject sourceObject)
        {
            CheckDisposed();

            m_cache = sourceObject.Cache;

            // Find the sense owning our LexExampleSentence
            if (sourceObject is LexExampleSentence)
            {
                m_les         = sourceObject as LexExampleSentence;
                m_owningSense = LexSense.CreateFromDBObject(m_cache, m_les.OwnerHVO);
            }
            else if (sourceObject is LexSense)
            {
                m_owningSense = sourceObject as ILexSense;
            }
            else
            {
                throw new ArgumentException("Invalid object type for sourceObject.");
            }

            m_mediator          = mediator;
            m_configurationNode = configurationNode;
            AddConfigurableControls();

            m_virtFlidReference = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "CmBaseAnnotation", "Reference");
        }
Esempio n. 2
0
        public TitleContentsVc(FdoCache cache)
        {
            int wsUser = cache.DefaultUserWs;

            m_wsAnalysis = cache.DefaultAnalWs;
            ITsStrFactory tsf = TsStrFactoryClass.Create();

            m_tssTitle = tsf.MakeString(ITextStrings.ksTitle, wsUser);
            //m_tssComments = tsf.MakeString("Comments", wsUser);
            //m_tssComments = tsf.MakeString("Source", wsUser);
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptBold,
                                 (int)FwTextPropVar.ktpvEnum,
                                 (int)FwTextToggleVal.kttvForceOn);
            m_ttpBold = tpb.GetTextProps();
            tpb       = TsPropsBldrClass.Create();
            // Set some padding all around.
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTop,
                                 (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadBottom,
                                 (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadLeading,
                                 (int)FwTextPropVar.ktpvMilliPoint, 3000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTrailing,
                                 (int)FwTextPropVar.ktpvMilliPoint, 3000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptMarginTrailing,
                                 (int)FwTextPropVar.ktpvMilliPoint, 11000); // 10000 clips right border.
            m_ttpDataCellProps = tpb.GetTextProps();

            m_vtagStTextTitle = BaseVirtualHandler.GetInstalledHandlerTag(cache, "StText", "Title");

            // Set up the array of writing systems we will display for title.
            SetupWritingSystemsForTitle(cache);
        }
Esempio n. 3
0
        protected InterlinearExporter(FdoCache cache, XmlWriter writer, int hvoRoot, InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
            : base(null, cache.MainCacheAccessor, hvoRoot)
        {
            m_cache                = cache;
            m_writer               = writer;
            ktagParaSegments       = InterlinVc.ParaSegmentTag(cache);
            ktagSegmentForms       = InterlinVc.SegmentFormsTag(cache);
            m_flidStringValue      = CmBaseAnnotation.StringValuePropId(cache);
            m_lineChoices          = lineChoices;
            m_defaultGlossVirtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense");
            m_vc = vc;
            m_tssPendingTitle      = tssTextName;
            m_tssTitleAbbreviation = tssTextAbbreviation;

            // Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
            IMoMorphType mmtStem;
            IMoMorphType mmtPrefix;
            IMoMorphType mmtSuffix;
            IMoMorphType mmtInfix;
            IMoMorphType mmtBoundStem;
            IMoMorphType mmtSimulfix;
            IMoMorphType mmtSuprafix;

            MoMorphType.GetMajorMorphTypes(cache, out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
                                           out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
        }
Esempio n. 4
0
        public void FixtureInit()
        {
            base.FixtureSetup();

            BaseVirtualHandler.InstallVirtuals(@"Language Explorer\Configuration\Grammar\areaConfiguration.xml",
                                               new string[] { "SIL.FieldWorks.FDO." }, Cache, true);

            Guid appGuid = Guid.NewGuid();

            Cache.MakeDbSyncRecords(appGuid);

            SetUpDataFiles();
            m_tsStartUp = new TimeStamp(m_sqlConnection);
        }
Esempio n. 5
0
        public override void Init(FdoCache cache, Mediator mediator, XmlNode recordListNode)
        {
            CheckDisposed();

            // <recordList class="WfiWordform" field="OccurrencesInTexts"/>
            BaseInit(cache, mediator, recordListNode);
            //string owner = XmlUtils.GetOptionalAttributeValue(recordListNode, "owner");
            IVwVirtualHandler vh = BaseVirtualHandler.GetInstalledHandler(cache, "WfiWordform", "OccurrencesInTexts");

            Debug.Assert(vh != null);
            m_flid       = vh.Tag;
            Sorter       = new OccurrenceSorter();
            Sorter.Cache = cache;
        }
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			BaseVirtualHandler.InstallVirtuals(Path.Combine(FwUtils.ksFlexAppName,
				Path.Combine("Configuration",
				Path.Combine("Grammar", "areaConfiguration.xml"))),
				new string[] { "SIL.FieldWorks.FDO." }, Cache, true);

			Guid appGuid = Guid.NewGuid();
			Cache.MakeDbSyncRecords(appGuid);

			SetUpDataFiles();
			m_tsStartUp = new TimeStamp(m_sqlConnection);
		}
Esempio n. 7
0
        /// <summary>
        /// Initialize the required inventories.
        /// </summary>
        private void InitializePartInventories(FdoCache cache, bool fLoadUserOverrides)
        {
            WriteSplashScreen(LexTextStrings.ksInitializingLayouts_);
            LayoutCache.InitializePartInventories(false, cache.DatabaseName, fLoadUserOverrides);
            int flid = BaseVirtualHandler.GetInstalledHandlerTag(cache, "LexDb", "CurrentReversalIndices");

            if (flid == 0)
            {
                flid = (int)LexDb.LexDbTags.kflidReversalIndexes;
            }
            int[] rghvoIndexes = cache.GetVectorProperty(cache.LangProject.LexDbOA.Hvo, flid, false);
            foreach (int hvoIndex in rghvoIndexes)
            {
                int    ws  = cache.GetObjProperty(hvoIndex, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem);
                string sWs = cache.GetUnicodeProperty(ws, (int)LgWritingSystem.LgWritingSystemTags.kflidICULocale);
                LayoutCache.InitializeLayoutsForWsTag(sWs, cache.DatabaseName);
            }
        }
Esempio n. 8
0
        protected override FdoObjectSet <ICmObject> GetObjectSet()
        {
            IVwVirtualHandler handler = BaseVirtualHandler.GetInstalledHandler(m_cache, "WfiWordform", "OccurrencesInTexts");

            Debug.Assert(handler != null);

            IWfiWordform wf          = m_owningObject as IWfiWordform;
            List <int>   occurrences = wf.OccurrencesInTexts;

            IVwVirtualHandler vh = m_cache.VwCacheDaAccessor.GetVirtualHandlerName("WfiWordform", "OccurrencesInCaptions");

            if (vh != null)
            {
                occurrences.AddRange(m_cache.GetVectorProperty(wf.Hvo, vh.Tag, true));
            }

            return(new FdoObjectSet <ICmObject>(m_cache, occurrences.ToArray(), true));
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        internal TimeStamp RetrieveModel(SqlConnection connection, string LangProject, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate)
        {
            TimeStamp began = new TimeStamp(connection);

            using (FdoCache cache = FdoCache.Create(connection.DataSource, connection.Database, null))
            {
                BaseVirtualHandler.InstallVirtuals(@"Language Explorer\Configuration\Main.xml",
                                                   new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." }, cache, true);

                string sDescription;
                string sFxtFile;
                SetDescriptionAndFxtFile(eNeedsUpdate, out sDescription, out sFxtFile);
                using (m_topLevelTask = parentTask.AddSubTask(sDescription))
                {
                    m_taskStack.Push(m_topLevelTask);
                    string sFxtPath = Path.Combine(DirectoryFinder.FWCodeDirectory, sFxtFile);
                    m_sFxtOutputPath = Path.Combine(m_outputDirectory, m_database + "ParserFxtResult.xml");
                    if ((eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) &&
                        File.Exists(m_sFxtTemplateOutputPath))
                    {
                        try
                        {
                            DoUpdate(cache, sFxtPath, ref m_modelDom);
                            DoUpdate(cache, m_sGafawsFxtPath, ref m_templateDom);
                        }
                        // (SteveMiller): Unremarked, the following often causes an error:
                        // Warning as Error: The variable 'e' is declared but never used
                        catch (XUpdaterException)
                        {
                            //Trace.WriteLine("XUpdater exception caught: " + e.Message);
                            // do something useful for the user
                            DoDump(eNeedsUpdate, cache, sFxtPath);
                        }
                    }
                    else
                    {
                        DoDump(eNeedsUpdate, cache, sFxtPath);
                    }
                }
            }
            m_topLevelTask = null;
            return(began);
        }
Esempio n. 10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// For dialogs which involve displaying lexical data, ensure that the virtual
        /// properties needed by the XMLViews based displays are installed. Also ensure that
        /// they aren't holding a pointer to a previous temporary cache which was disposed by a
        /// previous lookup.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="mediator">The mediator.</param>
        /// ------------------------------------------------------------------------------------
        public static void EnsureFlexVirtuals(FdoCache cache, Mediator mediator)
        {
            TSStringPropertyVirtualHandler vh =
                cache.GetVirtualProperty("LexEntry", "HeadWord") as TSStringPropertyVirtualHandler;

            if (vh == null || vh.Cache.IsDisposed)
            {
                // This can be called from TE...in that case, we don't complain about missing include
                // files (true argument) but just trust that we put enough in the installer to make it work.
                XmlDocument configuration = XmlUtils.LoadConfigurationWithIncludes(FlexConfigFile, true);
                XmlNode     configNode    = configuration.SelectSingleNode("window");
                BaseVirtualHandler.InstallVirtuals(configNode.SelectSingleNode("virtuals"), cache, true);
                if (mediator != null)
                {
                    mediator.PropertyTable.SetProperty("WindowConfiguration", configNode);
                    mediator.PropertyTable.SetPropertyPersistence("WindowConfiguration", false);
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Merge the underling objects. This method handles the transaction, then delegates
        /// the actual merge to MergeObject. If the flag is true, we merge
        /// strings and owned atomic objects; otherwise, we don't change any that aren't null
        /// to begin with.
        /// </summary>
        /// <param name="fLoseNoTextData"></param>
        protected override void ReallyMergeUnderlyingObject(int survivorHvo, bool fLoseNoTextData)
        {
            ICmObject survivor = CmObject.CreateFromDBObject(m_cache, survivorHvo);

            base.ReallyMergeUnderlyingObject(survivorHvo, fLoseNoTextData);

            // Update virtual prop on survivor, so it is displayed properly.
            // Reloading the VH and calling PropChanged fixes LT-6274.
            IVwVirtualHandler vh = BaseVirtualHandler.GetInstalledHandler(m_cache, "ReversalIndexEntry", "ReferringSenses");
            int flid             = vh.Tag;

            vh.Load(survivor.Hvo, flid, 0, m_cache.VwCacheDaAccessor);
            m_cache.MainCacheAccessor.PropChanged(
                null,
                (int)PropChangeType.kpctNotifyAll,
                survivor.Hvo,
                flid,
                0,
                0,
                0);
        }
Esempio n. 12
0
        protected override void ReallyDeleteUnderlyingObject()
        {
            IReversalIndexEntry rei = Object as IReversalIndexEntry;
            int hvoGoner            = rei.Hvo;
            int hvoIndex            = rei.ReversalIndex.Hvo;
            IVwVirtualHandler vh    = BaseVirtualHandler.GetInstalledHandler(m_cache, "ReversalIndex", "AllEntries");
            int flid = vh.Tag;

            base.ReallyDeleteUnderlyingObject();

            // Remove goner from the cache.
            vh.Load(hvoIndex, flid, 0, m_cache.VwCacheDaAccessor);

            m_cache.MainCacheAccessor.PropChanged(
                null,
                (int)PropChangeType.kpctNotifyAll,
                hvoIndex,
                flid,
                0,
                0,
                1);
        }
Esempio n. 13
0
        /// <summary>
        /// This will recache some information related to a wordform and its analyses,
        /// and call PropChanged to get the display to refresh.
        /// </summary>
        /// <param name="curDisplayedWfId"></param>
        /// <param name="updateUserCount"></param>
        /// <param name="updateUserStatusIcon"></param>
        /// <param name="updateParserCount"></param>
        /// <param name="updateParserStatusIcon"></param>
        /// <remarks>
        /// It makes no sense to call this method if the active area isn't the Words area,
        /// and the tool isn't Analyses.
        /// </remarks>
        public void UpdateWordsToolDisplay(
            int curDisplayedWfId,
            bool updateUserCount, bool updateUserStatusIcon,
            bool updateParserCount, bool updateParserStatusIcon)
        {
            CheckDisposed();

            IWfiWordform wf = (IWfiWordform)Object;

            // First update the cache of the real property on which everything else depends.
            // This should take care of LT-3874.
            string sql = string.Format("select id from WfiAnalysis_ where owner$ = {0}", wf.Hvo);

            int[] newAnalyses = DbOps.ReadIntArrayFromCommand(wf.Cache, sql, null);
            int   oldCount    = m_cache.MainCacheAccessor.get_VecSize(wf.Hvo, (int)WfiWordform.WfiWordformTags.kflidAnalyses);

            m_cache.VwCacheDaAccessor.CacheVecProp(wf.Hvo, (int)WfiWordform.WfiWordformTags.kflidAnalyses, newAnalyses, newAnalyses.Length);
            m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, wf.Hvo,
                                (int)WfiWordform.WfiWordformTags.kflidAnalyses, 0, newAnalyses.Length, oldCount);

            bool updateConflictCount = false;

            if (updateUserCount)
            {
                m_cache.PropChanged(
                    null,
                    PropChangeType.kpctNotifyAll,
                    wf.Hvo,
                    BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "UserCount"),
                    0, 0, 0);
                updateConflictCount = true;
            }
            if (updateParserCount)
            {
                m_cache.PropChanged(
                    null,
                    PropChangeType.kpctNotifyAll,
                    wf.Hvo,
                    BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "ParserCount"),
                    0, 0, 0);
                updateConflictCount = true;
            }
            if (updateConflictCount)
            {
                m_cache.PropChanged(
                    null,
                    PropChangeType.kpctNotifyAll,
                    wf.Hvo,
                    BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "ConflictCount"),
                    0, 0, 0);
            }

            if (curDisplayedWfId == wf.Hvo)
            {
                // Update "WfiWordform"-"HumanApprovedAnalyses"
                m_cache.PropChanged(
                    null,
                    PropChangeType.kpctNotifyAll,
                    wf.Hvo,
                    BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "HumanApprovedAnalyses"),
                    0, 0, 0);
                // Update "WfiWordform"-"HumanNoOpinionParses"
                m_cache.PropChanged(
                    null,
                    PropChangeType.kpctNotifyAll,
                    wf.Hvo,
                    BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "HumanNoOpinionParses"),
                    0, 0, 0);
                // Update "WfiWordform"-"HumanDisapprovedParses"
                m_cache.PropChanged(
                    null,
                    PropChangeType.kpctNotifyAll,
                    wf.Hvo,
                    BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "HumanDisapprovedParses"),
                    0, 0, 0);
                // Update "WfiAnalysis", "ParserStatusIcon"
                int psiFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiAnalysis", "ParserStatusIcon");
                foreach (int analId in m_cache.GetVectorProperty(wf.Hvo, (int)WfiWordform.WfiWordformTags.kflidAnalyses, true))
                {
                    if (updateParserStatusIcon)
                    {
                        // This will force an update to the slice the shows the parser results.
                        WfiAnalysis anal = (WfiAnalysis)CmObject.CreateFromDBObject(m_cache, analId, true);
                        m_cache.PropChanged(
                            null,
                            PropChangeType.kpctNotifyAll,
                            analId,
                            psiFlid,
                            0, 0, 0);
                    }
                }
            }
        }
Esempio n. 14
0
        protected void CreateTestData()
        {
            // Create required virtual properties
            XmlDocument doc = new XmlDocument();

            // Subset of Flex virtuals required for parsing paragraphs etc.
            doc.LoadXml(
                "<virtuals>"
                + "<virtual modelclass=\"StTxtPara\" virtualfield=\"Segments\">"
                + "<dynamicloaderinfo assemblyPath=\"ITextDll.dll\" class=\"SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"OccurrencesInTexts\" destinationClass=\"CmBaseAnnotation\">"
                + "<dynamicloaderinfo assemblyPath=\"ITextDll.dll\" class=\"SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"HumanApprovedAnalyses\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.FDOSequencePropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"HumanNoOpinionParses\" computeeverytime=\"true\" requiresRealParserGeneratedData=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.FDOSequencePropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"HumanDisapprovedParses\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.FDOSequencePropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"FullConcordanceCount\" depends=\"OccurrencesInTexts\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"UserCount\" bulkLoadMethod=\"LoadAllUserCounts\" computeeverytime=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"ParserCount\" bulkLoadMethod=\"LoadAllParserCounts\" computeeverytime=\"true\" requiresRealParserGeneratedData=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WfiWordform\" virtualfield=\"ConflictCount\" computeeverytime=\"true\" requiresRealParserGeneratedData=\"true\">"
                + "<dynamicloaderinfo assemblyPath=\"FDO.dll\" class=\"SIL.FieldWorks.FDO.IntegerPropertyVirtualHandler\"/>"
                + "</virtual>"
                + "<virtual modelclass=\"WordformInventory\" virtualfield=\"ConcordanceWords\" destinationClass=\"WfiWordform\">"
                + "<dynamicloaderinfo assemblyPath=\"ITextDll.dll\" class=\"SIL.FieldWorks.IText.ConcordanceWordsVirtualHandler\"/>"
                + "</virtual>"
                + "</virtuals>");
            BaseVirtualHandler.InstallVirtuals(doc.DocumentElement, Cache);

            m_text = new Text();
            Cache.LangProject.TextsOC.Add(m_text);
            string para1 = "Axx simplexx testxx withxx axx lotxx ofxx wordsxx endingxx inxx xx";
            string para2 = "axx sentencexx axx havingxx axx lotxx ofxx axx";

            m_para1           = new StTxtPara();
            m_stText          = new StText();
            m_text.ContentsOA = m_stText;
            m_para1           = MakePara(para1);
            m_para2           = MakePara(para2);
            m_wfAxx           = WfiWordform.CreateFromDBObject(Cache,
                                                               WfiWordform.FindOrCreateWordform(Cache, "axx", Cache.DefaultVernWs, true));
            // Make one real annotation, which also serves to link the Axx to this.
            m_cbaAxx = CmBaseAnnotation.CreateUnownedCba(Cache);
            m_cbaAxx.InstanceOfRA     = m_wfAxx;
            m_cbaAxx.BeginObjectRA    = m_para1;
            m_cbaAxx.BeginOffset      = 0;
            m_cbaAxx.EndOffset        = 3;
            m_cbaAxx.Flid             = (int)StTxtPara.StTxtParaTags.kflidContents;
            m_cbaAxx.AnnotationTypeRA = CmAnnotationDefn.Twfic(Cache);

            // Make another real annotation, which should get updated during Apply.
            IWfiWordform wf2 = WfiWordform.CreateFromDBObject(Cache,
                                                              WfiWordform.FindOrCreateWordform(Cache, "lotxx", Cache.DefaultVernWs, true));

            m_cba2 = CmBaseAnnotation.CreateUnownedCba(Cache);
            m_cba2.InstanceOfRA     = wf2;
            m_cba2.BeginObjectRA    = m_para2;
            m_cba2.BeginOffset      = "axx sentencexx axx havingxx axx ".Length;
            m_cba2.EndOffset        = m_cba2.BeginOffset + "lotxx".Length;
            m_cba2.AnnotationTypeRA = CmAnnotationDefn.Twfic(Cache);
            m_cba2.Flid             = (int)StTxtPara.StTxtParaTags.kflidContents;

            ParagraphParser.ConcordTexts(Cache, new int[] { m_stText.Hvo }, new NullProgressState());
            m_axxOccurrences   = m_wfAxx.ConcordanceIds;
            m_para1Occurrences = OccurrencesInPara(m_para1.Hvo, m_axxOccurrences);
            m_para2Occurrences = OccurrencesInPara(m_para2.Hvo, m_axxOccurrences);

            // to improve test isolation, be sure to null things not always initialized.
            m_wfaAxe    = m_wfaCut = m_wfaCutIt = m_wfaNotRude = null;
            m_cAnalyses = 0;
        }
Esempio n. 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument">The xCore Command object.</param>
        /// <returns>true</returns>
        public bool OnAddApprovedAnalysis(object argument)
        {
            using (EditMorphBreaksDlg dlg = new EditMorphBreaksDlg())
            {
                IWfiWordform wf = Wordform;
                if (wf == null)
                {
                    return(true);
                }
                ITsString tssWord = Wordform.Form.BestVernacularAlternative;
                string    morphs  = tssWord.Text;
                FdoCache  cache   = Cache;
                dlg.Initialize(tssWord, morphs, cache.MainCacheAccessor.WritingSystemFactory,
                               cache, m_dataEntryForm.Mediator.StringTbl, m_dataEntryForm.StyleSheet);
                Form mainWnd = m_dataEntryForm.FindForm();
                // Making the form active fixes problems like LT-2619.
                // I'm (RandyR) not sure what adverse impact might show up by doing this.
                mainWnd.Activate();
                if (dlg.ShowDialog(mainWnd) == DialogResult.OK)
                {
                    morphs = dlg.GetMorphs().Trim();
                    if (morphs.Length == 0)
                    {
                        return(true);
                    }

                    string[] prefixMarkers  = MoMorphType.PrefixMarkers(cache);
                    string[] postfixMarkers = MoMorphType.PostfixMarkers(cache);

                    List <string> allMarkers = new List <string>();
                    foreach (string s in prefixMarkers)
                    {
                        allMarkers.Add(s);
                    }

                    foreach (string s in postfixMarkers)
                    {
                        if (!allMarkers.Contains(s))
                        {
                            allMarkers.Add(s);
                        }
                    }
                    allMarkers.Add(" ");

                    string[] breakMarkers = new string[allMarkers.Count];
                    for (int i = 0; i < allMarkers.Count; ++i)
                    {
                        breakMarkers[i] = allMarkers[i];
                    }

                    string fullForm = SandboxBase.MorphemeBreaker.DoBasicFinding(morphs, breakMarkers, prefixMarkers, postfixMarkers);

                    using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(Cache,
                                                                                          argument as Command))
                    {
                        IWfiAnalysis newAnalysis = Wordform.AnalysesOC.Add(new WfiAnalysis());
                        newAnalysis.ApprovalStatusIcon = 1;                         // Make it human approved.
                        int vernWS = StringUtils.GetWsAtOffset(tssWord, 0);
                        foreach (string morph in fullForm.Split(Unicode.SpaceChars))
                        {
                            if (morph != null && morph.Length != 0)
                            {
                                IWfiMorphBundle mb = newAnalysis.MorphBundlesOS.Append(new WfiMorphBundle());
                                mb.Form.SetAlternative(morph, vernWS);
                            }
                        }
                        int outlineFlid = BaseVirtualHandler.GetInstalledHandlerTag(cache, "WfiAnalysis", "HumanApprovedNumber");
                        foreach (int haaHvo in Wordform.HumanApprovedAnalyses)
                        {
                            // Do PropChanged for the outline number for all of them.
                            // This fixes LT-5007, as the older ones kept their old number,
                            // which could have been a duplicate number.
                            cache.PropChanged(
                                null,
                                PropChangeType.kpctNotifyAll,
                                haaHvo,
                                outlineFlid,
                                0, 0, 0);
                        }
                        cache.PropChanged(
                            null,
                            PropChangeType.kpctNotifyAll,
                            Wordform.Hvo,
                            BaseVirtualHandler.GetInstalledHandlerTag(cache, "WfiWordform", "HumanApprovedAnalyses"),
                            0, 1, 0);
                    }
                }
            }

            return(true);
        }
Esempio n. 16
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Install Virtual properties from Fieldworks xml configuration.
 /// </summary>
 /// <param name="fwInstallFile">The fw install file.</param>
 /// <param name="assemblyNamespaces">The assembly namespaces.</param>
 /// ------------------------------------------------------------------------------------
 protected void InstallVirtuals(string fwInstallFile, string[] assemblyNamespaces)
 {
     m_installedVirtualHandlers = BaseVirtualHandler.InstallVirtuals(fwInstallFile, assemblyNamespaces, Cache);
 }
Esempio n. 17
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// actually install the virtual handlers specified in virtuals
 /// </summary>
 /// <param name="virtuals">The virtuals.</param>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 protected virtual List <IVwVirtualHandler> InstallVirtuals(XmlNode virtuals)
 {
     return(BaseVirtualHandler.InstallVirtuals(virtuals, Cache));
 }
Esempio n. 18
0
        private void SetNewStatus(IWfiAnalysis anal, int newStatus)
        {
            // Getting the wordform's hvo here fixes: LT-5990 and its twin LT-5988.
            int wordformHvo   = anal.OwnerHVO;
            int currentStatus = anal.ApprovalStatusIcon;

            if (currentStatus == newStatus)
            {
                return;
            }

            Cache.BeginUndoTask(MEStrings.ksUndoChangingApprovalStatus,
                                MEStrings.ksRedoChangingApprovalStatus);
            if (currentStatus == 1)
            {
                anal.MoveConcAnnotationsToWordform();
            }
            anal.ApprovalStatusIcon = newStatus;
            if (newStatus == 1)
            {
                // make sure default senses are set to be real values,
                // since the user has seen the defaults, and approved the analysis based on them.
                foreach (IWfiMorphBundle mb in anal.MorphBundlesOS)
                {
                    int currentSense = mb.SenseRAHvo;
                    int defaultSense = mb.DefaultSense;
                    if (currentSense == 0 && defaultSense > 0)
                    {
                        mb.SenseRAHvo = defaultSense;
                    }
                }
            }
            Cache.EndUndoTask();

            // Remove it from the old virtual property.
            int oldVFlid = 0;

            switch (currentStatus)
            {
            case 0:                     // Unknown.
                oldVFlid = BaseVirtualHandler.GetInstalledHandlerTag(Cache, "WfiWordform", "HumanNoOpinionParses");
                break;

            case 1:                     // Approve.
                oldVFlid = BaseVirtualHandler.GetInstalledHandlerTag(Cache, "WfiWordform", "HumanApprovedAnalyses");
                break;

            case 2:                     // Disapprove.
                oldVFlid = BaseVirtualHandler.GetInstalledHandlerTag(Cache, "WfiWordform", "HumanDisapprovedParses");
                break;
            }
            Debug.Assert(oldVFlid != 0);
            Cache.PropChanged(null, PropChangeType.kpctNotifyAll, wordformHvo, oldVFlid, 0, 0, 1);

            // Add it to the new virtual property.
            int newVFlid = 0;

            switch (newStatus)
            {
            case 0:                     // Unknown.
                newVFlid = BaseVirtualHandler.GetInstalledHandlerTag(Cache, "WfiWordform", "HumanNoOpinionParses");
                break;

            case 1:                     // Approve.
                newVFlid = BaseVirtualHandler.GetInstalledHandlerTag(Cache, "WfiWordform", "HumanApprovedAnalyses");
                break;

            case 2:                     // Disapprove.
                newVFlid = BaseVirtualHandler.GetInstalledHandlerTag(Cache, "WfiWordform", "HumanDisapprovedParses");
                break;
            }
            Debug.Assert(newVFlid != 0);
            Cache.PropChanged(null, PropChangeType.kpctNotifyAll, wordformHvo, newVFlid, 0, 1, 0);

            // No need to do a PropChanged on "WfiWordform"-"UserCount" here,
            // since it gets done in ApprovalStatusIcon in FDO.

            // Wipe all of the old slices out,
            // so we get new numbers.
            // This fixes LT-5935.
            m_dataEntryForm.RefreshList(true);
        }