Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10000 for trunk/sources


Ignore:
Timestamp:
09/24/13 11:49:28 (11 years ago)
Author:
jkarder
Message:

#2110: refactored ProblemInstanceProviderViews

Location:
trunk/sources
Files:
4 deleted
10 edited
2 copied
10 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.Designer.cs

    r9456 r10000  
    4646    private void InitializeComponent() {
    4747      this.problemInstanceSplitContainer = new System.Windows.Forms.SplitContainer();
    48       this.ProblemInstanceConsumerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     48      this.libraryLabel = new System.Windows.Forms.Label();
     49      this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox();
     50      this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4951      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5052      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit();
     
    8789      // problemInstanceSplitContainer.Panel1
    8890      //
    89       this.problemInstanceSplitContainer.Panel1.Controls.Add(this.ProblemInstanceConsumerViewHost);
     91      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryLabel);
     92      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox);
     93      this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderViewHost);
    9094      this.problemInstanceSplitContainer.Panel1MinSize = 10;
    9195      //
     
    100104      this.problemInstanceSplitContainer.TabIndex = 13;
    101105      //
    102       // ProblemInstanceConsumerViewHost
     106      // libraryLabel
    103107      //
    104       this.ProblemInstanceConsumerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     108      this.libraryLabel.AutoSize = true;
     109      this.libraryLabel.Location = new System.Drawing.Point(3, 6);
     110      this.libraryLabel.Name = "libraryLabel";
     111      this.libraryLabel.Size = new System.Drawing.Size(41, 13);
     112      this.libraryLabel.TabIndex = 17;
     113      this.libraryLabel.Text = "Library:";
     114      //
     115      // problemInstanceProviderComboBox
     116      //
     117      this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     118      this.problemInstanceProviderComboBox.FormattingEnabled = true;
     119      this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 2);
     120      this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
     121      this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(208, 21);
     122      this.problemInstanceProviderComboBox.TabIndex = 18;
     123      this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
     124      //
     125      // problemInstanceProviderViewHost
     126      //
     127      this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    105128            | System.Windows.Forms.AnchorStyles.Left)
    106129            | System.Windows.Forms.AnchorStyles.Right)));
    107       this.ProblemInstanceConsumerViewHost.Caption = "ProblemInstanceConsumerView";
    108       this.ProblemInstanceConsumerViewHost.Content = null;
    109       this.ProblemInstanceConsumerViewHost.Enabled = false;
    110       this.ProblemInstanceConsumerViewHost.Location = new System.Drawing.Point(0, 1);
    111       this.ProblemInstanceConsumerViewHost.Name = "ProblemInstanceConsumerViewHost";
    112       this.ProblemInstanceConsumerViewHost.ReadOnly = false;
    113       this.ProblemInstanceConsumerViewHost.Size = new System.Drawing.Size(511, 23);
    114       this.ProblemInstanceConsumerViewHost.TabIndex = 0;
    115       this.ProblemInstanceConsumerViewHost.ViewsLabelVisible = false;
    116       this.ProblemInstanceConsumerViewHost.ViewType = null;
     130      this.problemInstanceProviderViewHost.Caption = "ProblemInstanceConsumerView";
     131      this.problemInstanceProviderViewHost.Content = null;
     132      this.problemInstanceProviderViewHost.Enabled = false;
     133      this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(264, 1);
     134      this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost";
     135      this.problemInstanceProviderViewHost.ReadOnly = false;
     136      this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(247, 23);
     137      this.problemInstanceProviderViewHost.TabIndex = 0;
     138      this.problemInstanceProviderViewHost.ViewsLabelVisible = false;
     139      this.problemInstanceProviderViewHost.ViewType = null;
    117140      //
    118141      // ProblemView
    119142      //
    120       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    121143      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    122144      this.Controls.Add(this.problemInstanceSplitContainer);
     
    125147      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    126148      this.problemInstanceSplitContainer.Panel1.ResumeLayout(false);
     149      this.problemInstanceSplitContainer.Panel1.PerformLayout();
    127150      this.problemInstanceSplitContainer.Panel2.ResumeLayout(false);
    128151      this.problemInstanceSplitContainer.Panel2.PerformLayout();
     
    136159
    137160    protected System.Windows.Forms.SplitContainer problemInstanceSplitContainer;
    138     protected HeuristicLab.MainForm.WindowsForms.ViewHost ProblemInstanceConsumerViewHost;
     161    protected HeuristicLab.MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
     162    protected System.Windows.Forms.Label libraryLabel;
     163    protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
    139164  }
    140165}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs

    r9456 r10000  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Windows.Forms;
    2625using HeuristicLab.Core.Views;
    2726using HeuristicLab.MainForm;
     
    3736  public partial class ProblemView : ParameterizedNamedItemView {
    3837
    39     private static Type neededViewType = typeof(ProblemInstanceConsumerView);
    40 
    4138    public new IProblem Content {
    4239      get { return (IProblem)base.Content; }
    4340      set { base.Content = value; }
    4441    }
     42
     43    protected IEnumerable<IProblemInstanceProvider> problemInstanceProviders;
     44    public IEnumerable<IProblemInstanceProvider> ProblemInstanceProviders {
     45      get { return new List<IProblemInstanceProvider>(problemInstanceProviders); }
     46    }
     47
     48    public IProblemInstanceProvider SelectedProvider { get; protected set; }
    4549
    4650    /// <summary>
     
    5357    protected override void OnContentChanged() {
    5458      base.OnContentChanged();
    55       IProblemInstanceConsumer consumer = Content as IProblemInstanceConsumer;
    56       if (consumer != null) {
    57         IEnumerable<Type> viewTypes = MainFormManager.GetViewTypes(consumer.GetType(), true);
    58         Type genericView = viewTypes.Where(x => x.IsSubclassOf(neededViewType)).First();
    59         ProblemInstanceConsumerViewHost.Content = null; //necessary to enable the change of the ViewType
    60         ProblemInstanceConsumerViewHost.ViewType = genericView;
    61         ProblemInstanceConsumerViewHost.Content = consumer;
    62         ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)ProblemInstanceConsumerViewHost.ActiveView;
    63         problemInstanceSplitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any();
     59      if (Content == null) {
     60        problemInstanceProviders = null;
     61        problemInstanceProviderComboBox.DataSource = null;
     62        problemInstanceSplitContainer.Panel1Collapsed = true;
    6463      } else {
    65         problemInstanceSplitContainer.Panel1Collapsed = true;
     64        var consumer = Content as IProblemInstanceConsumer;
     65        if (consumer != null) {
     66          problemInstanceProviders = ProblemInstanceManager.GetProviders(Content);
     67          bool expand = problemInstanceProviders.Any();
     68          if (expand) {
     69            problemInstanceProviderComboBox.DisplayMember = "Name";
     70            problemInstanceProviderComboBox.DataSource = ProblemInstanceProviders.OrderBy(x => x.Name).ToList();
     71          }
     72          problemInstanceSplitContainer.Panel1Collapsed = !expand;
     73        }
    6674      }
    6775      SetEnabledStateOfControls();
    6876    }
    6977
     78    protected virtual void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     79      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
     80        SelectedProvider = (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem;
     81        problemInstanceProviderViewHost.Content = SelectedProvider;
     82        var view = (ProblemInstanceProviderView)problemInstanceProviderViewHost.ActiveView;
     83        var consumer = (IProblemInstanceConsumer)Content;
     84        view.Consumer = consumer;
     85        if (CheckForIProblemInstanceExporter(consumer))
     86          view.Exporter = (IProblemInstanceExporter)Content;
     87        else view.Exporter = null;
     88        SetTooltip();
     89      } else {
     90        SelectedProvider = null;
     91      }
     92      SetEnabledStateOfControls();
     93    }
     94
     95    protected bool CheckForIProblemInstanceExporter(IProblemInstanceConsumer content) {
     96      return Content.GetType().GetInterfaces()
     97                    .Any(x => x == typeof(IProblemInstanceExporter));
     98    }
     99
     100    #region ToolTip
     101    protected void SetTooltip() {
     102      toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip());
     103    }
     104
     105    private string GetProviderToolTip() {
     106      var provider = SelectedProvider;
     107      string toolTip = provider.Name;
     108
     109      if (!String.IsNullOrEmpty(provider.ReferencePublication)) {
     110        toolTip = toolTip
     111            + Environment.NewLine + Environment.NewLine
     112            + provider.ReferencePublication;
     113      }
     114      if (provider.WebLink != null) {
     115        toolTip = toolTip
     116            + Environment.NewLine
     117            + provider.WebLink.ToString();
     118      }
     119
     120      return toolTip;
     121    }
     122    #endregion
    70123  }
    71124}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/ClassificationInstanceProviderView.Designer.cs

    r9999 r10000  
    2121
    2222namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    23   partial class ClassificationInstanceConsumerView {
     23  partial class ClassificationInstanceProviderView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/ClassificationInstanceProviderView.cs

    r9999 r10000  
    2828namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    2929  [View("Classification InstanceProvider View")]
    30   [Content(typeof(IProblemInstanceConsumer<IClassificationProblemData>), IsDefaultView = true)]
    31   public partial class ClassificationInstanceConsumerView : DataAnalysisInstanceConsumerView<IClassificationProblemData> {
    32     public new IProblemInstanceConsumer<IClassificationProblemData> Content {
    33       get { return (IProblemInstanceConsumer<IClassificationProblemData>)base.Content; }
     30  [Content(typeof(ClassificationInstanceProvider), IsDefaultView = true)]
     31  public partial class ClassificationInstanceProviderView : DataAnalysisInstanceProviderView<IClassificationProblemData> {
     32
     33    public new ClassificationInstanceProvider Content {
     34      get { return (ClassificationInstanceProvider)base.Content; }
    3435      set { base.Content = value; }
    3536    }
    3637
    37     public ClassificationInstanceConsumerView() {
     38    public ClassificationInstanceProviderView() {
    3839      InitializeComponent();
    3940    }
    4041
    4142    protected override void importButton_Click(object sender, EventArgs e) {
    42       var provider = SelectedProvider as ClassificationInstanceProvider;
    43       if (provider != null) {
    44         ClassificationImportTypeDialog importTypeDialog = new ClassificationImportTypeDialog();
    45         if (importTypeDialog.ShowDialog() == DialogResult.OK) {
    46           IClassificationProblemData instance = null;
    47           try {
    48             instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    49           }
    50           catch (IOException ex) {
    51             ErrorWhileParsing(ex);
    52             return;
    53           }
    54           try {
    55             GenericConsumer.Load(instance);
    56           }
    57           catch (IOException ex) {
    58             ErrorWhileLoading(ex, importTypeDialog.Path);
    59           }
    60         } else {
     43      var importTypeDialog = new ClassificationImportTypeDialog();
     44      if (importTypeDialog.ShowDialog() == DialogResult.OK) {
     45        IClassificationProblemData instance = null;
     46        try {
     47          instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
     48        } catch (IOException ex) {
     49          ErrorWhileParsing(ex);
    6150          return;
    6251        }
    63       } else {
    64         base.importButton_Click(sender, e);
     52        try {
     53          GenericConsumer.Load(instance);
     54          instancesComboBox.SelectedIndex = -1;
     55        } catch (IOException ex) {
     56          ErrorWhileLoading(ex, importTypeDialog.Path);
     57        }
    6558      }
    6659    }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/ClusteringInstanceProviderView.Designer.cs

    r9999 r10000  
    2121
    2222namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    23   partial class ClassificationInstanceConsumerView {
     23  partial class ClusteringInstanceProviderView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/ClusteringInstanceProviderView.cs

    r9999 r10000  
    2727
    2828namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    29   [View("Classification InstanceProvider View")]
    30   [Content(typeof(IProblemInstanceConsumer<IClassificationProblemData>), IsDefaultView = true)]
    31   public partial class ClassificationInstanceConsumerView : DataAnalysisInstanceConsumerView<IClassificationProblemData> {
    32     public new IProblemInstanceConsumer<IClassificationProblemData> Content {
    33       get { return (IProblemInstanceConsumer<IClassificationProblemData>)base.Content; }
     29  [View("Clustering InstanceProvider View")]
     30  [Content(typeof(ClusteringInstanceProvider), IsDefaultView = true)]
     31  public partial class ClusteringInstanceProviderView : DataAnalysisInstanceProviderView<IClusteringProblemData> {
     32
     33    public new ClusteringInstanceProvider Content {
     34      get { return (ClusteringInstanceProvider)base.Content; }
    3435      set { base.Content = value; }
    3536    }
    3637
    37     public ClassificationInstanceConsumerView() {
     38    public ClusteringInstanceProviderView() {
    3839      InitializeComponent();
    3940    }
    4041
    4142    protected override void importButton_Click(object sender, EventArgs e) {
    42       var provider = SelectedProvider as ClassificationInstanceProvider;
    43       if (provider != null) {
    44         ClassificationImportTypeDialog importTypeDialog = new ClassificationImportTypeDialog();
    45         if (importTypeDialog.ShowDialog() == DialogResult.OK) {
    46           IClassificationProblemData instance = null;
    47           try {
    48             instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    49           }
    50           catch (IOException ex) {
    51             ErrorWhileParsing(ex);
    52             return;
    53           }
    54           try {
    55             GenericConsumer.Load(instance);
    56           }
    57           catch (IOException ex) {
    58             ErrorWhileLoading(ex, importTypeDialog.Path);
    59           }
    60         } else {
     43      var importTypeDialog = new DataAnalysisImportTypeDialog();
     44      if (importTypeDialog.ShowDialog() == DialogResult.OK) {
     45        IClusteringProblemData instance = null;
     46        try {
     47          instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
     48        } catch (IOException ex) {
     49          ErrorWhileParsing(ex);
    6150          return;
    6251        }
    63       } else {
    64         base.importButton_Click(sender, e);
     52        try {
     53          GenericConsumer.Load(instance);
     54          instancesComboBox.SelectedIndex = -1;
     55        } catch (IOException ex) {
     56          ErrorWhileLoading(ex, importTypeDialog.Path);
     57        }
    6558      }
    6659    }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisInstanceProviderView.Designer.cs

    r9999 r10000  
    2121
    2222namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    23   partial class DataAnalysisInstanceConsumerView<T> {
     23  partial class DataAnalysisInstanceProviderView<T> {
    2424    /// <summary>
    2525    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/DataAnalysisInstanceProviderView.cs

    r9999 r10000  
    2929namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    3030  [View("DataAnalysis InstanceProvider View")]
    31   [Content(typeof(IProblemInstanceConsumer<IDataAnalysisProblemData>), IsDefaultView = true)]
    32   [Content(typeof(IProblemInstanceConsumer<IClusteringProblemData>), IsDefaultView = true)]
    33   public partial class DataAnalysisInstanceConsumerView<T> : ProblemInstanceConsumerViewGeneric<T>
     31  public partial class DataAnalysisInstanceProviderView<T> : ProblemInstanceProviderViewGeneric<T>
    3432    where T : class, IDataAnalysisProblemData {
    35     public new IProblemInstanceConsumer<T> Content {
    36       get { return (IProblemInstanceConsumer<T>)base.Content; }
    37       set { base.Content = value; }
    38     }
    3933
    40     public DataAnalysisInstanceConsumerView() {
     34    public DataAnalysisInstanceProviderView() {
    4135      InitializeComponent();
    4236    }
    4337
    4438    protected override void importButton_Click(object sender, EventArgs e) {
    45       var provider = SelectedProvider as DataAnalysisInstanceProvider<T, DataAnalysisImportType>;
     39      var provider = Content as DataAnalysisInstanceProvider<T, DataAnalysisImportType>;
    4640      if (provider != null) {
    47         DataAnalysisImportTypeDialog importTypeDialog = new DataAnalysisImportTypeDialog();
     41        var importTypeDialog = new DataAnalysisImportTypeDialog();
    4842        if (importTypeDialog.ShowDialog() == DialogResult.OK) {
    4943          T instance = default(T);
    5044          try {
    5145            instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    52           }
    53           catch (IOException ex) {
     46          } catch (IOException ex) {
    5447            ErrorWhileParsing(ex);
    5548            return;
     
    5750          try {
    5851            GenericConsumer.Load(instance);
    59           }
    60           catch (IOException ex) {
     52            instancesComboBox.SelectedIndex = -1;
     53          } catch (IOException ex) {
    6154            ErrorWhileLoading(ex, importTypeDialog.Path);
    6255          }
    63         } else {
    64           return;
    6556        }
    6657      } else {
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.csproj

    r8885 r10000  
    9292      <DependentUpon>ClassificationImportTypeDialog.cs</DependentUpon>
    9393    </Compile>
    94     <Compile Include="ClassificationInstanceConsumerView.cs">
    95       <SubType>UserControl</SubType>
    96     </Compile>
    97     <Compile Include="ClassificationInstanceConsumerView.Designer.cs">
    98       <DependentUpon>ClassificationInstanceConsumerView.cs</DependentUpon>
     94    <Compile Include="ClassificationInstanceProviderView.cs">
     95      <SubType>UserControl</SubType>
     96    </Compile>
     97    <Compile Include="ClassificationInstanceProviderView.Designer.cs">
     98      <DependentUpon>ClassificationInstanceProviderView.cs</DependentUpon>
     99    </Compile>
     100    <Compile Include="ClusteringInstanceProviderView.cs">
     101      <SubType>UserControl</SubType>
     102    </Compile>
     103    <Compile Include="ClusteringInstanceProviderView.Designer.cs">
     104      <DependentUpon>ClusteringInstanceProviderView.cs</DependentUpon>
    99105    </Compile>
    100106    <Compile Include="TimeSeriesPrognosisImportTypeDialog.cs">
     
    104110      <DependentUpon>TimeSeriesPrognosisImportTypeDialog.cs</DependentUpon>
    105111    </Compile>
    106     <Compile Include="TimeSeriesPrognosisInstanceConsumerView.cs">
    107       <SubType>UserControl</SubType>
    108     </Compile>
    109     <Compile Include="TimeSeriesPrognosisInstanceConsumerView.Designer.cs">
    110       <DependentUpon>TimeSeriesPrognosisInstanceConsumerView.cs</DependentUpon>
     112    <Compile Include="TimeSeriesPrognosisInstanceProviderView.cs">
     113      <SubType>UserControl</SubType>
     114    </Compile>
     115    <Compile Include="TimeSeriesPrognosisInstanceProviderView.Designer.cs">
     116      <DependentUpon>TimeSeriesPrognosisInstanceProviderView.cs</DependentUpon>
    111117    </Compile>
    112118    <Compile Include="DataAnalysisImportTypeDialog.cs">
     
    116122      <DependentUpon>DataAnalysisImportTypeDialog.cs</DependentUpon>
    117123    </Compile>
    118     <Compile Include="DataAnalysisInstanceConsumerView.cs">
    119       <SubType>UserControl</SubType>
    120     </Compile>
    121     <Compile Include="DataAnalysisInstanceConsumerView.Designer.cs">
    122       <DependentUpon>DataAnalysisInstanceConsumerView.cs</DependentUpon>
     124    <Compile Include="DataAnalysisInstanceProviderView.cs">
     125      <SubType>UserControl</SubType>
     126    </Compile>
     127    <Compile Include="DataAnalysisInstanceProviderView.Designer.cs">
     128      <DependentUpon>DataAnalysisInstanceProviderView.cs</DependentUpon>
    123129    </Compile>
    124130    <Compile Include="Plugin.cs" />
     
    129135      <DependentUpon>RegressionImportTypeDialog.cs</DependentUpon>
    130136    </Compile>
    131     <Compile Include="RegressionInstanceConsumerView.cs">
    132       <SubType>UserControl</SubType>
    133     </Compile>
    134     <Compile Include="RegressionInstanceConsumerView.Designer.cs">
    135       <DependentUpon>RegressionInstanceConsumerView.cs</DependentUpon>
     137    <Compile Include="RegressionInstanceProviderView.cs">
     138      <SubType>UserControl</SubType>
     139    </Compile>
     140    <Compile Include="RegressionInstanceProviderView.Designer.cs">
     141      <DependentUpon>RegressionInstanceProviderView.cs</DependentUpon>
    136142    </Compile>
    137143    <None Include="HeuristicLab.snk" />
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/RegressionInstanceProviderView.Designer.cs

    r9999 r10000  
    2121
    2222namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    23   partial class RegressionInstanceConsumerView {
     23  partial class RegressionInstanceProviderView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/RegressionInstanceProviderView.cs

    r9999 r10000  
    2828namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    2929  [View("Regression InstanceProvider View")]
    30   [Content(typeof(IProblemInstanceConsumer<IRegressionProblemData>), IsDefaultView = true)]
    31   public partial class RegressionInstanceConsumerView : DataAnalysisInstanceConsumerView<IRegressionProblemData> {
    32     public new IProblemInstanceConsumer<IRegressionProblemData> Content {
    33       get { return (IProblemInstanceConsumer<IRegressionProblemData>)base.Content; }
     30  [Content(typeof(RegressionInstanceProvider), IsDefaultView = true)]
     31  public partial class RegressionInstanceProviderView : DataAnalysisInstanceProviderView<IRegressionProblemData> {
     32
     33    public new RegressionInstanceProvider Content {
     34      get { return (RegressionInstanceProvider)base.Content; }
    3435      set { base.Content = value; }
    3536    }
    3637
    37     public RegressionInstanceConsumerView() {
     38    public RegressionInstanceProviderView() {
    3839      InitializeComponent();
    3940    }
    4041
    4142    protected override void importButton_Click(object sender, EventArgs e) {
    42       var provider = SelectedProvider as RegressionInstanceProvider;
    43       if (provider != null) {
    44         RegressionImportTypeDialog importTypeDialog = new RegressionImportTypeDialog();
    45         if (importTypeDialog.ShowDialog() == DialogResult.OK) {
    46           IRegressionProblemData instance = null;
    47           try {
    48             instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    49           }
    50           catch (IOException ex) {
    51             ErrorWhileParsing(ex);
    52             return;
    53           }
    54           try {
    55             GenericConsumer.Load(instance);
    56           }
    57           catch (IOException ex) {
    58             ErrorWhileLoading(ex, importTypeDialog.Path);
    59           }
    60         } else {
     43      var importTypeDialog = new RegressionImportTypeDialog();
     44      if (importTypeDialog.ShowDialog() == DialogResult.OK) {
     45        IRegressionProblemData instance = null;
     46        try {
     47          instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
     48        } catch (IOException ex) {
     49          ErrorWhileParsing(ex);
    6150          return;
    6251        }
    63       } else {
    64         base.importButton_Click(sender, e);
     52        try {
     53          GenericConsumer.Load(instance);
     54          instancesComboBox.SelectedIndex = -1;
     55        } catch (IOException ex) {
     56          ErrorWhileLoading(ex, importTypeDialog.Path);
     57        }
    6558      }
    6659    }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/TimeSeriesPrognosisInstanceProviderView.Designer.cs

    r9999 r10000  
    2121
    2222namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    23   partial class TimeSeriesPrognosisInstanceConsumerView {
     23  partial class TimeSeriesPrognosisInstanceProviderView {
    2424    /// <summary>
    2525    /// Required designer variable.
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/TimeSeriesPrognosisInstanceProviderView.cs

    r9999 r10000  
    2828namespace HeuristicLab.Problems.Instances.DataAnalysis.Views {
    2929  [View("TimeSeriesPrognosis InstanceProvider View")]
    30   [Content(typeof(IProblemInstanceConsumer<ITimeSeriesPrognosisProblemData>), IsDefaultView = true)]
    31   public partial class TimeSeriesPrognosisInstanceConsumerView : DataAnalysisInstanceConsumerView<ITimeSeriesPrognosisProblemData> {
    32     public new IProblemInstanceConsumer<ITimeSeriesPrognosisProblemData> Content {
    33       get { return (IProblemInstanceConsumer<ITimeSeriesPrognosisProblemData>)base.Content; }
     30  [Content(typeof(TimeSeriesPrognosisInstanceProvider), IsDefaultView = true)]
     31  public partial class TimeSeriesPrognosisInstanceProviderView : DataAnalysisInstanceProviderView<ITimeSeriesPrognosisProblemData> {
     32
     33    public new TimeSeriesPrognosisInstanceProvider Content {
     34      get { return (TimeSeriesPrognosisInstanceProvider)base.Content; }
    3435      set { base.Content = value; }
    3536    }
    3637
    37     public TimeSeriesPrognosisInstanceConsumerView() {
     38    public TimeSeriesPrognosisInstanceProviderView() {
    3839      InitializeComponent();
    3940    }
    4041
    4142    protected override void importButton_Click(object sender, EventArgs e) {
    42       var provider = SelectedProvider as TimeSeriesPrognosisInstanceProvider;
    43       if (provider != null) {
    44         TimeSeriesPrognosisImportTypeDialog importTypeDialog = new TimeSeriesPrognosisImportTypeDialog();
    45         if (importTypeDialog.ShowDialog() == DialogResult.OK) {
    46           ITimeSeriesPrognosisProblemData instance = null;
    47           try {
    48             instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
    49           }
    50           catch (IOException ex) {
    51             ErrorWhileParsing(ex);
    52             return;
    53           }
    54           try {
    55             GenericConsumer.Load(instance);
    56           }
    57           catch (IOException ex) {
    58             ErrorWhileLoading(ex, importTypeDialog.Path);
    59           }
    60         } else {
     43      var importTypeDialog = new TimeSeriesPrognosisImportTypeDialog();
     44      if (importTypeDialog.ShowDialog() == DialogResult.OK) {
     45        ITimeSeriesPrognosisProblemData instance = null;
     46        try {
     47          instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
     48        } catch (IOException ex) {
     49          ErrorWhileParsing(ex);
    6150          return;
    6251        }
    63       } else {
    64         base.importButton_Click(sender, e);
     52        try {
     53          GenericConsumer.Load(instance);
     54          instancesComboBox.SelectedIndex = -1;
     55        } catch (IOException ex) {
     56          ErrorWhileLoading(ex, importTypeDialog.Path);
     57        }
    6558      }
    6659    }
  • trunk/sources/HeuristicLab.Problems.Instances.TSPLIB.Views/3.3/TSPLIBTSPInstanceProviderView.cs

    r9456 r10000  
    2424using System.Windows.Forms;
    2525using HeuristicLab.MainForm;
    26 using HeuristicLab.MainForm.WindowsForms;
    2726using HeuristicLab.Problems.Instances.Views;
    2827
    2928namespace HeuristicLab.Problems.Instances.TSPLIB.Views {
    3029  [View("TSPLIB TSP InstanceProvider View")]
    31   [Content(typeof(IProblemInstanceConsumer<TSPData>), IsDefaultView = true)]
    32   public partial class TSPLIBTSPInstanceProviderView : ProblemInstanceConsumerViewGeneric<TSPData> {
    33     public new IProblemInstanceConsumer<TSPData> Content {
    34       get { return (IProblemInstanceConsumer<TSPData>)base.Content; }
     30  [Content(typeof(TSPLIBTSPInstanceProvider), IsDefaultView = true)]
     31  public partial class TSPLIBTSPInstanceProviderView : ProblemInstanceProviderViewGeneric<TSPData> {
     32    public new TSPLIBTSPInstanceProvider Content {
     33      get { return (TSPLIBTSPInstanceProvider)base.Content; }
    3534      set { base.Content = value; }
    3635    }
     
    4140
    4241    protected override void importButton_Click(object sender, EventArgs e) {
    43       TSPLIBTSPInstanceProvider provider = SelectedProvider as TSPLIBTSPInstanceProvider;
    44       if (provider != null) {
    45         using (var dialog = new TSPLIBImportDialog()) {
    46           if (dialog.ShowDialog() == DialogResult.OK) {
    47             var instance = provider.LoadData(dialog.TSPFileName, dialog.TourFileName, dialog.Quality);
    48             try {
    49               GenericConsumer.Load(instance);
    50             }
    51             catch (Exception ex) {
    52               MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
    53             }
     42      using (var dialog = new TSPLIBImportDialog()) {
     43        if (dialog.ShowDialog() == DialogResult.OK) {
     44          var instance = Content.LoadData(dialog.TSPFileName, dialog.TourFileName, dialog.Quality);
     45          try {
     46            GenericConsumer.Load(instance);
     47            instancesComboBox.SelectedIndex = -1;
     48          } catch (Exception ex) {
     49            MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
    5450          }
    5551        }
    56       } else {
    57         base.importButton_Click(sender, e);
    5852      }
    5953    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/HeuristicLab.Problems.Instances.VehicleRouting.Views-3.4.csproj

    r8600 r10000  
    115115    <Compile Include="Plugin.cs" />
    116116    <Compile Include="Properties\AssemblyInfo.cs" />
    117     <Compile Include="VRPInstanceConsumerView.cs">
     117    <Compile Include="VRPInstanceProviderView.cs">
    118118      <SubType>UserControl</SubType>
    119119    </Compile>
    120     <Compile Include="VRPInstanceConsumerView.designer.cs">
    121       <DependentUpon>VRPInstanceConsumerView.cs</DependentUpon>
     120    <Compile Include="VRPInstanceProviderView.designer.cs">
     121      <DependentUpon>VRPInstanceProviderView.cs</DependentUpon>
    122122    </Compile>
    123123    <Compile Include="VRPImportDialog.cs">
     
    182182  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    183183  <PropertyGroup>
    184    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     184    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    185185set ProjectDir=$(ProjectDir)
    186186set SolutionDir=$(SolutionDir)
     
    188188
    189189call PreBuildEvent.cmd</PreBuildEvent>
    190 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     190    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    191191export ProjectDir=$(ProjectDir)
    192192export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceProviderView.cs

    r9999 r10000  
    2424using System.Windows.Forms;
    2525using HeuristicLab.MainForm;
    26 using HeuristicLab.MainForm.WindowsForms;
    2726using HeuristicLab.PluginInfrastructure;
    2827using HeuristicLab.Problems.Instances.Views;
     
    3029namespace HeuristicLab.Problems.Instances.VehicleRouting.Views {
    3130  [View("VRP InstanceProvider View")]
    32   [Content(typeof(IProblemInstanceConsumer<IVRPData>), IsDefaultView = true)]
    33   public partial class VRPInstanceProviderView<T> : ProblemInstanceConsumerViewGeneric<T> where T : class, IVRPData {
    34 
    35     public new IProblemInstanceConsumer<T> Content {
    36       get { return (IProblemInstanceConsumer<T>)base.Content; }
    37       set { base.Content = value; }
    38     }
     31  [Content(typeof(IProblemInstanceProvider<IVRPData>), IsDefaultView = true)]
     32  public partial class VRPInstanceProviderView<T> : ProblemInstanceProviderViewGeneric<T> where T : class, IVRPData {
    3933
    4034    public VRPInstanceProviderView() {
     
    4236    }
    4337
    44     protected override void SetEnabledStateOfControls() {
    45       problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;
    46       libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;
    47       IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
    48       importButton.Enabled = !ReadOnly && !Locked && Content != null && Consumer != null &&
    49                              provider != null && provider.CanImportData;
    50       ProviderImportSplitContainer.Panel2Collapsed = !importButton.Enabled;
    51       exportButton.Enabled = !ReadOnly && !Locked && Content != null && Exporter != null &&
    52                              provider != null && provider.CanExportData;
    53       ProviderExportSplitContainer.Panel2Collapsed = !exportButton.Enabled;
    54     }
    55 
    5638    protected override void importButton_Click(object sender, EventArgs e) {
    57       IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     39      var provider = Content as IVRPInstanceProvider;
    5840      if (provider != null) {
    59         using (var dialog = new VRPImportDialog(SelectedProvider.Name)) {
     41        using (var dialog = new VRPImportDialog(Content.Name)) {
    6042          if (dialog.ShowDialog() == DialogResult.OK) {
    6143            var instance = provider.Import(dialog.VRPFileName, dialog.TourFileName);
    6244            try {
    6345              GenericConsumer.Load(instance as T);
    64             }
    65             catch (Exception ex) {
     46              instancesComboBox.SelectedIndex = -1;
     47            } catch (Exception ex) {
    6648              MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
    6749            }
     
    7254
    7355    protected override void exportButton_Click(object sender, EventArgs e) {
    74       IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     56      var provider = Content as IVRPInstanceProvider;
    7557      if (provider != null) {
    7658        if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
    7759          try {
    7860            provider.Export(GenericExporter.Export(), saveFileDialog.FileName);
    79           }
    80           catch (Exception ex) {
     61          } catch (Exception ex) {
    8162            ErrorHandling.ShowErrorDialog(this, ex);
    8263          }
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/HeuristicLab.Problems.Instances.Views-3.3.csproj

    r8600 r10000  
    113113  </ItemGroup>
    114114  <ItemGroup>
    115     <Compile Include="ProblemInstanceConsumerViewGeneric.cs">
    116       <SubType>UserControl</SubType>
    117     </Compile>
    118     <Compile Include="ProblemInstanceConsumerViewGeneric.Designer.cs">
    119       <DependentUpon>ProblemInstanceConsumerViewGeneric.cs</DependentUpon>
    120     </Compile>
    121115    <Compile Include="Plugin.cs" />
    122     <Compile Include="ProblemInstanceConsumerView.cs">
    123       <SubType>UserControl</SubType>
    124     </Compile>
    125     <Compile Include="ProblemInstanceConsumerView.Designer.cs">
    126       <DependentUpon>ProblemInstanceConsumerView.cs</DependentUpon>
    127     </Compile>
    128116    <Compile Include="ProblemInstanceProviderView.cs">
    129117      <SubType>UserControl</SubType>
     
    199187  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    200188  <PropertyGroup>
    201    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     189    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    202190set ProjectDir=$(ProjectDir)
    203191set SolutionDir=$(SolutionDir)
     
    206194call PreBuildEvent.cmd
    207195</PreBuildEvent>
    208 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     196    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    209197export ProjectDir=$(ProjectDir)
    210198export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderView.cs

    r9456 r10000  
    2121
    2222using System.Windows.Forms;
     23using HeuristicLab.Core;
    2324using HeuristicLab.MainForm;
    2425using HeuristicLab.MainForm.WindowsForms;
     
    3536
    3637    public abstract IProblemInstanceConsumer Consumer { get; set; }
     38    public abstract IProblemInstanceExporter Exporter { get; set; }
    3739
    38     public ProblemInstanceProviderView() {
     40    protected ProblemInstanceProviderView() {
    3941      InitializeComponent();
    4042    }
     43
     44    protected string GetProblemType() {
     45      var item = Consumer as IItem;
     46      return item != null ? item.ItemName : "problem";
     47    }
     48
     49    protected string GetProviderFormatInfo() {
     50      return Content != null ? Content.Name : string.Empty;
     51    }
     52
     53    protected abstract void SetTooltip();
    4154  }
    4255}
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.Designer.cs

    r9456 r10000  
    1919 */
    2020#endregion
     21
    2122
    2223namespace HeuristicLab.Problems.Instances.Views {
     
    4546    /// </summary>
    4647    private void InitializeComponent() {
    47       this.components = new System.ComponentModel.Container();
    48       this.instanceLabel = new System.Windows.Forms.Label();
    4948      this.instancesComboBox = new System.Windows.Forms.ComboBox();
    5049      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    5150      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
     51      this.instanceLabel = new System.Windows.Forms.Label();
     52      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
     53      this.exportButton = new System.Windows.Forms.Button();
     54      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     55      this.importButton = new System.Windows.Forms.Button();
     56      this.libraryInfoButton = new System.Windows.Forms.Button();
     57      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
     58      this.splitContainer2.Panel1.SuspendLayout();
     59      this.splitContainer2.Panel2.SuspendLayout();
     60      this.splitContainer2.SuspendLayout();
     61      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
     62      this.splitContainer1.Panel1.SuspendLayout();
     63      this.splitContainer1.Panel2.SuspendLayout();
     64      this.splitContainer1.SuspendLayout();
    5265      this.SuspendLayout();
    53       //
    54       // instanceLabel
    55       //
    56       this.instanceLabel.AutoSize = true;
    57       this.instanceLabel.Location = new System.Drawing.Point(3, 4);
    58       this.instanceLabel.Name = "instanceLabel";
    59       this.instanceLabel.Size = new System.Drawing.Size(51, 13);
    60       this.instanceLabel.TabIndex = 4;
    61       this.instanceLabel.Text = "Instance:";
    6266      //
    6367      // instancesComboBox
     
    6771      this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    6872      this.instancesComboBox.FormattingEnabled = true;
    69       this.instancesComboBox.Location = new System.Drawing.Point(60, 1);
     73      this.instancesComboBox.Location = new System.Drawing.Point(60, 2);
    7074      this.instancesComboBox.Name = "instancesComboBox";
    71       this.instancesComboBox.Size = new System.Drawing.Size(632, 21);
     75      this.instancesComboBox.Size = new System.Drawing.Size(540, 21);
    7276      this.instancesComboBox.TabIndex = 7;
     77      this.instancesComboBox.SelectionChangeCommitted += new System.EventHandler(this.instancesComboBox_SelectionChangeCommitted);
    7378      this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.instancesComboBox_DataSourceChanged);
    74       this.instancesComboBox.SelectionChangeCommitted += new System.EventHandler(instancesComboBox_SelectionChangeCommitted);
    7579      //
    7680      // openFileDialog
     
    8387      this.saveFileDialog.Title = "Save RegressionInstance...";
    8488      //
     89      // instanceLabel
     90      //
     91      this.instanceLabel.AutoSize = true;
     92      this.instanceLabel.Location = new System.Drawing.Point(3, 5);
     93      this.instanceLabel.Name = "instanceLabel";
     94      this.instanceLabel.Size = new System.Drawing.Size(51, 13);
     95      this.instanceLabel.TabIndex = 4;
     96      this.instanceLabel.Text = "Instance:";
     97      //
     98      // splitContainer2
     99      //
     100      this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
     101      this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
     102      this.splitContainer2.IsSplitterFixed = true;
     103      this.splitContainer2.Location = new System.Drawing.Point(0, 0);
     104      this.splitContainer2.Name = "splitContainer2";
     105      //
     106      // splitContainer2.Panel1
     107      //
     108      this.splitContainer2.Panel1.Controls.Add(this.exportButton);
     109      //
     110      // splitContainer2.Panel2
     111      //
     112      this.splitContainer2.Panel2.Controls.Add(this.instanceLabel);
     113      this.splitContainer2.Panel2.Controls.Add(this.instancesComboBox);
     114      this.splitContainer2.Size = new System.Drawing.Size(632, 23);
     115      this.splitContainer2.SplitterDistance = 25;
     116      this.splitContainer2.TabIndex = 21;
     117      //
     118      // exportButton
     119      //
     120      this.exportButton.Location = new System.Drawing.Point(1, 0);
     121      this.exportButton.Name = "exportButton";
     122      this.exportButton.Size = new System.Drawing.Size(24, 24);
     123      this.exportButton.TabIndex = 20;
     124      this.exportButton.Text = "Export";
     125      this.exportButton.UseVisualStyleBackColor = true;
     126      this.exportButton.Click += new System.EventHandler(exportButton_Click);
     127      //
     128      // splitContainer1
     129      //
     130      this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     131            | System.Windows.Forms.AnchorStyles.Right)));
     132      this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
     133      this.splitContainer1.IsSplitterFixed = true;
     134      this.splitContainer1.Location = new System.Drawing.Point(33, -1);
     135      this.splitContainer1.Name = "splitContainer1";
     136      //
     137      // splitContainer1.Panel1
     138      //
     139      this.splitContainer1.Panel1.Controls.Add(this.importButton);
     140      //
     141      // splitContainer1.Panel2
     142      //
     143      this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
     144      this.splitContainer1.Size = new System.Drawing.Size(661, 23);
     145      this.splitContainer1.SplitterDistance = 25;
     146      this.splitContainer1.TabIndex = 21;
     147      //
     148      // importButton
     149      //
     150      this.importButton.Location = new System.Drawing.Point(0, 0);
     151      this.importButton.Name = "importButton";
     152      this.importButton.Size = new System.Drawing.Size(24, 24);
     153      this.importButton.TabIndex = 19;
     154      this.importButton.Text = "Import";
     155      this.importButton.UseVisualStyleBackColor = true;
     156      this.importButton.Click += new System.EventHandler(importButton_Click);
     157      //
     158      // libraryInfoButton
     159      //
     160      this.libraryInfoButton.Location = new System.Drawing.Point(3, -1);
     161      this.libraryInfoButton.Name = "libraryInfoButton";
     162      this.libraryInfoButton.Size = new System.Drawing.Size(24, 24);
     163      this.libraryInfoButton.TabIndex = 22;
     164      this.libraryInfoButton.Text = "Info";
     165      this.libraryInfoButton.UseVisualStyleBackColor = true;
     166      this.libraryInfoButton.Click += new System.EventHandler(this.libraryInfoButton_Click);
     167      //
    85168      // ProblemInstanceProviderViewGeneric
    86169      //
    87       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    88170      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    89       this.Controls.Add(this.instanceLabel);
    90       this.Controls.Add(this.instancesComboBox);
     171      this.Controls.Add(this.libraryInfoButton);
     172      this.Controls.Add(this.splitContainer1);
    91173      this.Name = "ProblemInstanceProviderViewGeneric";
    92       this.Size = new System.Drawing.Size(694, 21);
     174      this.splitContainer2.Panel1.ResumeLayout(false);
     175      this.splitContainer2.Panel2.ResumeLayout(false);
     176      this.splitContainer2.Panel2.PerformLayout();
     177      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
     178      this.splitContainer2.ResumeLayout(false);
     179      this.splitContainer1.Panel1.ResumeLayout(false);
     180      this.splitContainer1.Panel2.ResumeLayout(false);
     181      ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
     182      this.splitContainer1.ResumeLayout(false);
    93183      this.ResumeLayout(false);
    94       this.PerformLayout();
    95184
    96185    }
     
    98187
    99188    protected System.Windows.Forms.OpenFileDialog openFileDialog;
    100     protected System.Windows.Forms.Label instanceLabel;
    101189    protected System.Windows.Forms.ComboBox instancesComboBox;
    102190    protected System.Windows.Forms.SaveFileDialog saveFileDialog;
     191    protected System.Windows.Forms.Label instanceLabel;
     192    protected System.Windows.Forms.SplitContainer splitContainer2;
     193    protected System.Windows.Forms.SplitContainer splitContainer1;
     194    protected System.Windows.Forms.Button libraryInfoButton;
     195    protected System.Windows.Forms.Button importButton;
     196    protected System.Windows.Forms.Button exportButton;
    103197  }
    104198}
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceProviderViewGeneric.cs

    r9991 r10000  
    2121
    2222using System;
    23 using System.ComponentModel;
     23using System.Diagnostics;
     24using System.IO;
    2425using System.Linq;
    2526using System.Threading.Tasks;
    2627using System.Windows.Forms;
     28using HeuristicLab.Common.Resources;
    2729using HeuristicLab.MainForm;
    2830using HeuristicLab.MainForm.WindowsForms;
     
    3941    }
    4042
    41     private IProblemInstanceConsumer<T> GenericConsumer { get { return Consumer as IProblemInstanceConsumer<T>; } }
    42 
    43     private IProblemInstanceConsumer consumer;
     43    #region Importer & Exporter
     44    protected IProblemInstanceConsumer<T> GenericConsumer { get { return Consumer as IProblemInstanceConsumer<T>; } }
     45    protected IProblemInstanceConsumer consumer;
    4446    public override IProblemInstanceConsumer Consumer {
    4547      get { return consumer; }
     
    4749        consumer = value;
    4850        SetEnabledStateOfControls();
     51        SetTooltip();
    4952      }
    5053    }
    5154
     55    protected IProblemInstanceExporter<T> GenericExporter { get { return Exporter as IProblemInstanceExporter<T>; } }
     56    protected IProblemInstanceExporter exporter;
     57    public override IProblemInstanceExporter Exporter {
     58      get { return exporter; }
     59      set {
     60        exporter = value;
     61        SetEnabledStateOfControls();
     62      }
     63    }
     64    #endregion
     65
    5266    public ProblemInstanceProviderViewGeneric() {
    5367      InitializeComponent();
     68      importButton.Text = String.Empty;
     69      importButton.Image = VSImageLibrary.Open;
     70      exportButton.Text = String.Empty;
     71      exportButton.Image = VSImageLibrary.SaveAs;
     72      libraryInfoButton.Text = String.Empty;
     73      libraryInfoButton.Image = VSImageLibrary.Help;
    5474    }
    5575
     
    6585        instancesComboBox.SelectedIndex = -1;
    6686      }
     87      SetTooltip();
    6788    }
    6889
     
    80101      base.SetEnabledStateOfControls();
    81102      instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null;
     103      libraryInfoButton.Enabled = Content != null && Content.WebLink != null;
     104      importButton.Enabled = !ReadOnly && !Locked && Content != null && GenericConsumer != null && Content.CanImportData;
     105      splitContainer1.Panel1Collapsed = !importButton.Enabled;
     106      exportButton.Enabled = !ReadOnly && !Locked && Content != null && GenericExporter != null && Content.CanExportData;
     107      splitContainer2.Panel1Collapsed = !exportButton.Enabled;
    82108    }
    83109
     
    89115    }
    90116
    91     private void instancesComboBox_SelectionChangeCommitted(object sender, System.EventArgs e) {
     117    protected virtual void instancesComboBox_SelectionChangeCommitted(object sender, EventArgs e) {
    92118      toolTip.SetToolTip(instancesComboBox, String.Empty);
    93119      if (instancesComboBox.SelectedIndex >= 0) {
     
    98124        // lock active view and show progress bar
    99125        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);
    102126
    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));
     127        Task.Factory.StartNew(() => {
     128          T data;
     129          try {
     130            data = Content.LoadData(descriptor);
     131          } catch (Exception ex) {
     132            ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), ex);
     133            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     134            return;
     135          }
     136          try {
     137            GenericConsumer.Load(data);
     138          } catch (Exception ex) {
     139            ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
     140          } finally {
     141            mainForm.RemoveOperationProgressFromContent(activeView.Content);
     142          }
     143        });
     144      }
     145    }
    114146
    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);
     147    private void libraryInfoButton_Click(object sender, EventArgs e) {
     148      Process.Start(Content.WebLink.ToString());
     149    }
    122150
    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);
     151    protected virtual void importButton_Click(object sender, EventArgs e) {
     152      openFileDialog.FileName = Content.Name + " instance";
     153      if (openFileDialog.ShowDialog() == DialogResult.OK) {
     154        T instance = default(T);
     155        try {
     156          instance = Content.ImportData(openFileDialog.FileName);
     157        } catch (Exception ex) {
     158          MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
     159          return;
     160        }
     161        try {
     162          GenericConsumer.Load(instance);
     163          instancesComboBox.SelectedIndex = -1;
     164        } catch (Exception ex) {
     165          MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
     166        }
     167      }
     168    }
    130169
    131         // start async loading task
    132         loadFromProvider.Start();
     170    protected virtual void exportButton_Click(object sender, EventArgs e) {
     171      if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
     172        try {
     173          Content.ExportData(GenericExporter.Export(), saveFileDialog.FileName);
     174        } catch (Exception ex) {
     175          ErrorHandling.ShowErrorDialog(this, ex);
     176        }
    133177      }
     178    }
     179
     180    protected override void SetTooltip() {
     181      toolTip.SetToolTip(importButton, "Import a " + GetProblemType() + " from a file in the " + GetProviderFormatInfo() + " format.");
     182      toolTip.SetToolTip(exportButton, "Export currently loaded " + GetProblemType() + " to a file in the " + GetProviderFormatInfo() + " format.");
     183      if (Content != null && Content.WebLink != null)
     184        toolTip.SetToolTip(libraryInfoButton, "Browse to " + Content.WebLink);
     185      else toolTip.SetToolTip(libraryInfoButton, "Library does not have a web reference.");
    134186    }
    135187  }
  • trunk/sources/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.Designer.cs

    r9456 r10000  
    7171      // ProblemInstanceConsumerViewHost
    7272      //
    73       this.ProblemInstanceConsumerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
    74       this.ProblemInstanceConsumerViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    75       this.ProblemInstanceConsumerViewHost.Location = new System.Drawing.Point(0, 0);
    76       this.ProblemInstanceConsumerViewHost.Size = new System.Drawing.Size(511, 26);
     73      this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     74      this.problemInstanceProviderViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     75      this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(0, 0);
     76      this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(511, 26);
    7777      //
    7878      // parameterCollectionView
     
    9595      // problemTabControl
    9696      //
    97       this.problemTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    98             | System.Windows.Forms.AnchorStyles.Left) 
     97      this.problemTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     98            | System.Windows.Forms.AnchorStyles.Left)
    9999            | System.Windows.Forms.AnchorStyles.Right)));
    100100      this.problemTabControl.Controls.Add(this.problemTabPage);
Note: See TracChangeset for help on using the changeset viewer.