示例#1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Links to lexicon.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void LinkToLexicon()
        {
            CheckDisposed();
            int hvo = m_hvoSelected;

            if (hvo == 0 && m_rghvo != null && m_rghvo.Count > 0)
            {
                hvo = m_rghvo[0];
            }
            // REVIEW: THIS SHOULD NEVER HAPPEN, BUT IF IT DOES, SHOULD WE TELL THE USER ANYTHING?
            if (hvo == 0)
            {
                return;
            }
            FwLink link = FwLink.Create("Language Explorer", "lexiconEdit", m_cache.GetGuidFromId(hvo),
                                        m_cache.ServerName, m_cache.DatabaseName);

            if (Application.ProductName == link.ApplicationName)
            {
                Debug.Assert(m_mediator != null,
                             "If we're linking to same app, then the program must pass in a mediator!");
                m_mediator.SendMessage("FollowLink", link);
            }
            else
            {
                link.Activate();
            }
        }
示例#2
0
        /// <summary>
        /// Have the main FLEx window jump to the appropriate item
        /// </summary>
        /// <param name="hvo">item whose parent will indcate where to jump to</param>
        public void JumpToToolBasedOnHvo(int hvo)
        {
            if (hvo == 0)
            {
                return;
            }
            string    sTool         = null;
            int       parentClassId = 0;
            ICmObject obj           = CmObject.CreateFromDBObject(m_cache, hvo);

            switch (obj.ClassID)
            {
            case MoForm.kclsidMoForm:                                  // fall through
            case MoAffixAllomorph.kclsidMoAffixAllomorph:              // fall through
            case MoStemAllomorph.kclsidMoStemAllomorph:                // fall through
            case MoInflAffMsa.kclsidMoInflAffMsa:                      // fall through
            case MoDerivAffMsa.kclsidMoDerivAffMsa:                    // fall through
            case MoUnclassifiedAffixMsa.kclsidMoUnclassifiedAffixMsa:  // fall through
            case MoStemMsa.kclsidMoStemMsa:                            // fall through
            case MoMorphSynAnalysis.kclsidMoMorphSynAnalysis:
            case MoAffixProcess.kclsidMoAffixProcess:
                sTool         = "lexiconEdit";
                parentClassId = LexEntry.kclsidLexEntry;
                break;

            case MoInflAffixSlot.kclsidMoInflAffixSlot:                              // fall through
            case MoInflAffixTemplate.kclsidMoInflAffixTemplate:                      // fall through
            case PartOfSpeech.kclsidPartOfSpeech:
                sTool         = "posEdit";
                parentClassId = PartOfSpeech.kclsidPartOfSpeech;
                break;

            // still need to test compound rule ones
            case MoCoordinateCompound.kclsidMoCoordinateCompound:
            case MoEndoCompound.kclsidMoEndoCompound:
            case MoExoCompound.kclsidMoExoCompound:
                sTool         = "compoundRuleAdvancedEdit";
                parentClassId = obj.ClassID;
                break;

            case PhRegularRule.kclsidPhRegularRule:                     // fall through
            case PhMetathesisRule.kclsidPhMetathesisRule:
                sTool         = "PhonologicalRuleEdit";
                parentClassId = obj.ClassID;
                break;
            }
            if (parentClassId <= 0)
            {
                return;                 // do nothing
            }
            int parentHvo = CmObjectUi.GetParentOfClass(m_cache, hvo, parentClassId);

            if (parentHvo <= 0)
            {
                return;                 // do nothing
            }
            m_mediator.PostMessage("FollowLink",
                                   SIL.FieldWorks.FdoUi.FwLink.Create(sTool, m_cache.GetGuidFromId(parentHvo), m_cache.ServerName, m_cache.DatabaseName));
        }
示例#3
0
        internal string LinkRef(int hvo)
        {
            Guid guid = m_cache.GetGuidFromId(hvo);

            if (guid == Guid.Empty)
            {
                return(null);
            }
            FdoUi.FwLink link = FdoUi.FwLink.Create("lexiconEdit", guid,
                                                    m_cache.ServerName, m_cache.DatabaseName);
            return(link.ToString());
        }
示例#4
0
        protected Guid WriteGuidAttributeForObj(int hvo)
        {
            if (m_cache.IsDummyObject(hvo))
            {
                return(System.Guid.Empty);
            }
            Guid guid = m_cache.GetGuidFromId(hvo);

            // (note: using m_sda.get_GuidProp(m_hvoCurr, tag) caused a general database error)
            m_writer.WriteAttributeString("guid", guid.ToString());
            return(guid);
        }
