Ejemplo n.º 1
0
        /// <summary>
        /// Receives the broadcast message "PropertyChanged"
        /// </summary>
        public override void OnPropertyChanged(string name)
        {
            CheckDisposed();

            switch (name)
            {
            default:
                base.OnPropertyChanged(name);
                break;

            case "ReversalIndexHvo":
                ChangeOwningObjectIfPossible();
                break;

            case "ActiveClerk":
                RecordClerk activeClerk = (RecordClerk)m_mediator.PropertyTable.GetValue("ActiveClerk");
                if (activeClerk == this)
                {
                    ChangeOwningObjectIfPossible();
                }
                else
                {
                    base.OnPropertyChanged(name);
                }
                break;
            }
        }
Ejemplo n.º 2
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)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            base.Dispose(disposing);

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_vc != null)
                {
                    m_vc.Dispose();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_clerk = null;
            m_vc    = null;
            m_configurationParameters = null;
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public InfoPane(FdoCache cache, Mediator mediator, RecordClerk clerk)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            Initialize(cache, mediator, clerk);
        }
Ejemplo n.º 5
0
            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.
            }
Ejemplo n.º 6
0
        public bool OnDisplayExport(object commandObject,
                                    ref UIItemDisplayProperties display)
        {
            CheckDisposed();
            // In order for this menu to be visible and enabled it has to be in the correct area (lexicon)
            // and the right tool(s).
            // Tools that allow this menu, as far as I (RickM) can tell, as of 10 Aug 2007:
            // (areaChoice == "lexicon" or "words" or "grammar" or "lists"

            RecordClerk clerk      = Clerk;
            string      areaChoice = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
            //uncomment the following line if we need to turn on or off the Export menu item
            //for specific tools in the various areas of the application.
            //string toolChoice = m_mediator.PropertyTable.GetStringProperty("ToolForAreaNamed_lexicon", null);
            string toolChoice          = m_mediator.PropertyTable.GetStringProperty("grammarSketch_grammar", null);
            bool   inFriendlyTerritory = (areaChoice == "lexicon" ||
                                          areaChoice == "notebook" ||
                                          clerk.Id == "concordanceWords" ||
                                          areaChoice == "grammar" ||
                                          areaChoice == "lists");

            if (inFriendlyTerritory)
            {
                display.Enabled = display.Visible = true;
            }
            else
            {
                display.Enabled = display.Visible = false;
            }

            return(true);
        }
Ejemplo n.º 7
0
        private void InitializeInfoView(RecordClerk clerk)
        {
            if (m_mediator == null)
            {
                return;
            }
            XmlNode xnWindow = (XmlNode)m_mediator.PropertyTable.GetValue("WindowConfiguration");

            if (xnWindow == null)
            {
                return;
            }
            XmlNode xnControl = xnWindow.SelectSingleNode(
                "controls/parameters/guicontrol[@id=\"TextInformationPane\"]/control/parameters");

            if (xnControl == null)
            {
                return;
            }
            m_xrev       = new InterlinearTextsRecordEditView();
            m_xrev.Clerk = clerk;
            m_xrev.Init(m_mediator, xnControl);
            m_xrev.Dock = DockStyle.Fill;
            this.Controls.Add(m_xrev);
        }
