Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12692 for trunk/sources


Ignore:
Timestamp:
07/08/15 15:59:11 (9 years ago)
Author:
abeham
Message:

#2270:

  • Fixed bug in RunCollectionChartAggregationView regarding null value
  • Fixed bug in RunCollectionTableView when runs were added during UpdateOfRunsInProgress
  • Added suppressUpdates to RunCollectionView and listening to UpdateOfRunsInProgress
  • Made sure that RunCollection would reset updateOfRunsInProgress to the same value as before when changing it in internal methods
Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs

    r12631 r12692  
    242242      dataRowComboBox.Items.Clear();
    243243      var resultName = (string)dataTableComboBox.SelectedItem;
     244      if (resultName == null) return;
     245
    244246      var dataTables = from run in Content
    245247                       where run.Results.ContainsKey(resultName)
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs

    r12077 r12692  
    5353      base.OnContentChanged();
    5454      if (Content != null) {
    55         runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    5655        UpdateRowAttributes();
    5756      }
     
    151150        suppressUpdates = Content.UpdateOfRunsInProgress;
    152151        if (!suppressUpdates) {
     152          UpdateData();
    153153          UpdateRowAttributes();
    154           UpdateData();
    155154        }
    156155      }
     
    179178    protected override void ClearSorting() {
    180179      base.ClearSorting();
    181       runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    182180      UpdateRowAttributes();
    183181    }
     
    198196        i++;
    199197      }
    200       UpdateRowAttributes();
     198      UpdateRowAttributes(rebuild: false);
    201199      return newSortedIndex;
    202200    }
    203201
    204     private void UpdateRowAttributes() {
     202    private void UpdateRowAttributes(bool rebuild = true) {
     203      if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    205204      int runIndex = 0;
    206205      foreach (IRun run in Content) {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r12012 r12692  
    4141    private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping;
    4242    private bool validDragOperation;
     43    private bool suppressUpdates;
    4344
    4445    public new IItemCollection<IRun> Content {
     
    6667      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    6768      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     69      if (RunCollection != null)
     70        RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    6871      foreach (IRun run in itemListViewItemMapping.Keys) {
    6972        DeregisterItemEvents(run);
     
    7679      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    7780      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     81      if (RunCollection != null)
     82        RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    7883    }
    7984    private void DeregisterItemEvents(IRun item) {
     
    394399    #region Content Events
    395400    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     401      if (suppressUpdates) return;
    396402      if (InvokeRequired)
    397403        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
     
    407413    }
    408414    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     415      if (suppressUpdates) return;
    409416      if (InvokeRequired)
    410417        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
     
    422429    }
    423430    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     431      if (suppressUpdates) return;
    424432      if (InvokeRequired)
    425433        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
     
    440448      }
    441449    }
     450    private void RunCollection_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     451      if (InvokeRequired) Invoke((Action<object, EventArgs>)RunCollection_UpdateOfRunsInProgressChanged, sender, e);
     452      else {
     453        suppressUpdates = RunCollection.UpdateOfRunsInProgress;
     454        if (!suppressUpdates) {
     455          foreach (IRun item in Content) {
     456            //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection
     457            ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault();
     458            if (listViewItem != null) RemoveListViewItem(listViewItem);
     459          }
     460          RebuildImageList();
     461          foreach (IRun item in Content)
     462            AddListViewItem(CreateListViewItem(item));
     463
     464          AdjustListViewColumnSizes();
     465          analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     466          clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
     467          runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     468        }
     469      }
     470    }
    442471    #endregion
    443472
    444473    #region Item Events
    445474    private void Item_ItemImageChanged(object sender, EventArgs e) {
     475      if (suppressUpdates) return;
    446476      if (InvokeRequired)
    447477        Invoke(new EventHandler(Item_ItemImageChanged), sender, e);
     
    453483    }
    454484    private void Item_ToStringChanged(object sender, EventArgs e) {
     485      if (suppressUpdates) return;
    455486      if (InvokeRequired)
    456487        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
     
    463494    }
    464495    private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     496      if (suppressUpdates) return;
    465497      if (InvokeRequired)
    466         this.Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
     498        Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
    467499      else {
    468500        IRun run = (IRun)sender;
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r12672 r12692  
    483483    #region Filtering
    484484    private void UpdateFiltering(bool reset) {
     485      var oldUpateRuns = UpdateOfRunsInProgress;
    485486      UpdateOfRunsInProgress = true;
    486487      if (reset)
     
    488489      foreach (IRunCollectionConstraint constraint in this.constraints)
    489490        constraint.Check();
    490       UpdateOfRunsInProgress = false;
     491      UpdateOfRunsInProgress = oldUpateRuns;
    491492    }
    492493
     
    550551    #region Modification
    551552    public void Modify() {
     553      var oldUpateRuns = UpdateOfRunsInProgress;
    552554      UpdateOfRunsInProgress = true;
    553555      var runs = this.ToList();
     
    564566        }
    565567      }
    566       UpdateOfRunsInProgress = false;
     568      UpdateOfRunsInProgress = oldUpateRuns;
    567569    }
    568570
Note: See TracChangeset for help on using the changeset viewer.