Exemple #1
0
        /// <summary>
        /// Initialize this as an IxCoreColleague
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="configurationParameters"></param>
        public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();
            InitBase(mediator, propertyTable, configurationParameters);
            m_browseViewer.Init(mediator, propertyTable, configurationParameters);
            m_fullyInitialized = true;
            // These have to be done here, rather than in SetupDataContext(),
            // or the record clerk resets its current object,
            // when the root object gets set in the borwse view's MakeRoot,
            // which, in  turn, resets its current index to zero,
            // which fires events. By connecting them here,
            // they won't be ready to hand off to clients.
            m_browseViewer.SelectionChanged     += OnSelectionChanged;
            m_browseViewer.SelectedIndexChanged += m_browseViewer_SelectedIndexChanged;
            m_browseViewer.FilterChanged        += FilterChangedHandler;
            m_browseViewer.SorterChanged        += SortChangedHandler;
            m_browseViewer.ListModificationInProgressChanged += m_browseViewer_ListModificationInProgressChanged;
            m_browseViewer.BrowseView.RightMouseClickedEvent += OnFwRightMouseClick;
            m_browseViewer.SelectionDrawingFailure           += OnBrowseSelectionDrawingFailed;
            m_browseViewer.CheckBoxChanged += OnCheckBoxChanged;
            Clerk.FilterChangedByClerk     += Clerk_FilterChangedByClerk;
            Clerk.SorterChangedByClerk     += Clerk_SorterChangedByClerk;
            if (m_browseViewer.BulkEditBar != null)
            {
                // We have a browse viewer that is using a bulk edit bar, so make sure our RecordClerk
                // is properly setup/sync'd with its saved settings.
                m_browseViewer.BulkEditBar.TargetComboSelectedIndexChanged += TargetColumnChanged;
                if (m_browseViewer.BulkEditBar.ExpectedListItemsClassId != 0)
                {
                    m_browseViewer.BulkEditBar.OnTargetComboSelectedIndexChanged();
                    CheckExpectedListItemsClassInSync();
                }
                else
                {
                    // now that we're finished setting up the bulk edit bar, we need to make
                    // sure our clerk loads its defaults, since bulk edit didn't provide information
                    // for which list items class to load objects for.
                    if (Clerk.ListSize == 0)
                    {
                        Clerk.OnChangeListItemsClass(Clerk.SortItemProvider.ListItemsClass, 0, false);
                    }
                }
            }

            // We're seeing an odd crash occurring during Init.ShowRecord() (see LT-9498)
            // where the Display is getting updated in RestoreSelectionAndScrollPos
            // after ShowRecord() below sets m_browseViewer.CurrentIndex.
            // As far as I (EricP) can tell "RestoreSelectionAndScrollPos" should only occur
            // after Init() (ie. Application.Idle()) and the user has created a new selection based upon
            // clicking or keyboard input. In otherwords, there is no reason to try to
            // restore a BrowseView Selection that has occurred before the user has
            // done anything to create a selection with the cursor.
            // In effort to avoid this crashing path, we clear any RootBox.Selection that
            // has been set by the program up to this point. If a Selection exists,
            // we will display a Debug message alerting programmers to investigate
            // how they got into this state.
            // The only reliable ways to trigger the assertion below seemed to involve active filters
            // and switching between areas (not tools). Since clicking Ignore seems to not cause
            // any problems, I am commenting out the assertion for now.
            if (m_browseViewer.BrowseView != null &&
                m_browseViewer.BrowseView.RootBox != null &&
                m_browseViewer.BrowseView.RootBox.Selection != null)
            {
                //Debug.Fail("Not sure how/why we have a RootBox.Selection at this point in initialization. " +
                //	"Please comment in LT-9498 how you reproduced this. Perhaps it would indicate how to reproduce this crash.");

                m_browseViewer.BrowseView.RootBox.DestroySelection();
            }

            // ShowRecord() was called in InitBase, but quit without doing anything,
            // so call it again, since we are ready now.
            ShowRecord();
        }