Ejemplo n.º 8
0
        private void InitializeInfoView(RecordClerk clerk)
        {
            if (m_mediator == null)
            {
                return;
            }
            if (m_propertyTable == null)
            {
                return;
            }
            var xnWindow = m_propertyTable.GetValue <XmlNode>("WindowConfiguration");

            if (xnWindow == null)
            {
                return;
            }
            XmlNode xnControl = xnWindow.SelectSingleNode(
                "controls/parameters/guicontrol[@id=\"TextInformationPane\"]/control/parameters");

            if (xnControl == null)
            {
                return;
            }
            var activeClerk = m_propertyTable.GetValue <RecordClerk>("ActiveClerk");
            var toolChoice  = m_propertyTable.GetStringProperty("currentContentControl", null);

            if (m_xrev != null)
            {
                //when re-using the infoview we want to remove and dispose of the old recordeditview and
                //associated datatree. (LT-13216)
                Controls.Remove(m_xrev);
                m_xrev.Dispose();
            }
            m_xrev = new InterlinearTextsRecordEditView(this);
            if (clerk.GetType().Name == "InterlinearTextsRecordClerk")
            {
                m_xrev.Clerk = clerk;
            }
            else
            {
                //We want to make sure that the following initialization line will initialize this
                //clerk if we haven't already set it. Without this assignment to null, the InfoPane
                //misbehaves in the Concordance view (it uses the filter from the InterlinearTexts view)
                m_xrev.Clerk = null;
            }
            m_xrev.Init(m_mediator, m_propertyTable, xnControl);             // <-- This call will change the ActiveClerk
            DisplayCurrentRoot();
            m_xrev.Dock = DockStyle.Fill;
            Controls.Add(m_xrev);
            // There are times when moving to the InfoPane causes the wrong ActiveClerk to be set.
            // See FWR-3390 (and InterlinearTextsRecordClerk.OnDisplayInsertInterlinText).
            var activeClerkNew = m_propertyTable.GetValue <RecordClerk>("ActiveClerk");

            if (toolChoice != "interlinearEdit" && activeClerk != null && activeClerk != activeClerkNew)
            {
                m_propertyTable.SetProperty("ActiveClerk", activeClerk, true);
                activeClerk.ActivateUI(true);
            }
        }
        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);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Save the configuration parameters in case we want to use them locally.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="configurationParameters"></param>
        public override void Init(Mediator mediator, System.Xml.XmlNode configurationParameters)
        {
            CheckDisposed();

            base.Init(mediator, configurationParameters);
            m_configurationParameters = configurationParameters;
            m_clerk = ToolConfiguration.FindClerk(m_mediator, m_configurationParameters);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Save the configuration parameters in case we want to use them locally.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="configurationParameters"></param>
        public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();

            base.Init(mediator, propertyTable, configurationParameters);
            m_configurationParameters = configurationParameters;
            m_clerk      = ToolConfiguration.FindClerk(m_propertyTable, m_configurationParameters);
            m_styleSheet = FontHeightAdjuster.StyleSheetFromPropertyTable(m_propertyTable);
        }
Ejemplo n.º 12
0
        public InfoPane(FdoCache cache, Mediator mediator, RecordClerk clerk)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            m_cache    = cache;
            m_mediator = mediator;
            InitializeInfoView(clerk);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Save the configuration parameters in case we want to use them locally.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="configurationParameters"></param>
        public override void Init(Mediator mediator, System.Xml.XmlNode configurationParameters)
        {
            CheckDisposed();

            base.Init(mediator, configurationParameters);
            m_configurationParameters = configurationParameters;
            m_clerk      = ToolConfiguration.FindClerk(m_mediator, m_configurationParameters);
            m_styleSheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
        }