示例#5
0
        /// <summary>
        /// Try to find a WfiWordform object corresponding the the focus selection.
        /// If successful return its guid, otherwise, return Guid.Empty.
        /// </summary>
        /// <returns></returns>
        internal static Guid ActiveWordform(FdoCache cache, Mediator mediator)
        {
            IApp app = mediator.PropertyTable.GetValue("App") as IApp;

            if (app == null)
            {
                return(Guid.Empty);
            }
            IFwMainWnd window = app.ActiveMainWindow as IFwMainWnd;

            if (window == null)
            {
                return(Guid.Empty);
            }
            IRootSite activeView = window.ActiveView;

            if (activeView == null)
            {
                return(Guid.Empty);
            }
            List <IVwRootBox> roots = activeView.AllRootBoxes();

            if (roots.Count < 1)
            {
                return(Guid.Empty);
            }
            SelectionHelper helper = SelectionHelper.Create(roots[0].Site);

            if (helper == null)
            {
                return(Guid.Empty);
            }
            ITsString word = helper.SelectedWord;

            if (word == null || word.Length == 0)
            {
                return(Guid.Empty);
            }
#if WANTPORT // FWR-2784
            int hvoWordform = cache.LangProject.WordformInventoryOA.GetWordformId(word);
            if (hvoWordform == 0 || cache.IsDummyObject(hvoWordform))
            {
                return(Guid.Empty);
            }
            return(cache.GetGuidFromId(hvoWordform));
#else
            return(Guid.Empty);
#endif
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool OnTestFollowLink(object unused)
        {
            CheckDisposed();

            FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");

            int[] hvos = cache.LangProject.LexDbOA.EntriesOC.HvoArray;

            m_mediator.SendMessage("FollowLink",
                                   FwLink.Create("lexiconEdit",
                                                 cache.GetGuidFromId(hvos[hvos.Length - 1]) /*the last one*/,
                                                 cache.ServerName,
                                                 cache.DatabaseName));
            return(true);
        }
示例#7
0
 /// <summary>
 /// create and register a URL describing the current context, for use in going backwards and forwards
 /// </summary>
 protected virtual void UpdateContextHistory()
 {
     //are we the dominant pane? The thinking here is that if our clerk is controlling the record tree bar, then we are.
     if (Clerk.IsControllingTheRecordTreeBar)
     {
         //add our current state to the history system
         string toolName = m_mediator.PropertyTable.GetStringProperty("currentContentControl", "");
         int    hvo      = -1;
         if (Clerk.CurrentObject != null)
         {
             hvo = Clerk.CurrentObject.Hvo;
         }
         FdoCache cache = Cache;
         m_mediator.SendMessage("AddContextToHistory", FwLink.Create(toolName,
                                                                     cache.GetGuidFromId(hvo), cache.ServerName, cache.DatabaseName), false);
     }
 }
示例#8
0
        /// <summary>
        /// Try to find a WfiWordform object corresponding the the focus selection.
        /// If successful return its guid, otherwise, return Guid.Empty.
        /// </summary>
        /// <returns></returns>
        internal static Guid ActiveWordform(FdoCache cache)
        {
            if (!(FwApp.App is FwXApp))
            {
                return(Guid.Empty);
            }
            FwXWindow window = (FwApp.App as FwXApp).ActiveMainWindow as FwXWindow;

            if (window == null)
            {
                return(Guid.Empty);
            }
            IRootSite activeView = window.ActiveView;

            if (activeView == null)
            {
                return(Guid.Empty);
            }
            List <IVwRootBox> roots = activeView.AllRootBoxes();

            if (roots.Count < 1)
            {
                return(Guid.Empty);
            }
            SelectionHelper helper = SelectionHelper.Create(roots[0].Site);

            if (helper == null)
            {
                return(Guid.Empty);
            }
            ITsString word = helper.SelectedWord;

            if (word == null || word.Length == 0)
            {
                return(Guid.Empty);
            }
            int hvoWordform = cache.LangProject.WordformInventoryOA.GetWordformId(word);

            if (hvoWordform == 0 || cache.IsDummyObject(hvoWordform))
            {
                return(Guid.Empty);
            }
            return(cache.GetGuidFromId(hvoWordform));
        }
示例#9
0
        internal int DisplayChooser(string fieldName, string linkText, string toolName, string guiControl, Set <int> candidates)
        {
            int hvo = 0;

            ObjectLabelCollection labels = new ObjectLabelCollection(m_cache, candidates);

            using (SimpleListChooser chooser = new SimpleListChooser(m_persistenceProvider, labels, fieldName))
            {
                chooser.Cache        = m_cache;
                chooser.TextParamHvo = m_cache.LangProject.PhonologicalDataOAHvo;
                chooser.AddLink(linkText, SimpleListChooser.LinkType.kGotoLink,
                                FwLink.Create(toolName, m_cache.GetGuidFromId(chooser.TextParamHvo), m_cache.ServerName,
                                              m_cache.DatabaseName));
                chooser.ReplaceTreeView(m_mediator, guiControl);
                if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.RegRuleFormulaControl)
                {
                    chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-RegRuleFormulaControl");
                }
                else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl)
                {
                    chooser.SetHelpTopic("khtpChoose-Grammar-PhonFeats-MetaRuleFormulaControl");
                }
                else if (this.Parent is SIL.FieldWorks.XWorks.MorphologyEditor.MetaRuleFormulaControl)
                {
                    chooser.SetHelpTopic("khtpChoose-LexiconEdit-PhonFeats-AffixRuleFormulaControl");
                }

                DialogResult res = chooser.ShowDialog();
                if (res != DialogResult.Cancel)
                {
                    chooser.HandleAnyJump();

                    if (chooser.ChosenOne != null)
                    {
                        hvo = chooser.ChosenOne.Hvo;
                    }
                }
            }

            return(hvo);
        }
