Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj	(revision 7469)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj	(revision 7558)
@@ -99,4 +99,5 @@
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.CSharp" />
     <Reference Include="System" />
     <Reference Include="System.Core">
@@ -137,4 +138,16 @@
     </Compile>
     <Compile Include="Plugin.cs" />
+    <Compile Include="ProblemInstanceProviderView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="ProblemInstanceProviderView.Designer.cs">
+      <DependentUpon>ProblemInstanceProviderView.cs</DependentUpon>
+    </Compile>
+    <Compile Include="ProblemView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="ProblemView.designer.cs">
+      <DependentUpon>ProblemView.cs</DependentUpon>
+    </Compile>
     <Compile Include="RunCollectionModifierListView.cs">
       <SubType>UserControl</SubType>
@@ -251,9 +264,9 @@
       <DependentUpon>EngineAlgorithmView.cs</DependentUpon>
     </Compile>
-    <Compile Include="ProblemView.cs">
-      <SubType>UserControl</SubType>
-    </Compile>
-    <Compile Include="ProblemView.Designer.cs">
-      <DependentUpon>ProblemView.cs</DependentUpon>
+    <Compile Include="HeuristicOptimizationProblemView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="HeuristicOptimizationProblemView.Designer.cs">
+      <DependentUpon>HeuristicOptimizationProblemView.cs</DependentUpon>
     </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -335,4 +348,8 @@
       <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
       <Private>False</Private>
