internal RecordClerk CreateClerk(bool loadList)
        {
            var clerk = RecordClerkFactory.CreateClerk(m_mediator, m_configurationParameters, loadList);

            clerk.Editable = XmlUtils.GetOptionalBooleanAttributeValue(m_configurationParameters, "allowInsertDeleteRecord", true);
            return(clerk);
        }
Exemple #2
0
        public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();
            _mediator      = mediator;        //allows the Cache property to function
            _propertyTable = propertyTable;
            _cache         = _propertyTable.GetValue <LcmCache>("cache");

            string name  = XmlUtils.GetAttributeValue(configurationParameters, "clerk");
            var    clerk = RecordClerk.FindClerk(_propertyTable, name);

            m_clerk = (clerk == null || clerk is TemporaryRecordClerk) ?
                      (InterlinearTextsRecordClerk)RecordClerkFactory.CreateClerk(mediator, _propertyTable, configurationParameters, true) :
                      (InterlinearTextsRecordClerk)clerk;
            // There's no record bar for it to control, but it should control the staus bar (e.g., it should update if we change
            // the set of selected texts).
            m_clerk.ActivateUI(true);
            _areaName = XmlUtils.GetOptionalAttributeValue(configurationParameters, "area", "unknown");
            RebuildStatisticsTable();
            //add ourselves so that we can receive messages (related to the text selection currently misnamed AddTexts)
            mediator.AddColleague(this);
            //add our current state to the history system
            string toolName = _propertyTable.GetStringProperty("currentContentControl", "");

            mediator.SendMessage("AddContextToHistory", new FwLinkArgs(toolName, Guid.Empty), false);
        }
            public static ClerkActivator ActivateClerkMatchingExportType(string exportType, Mediator mediator)
            {
                var          isDictionary = exportType == DictionaryType;
                const string area         = "lexicon";
                var          tool         = isDictionary ? "lexiconDictionary" : "reversalToolEditComplete";
                var          collector    = new XmlNode[1];
                var          parameter    = new Tuple <string, string, XmlNode[]>(area, tool, collector);

                mediator.SendMessage("GetContentControlParameters", parameter);
                var parameters   = collector[0].SelectSingleNode(".//parameters[@clerk]");
                var currentClerk = mediator.PropertyTable.GetValue("ActiveClerk", null) as RecordClerk;

                if (DoesClerkMatchParams(currentClerk, parameters))
                {
                    return(null);                    // No need to juggle clerks if the one we want is already active
                }
                var tempClerk = isDictionary ? s_dictionaryClerk : s_reversalIndexClerk;

                if (tempClerk == null || tempClerk.IsDisposed)
                {
                    tempClerk = RecordClerk.FindClerk(mediator, isDictionary ? "entries" : "AllReversalEntries");
                    if (tempClerk == null || tempClerk.IsDisposed)
                    {
                        tempClerk = RecordClerkFactory.CreateClerk(mediator, parameters, true);
                    }
                    CacheClerk(exportType, tempClerk);
                }
                tempClerk.ActivateUI(true, false);
                tempClerk.UpdateList(true, true);
                return(new ClerkActivator(currentClerk));                // ensure the current active clerk is reactivated after we use the temporary clerk.
            }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            FwRegistrySettings.Init();
            m_application = new MockFwXApp(new MockFwManager {
                Cache = Cache
            }, null, null);
            var configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname);

            m_window = new MockFwXWindow(m_application, configFilePath);
            ((MockFwXWindow)m_window).Init(Cache);             // initializes Mediator values
            m_mediator = m_window.Mediator;
            m_mediator.AddColleague(new StubContentControlProvider());
            m_window.LoadUI(configFilePath);
            // set up clerk to allow DictionaryPublicationDecorator to be created during the UploadToWebonaryController driven export
            const string reversalIndexClerk = @"<?xml version='1.0' encoding='UTF-8'?>
			<root>
				<clerks>
					<clerk id='entries'>
						<recordList owner='LexDb' property='Entries'/>
					</clerk>
				</clerks>
				<tools>
					<tool label='Dictionary' value='lexiconDictionary' icon='DocumentView'>
						<control>
							<dynamicloaderinfo assemblyPath='xWorks.dll' class='SIL.FieldWorks.XWorks.XhtmlDocView'/>
							<parameters area='lexicon' clerk='entries' layout='Bartholomew' layoutProperty='DictionaryPublicationLayout' editable='false' configureObjectName='Dictionary'/>
						</control>
					</tool>
				</tools>
			</root>"            ;
            var          doc = new XmlDocument();

            doc.LoadXml(reversalIndexClerk);
            XmlNode clerkNode = doc.SelectSingleNode("//tools/tool[@label='Dictionary']//parameters[@area='lexicon']");

            m_Clerk = RecordClerkFactory.CreateClerk(m_mediator, clerkNode, false);
            m_mediator.PropertyTable.SetProperty("ActiveClerk", m_Clerk);
            m_mediator.PropertyTable.SetProperty("ToolForAreaNamed_lexicon", "lexiconDictionary");
            Cache.ProjectId.Path = Path.Combine(FwDirectoryFinder.SourceDirectory, "xWorks/xWorksTests/TestData/");
            // setup style sheet and style to allow the css to generate during the UploadToWebonaryController driven export
            m_styleSheet  = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
            m_owningTable = new StyleInfoTable("AbbySomebody", (IWritingSystemManager)Cache.WritingSystemFactory);
            var fontInfo     = new FontInfo();
            var letHeadStyle = new TestStyle(fontInfo, Cache)
            {
                Name = CssGenerator.LetterHeadingStyleName, IsParagraphStyle = false
            };
            var dictNormStyle = new TestStyle(fontInfo, Cache)
            {
                Name = CssGenerator.DictionaryNormal, IsParagraphStyle = true
            };

            m_styleSheet.Styles.Add(letHeadStyle);
            m_styleSheet.Styles.Add(dictNormStyle);
            m_owningTable.Add(CssGenerator.LetterHeadingStyleName, letHeadStyle);
            m_owningTable.Add(CssGenerator.DictionaryNormal, dictNormStyle);
        }
