Exemplo n.º 1
0
        private void OnAggregateDescriptorsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            this.dataChangeFlags |= DataChangeFlags.Aggregate;
            this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.AffectsData);

            this.GridView.ProcessDataChangeFlags(this.dataChangeFlags);
        }
Exemplo n.º 2
0
        private void OnDataProviderViewChanged(object sender, ViewChangedEventArgs e)
        {
            if (!this.IsDataReady)
            {
                this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.All);
                return;
            }

            if (e.Action == CollectionChange.Reset)
            {
                this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.All);
            }
            else if (e.Action == CollectionChange.ItemChanged)
            {
                this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.AffectsContent);
                this.dataChangeFlags |= DataChangeFlags.PropertyChanged;
            }
            else
            {
                var changes = e.Changes;
                for (int i = 0; i < changes.Count; i++)
                {
                    var    change        = changes[i];
                    object changedItem   = change.ChangedCoordinate.RowGroup;
                    object addRemoveItem = change.AddedOrRemovedCoordinate.RowGroup;

                    // We use only RowGroupIndex for RowLayout and ColumnGroupIndex for ColumnLayout.
                    // For now only rowLayout is updated.
                    int index = change.AddRemoveRowGroupIndex;

                    AddRemoveLayoutResult result;
                    switch (e.Action)
                    {
                    case CollectionChange.ItemInserted:
                        result = this.rowLayout.AddItem(changedItem, addRemoveItem, index);
                        this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.AffectsContent);

                        break;

                    case CollectionChange.ItemRemoved:
                        result = this.rowLayout.RemoveItem(changedItem, addRemoveItem, index);

                        this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.AffectsContent);
                        break;

                    default:
                        Debug.Assert(true, "Not expected action. Only Add, Remove or Reset are supported");
                        break;
                    }
                }
            }

            this.GridView.CurrencyService.OnDataViewChanged(e);

            ////TODO: Consider what should we do in reset action.
            this.GridView.CommandService.ExecuteCommand(CommandId.DataBindingComplete, new DataBindingCompleteEventArgs()
            {
                ChangeFlags = this.dataChangeFlags, DataView = this.GridView.GetDataView()
            });
        }
Exemplo n.º 3
0
        private void EndDataUpdate(DataProviderStatusChangedEventArgs e)
        {
            if (e.NewStatus == DataProviderStatus.Faulted || e.NewStatus == DataProviderStatus.Uninitialized)
            {
                this.layoutController.ScheduleCleanUp();
                this.ResumeUpdateService(ListView.UpdateFlags.AllButData);
                return;
            }

            if (!this.isDataProviderUpdating)
            {
                // System.Diagnostics.Debug.Assert(false, "Flag not raised properly.");
                return;
            }

            if (e.NewStatus != DataProviderStatus.Ready || !e.ResultsChanged)
            {
                return;
            }

            //// NOTE: This call comes from another thread and everything related to the UI should be dispatched on the UI thread.
            //// It will also clear the IndexTree which will definitely throw NullReference exception if some UI operation is requested before Dispatcher is invoked.
            //// To solve this issue it will be better to create new Layout class and replace the existing one when dispatched to the Main thread.
            //// this.SetLayoutSource();
            this.View.UpdateService.DispatchOnUIThread(
                true,
                () =>
            {
                if (this.CurrentDataProvider.Status != DataProviderStatus.Ready)
                {
                    // This may happen if during the Dispatching on UI thread we have a change in the provider - e.g. ItemsSource change.
                    return;
                }

                if (this.hasPendingDataRefresh)
                {
                    this.hasPendingDataRefresh = false;
                    this.RefreshData();
                    return;
                }

                this.SetLayoutSource();
                this.RestoreCollapsedState();

                ListView.UpdateFlags uiUpdateflags = ListView.UpdateFlags.AffectsContent;

                this.dataChangeFlags        = DataChangeFlags.None;
                this.isDataProviderUpdating = false;

                System.Diagnostics.Debug.Assert(!uiUpdateflags.HasFlag(ListView.UpdateFlags.AffectsData), "The AffectsData flag should not be raised here!");
                this.ResumeUpdateService(uiUpdateflags);

                this.NotifyView(this.CurrentDataProvider.Status);
            });
        }
Exemplo n.º 4
0
 /// <inheritdoc />
 public void Refresh(DataChangeFlags dataChangeFlags = DataChangeFlags.None)
 {
     try
     {
         this.RefreshOverride(dataChangeFlags);
     }
     finally
     {
         this.ClearPendingChanges();
     }
 }