+    </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
+      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
+      <Name>HeuristicLab.Problems.Instances-3.3</Name>
     </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj">
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicOptimizationProblemView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicOptimizationProblemView.Designer.cs	(revision 7558)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicOptimizationProblemView.Designer.cs	(revision 7558)
@@ -0,0 +1,157 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Optimization.Views {
+  partial class HeuristicOptimizationProblemView {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.libraryLabel = new System.Windows.Forms.Label();
+      this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
+      this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox();
+      this.libraryInfoButton = new System.Windows.Forms.Button();
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      this.SuspendLayout();
+      // 
+      // parameterCollectionView
+      // 
+      this.parameterCollectionView.Location = new System.Drawing.Point(0, 58);
+      this.parameterCollectionView.Size = new System.Drawing.Size(650, 394);
+      // 
+      // nameTextBox
+      // 
+      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
+      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
+      this.nameTextBox.Location = new System.Drawing.Point(50, 32);
+      this.nameTextBox.Size = new System.Drawing.Size(578, 20);
+      // 
+      // nameLabel
+      // 
+      this.nameLabel.Location = new System.Drawing.Point(3, 35);
+      // 
+      // toolTip
+      // 
+      this.toolTip.AutoPopDelay = 10000;
+      this.toolTip.InitialDelay = 100;
+      this.toolTip.ReshowDelay = 100;
+      // 
+      // infoLabel
+      // 
+      this.infoLabel.Location = new System.Drawing.Point(634, 35);
+      // 
+      // libraryLabel
+      // 
+      this.libraryLabel.AutoSize = true;
+      this.libraryLabel.Location = new System.Drawing.Point(3, 8);
+      this.libraryLabel.Name = "libraryLabel";
+      this.libraryLabel.Size = new System.Drawing.Size(41, 13);
+      this.libraryLabel.TabIndex = 4;
+      this.libraryLabel.Text = "Library:";
+      // 
+      // problemInstanceProviderViewHost
+      // 
+      this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.problemInstanceProviderViewHost.Caption = "View";
+      this.problemInstanceProviderViewHost.Content = null;
+      this.problemInstanceProviderViewHost.Enabled = false;
+      this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(259, 5);
+      this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost";
+      this.problemInstanceProviderViewHost.ReadOnly = false;
+      this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(391, 21);
+      this.problemInstanceProviderViewHost.TabIndex = 6;
+      this.problemInstanceProviderViewHost.ViewsLabelVisible = false;
+      this.problemInstanceProviderViewHost.ViewType = null;
+      // 
+      // problemInstanceProviderComboBox
+      // 
+      this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.problemInstanceProviderComboBox.FormattingEnabled = true;
+      this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 5);
+      this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
+      this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(171, 21);
+      this.problemInstanceProviderComboBox.TabIndex = 7;
+      this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
+      this.problemInstanceProviderComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged);
+      // 
+      // libraryInfoButton
+      // 
+      this.libraryInfoButton.Location = new System.Drawing.Point(227, 4);
+      this.libraryInfoButton.Name = "libraryInfoButton";
+      this.libraryInfoButton.Size = new System.Drawing.Size(26, 23);
+      this.libraryInfoButton.TabIndex = 8;
+      this.libraryInfoButton.Text = "Info";
+      this.libraryInfoButton.UseVisualStyleBackColor = true;
+      this.libraryInfoButton.Click += new System.EventHandler(this.libraryInfoButton_Click);
+      // 
+      // ProblemView
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.Controls.Add(this.problemInstanceProviderViewHost);
+      this.Controls.Add(this.problemInstanceProviderComboBox);
+      this.Controls.Add(this.libraryLabel);
+      this.Controls.Add(this.libraryInfoButton);
+      this.Name = "ProblemView";
+      this.Size = new System.Drawing.Size(653, 455);
+      this.Controls.SetChildIndex(this.libraryInfoButton, 0);
+      this.Controls.SetChildIndex(this.libraryLabel, 0);
+      this.Controls.SetChildIndex(this.problemInstanceProviderComboBox, 0);
+      this.Controls.SetChildIndex(this.problemInstanceProviderViewHost, 0);
+      this.Controls.SetChildIndex(this.infoLabel, 0);
+      this.Controls.SetChildIndex(this.nameTextBox, 0);
+      this.Controls.SetChildIndex(this.nameLabel, 0);
+      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    protected System.Windows.Forms.Label libraryLabel;
+    protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
+    protected MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
+    protected System.Windows.Forms.Button libraryInfoButton;
+
+  }
+}
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicOptimizationProblemView.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicOptimizationProblemView.cs	(revision 7558)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicOptimizationProblemView.cs	(revision 7558)
@@ -0,0 +1,137 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Windows.Forms;
+using HeuristicLab.Common.Resources;
+using HeuristicLab.Core.Views;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Optimization.Views {
+  [View("HeuristicOptimizationProblemView")]
+  [Content(typeof(IHeuristicOptimizationProblem), IsDefaultView = true)]
+  public partial class HeuristicOptimizationProblemView : ParameterizedNamedItemView {
+
+    public new IProblem Content {
+      get { return (IProblem)base.Content; }
+      set { base.Content = value; }
+    }
+
+    protected IProblemInstanceProvider SelectedProvider {
+      get { return (problemInstanceProviderComboBox.SelectedIndex >= 0 ? (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem : null); }
+    }
+
+    public HeuristicOptimizationProblemView() {
+      InitializeComponent();
+      libraryInfoButton.Text = String.Empty;
+      libraryInfoButton.Image = VSImageLibrary.Information;
+    }
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        problemInstanceProviderComboBox.DataSource = null;
+      } else {
+        problemInstanceProviderComboBox.DisplayMember = "Name";
+        problemInstanceProviderComboBox.DataSource = GetProblemInstanceProviders().ToList();
+      }
+      SetEnabledStateOfControls();
+    }
+
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;
+      libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;
+    }
+
+    protected virtual void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
+      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
+        dynamic provider = SelectedProvider;
+        dynamic consumer = Content;
+        provider.Consumer = consumer;
+        problemInstanceProviderViewHost.Content = SelectedProvider;
+        SetTooltip();
+      }
+      SetEnabledStateOfControls();
+    }
+
+    private void comboBox_DataSourceChanged(object sender, EventArgs e) {
+      var comboBox = (ComboBox)sender;
+      if (comboBox.DataSource == null)
+        comboBox.Items.Clear();
+    }
+
+    protected virtual void libraryInfoButton_Click(object sender, EventArgs e) {
+      if (problemInstanceProviderComboBox.SelectedIndex >= 0) {
+        if (SelectedProvider != null && SelectedProvider.WebLink != null)
+          Process.Start(SelectedProvider.WebLink.ToString());
+      }
+    }
+
+    protected virtual IEnumerable<IProblemInstanceProvider> GetProblemInstanceProviders() {
+      var consumerTypes = Content.GetType().GetInterfaces()
+        .Where(x => x.IsGenericType
+          && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>));
+
+      if (consumerTypes.Any()) {
+        var instanceTypes = consumerTypes
+          .Select(x => x.GetGenericArguments().First())
+          .Select(x => typeof(IProblemInstanceProvider<>).MakeGenericType(x));
+
+        foreach (var type in instanceTypes) {
+          foreach (var provider in ApplicationManager.Manager.GetInstances(type))
+            yield return (IProblemInstanceProvider)provider;
+        }
+      }
+    }
+
+    protected virtual void SetTooltip() {
+      toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip());
+      if (SelectedProvider.WebLink != null)
+        toolTip.SetToolTip(libraryInfoButton, "Browse to " + SelectedProvider.WebLink.ToString());
+      else toolTip.SetToolTip(libraryInfoButton, "Library does not have a web reference.");
+    }
+
+    protected virtual string GetProviderToolTip() {
+      var provider = SelectedProvider;
+      string toolTip = provider.Name;
+
+      if (!String.IsNullOrEmpty(provider.ReferencePublication)) {
+        toolTip = toolTip
+            + Environment.NewLine + Environment.NewLine
+            + provider.ReferencePublication;
+      }
+      if (provider.WebLink != null) {
+        toolTip = toolTip
+            + Environment.NewLine
+            + provider.WebLink.ToString();
+      }
+
+      return toolTip;
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame	(revision 7469)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame	(revision 7558)
@@ -38,4 +38,5 @@
   [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
   [PluginDependency("HeuristicLab.Optimization", "3.3")]
+  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
   [PluginDependency("HeuristicLab.Visualization.ChartControlsExtensions","3.3")]
   public class HeuristicLabOptimizationViewsPlugin : PluginBase {
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.Designer.cs	(revision 7558)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.Designer.cs	(revision 7558)
@@ -0,0 +1,129 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+namespace HeuristicLab.Optimization.Views {
+  partial class ProblemInstanceProviderView<T> {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.components = new System.ComponentModel.Container();
+      this.loadButton = new System.Windows.Forms.Button();
+      this.instanceLabel = new System.Windows.Forms.Label();
+      this.instancesComboBox = new System.Windows.Forms.ComboBox();
+      this.importButton = new System.Windows.Forms.Button();
+      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
+      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
+      this.SuspendLayout();
+      // 
+      // loadButton
+      // 
+      this.loadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+      this.loadButton.Location = new System.Drawing.Point(549, -1);
+      this.loadButton.Name = "loadButton";
+      this.loadButton.Size = new System.Drawing.Size(26, 23);
+      this.loadButton.TabIndex = 6;
+      this.loadButton.Text = "Load";
+      this.loadButton.UseVisualStyleBackColor = true;
+      this.loadButton.Click += new System.EventHandler(this.loadButton_Click);
+      // 
+      // instanceLabel
+      // 
+      this.instanceLabel.AutoSize = true;
+      this.instanceLabel.Location = new System.Drawing.Point(-3, 3);
+      this.instanceLabel.Name = "instanceLabel";
+      this.instanceLabel.Size = new System.Drawing.Size(51, 13);
+      this.instanceLabel.TabIndex = 4;
+      this.instanceLabel.Text = "Instance:";
+      // 
+      // instancesComboBox
+      // 
+      this.instancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.instancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.instancesComboBox.FormattingEnabled = true;
+      this.instancesComboBox.Location = new System.Drawing.Point(54, 0);
+      this.instancesComboBox.Name = "instancesComboBox";
+      this.instancesComboBox.Size = new System.Drawing.Size(489, 21);
+      this.instancesComboBox.TabIndex = 7;
+      this.instancesComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged);
+      // 
+      // importButton
+      // 
+      this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+      this.importButton.Location = new System.Drawing.Point(581, -1);
+      this.importButton.Name = "importButton";
+      this.importButton.Size = new System.Drawing.Size(26, 23);
+      this.importButton.TabIndex = 6;
+      this.importButton.Text = "Import";
+      this.importButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
+      this.importButton.UseVisualStyleBackColor = true;
+      this.importButton.Click += new System.EventHandler(this.importButton_Click);
+      // 
+      // openFileDialog
+      // 
+      this.openFileDialog.Filter = "All files|*.*";
+      // 
+      // ProblemInstanceProviderView
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.Controls.Add(this.instancesComboBox);
+      this.Controls.Add(this.importButton);
+      this.Controls.Add(this.loadButton);
+      this.Controls.Add(this.instanceLabel);
+      this.Name = "ProblemInstanceProviderView";
+      this.Size = new System.Drawing.Size(610, 21);
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.OpenFileDialog openFileDialog;
+    private System.Windows.Forms.ToolTip toolTip;
+    protected System.Windows.Forms.Button loadButton;
+    protected System.Windows.Forms.Label instanceLabel;
+    protected System.Windows.Forms.ComboBox instancesComboBox;
+    protected System.Windows.Forms.Button importButton;
+
+  }
+}
Index: trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.cs
===================================================================
--- trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.cs	(revision 7558)
+++ trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.cs	(revision 7558)
@@ -0,0 +1,108 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Windows.Forms;
+using HeuristicLab.Common.Resources;
+using HeuristicLab.MainForm;
+using HeuristicLab.MainForm.WindowsForms;
+using HeuristicLab.Problems.Instances;
+
+namespace HeuristicLab.Optimization.Views {
+  [View("ProblemInstanceProviderView")]
+  [Content(typeof(IProblemInstanceProvider<>), IsDefaultView = true)]
+  public partial class ProblemInstanceProviderView<T> : AsynchronousContentView {
+
+    public new IProblemInstanceProvider<T> Content {
+      get { return (IProblemInstanceProvider<T>)base.Content; }
+      set { base.Content = value; }
+    }
+
+    public ProblemInstanceProviderView() {
+      InitializeComponent();
+      importButton.Text = String.Empty;
+      importButton.Image = VSImageLibrary.Open;
+      toolTip.SetToolTip(importButton, "Import a " + GetProblemType() + " instance from file.");
+      loadButton.Text = String.Empty;
+      loadButton.Image = VSImageLibrary.Checkout;
+      toolTip.SetToolTip(loadButton, "Load the selected instance.");
+    }
+
+    protected override void OnContentChanged() {
+      base.OnContentChanged();
+      if (Content == null) {
+        instancesComboBox.DataSource = null;
+      } else {
+        instancesComboBox.DisplayMember = "Name";
+        instancesComboBox.DataSource = Content.GetDataDescriptors().ToList();
+      }
+    }
+
+    protected override void SetEnabledStateOfControls() {
+      base.SetEnabledStateOfControls();
+      instancesComboBox.Enabled = !ReadOnly && !Locked && Content != null && Content.Consumer != null;
+      loadButton.Enabled = !ReadOnly && !Locked && Content != null && Content.Consumer != null;
+    }
+
+    protected virtual void loadButton_Click(object sender, EventArgs e) {
+      var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;
+      var instance = Content.LoadData(descriptor);
+      try {
+        Content.Consumer.Load(instance);
+      } catch (Exception ex) {
+        MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", descriptor.Name, Environment.NewLine + ex.Message), "Cannot load instance");
+      }
+    }
+
+    protected virtual void importButton_Click(object sender, EventArgs e) {
+      openFileDialog.FileName = GetProblemType() + " instance";
+      if (openFileDialog.ShowDialog() == DialogResult.OK) {
+        T instance = default(T);
+        try {
+          instance = Content.LoadData(openFileDialog.FileName);
+        } catch (Exception ex) {
+          MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
+          return;
+        }
+        try {
+          Content.Consumer.Load(instance);
+        } catch (Exception ex) {
+          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");
+        }
+      }
+    }
+
+    private void comboBox_DataSourceChanged(object sender, EventArgs e) {
+      var comboBox = (ComboBox)sender;
+      if (comboBox.DataSource == null)
+        comboBox.Items.Clear();
+    }
+
+    protected virtual string GetProblemType() {
+      string dataTypeName = typeof(T).Name.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last();
+      if (dataTypeName.EndsWith("Data"))
+        return dataTypeName.Substring(0, dataTypeName.Length - "Data".Length);
+      else return dataTypeName;
+    }
+  }
+}