Exemple #5
0
        private void AddClerkToConfigForList(ICmPossibilityList curList, XmlNode windowConfig)
        {
            // Put the clerk node in the window configuration for this list
            var clerkNode = CreateCustomClerkNode(curList);

            windowConfig.SelectSingleNode(GetListClerksXPath()).AppendChild(
                windowConfig.OwnerDocument.ImportNode(clerkNode, true));

            // THEN create the clerk
            var     toolParamNodeXPath = GetToolParamNodeXPath(curList);
            XmlNode x = windowConfig.SelectSingleNode(toolParamNodeXPath);

            if (x == null)
            {
                x = FindToolParamNode(windowConfig, curList);
            }
            // REVIEW: I'm not sure where the created RecordClerk gets disposed
            RecordClerkFactory.CreateClerk(m_mediator, x, true);
        }
Exemple #6
0
        private void AddConfigurableControls()
        {
            // Load the controls.

            // 1. Initialize the preview pane (lower pane)
            m_previewPane            = new XmlView(0, "publicationNew", false);
            m_previewPane.Cache      = m_cache;
            m_previewPane.StyleSheet = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);

            BasicPaneBarContainer pbc = new BasicPaneBarContainer();

            pbc.Init(m_mediator, m_propertyTable, m_previewPane);
            pbc.Dock         = DockStyle.Fill;
            pbc.PaneBar.Text = LexEdStrings.ksFindExampleSentenceDlgPreviewPaneTitle;
            panel2.Controls.Add(pbc);
            if (m_previewPane.RootBox == null)
            {
                m_previewPane.MakeRoot();
            }

            // 2. load the browse view. (upper pane)
            XmlNode xnBrowseViewControlParameters = this.BrowseViewControlParameters;

            // First create our Clerk, since we can't set it's OwningObject via the configuration/mediator/PropertyTable info.
            m_clerk = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, xnBrowseViewControlParameters, true);
            m_clerk.OwningObject = m_owningSense;

            m_rbv = DynamicLoader.CreateObject(xnBrowseViewControlParameters.ParentNode.SelectSingleNode("dynamicloaderinfo")) as ConcOccurrenceBrowseView;
            m_rbv.Init(m_mediator, m_propertyTable, xnBrowseViewControlParameters, m_previewPane, m_clerk.VirtualListPublisher);
            m_rbv.CheckBoxChanged += m_rbv_CheckBoxChanged;
            // add it to our controls.
            BasicPaneBarContainer pbc1 = new BasicPaneBarContainer();

            pbc1.Init(m_mediator, m_propertyTable, m_rbv);
            pbc1.BorderStyle  = BorderStyle.FixedSingle;
            pbc1.Dock         = DockStyle.Fill;
            pbc1.PaneBar.Text = LexEdStrings.ksFindExampleSentenceDlgBrowseViewPaneTitle;
            panel1.Controls.Add(pbc1);

            CheckAddBtnEnabling();
        }
            internal void LoadList(SplitterPanel parent, ICmObject mainObject)
            {
                parent.FindForm().UseWaitCursor = true;
                parent.SuspendLayout();
                m_mediator.RemoveColleague(this);
                if (m_currentControl != null)
                {
                    m_currentControl.SuspendLayout();
                    m_currentControl.Parent.Controls.Remove(m_currentControl);
                    m_currentControl.Dispose();
                    m_currentControl = null;
                }

                // Add the new browse view, if available in the config node.
                if (m_configurationNode.HasChildNodes)
                {
                    XmlNode parms = m_configurationNode.SelectSingleNode("parameters");
                    if (mainObject != null)
                    {
                        RecordClerk clerk = (RecordClerk)m_mediator.PropertyTable.GetValue("RecordClerk-" + parms.Attributes["clerk"].Value);
                        if (clerk == null)
                        {
                            clerk = RecordClerkFactory.CreateClerk(m_mediator, parms);
                        }
                        clerk.OwningObject = mainObject;
                    }
                    RecordBrowseView browseView = new RecordBrowseView();
                    browseView.SuspendLayout();
                    browseView.Dock  = DockStyle.Fill;
                    m_currentControl = browseView;
                    parent.Controls.Add(browseView);
                    browseView.Init(m_mediator, parms);
                    m_mediator.RemoveColleague(browseView);
                    browseView.BringToFront();
                    browseView.ResumeLayout();
                    m_mediator.AddColleague(this);
                }

                parent.ResumeLayout();
                parent.FindForm().UseWaitCursor = false;
            }