Ejemplo n.º 14
0
        public bool IsSortingOnAlphaHeaders()
        {
            var clerk = m_propertyTable.GetValue <RecordClerk>("ActiveClerk", null);

            int[] entriesToSave;
            var   publicationDecorator =
                ConfiguredXHTMLGenerator.GetPublicationDecoratorAndEntries(m_propertyTable, out entriesToSave, "Dictionary");

            return(RecordClerk.IsClerkSortingByHeadword(clerk));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Record browse view implements ShowRecord by scrolling to show the current record. However,
        /// that may well not be all the response to selecting that record in the Clerk: for example,
        /// another pane may show a more detailed view of the selected record. Therefore, RecordBrowseView
        /// never claims to have 'handled' this event.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns>
        /// false; we didn't fully handle it, even though we may have done something.
        /// </returns>
        public override bool OnRecordNavigation(object argument)
        {
            CheckDisposed();

            // Can't do anything if it isn't fully initialized,
            // and we don't want to do anything, if we are told not to.
            if (!m_fullyInitialized || m_suppressRecordNavigation)
            {
                return(false);
            }
            Debug.Assert(m_browseViewer != null, "RecordBrowseView.SetupDataContext() has to be called before RecordBrowseView.OnRecordNavigation().");

            if (m_browseViewer == null || m_browseViewer.BrowseView == null || m_browseViewer.BrowseView.RootBox == null)
            {
                return(false);                // can't do anything useful without a root box to select in.
            }
            var rni = (RecordNavigationInfo)argument;

            m_suppressShowRecord       = rni.SkipShowRecord;
            m_suppressRecordNavigation = rni.SuppressSaveOnChangeRecord;
            bool bvEnabled = m_browseViewer.Enabled;

            if (rni.SuppressFocusChange && bvEnabled)
            {
                m_browseViewer.Enabled = false;
            }
            try
            {
                RecordClerk clerk        = Clerk;
                RecordClerk sendingClerk = RecordNavigationInfo.GetSendingClerk(argument);
                // NOTE: If the clerk's current index is less than zero,
                // or greater than the number of objects in the vector,
                // SelectedIndex will assert in a debug build,
                // and throw an exception in a release build.
                if (clerk != null && sendingClerk == clerk && clerk.IsActiveInGui)
                {
                    m_browseViewer.SelectedIndex = clerk.CurrentIndex;
                    // go ahead and SetInfoBarText even if we didn't change indices
                    // we may have changed objects or root object classes (from Entries to Senses)
                    SetInfoBarText();
                }
                //base.OnRecordNavigation(argument);
            }
            finally
            {
                m_suppressShowRecord       = false;
                m_suppressRecordNavigation = false;
                if (rni.SuppressFocusChange && bvEnabled)
                {
                    m_browseViewer.Enabled = true;
                }
            }

            return(false);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Have the utility do what it does.
        /// </summary>
        public void Process()
        {
            Debug.Assert(m_dlg != null);
            FdoCache   cache       = (FdoCache)m_dlg.Mediator.PropertyTable.GetValue("cache");
            List <int> wordformIds = DbOps.ReadIntsFromCommand(
                cache,
                "SELECT Id FROM WfiWordform",
                null);
            int curObjId = 0;

            if (m_dlg.Mediator != null)
            {
                Mediator    mediator    = m_dlg.Mediator;
                RecordClerk activeClerk = (RecordClerk)mediator.PropertyTable.GetValue("ActiveClerk");
                if (activeClerk != null && activeClerk.Id == "concordanceWords" && activeClerk.CurrentObject != null)
                {
                    curObjId = activeClerk.CurrentObject.Hvo;
                }
            }

            // Set up progress bar.
            m_dlg.ProgressBar.Minimum = 0;
            m_dlg.ProgressBar.Maximum = wordformIds.Count;
            m_dlg.ProgressBar.Step    = 1;

            // stop parser if it's running.
            m_dlg.Mediator.SendMessage("StopParser", null);

            if (wordformIds.Count > 0)
            {
                if (cache.DatabaseAccessor.IsTransactionOpen())
                {
                    cache.DatabaseAccessor.CommitTrans();
                }
                foreach (int wfId in wordformIds)
                {
                    cache.DatabaseAccessor.BeginTrans();
                    DbOps.ExecuteStoredProc(
                        cache,
                        string.Format("EXEC RemoveParserApprovedAnalyses$ {0}", wfId),
                        null);
                    cache.DatabaseAccessor.CommitTrans();
                    using (WfiWordformUi wfui = new WfiWordformUi(WfiWordform.CreateFromDBObject(cache, wfId)))
                    {
                        wfui.UpdateWordsToolDisplay(curObjId, false, false, true, true);
                    }
                    m_dlg.ProgressBar.PerformStep();
                }
            }
            else
            {
                m_dlg.ProgressBar.PerformStep();
            }
        }
Ejemplo n.º 17
0
        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;
        }
Ejemplo n.º 18
0
        protected override void SetupDataContext()
        {
            TriggerMessageBoxIfAppropriate();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            //m_flid = RecordClerk.GetFlidOfVectorFromName(m_vectorName, Cache, out m_owningObject);
            RecordClerk clerk = Clerk;

            clerk.ActivateUI(false);
            m_fakeFlid = clerk.VirtualFlid;
            // retrieve persisted clerk index and set it.
            int idx = m_mediator.PropertyTable.GetIntProperty(clerk.PersistedIndexProperty, -1, PropertyTable.SettingsGroup.LocalSettings);

            if (idx >= 0 && !clerk.HasEmptyList)
            {
                int idxOld = clerk.CurrentIndex;
                try
                {
                    clerk.JumpToIndex(idx);
                }
                catch
                {
                    clerk.JumpToIndex(idxOld >= 0 ? idxOld : 0);
                }
            }
            clerk.SelectedRecordChanged();
            m_hvoOwner = clerk.OwningObject.Hvo;

            clerk.IsDefaultSort = false;

            // Create the main view

            // Review JohnT: should it be m_configurationParameters or .FirstChild?
            m_mainView = new XmlSeqView(m_hvoOwner, m_fakeFlid, m_configurationParameters);
            m_mainView.Init(m_mediator, m_configurationParameters);             // Required call to xCore.Colleague.
            m_mainView.Dock  = System.Windows.Forms.DockStyle.Fill;
            m_mainView.Cache = Cache;
            m_mainView.SelectionChangedEvent +=
                new FwSelectionChangedEventHandler(OnSelectionChanged);
            m_mainView.ShowRangeSelAfterLostFocus = true;               // This makes selections visible.
            // If the rootsite doesn't have a rootbox, we can't display the record!
            // Calling ShowRecord() from InitBase() sets the state to appear that we have
            // displayed (and scrolled), even though we haven't.  See LT-7588 for the effect.
            m_mainView.MakeRoot();
            SetupStylesheet();
            Controls.Add(m_mainView);
            if (Controls.Count == 2)
            {
                Controls.SetChildIndex(m_mainView, 1);
                m_mainView.BringToFront();
            }
            m_fullyInitialized = true;             // Review JohnT: was this really the crucial last step?
        }
Ejemplo n.º 19
0
            private static void CacheClerk(string clerkType, RecordClerk clerk)
            {
                switch (clerkType)
                {
                case DictionaryType:
                    s_dictionaryClerk = clerk;
                    break;

                case ReversalType:
                    s_reversalIndexClerk = clerk;
                    break;
                }
            }
Ejemplo n.º 20
0
            private static bool DoesClerkMatchParams(RecordClerk clerk, XmlNode parameters)
            {
                if (clerk == null)
                {
                    return(false);
                }
                var atts = parameters.Attributes;

                if (atts == null)
                {
                    return(false);
                }
                var id = atts["clerk"].Value;

                return(id == clerk.Id);
            }
Ejemplo n.º 21
0
        /// <summary>
        /// Receives the broadcast message "PropertyChanged"
        /// </summary>
        public override void OnPropertyChanged(string name)
        {
            CheckDisposed();

            var window = m_propertyTable.GetValue <FwXWindow>("window");

            if (window != null)
            {
                window.ClearInvalidatedStoredData();
            }
            switch (name)
            {
            default:
                base.OnPropertyChanged(name);
                break;

            case "ReversalIndexGuid":
                ChangeOwningObjectIfPossible();
                break;

            case "ToolForAreaNamed_lexicon":
                int rootIndex = GetRootIndex(m_list.CurrentIndex);
                JumpToIndex(rootIndex);
                base.OnPropertyChanged(name);
                break;

            case "ActiveClerk":
                RecordClerk activeClerk = m_propertyTable.GetValue <RecordClerk>("ActiveClerk");
                if (activeClerk == this)
                {
                    ChangeOwningObjectIfPossible();
                }
                else
                {
                    base.OnPropertyChanged(name);
                }
                break;

            case "ReversalIndexPublicationLayout":
                // When the user chooses a different reversal index configuration from the drop-down menu,
                // set the list of associated reversal index entries.
                DictionaryConfigurationUtils.SetReversalIndexGuidBasedOnReversalIndexConfiguration(m_propertyTable, Cache);
                break;
            }
        }
Ejemplo n.º 22
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="argument"></param>
            /// <returns>
            /// true; we fully handled it.
            /// </returns>
            public bool OnRecordNavigation(object argument)
            {
                RecordNavigationInfo rni   = argument as RecordNavigationInfo;
                RecordClerk          clerk = rni.Clerk;
                string clerkId             = clerk.Id;
                string myClerkId           = m_configurationNode.SelectSingleNode("parameters").Attributes["clerk"].Value;

                if (clerk.Id == myClerkId)
                {
                    MainControl.SelectedFinder = rni.Clerk.CurrentObject;

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Ejemplo n.º 23
0
        /// <summary>
        /// Initialize this as an IxCoreColleague
        /// </summary>
        /// <remarks> subclasses must call this from their Init.
        /// This was done, rather than providing an Init() here in the normal way,
        /// to drive home the point that the subclass must set m_fullyInitialized
        /// to true when it is fully initialized.</remarks>
        /// <param name="mediator"></param>
        /// <param name="configurationParameters"></param>
        protected void InitBase(Mediator mediator, XmlNode configurationParameters)
        {
            Debug.Assert(m_fullyInitialized == false, "No way we are fully initialized yet!");

            m_mediator = mediator;
            m_configurationParameters = configurationParameters;

            ReadParameters();

            RecordClerk clerk = ExistingClerk;

            if (clerk == null)
            {
                // NOTE: new clerks do not typically complete ReloadList()
                // until Clerk.ActivateUI() is set (eg. here in SetupDataContext()).
                // however, we should further delay loading the list
                // if the subclass is initializing sorters/filters.
                // so we use ListUpdateHelper below to delay reloading the list.
                clerk = Clerk;
                Debug.Assert(clerk != null);
            }
            // suspend any loading of the Clerk's list items until after a
            // subclass (possibly) initializes sorters/filters
            // in SetupDataContext()
            using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(clerk))
            {
                luh.ClearBrowseListUntilReload = true;
                clerk.UpdateOwningObjectIfNeeded();
                SetTreebarAvailability();
                AddPaneBar();

                // NB: It is critical that we get added *after* our RecordClerk,
                // so that it will get messages, for example about a change of cache, before we do.
                mediator.AddColleague(this);
                SetupDataContext();
            }
            // In case it hasn't yet been loaded, load it!  See LT-10185.
            if (!Clerk.ListLoadingSuppressed && Clerk.RequestedLoadWhileSuppressed)
            {
                Clerk.UpdateList(true, true);
            }
            ShowRecord();
        }
Ejemplo n.º 24
0
        public bool OnMoveReversalindexEntry(object cmd)
        {
            using (var dlg = new ReversalEntryGoDlg())
            {
                Slice slice = m_dataEntryForm.CurrentSlice;
                Debug.Assert(slice != null, "No slice was current");
                var currentEntry = (IReversalIndexEntry)slice.Object;
                dlg.ReversalIndex = currentEntry.ReversalIndex;
                dlg.FilteredReversalEntries.Add(currentEntry);
                IReversalIndexEntry owningEntry = currentEntry.OwningEntry;
                if (owningEntry != null)
                {
                    dlg.FilteredReversalEntries.Add(owningEntry);
                }
                dlg.SetHelpTopic("khtpMoveReversalEntry");
                var wp = new WindowParams {
                    m_btnText = LexEdStrings.ks_MoveEntry, m_title = LexEdStrings.ksMoveRevEntry
                };
                var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                dlg.SetDlgInfo(cache, wp, m_mediator);
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var newOwner = (IReversalIndexEntry)dlg.SelectedObject;
                    UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMoveRevEntry,
                                                LexEdStrings.ksRedoMoveRevEntry, Cache.ActionHandlerAccessor,
                                                () =>
                    {
                        newOwner.MoveIfNeeded(currentEntry);
                        newOwner.SubentriesOC.Add(currentEntry);
                    });
                    RecordClerk clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk;
                    if (clerk != null)
                    {
                        clerk.RemoveItemsFor(currentEntry.Hvo);
                    }
                    // Note: PropChanged should happen on the old owner and the new while completing the unit of work.
                    // Have to jump to a main entry, as RecordClerk doesn't know anything about subentries.
                    m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainEntry.Hvo);
                }
            }

            return(true);
        }
        public bool OnMoveReversalindexEntry(object cmd)
        {
            using (ReversalEntryGoDlg dlg = new ReversalEntryGoDlg())
            {
                Slice slice = m_dataEntryForm.CurrentSlice;
                Debug.Assert(slice != null, "No slice was current");
                IReversalIndexEntry        currentEntry    = (IReversalIndexEntry)slice.Object;
                List <IReversalIndexEntry> filteredEntries = new List <IReversalIndexEntry>();
                filteredEntries.Add(currentEntry);
                IReversalIndexEntry owningEntry = currentEntry.OwningEntry;
                if (owningEntry != null)
                {
                    filteredEntries.Add(owningEntry);
                }

                WindowParams wp = new WindowParams();
                wp.m_btnText = LexEdStrings.ks_MoveEntry;
                wp.m_label   = LexEdStrings.ks_Find_;
                wp.m_title   = LexEdStrings.ksMoveRevEntry;
                dlg.SetDlgInfo(m_mediator, wp, filteredEntries);                 // , true
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    FdoCache            cache    = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
                    IReversalIndexEntry newOwner = ReversalIndexEntry.CreateFromDBObject(cache, dlg.SelectedID);
                    cache.BeginUndoTask(LexEdStrings.ksUndoMoveRevEntry,
                                        LexEdStrings.ksRedoMoveRevEntry);
                    ICmObject newOwningObj = newOwner.MoveIfNeeded(currentEntry);
                    newOwner.SubentriesOC.Add(currentEntry);
                    cache.EndUndoTask();
                    RecordClerk clerk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk;
                    if (clerk != null)
                    {
                        clerk.RemoveItemsFor(currentEntry.Hvo);
                    }
                    // Note: PropChanged should happen on the old owner and the new in the 'Add" method call.
                    // Have to jump to a main entry, as RecordClerk doesn't know anything about subentries.
                    m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainEntry.Hvo);
                }
            }

            return(true);
        }
        protected override void OnFinishButton()
        {
            base.OnFinishButton();
            SaveSettings();
            if (string.IsNullOrEmpty(m_fileListBox.Text))
            {
                return;
            }
            using (var dlg = new ProgressDialogWithTask(this, m_cache.ThreadHelper))
            {
                dlg.AllowCancel = false;
                dlg.Minimum     = 0;
                // Allow 100 units of progress for each file for now. This allows for plenty of resolution for the LL importer
                dlg.Maximum = m_fileListBox.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count() * 100;

                try
                {
                    dlg.RunTask(true, DoConversion);
                }
                catch (WorkerThreadException ex)                 // any exception on the worker thread is converted to this
                {
                    // JohnT: I hate to just report and otherwise ignore all exceptions, but have not been able to find any doc of which ones,
                    // if any, EncConverters may throw.
                    System.Diagnostics.Debug.WriteLine("Error: " + ex.InnerException.Message);
                    MessageBox.Show(this, String.Format(ITextStrings.ksSfmImportProblem, ex.InnerException.Message),
                                    ITextStrings.ksUnhandledError,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DialogResult = DialogResult.Cancel;
                    Close();
                }
            }
            m_mediator.SendMessage("MasterRefresh", ActiveForm);
            if (m_firstNewText != null)
            {
                // try to select it.
                var clerk = RecordClerk.FindClerk(m_mediator, "interlinearTexts");
                if (clerk != null)
                {
                    clerk.JumpToRecord(m_firstNewText.ContentsOA.Hvo);
                }
            }
        }
Ejemplo n.º 27
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;
            }

            base.Dispose(disposing);

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

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_clerk = null;
            m_vc    = null;
            m_configurationParameters = null;
        }