Exemplo n.º 5
0
        internal void OnItemsSourceChanged(object newSource)
        {
            if (this.itemsSource != null)
            {
                ////TODO: Clean up items if it is required, else GC will do its work
            }

            this.areColumnsGenerated = false;
            this.dataChangeFlags    |= DataChangeFlags.Source;

            // external providers have precedence over local data provider
            IExternalItemsSource extItemSource = newSource as IExternalItemsSource;

            if (extItemSource != null)
            {
                // localDataProvider should be avoided in model logic from this moment on
                if (this.localDataProvider != null)
                {
                    this.localDataProvider.StatusChanged -= this.OnDataProviderStatusChanged;
                    this.localDataProvider = null;
                }

                if (newSource != this.externalDataProvider)
                {
                    this.externalDataProvider = extItemSource.GetExternalProvider();
                    this.UpdateProviderField(this.externalDataProvider);
                    this.externalDataProvider.Refresh(this.dataChangeFlags);
                    this.itemsSource = this.externalDataProvider.ItemsSource;
                }
            }
            else
            {
                this.itemsSource = newSource;

                if (this.localDataProvider == null)
                {
                    // create default data provider (Local (in-memory) data)
                    this.CreateDefaultDataProvider();
                }

                this.localDataProvider.ItemsSource = this.itemsSource;
            }

            this.UpdateRequestedItems(null, false);
            this.CheckDataDescriptorsCompatibility();

            // refresh the data
            this.RefreshLayout();
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        protected override void RefreshOverride(DataChangeFlags dataChangeFlags)
        {
            if (this.ItemsSource == null)
            {
                return;
            }

            if (this.descriptionsData == null)
            {
                this.refreshRequested = true;
                this.RefreshFieldDescriptions();

                return;
            }

            this.InitializeDescriptions();
            this.GenerateAndExecuteDataEngineRequest();
        }
Exemplo n.º 7
0
 protected override void RefreshOverride(DataChangeFlags dataChangeFlags)
 {
     this.RefreshCallCount++;
 }
Exemplo n.º 8
0
 void IGridView.ProcessDataChangeFlags(DataChangeFlags flags)
 {
     // TODO: Decide whether we need to keep the edit row synchronized with the DataView
     this.CancelEdit();
 }
Exemplo n.º 9
0
 void IDataProvider.Refresh(DataChangeFlags dataChangeFlags)
 {
     this.Refresh(dataChangeFlags);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Recreates the <see cref="Results" />.
 /// </summary>
 protected abstract void RefreshOverride(DataChangeFlags dataChangeFlags);
Exemplo n.º 11
0
        private void EndDataUpdate(DataProviderStatusChangedEventArgs e)
        {
            if (e.NewStatus == DataProviderStatus.Faulted || e.NewStatus == DataProviderStatus.Uninitialized)
            {
                this.CleanUp();
                this.ResumeUpdateService(UpdateFlags.AllButData);
                return;
            }

            if (!this.isDataProviderUpdating)
            {
                Debug.Assert(RadControl.IsInTestMode, "Flag not raised properly.");
                return;
            }

            if (e.NewStatus != DataProviderStatus.Ready || !e.ResultsChanged)
            {
                return;
            }

            //// NOTE: This call comes from another thread and everything related to the UI should be dispatched on the UI thread.
            //// It will also clear the IndexTree which will definitely throw NullReference exception if some UI operation is requested before Dispatcher is invoked.
            //// To solve this issue it will be better to create new Layout class and replace the existing one when dispatched to the Main thread.
            //// this.SetLayoutSource();
            this.GridView.UpdateService.DispatchOnUIThread(
                true,
                () =>
            {
                if (this.CurrentDataProvider.Status != DataProviderStatus.Ready)
                {
                    // This may happen if during the Dispatching on UI thread we have a change in the provider - e.g. ItemsSource change.
                    return;
                }

                if (this.hasPendingDataRefresh)
                {
                    this.hasPendingDataRefresh = false;
                    this.RefreshData();
                    return;
                }

                this.updatingData = true;

                this.GenerateColumns();
                this.SetRowLayoutSource();

                UpdateFlags uiUpdateflags = UpdateFlags.AffectsContent | UpdateFlags.AffectsDecorations;

                // check the data update flags and create the appropriate UI update
                if (this.dataChangeFlags.HasFlag(DataChangeFlags.Group) || this.dataChangeFlags.HasFlag(DataChangeFlags.Filter))
                {
                    uiUpdateflags |= UpdateFlags.AffectsColumnsWidth;
                }

                var eventArgs = new DataBindingCompleteEventArgs()
                {
                    ChangeFlags = this.dataChangeFlags, DataView = this.GridView.GetDataView()
                };

                this.dataChangeFlags        = DataChangeFlags.None;
                this.isDataProviderUpdating = false;
                this.updatingData           = false;

                this.GridView.CommandService.ExecuteCommand(CommandId.DataBindingComplete, eventArgs);

                Debug.Assert(!uiUpdateflags.HasFlag(UpdateFlags.AffectsData), "The AffectsData flag should not be raised here!");
                this.ResumeUpdateService(uiUpdateflags);

                this.NotifyView(this.CurrentDataProvider.Status);
            });
        }
Exemplo n.º 12
0
 internal void OnDataDescriptorPropertyChanged(DataDescriptor sender)
 {
     this.dataChangeFlags |= sender.UpdateFlags;
     this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.AffectsData);
 }
Exemplo n.º 13
0
 void IDataDescriptorsHost.OnDataDescriptorPropertyChanged(DataDescriptor descriptor)
 {
     this.dataChangeFlags |= descriptor.UpdateFlags;
     this.GridView.UpdateService.RegisterUpdate((int)UpdateFlags.AffectsData);
 }
Exemplo n.º 14
0
 public void Refresh(DataChangeFlags dataChangeFlags = DataChangeFlags.None)
 {
     throw new NotImplementedException();
 }