Exemple #8
0
        /// <summary>
        /// Initilize the gui control.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="configurationNode">NB: In this case it is the main 'window' element node,
        /// se we have to drill down to find the control definition node(s).</param>
        /// <param name="sourceObject"></param>
        public void Init(Mediator mediator, XmlNode configurationNode, ICmObject sourceObject)
        {
            CheckDisposed();

            Debug.Assert(mediator != null);
            Debug.Assert(configurationNode != null);
            Debug.Assert(sourceObject != null && (sourceObject is IWfiWordform || sourceObject is IWfiAnalysis || sourceObject is IWfiGloss));

            m_cache             = sourceObject.Cache;
            m_mediator          = mediator;
            m_configurationNode = configurationNode;
            m_sourceObject      = sourceObject;
            if (sourceObject is IWfiWordform)
            {
                m_wordform = sourceObject as IWfiWordform;
            }
            else
            {
                IWfiAnalysis anal = null;
                if (sourceObject is IWfiAnalysis)
                {
                    anal = sourceObject as IWfiAnalysis;
                }
                else
                {
                    anal = WfiAnalysis.CreateFromDBObject(m_cache, sourceObject.OwnerHVO);
                }
                m_wordform = WfiWordform.CreateFromDBObject(m_cache, anal.OwnerHVO);
            }

            m_mediator.PropertyTable.SetProperty("IgnoreStatusPanel", true);
            m_mediator.PropertyTable.SetPropertyPersistence("IgnoreStatusPanel", false);
            m_progAdvInd = new ProgressReporting(m_toolStripProgressBar);

            // Gather up the nodes.
            string  xpathBase  = "/window/controls/parameters[@id='guicontrols']/guicontrol[@id='{0}']/parameters[@id='{1}']";
            string  xpath      = String.Format(xpathBase, "WordformConcordanceBrowseView", "WordformInTwficsOccurrenceList");
            XmlNode configNode = m_configurationNode.SelectSingleNode(xpath);
            // And create the RecordClerks.
            RecordClerk clerk = RecordClerkFactory.CreateClerk(m_mediator, configNode);

            clerk.ProgressReporter = m_progAdvInd;
            m_recordClerks[WfiWordform.kclsidWfiWordform]       = clerk;
            m_configurationNodes[WfiWordform.kclsidWfiWordform] = configNode;

            xpath                  = String.Format(xpathBase, "AnalysisConcordanceBrowseView", "AnalysisInTwficsOccurrenceList");
            configNode             = m_configurationNode.SelectSingleNode(xpath);
            clerk                  = RecordClerkFactory.CreateClerk(m_mediator, configNode);
            clerk.ProgressReporter = m_progAdvInd;
            m_recordClerks[WfiAnalysis.kclsidWfiAnalysis]       = clerk;
            m_configurationNodes[WfiAnalysis.kclsidWfiAnalysis] = configNode;

            xpath                  = String.Format(xpathBase, "GlossConcordanceBrowseView", "GlossInTwficsOccurrenceList");
            configNode             = m_configurationNode.SelectSingleNode(xpath);
            clerk                  = RecordClerkFactory.CreateClerk(m_mediator, configNode);
            clerk.ProgressReporter = m_progAdvInd;
            m_recordClerks[WfiGloss.kclsidWfiGloss]       = clerk;
            m_configurationNodes[WfiGloss.kclsidWfiGloss] = configNode;

            int concordOnHvo = sourceObject.Hvo;

            Debug.Assert(m_wordform != null);
            Debug.Assert(concordOnHvo > 0);

            tvSource.Font = new Font("Arial", 9);
            tvTarget.Font = new Font("Arial", 9);

            TreeNode srcTnWf = new TreeNode();
            TreeNode tarTnWf = new TreeNode();

            StringUtils.InitIcuDataDir();               // used for normalizing strings to NFC
            tarTnWf.Text = srcTnWf.Text = StringUtils.NormalizeToNFC(MEStrings.ksNoAnalysis);
            tarTnWf.Tag  = srcTnWf.Tag = m_wordform.Hvo;
            tvSource.Nodes.Add(srcTnWf);
            tvTarget.Nodes.Add(tarTnWf);
            if ((int)srcTnWf.Tag == concordOnHvo)
            {
                tvSource.SelectedNode = srcTnWf;
            }
            int cnt = 0;

            // Note: the left side source tree only has human approved analyses,
            // since only those can have instances from text-land pointing at them.
            foreach (int humanApprovedAnalId in m_wordform.HumanApprovedAnalyses)
            {
                IWfiAnalysis anal      = WfiAnalysis.CreateFromDBObject(m_wordform.Cache, humanApprovedAnalId);
                TreeNode     srcTnAnal = new TreeNode();
                TreeNode     tarTnAnal = new TreeNode();
                tarTnAnal.Text = srcTnAnal.Text = StringUtils.NormalizeToNFC(
                    String.Format(MEStrings.ksAnalysisX, (++cnt).ToString()));
                tarTnAnal.Tag = srcTnAnal.Tag = anal.Hvo;
                srcTnWf.Nodes.Add(srcTnAnal);
                tarTnWf.Nodes.Add(tarTnAnal);
                if ((int)srcTnAnal.Tag == concordOnHvo)
                {
                    tvSource.SelectedNode = srcTnAnal;
                }
                foreach (WfiGloss gloss in anal.MeaningsOC)
                {
                    TreeNode     srcTnGloss = new TreeNode();
                    TreeNode     tarTnGloss = new TreeNode();
                    ITsString    tss        = gloss.Form.BestAnalysisAlternative;
                    ITsTextProps props      = tss.get_PropertiesAt(0);
                    int          nVar;
                    int          ws       = props.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
                    string       fontname = m_wordform.Cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws).DefaultMonospace;
                    tarTnGloss.NodeFont = new Font(fontname, 9);
                    srcTnGloss.NodeFont = new Font(fontname, 9);
                    tarTnGloss.Text     = srcTnGloss.Text = StringUtils.NormalizeToNFC(tss.Text);
                    tarTnGloss.Tag      = srcTnGloss.Tag = gloss.Hvo;
                    srcTnAnal.Nodes.Add(srcTnGloss);
                    tarTnAnal.Nodes.Add(tarTnGloss);
                    if ((int)srcTnGloss.Tag == concordOnHvo)
                    {
                        tvSource.SelectedNode = srcTnGloss;
                    }
                }
            }
            tvSource.ExpandAll();
            tvSource.SelectedNode.EnsureVisible();
            tvTarget.ExpandAll();
        }
