Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/19/13 11:29:28 (11 years ago)
Author:
gkronber
Message:

#1508

  • fixed a bug in the ECB problem instance provider (reversed time series)
  • improved the ProblemInstanceProviderViewGeneric class to show a progress bar while loading the problem instance
  • fixed the build fail (in SolutionLineChartView)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.cs

    r9456 r9991  
    2121
    2222using System;
     23using System.ComponentModel;
    2324using System.Linq;
     25using System.Threading.Tasks;
    2426using System.Windows.Forms;
    2527using HeuristicLab.MainForm;
     
    8890
    8991    private void instancesComboBox_SelectionChangeCommitted(object sender, System.EventArgs e) {
     92      toolTip.SetToolTip(instancesComboBox, String.Empty);
    9093      if (instancesComboBox.SelectedIndex >= 0) {
    9194        var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;
    92         T instance = Content.LoadData(descriptor);
    93         try {
    94           GenericConsumer.Load(instance);
    95         } catch (Exception ex) {
    96           ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
    97         }
    98         toolTip.SetToolTip(instancesComboBox, descriptor.Description);
    99       } else toolTip.SetToolTip(instancesComboBox, String.Empty);
     95
     96        IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
     97        var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     98        // lock active view and show progress bar
     99        mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");
     100        // continuation for removing the progess bar from the active view
     101        Action<Task> removeProgressFromContent = (_) => mainForm.RemoveOperationProgressFromContent(activeView.Content);
     102
     103        // task structure:
     104        // loadFromProvider
     105        // |
     106        // +-> on fault -> show error dialog -> remove progress bar
     107        // |
     108        // `-> success  -> loadToProblem
     109        //                 |
     110        //                 +-> on fault -> show error dialog -> remove progress bar
     111        //                 |
     112        //                 `-> success -> set tool tip -> remove progress bar
     113        var loadFromProvider = new Task<T>(() => Content.LoadData(descriptor));
     114
     115        // success
     116        var loadToProblem = loadFromProvider
     117          .ContinueWith(task => GenericConsumer.Load(task.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
     118        // on error
     119        loadFromProvider
     120          .ContinueWith(task => { ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), task.Exception); }, TaskContinuationOptions.OnlyOnFaulted)
     121          .ContinueWith(removeProgressFromContent);
     122
     123        // success
     124        loadToProblem
     125          .ContinueWith(task => toolTip.SetToolTip(instancesComboBox, descriptor.Description), TaskContinuationOptions.OnlyOnRanToCompletion)
     126          .ContinueWith(removeProgressFromContent);
     127        // on error
     128        loadToProblem.ContinueWith(task => { ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), task.Exception); }, TaskContinuationOptions.OnlyOnFaulted)
     129        .ContinueWith(removeProgressFromContent);
     130
     131        // start async loading task
     132        loadFromProvider.Start();
     133      }
    100134    }
    101135  }
Note: See TracChangeset for help on using the changeset viewer.