示例#10
0
        protected override void ShowRecord()
        {
            RecordClerk clerk = Clerk;

            // See if it is showing the same record, as before.
            if (m_currentObject != null && clerk.CurrentObject != null &&
                m_currentIndex == clerk.CurrentIndex &&
                m_currentObject.Hvo == clerk.CurrentObject.Hvo)
            {
                SetInfoBarText();
                return;
            }

            // See if the main owning object has changed.
            if (clerk.OwningObject.Hvo != m_hvoOwner)
            {
                m_hvoOwner = clerk.OwningObject.Hvo;
                m_mainView.ResetRoot(m_hvoOwner);
            }

            m_currentObject = clerk.CurrentObject;
            m_currentIndex  = clerk.CurrentIndex;
            //add our current state to the history system
            string toolName = m_mediator.PropertyTable.GetStringProperty(
                "currentContentControl", "");
            int hvo = -1;

            if (clerk.CurrentObject != null)
            {
                hvo = clerk.CurrentObject.Hvo;
            }
            FdoCache cache = Cache;

            m_mediator.SendMessage("AddContextToHistory",
                                   FwLink.Create(toolName, cache.GetGuidFromId(hvo), cache.ServerName,
                                                 cache.DatabaseName), false);

            SelectAndScrollToCurrentRecord();
            base.ShowRecord();
        }
示例#11
0
        public void DeleteFootnoteInRangeSelectionAcrossMultipleBooks()
        {
            SetupSelectionForRangeAcrossBooks();
            IScripture scr = m_cache.LangProject.TranslatedScriptureOA;

            ScrFootnote[] footnotes     = new ScrFootnote[4];
            Guid[]        guidFootnotes = new Guid[4];
            int[]         hvoParas      = new int[4];

            // First get the footnotes we're deleting from JAMES.
            IScrBook book = (IScrBook)scr.ScriptureBooksOS[1];

            footnotes[0] = new ScrFootnote(m_cache, book.FootnotesOS.HvoArray[31]);
            footnotes[1] = new ScrFootnote(m_cache, book.FootnotesOS.HvoArray[32]);

            // First get the footnotes we're deleting from JUDE.
            book         = (IScrBook)scr.ScriptureBooksOS[2];
            footnotes[2] = new ScrFootnote(m_cache, book.FootnotesOS.HvoArray[0]);
            footnotes[3] = new ScrFootnote(m_cache, book.FootnotesOS.HvoArray[1]);

            for (int i = 0; i < 4; i++)
            {
                guidFootnotes[i] = m_cache.GetGuidFromId(footnotes[i].Hvo);
                hvoParas[i]      = footnotes[i].ContainingParagraphHvo;
            }

            m_footnoteView.DeleteFootnote();

            foreach (IStFootnote footnote in footnotes)
            {
                Assert.IsFalse(m_cache.IsRealObject(footnote.Hvo, StFootnote.kClassId));
            }

            // now make sure that we don't find the footnote markers
            for (int i = 0; i < 4; i++)
            {
                Assert.IsFalse(IsFootnoteMarkerInText(hvoParas[i], guidFootnotes[i]),
                               "Footnote marker didn't get deleted from text");
            }
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commandObject"></param>
        /// <returns></returns>
        public virtual bool OnJumpToTool(object commandObject)
        {
            FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");

            XCore.Command cmd       = (XCore.Command)commandObject;
            string        className = SIL.Utils.XmlUtils.GetManditoryAttributeValue(cmd.Parameters[0], "className");
            int           hvo       = 0;

            if (className == "WfiAnalysis")
            {
                IWfiAnalysis anal = Analysis;
                if (anal != null)
                {
                    hvo = anal.Hvo;
                }
            }
            else if (className == "WfiGloss")
            {
                if (m_dataEntryForm != null && m_dataEntryForm.CurrentSlice != null &&
                    CurrentSliceObject != null && CurrentSliceObject.ClassID == WfiGloss.kclsidWfiGloss)
                {
                    hvo = CurrentSliceObject.Hvo;
                }
            }
            if (hvo != 0)
            {
                string tool = SIL.Utils.XmlUtils.GetManditoryAttributeValue(cmd.Parameters[0], "tool");
                m_mediator.PostMessage("FollowLink",
                                       SIL.FieldWorks.FdoUi.FwLink.Create(tool, cache.GetGuidFromId(hvo), cache.ServerName, cache.DatabaseName));
                return(true);
            }
            else
            {
                return(false);
            }
        }