Ejemplo n.º 28
0
            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;
            }
Ejemplo n.º 29
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();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
                ClearResetTimer();
            }
            m_cache       = null;
            m_cacheSearch = null;
            m_clerk       = null;

            base.Dispose(disposing);
        }
Ejemplo n.º 31
0
		private void AddConfigurableControls()
		{
			// Load the controls.

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

			BasicPaneBarContainer pbc = new BasicPaneBarContainer();
			pbc.Init(m_mediator, 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, xnBrowseViewControlParameters, true);
			m_clerk.OwningObject = m_owningSense;

			m_rbv = DynamicLoader.CreateObject(xnBrowseViewControlParameters.ParentNode.SelectSingleNode("dynamicloaderinfo")) as ConcOccurrenceBrowseView;
			m_rbv.Init(m_mediator, xnBrowseViewControlParameters, m_previewPane, m_clerk.VirtualListPublisher);
			m_rbv.CheckBoxChanged += new CheckBoxChangedEventHandler(m_rbv_CheckBoxChanged);
			// add it to our controls.
			BasicPaneBarContainer pbc1 = new BasicPaneBarContainer();
			pbc1.Init(m_mediator, m_rbv);
			pbc1.BorderStyle = BorderStyle.FixedSingle;
			pbc1.Dock = DockStyle.Fill;
			pbc1.PaneBar.Text = LexEdStrings.ksFindExampleSentenceDlgBrowseViewPaneTitle;
			panel1.Controls.Add(pbc1);

			CheckAddBtnEnabling();
		}