Exemple #9
0
        /// <summary>
        /// Initilize the gui control.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="configurationNode">NB: In this case it is the main 'window' element node,
        /// se we have to drill down to find the control definition node(s).</param>
        /// <param name="sourceObject"></param>
        public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationNode, ICmObject sourceObject)
        {
            CheckDisposed();

            Debug.Assert(mediator != null);
            Debug.Assert(configurationNode != null);
            Debug.Assert(sourceObject != null && (sourceObject is IWfiWordform || sourceObject is IWfiAnalysis || sourceObject is IWfiGloss));

            m_cache             = sourceObject.Cache;
            m_mediator          = mediator;
            m_propertyTable     = propertyTable;
            m_configurationNode = configurationNode;
            if (sourceObject is IWfiWordform)
            {
                m_wordform = (IWfiWordform)sourceObject;
            }
            else
            {
                var anal = sourceObject is IWfiAnalysis
                                                                                ? (IWfiAnalysis)sourceObject
                                                                                : sourceObject.OwnerOfClass <IWfiAnalysis>();
                m_wordform = anal.OwnerOfClass <IWfiWordform>();
            }

            helpProvider.HelpNamespace = m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider").HelpFile;
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            helpProvider.SetHelpKeyword(this, m_propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider").GetHelpString(s_helpTopic));
            helpProvider.SetShowHelp(this, true);


            m_propertyTable.SetProperty("IgnoreStatusPanel", true, true);
            m_propertyTable.SetPropertyPersistence("IgnoreStatusPanel", false);
            m_progAdvInd = new ProgressReporting(m_toolStripProgressBar);

            // Gather up the nodes.
            const string xpathBase  = "/window/controls/parameters[@id='guicontrols']/guicontrol[@id='{0}']/parameters[@id='{1}']";
            var          xpath      = String.Format(xpathBase, "WordformConcordanceBrowseView", "WordformInSegmentsOccurrenceList");
            var          configNode = m_configurationNode.SelectSingleNode(xpath);
            // And create the RecordClerks.
            var clerk = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, configNode, true);

            clerk.ProgressReporter = m_progAdvInd;
            m_recordClerks[WfiWordformTags.kClassId]       = clerk;
            m_configurationNodes[WfiWordformTags.kClassId] = configNode;

            xpath                  = String.Format(xpathBase, "AnalysisConcordanceBrowseView", "AnalysisInSegmentsOccurrenceList");
            configNode             = m_configurationNode.SelectSingleNode(xpath);
            clerk                  = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, configNode, true);
            clerk.ProgressReporter = m_progAdvInd;
            m_recordClerks[WfiAnalysisTags.kClassId]       = clerk;
            m_configurationNodes[WfiAnalysisTags.kClassId] = configNode;

            xpath                  = String.Format(xpathBase, "GlossConcordanceBrowseView", "GlossInSegmentsOccurrenceList");
            configNode             = m_configurationNode.SelectSingleNode(xpath);
            clerk                  = RecordClerkFactory.CreateClerk(m_mediator, m_propertyTable, configNode, true);
            clerk.ProgressReporter = m_progAdvInd;
            m_recordClerks[WfiGlossTags.kClassId]       = clerk;
            m_configurationNodes[WfiGlossTags.kClassId] = configNode;

            Debug.Assert(m_wordform != null);
            Debug.Assert(sourceObject != null);

            tvSource.Font = new Font(MiscUtils.StandardSansSerif, 9);
            tvTarget.Font = new Font(MiscUtils.StandardSansSerif, 9);

            var srcTnWf = new TreeNode();
            var tarTnWf = new TreeNode();

            tarTnWf.Text = srcTnWf.Text = TsStringUtils.NormalizeToNFC(MEStrings.ksNoAnalysis);
            tarTnWf.Tag  = srcTnWf.Tag = m_wordform;
            tvSource.Nodes.Add(srcTnWf);
            tvTarget.Nodes.Add(tarTnWf);
            if (srcTnWf.Tag == sourceObject)
            {
                tvSource.SelectedNode = srcTnWf;
            }
            var cnt = 0;

            // Note: the left side source tree only has human approved analyses,
            // since only those can have instances from text-land pointing at them.
            foreach (var anal in m_wordform.HumanApprovedAnalyses)
            {
                var srcTnAnal = new TreeNode();
                var tarTnAnal = new TreeNode
                {
                    Text = srcTnAnal.Text = TsStringUtils.NormalizeToNFC(
                        String.Format(MEStrings.ksAnalysisX, (++cnt))),
                    Tag = srcTnAnal.Tag = anal
                };
                srcTnWf.Nodes.Add(srcTnAnal);
                tarTnWf.Nodes.Add(tarTnAnal);
                if (srcTnAnal.Tag == sourceObject)
                {
                    tvSource.SelectedNode = srcTnAnal;
                }
                foreach (var gloss in anal.MeaningsOC)
                {
                    var srcTnGloss = new TreeNode();
                    var tarTnGloss = new TreeNode();
                    var tss        = gloss.Form.BestAnalysisAlternative;
                    var props      = tss.get_PropertiesAt(0);
                    int nVar;
                    var ws       = props.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
                    var fontname = m_wordform.Cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName;
                    tarTnGloss.NodeFont = new Font(fontname, 9);
                    srcTnGloss.NodeFont = new Font(fontname, 9);
                    tarTnGloss.Text     = srcTnGloss.Text = TsStringUtils.NormalizeToNFC(tss.Text);
                    tarTnGloss.Tag      = srcTnGloss.Tag = gloss;
                    srcTnAnal.Nodes.Add(srcTnGloss);
                    tarTnAnal.Nodes.Add(tarTnGloss);
                    if (srcTnGloss.Tag == sourceObject)
                    {
                        tvSource.SelectedNode = srcTnGloss;
                    }
                }
            }
            tvSource.ExpandAll();
            tvSource.SelectedNode.EnsureVisible();
            tvTarget.ExpandAll();
        }
        public virtual void Init(Mediator mediator, XmlNode configurationParameters)
        {
            CheckDisposed();
            m_mediator                = mediator;
            m_helpTopicProvider       = m_mediator.HelpTopicProvider;
            m_configurationParameters = configurationParameters;
            m_cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
            string name = RecordClerk.GetCorrespondingPropertyName(XmlUtils.GetAttributeValue(configurationParameters, "clerk"));

            m_clerk = (OccurrencesOfSelectedUnit)m_mediator.PropertyTable.GetValue(name) ?? (OccurrencesOfSelectedUnit)RecordClerkFactory.CreateClerk(m_mediator, m_configurationParameters, true);
            m_clerk.ConcordanceControl = this;
        }