Ejemplo n.º 32
0
		private bool SetDlgInfoPrivate(Mediator mediator, XmlNode configurationParameters)
		{
			using (new WaitCursor(this))
			{
				m_mediator = mediator;

				m_btnRefresh.Image = ResourceHelper.RefreshIcon;

				m_rbDiscardAnalyses.Checked = m_mediator.PropertyTable.GetBoolProperty("RemoveAnalyses", true);
				m_rbKeepAnalyses.Checked = !m_rbDiscardAnalyses.Checked;
				m_rbDiscardAnalyses.Click += m_rbDiscardAnalyses_Click;
				m_rbKeepAnalyses.Click += m_rbDiscardAnalyses_Click;

				m_cbUpdateLexicon.Checked = m_mediator.PropertyTable.GetBoolProperty("UpdateLexiconIfPossible", true);
				m_cbCopyAnalyses.Checked = m_mediator.PropertyTable.GetBoolProperty("CopyAnalysesToNewSpelling", true);
				m_cbCopyAnalyses.Click += m_cbCopyAnalyses_Click;
				m_cbMaintainCase.Checked = m_mediator.PropertyTable.GetBoolProperty("MaintainCaseOnChangeSpelling", true);
				m_cbMaintainCase.Click += m_cbMaintainCase_Click;
				m_cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");

				// We need to use the 'best vern' ws,
				// since that is what is showing in the Words-Analyses detail edit control.
				// Access to this respeller dlg is currently (Jan. 2008) only via a context menu in the detail edit pane.
				// The user may be showing multiple wordform WSes in the left hand browse view,
				// but we have no way of knowing if the user thinks one of those alternatives is wrong without asking.
				m_vernWs = WritingSystemServices.ActualWs(m_cache,
					WritingSystemServices.kwsFirstVern,
					m_srcwfiWordform.Hvo,
					WfiWordformTags.kflidForm);
				// Bail out if no vernacular writing system was found (see LT-8892).
				Debug.Assert(m_vernWs != 0);
				if (m_vernWs == 0)
					return false;
				// Bail out, rather than run into a null reference exception.
				// (Should fix LT-7666.)
				var vernForm = m_srcwfiWordform.Form.get_String(m_vernWs);
				if (vernForm == null || vernForm.Length == 0)
					return false;

				m_cbNewSpelling.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
				m_cbNewSpelling.WritingSystemCode = m_vernWs;
				m_cbNewSpelling.StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
				Debug.Assert(m_cbNewSpelling.StyleSheet != null); // if it is we get a HUGE default font (and can't get the correct size)
				if (m_cbNewSpelling.WritingSystemFactory.get_EngineOrNull(m_vernWs).RightToLeftScript)
				{
					m_cbNewSpelling.RightToLeft = RightToLeft.Yes;
				}
				m_cbNewSpelling.Tss = vernForm;
				m_cbNewSpelling.AdjustForStyleSheet(this, null, m_cbNewSpelling.StyleSheet);
				if (!Application.RenderWithVisualStyles)
					m_cbNewSpelling.Padding = new Padding(1, 2, 1, 1);

				SetSuggestions();

				m_btnApply.Enabled = false;
				m_cbNewSpelling.TextChanged += m_dstWordform_TextChanged;

				// Setup source browse view.
				var toolNode = configurationParameters.SelectSingleNode("controls/control[@id='srcSentences']/parameters");
				m_srcClerk = RecordClerkFactory.CreateClerk(m_mediator, toolNode, true);
				m_srcClerk.OwningObject = m_srcwfiWordform;
				m_sourceSentences.Init(m_mediator, toolNode);
				m_sourceSentences.CheckBoxChanged += sentences_CheckBoxChanged;
				m_specialSda = m_sourceSentences.BrowseViewer.SpecialCache;
				m_moreMinSize = Size;
				m_moreMinSize.Height -= m_sourceSentences.Height / 2;
				m_lessMinSize = m_moreMinSize;
				m_lessMinSize.Height -= m_optionsPanel.Height;
				AdjustHeightAndMinSize(Height - m_optionsPanel.Height, m_lessMinSize);
				m_optionsPanel.Visible = false;
				m_btnMore.Image = ResourceHelper.MoreButtonDoubleArrowIcon;
				m_btnMore.Click += btnMore_Click;
				m_sMoreButtonText = m_btnMore.Text;
				m_optionsPanel.Paint += m_optionsPanel_Paint;
				m_btnPreviewClear.Click += m_btnPreviewClear_Click;

				var specialMdc = m_specialSda.MetaDataCache;
				int fakeFlid = specialMdc.GetFieldId2(WfiWordformTags.kClassId, "Occurrences", false);
				int[] concordanceItems = m_specialSda.VecProp(m_srcwfiWordform.Hvo, fakeFlid);
				// (Re)set selected state in cache, so default behavior of checked is used.
				foreach (var concId in concordanceItems)
				{
					m_specialSda.SetInt(concId, m_sourceSentences.BrowseViewer.PreviewEnabledTag, 1);
					m_specialSda.SetInt(concId, XMLViewsDataCache.ktagItemSelected, 1);
				}
				// We initially check everything.
				var segmentRepos = m_cache.ServiceLocator.GetInstance<ISegmentRepository>();
				foreach (var hvo in m_sourceSentences.BrowseViewer.AllItems)
					m_enabledItems.Add(hvo);

				// no good...code in MakeRoot of XmlBrowseView happens later and overrides. Control with
				// selectionType attr in Xml configuration.
				//m_sourceSentences.BrowseViewer.SelectedRowHighlighting = XmlBrowseViewBase.SelectionHighlighting.none;

				m_lblExplainText = m_lblExplainDisabled.Text;
				// We only reload the list when refresh is pressed.
				m_srcClerk.ListLoadingSuppressed = true;
				CheckForOtherOccurrences();
				SetEnabledState();
			}
			return true;
		}
Ejemplo n.º 33
0
		internal bool SetDlgInfo(Mediator mediator, XmlNode configurationParameters)
		{
			m_wfClerk = (RecordClerk)mediator.PropertyTable.GetValue("RecordClerk-concordanceWords");
			m_wfClerk.SuppressSaveOnChangeRecord = true; // various things trigger change record and would prevent Undo

			//We need to re-parse the interesting texts so that the rows in the dialog show all the occurrences (make sure it is up to date)
			if(m_wfClerk is InterlinearTextsRecordClerk)
			{
				//Unsuppress to allow for the list to be reloaded during ParseInterstingTextsIfNeeded()
				//(this clerk and its list are not visible in this dialog, so there will be no future reload)
				m_wfClerk.ListLoadingSuppressed = false;
				(m_wfClerk as InterlinearTextsRecordClerk).ParseInterstingTextsIfNeeded(); //Trigger the parsing
			}
			m_srcwfiWordform = (IWfiWordform)m_wfClerk.CurrentObject;
			if (m_fDisposeMediator && m_mediator != null)
				m_mediator.Dispose();

			m_fDisposeMediator = false;
			return SetDlgInfoPrivate(mediator, configurationParameters);
		}