Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8192


Ignore:
Timestamp:
07/03/12 13:41:36 (12 years ago)
Author:
sforsten
Message:

#1782:

  • renamed CanSave to CanExportData and SaveData to ExportData
  • added the same functionality for importing problem instance as we implemented for exporting
  • some special changes had to be made in Problems.Instances.VehicleRouting
Location:
trunk/sources
Files:
23 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs

    r8180 r8192  
    8181    }
    8282
    83     public override GQAPData LoadData(string path) {
     83    public override bool CanImportData {
     84      get { return true; }
     85    }
     86    public override GQAPData ImportData(string path) {
    8487      var parser = new CordeauGQAPParser();
    8588      parser.Parse(path);
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/CSV/ClassifiactionCSVInstanceProvider.cs

    r8180 r8192  
    2020#endregion
    2121
    22 
    2322using System;
    2423using System.Collections.Generic;
    2524using System.IO;
     25using System.Linq;
    2626using System.Text;
    2727using HeuristicLab.Problems.DataAnalysis;
     28
    2829namespace HeuristicLab.Problems.Instances.DataAnalysis {
    2930  public class ClassificationCSVInstanceProvider : ClassificationInstanceProvider {
     
    4344    }
    4445
    45     public override bool CanSaveData {
    46       get { return true; }
    47     }
    48 
    4946    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5047      return new List<IDataDescriptor>();
    5148    }
    5249
    53     public override void SaveData(IClassificationProblemData instance, string path) {
     50    public override IClassificationProblemData LoadData(IDataDescriptor descriptor) {
     51      throw new NotImplementedException();
     52    }
     53
     54    public override bool CanImportData {
     55      get { return true; }
     56    }
     57    public override IClassificationProblemData ImportData(string path) {
     58      TableFileParser csvFileParser = new TableFileParser();
     59
     60      csvFileParser.Parse(path);
     61
     62      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     63      string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();
     64      IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar));
     65
     66      ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar);
     67
     68      int trainingPartEnd = csvFileParser.Rows * 2 / 3;
     69      claData.TrainingPartition.Start = 0;
     70      claData.TrainingPartition.End = trainingPartEnd;
     71      claData.TestPartition.Start = trainingPartEnd;
     72      claData.TestPartition.End = csvFileParser.Rows;
     73      int pos = path.LastIndexOf('\\');
     74      if (pos < 0)
     75        claData.Name = path;
     76      else {
     77        pos++;
     78        claData.Name = path.Substring(pos, path.Length - pos);
     79      }
     80
     81      return claData;
     82    }
     83
     84    public override bool CanExportData {
     85      get { return true; }
     86    }
     87    public override void ExportData(IClassificationProblemData instance, string path) {
    5488      StringBuilder strBuilder = new StringBuilder();
    5589
     
    74108      }
    75109    }
    76 
    77     public override IClassificationProblemData LoadData(IDataDescriptor descriptor) {
    78       throw new NotImplementedException();
    79     }
    80110  }
    81111}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Classification/ClassificationInstanceProvider.cs

    r8180 r8192  
    2020#endregion
    2121
    22 using System.Collections;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using HeuristicLab.Problems.DataAnalysis;
    2623
    2724namespace HeuristicLab.Problems.Instances.DataAnalysis {
    2825  public abstract class ClassificationInstanceProvider : ProblemInstanceProvider<IClassificationProblemData> {
    29     public override IClassificationProblemData LoadData(string path) {
    30       TableFileParser csvFileParser = new TableFileParser();
    31 
    32       csvFileParser.Parse(path);
    33 
    34       Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
    35       string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();
    36       IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar));
    37 
    38       ClassificationProblemData claData = new ClassificationProblemData(dataset, allowedInputVars, targetVar);
    39 
    40       int trainingPartEnd = csvFileParser.Rows * 2 / 3;
    41       claData.TrainingPartition.Start = 0;
    42       claData.TrainingPartition.End = trainingPartEnd;
    43       claData.TestPartition.Start = trainingPartEnd;
    44       claData.TestPartition.End = csvFileParser.Rows;
    45       int pos = path.LastIndexOf('\\');
    46       if (pos < 0)
    47         claData.Name = path;
    48       else {
    49         pos++;
    50         claData.Name = path.Substring(pos, path.Length - pos);
    51       }
    52 
    53       return claData;
    54     }
    5526  }
    5627}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs

    r8180 r8192  
    4747    }
    4848
    49     public override bool CanSaveData {
     49    public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
     50      throw new NotImplementedException();
     51    }
     52
     53    public override bool CanImportData {
    5054      get { return true; }
    5155    }
     56    public override IClusteringProblemData ImportData(string path) {
     57      var csvFileParser = new TableFileParser();
    5258
    53     public override void SaveData(IClusteringProblemData instance, string path) {
     59      csvFileParser.Parse(path);
     60
     61      var dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     62      var claData = new ClusteringProblemData(dataset, dataset.DoubleVariables);
     63
     64      int trainingPartEnd = csvFileParser.Rows * 2 / 3;
     65      claData.TrainingPartition.Start = 0;
     66      claData.TrainingPartition.End = trainingPartEnd;
     67      claData.TestPartition.Start = trainingPartEnd;
     68      claData.TestPartition.End = csvFileParser.Rows;
     69      int pos = path.LastIndexOf('\\');
     70      if (pos < 0)
     71        claData.Name = path;
     72      else {
     73        pos++;
     74        claData.Name = path.Substring(pos, path.Length - pos);
     75      }
     76
     77      return claData;
     78    }
     79
     80    public override bool CanExportData {
     81      get { return true; }
     82    }
     83    public override void ExportData(IClusteringProblemData instance, string path) {
    5484      var strBuilder = new StringBuilder();
    5585
     
    74104      }
    75105    }
    76 
    77     public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
    78       throw new NotImplementedException();
    79     }
    80106  }
    81107}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/ClusteringInstanceProvider.cs

    r8180 r8192  
    2424namespace HeuristicLab.Problems.Instances.DataAnalysis {
    2525  public abstract class ClusteringInstanceProvider : ProblemInstanceProvider<IClusteringProblemData> {
    26     public override IClusteringProblemData LoadData(string path) {
    27       var csvFileParser = new TableFileParser();
    28 
    29       csvFileParser.Parse(path);
    30 
    31       var dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
    32       var claData = new ClusteringProblemData(dataset, dataset.DoubleVariables);
    33 
    34       int trainingPartEnd = csvFileParser.Rows * 2 / 3;
    35       claData.TrainingPartition.Start = 0;
    36       claData.TrainingPartition.End = trainingPartEnd;
    37       claData.TestPartition.Start = trainingPartEnd;
    38       claData.TestPartition.End = csvFileParser.Rows;
    39       int pos = path.LastIndexOf('\\');
    40       if (pos < 0)
    41         claData.Name = path;
    42       else {
    43         pos++;
    44         claData.Name = path.Substring(pos, path.Length - pos);
    45       }
    46 
    47       return claData;
    48     }
    4926  }
    5027}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/CSV/RegressionCSVInstanceProvider.cs

    r8180 r8192  
    2020#endregion
    2121
    22 
    2322using System;
    2423using System.Collections.Generic;
    2524using System.IO;
     25using System.Linq;
    2626using System.Text;
    2727using HeuristicLab.Problems.DataAnalysis;
     28
    2829namespace HeuristicLab.Problems.Instances.DataAnalysis {
    2930  public class RegressionCSVInstanceProvider : RegressionInstanceProvider {
     
    4344    }
    4445
    45     public override bool CanSaveData {
    46       get { return true; }
    47     }
    48 
    4946    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    5047      return new List<IDataDescriptor>();
    5148    }
     49    public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {
     50      throw new NotImplementedException();
     51    }
    5252
    53     public override void SaveData(IRegressionProblemData instance, string path) {
     53    public override bool CanImportData {
     54      get { return true; }
     55    }
     56    public override IRegressionProblemData ImportData(string path) {
     57      TableFileParser csvFileParser = new TableFileParser();
     58      csvFileParser.Parse(path);
     59
     60      Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     61      string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();
     62
     63      IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar));
     64
     65      IRegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar);
     66
     67      int trainingPartEnd = csvFileParser.Rows * 2 / 3;
     68      regData.TrainingPartition.Start = 0;
     69      regData.TrainingPartition.End = trainingPartEnd;
     70      regData.TestPartition.Start = trainingPartEnd;
     71      regData.TestPartition.End = csvFileParser.Rows;
     72
     73      int pos = path.LastIndexOf('\\');
     74      if (pos < 0)
     75        regData.Name = path;
     76      else {
     77        pos++;
     78        regData.Name = path.Substring(pos, path.Length - pos);
     79      }
     80      return regData;
     81    }
     82
     83    public override bool CanExportData {
     84      get { return true; }
     85    }
     86    public override void ExportData(IRegressionProblemData instance, string path) {
    5487      StringBuilder strBuilder = new StringBuilder();
    5588
     
    74107      }
    75108    }
    76 
    77     public override IRegressionProblemData LoadData(IDataDescriptor descriptor) {
    78       throw new NotImplementedException();
    79     }
    80109  }
    81110}
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RegressionInstanceProvider.cs

    r8180 r8192  
    2020#endregion
    2121
    22 using System.Collections;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using HeuristicLab.Problems.DataAnalysis;
    2623
    2724namespace HeuristicLab.Problems.Instances.DataAnalysis {
    2825  public abstract class RegressionInstanceProvider : ProblemInstanceProvider<IRegressionProblemData> {
    29 
    30     public override IRegressionProblemData LoadData(string path) {
    31       TableFileParser csvFileParser = new TableFileParser();
    32       csvFileParser.Parse(path);
    33 
    34       Dataset dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
    35       string targetVar = csvFileParser.VariableNames.Where(x => dataset.DoubleVariables.Contains(x)).Last();
    36 
    37       IEnumerable<string> allowedInputVars = dataset.DoubleVariables.Where(x => !x.Equals(targetVar));
    38 
    39       IRegressionProblemData regData = new RegressionProblemData(dataset, allowedInputVars, targetVar);
    40 
    41       int trainingPartEnd = csvFileParser.Rows * 2 / 3;
    42       regData.TrainingPartition.Start = 0;
    43       regData.TrainingPartition.End = trainingPartEnd;
    44       regData.TestPartition.Start = trainingPartEnd;
    45       regData.TestPartition.End = csvFileParser.Rows;
    46 
    47       int pos = path.LastIndexOf('\\');
    48       if (pos < 0)
    49         regData.Name = path;
    50       else {
    51         pos++;
    52         regData.Name = path.Substring(pos, path.Length - pos);
    53       }
    54       return regData;
    55     }
    5626  }
    5727}
  • trunk/sources/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs

    r8180 r8192  
    103103    }
    104104
    105     public override CTAPData LoadData(string path) {
     105    public override bool CanImportData {
     106      get { return true; }
     107    }
     108    public override CTAPData ImportData(string path) {
    106109      var parser = new ElloumiCTAPParser();
    107110      parser.Parse(path);
  • trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs

    r8180 r8192  
    219219    }
    220220
    221     public override QAPData LoadData(string path) {
     221    public override bool CanImportData {
     222      get { return true; }
     223    }
     224    public override QAPData ImportData(string path) {
    222225      var parser = new QAPLIBParser();
    223226      parser.Parse(path);
  • trunk/sources/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs

    r8180 r8192  
    9090    }
    9191
    92     public override T LoadData(string path) {
     92    public override bool CanImportData {
     93      get { return true; }
     94    }
     95    public override T ImportData(string path) {
    9396      return LoadInstance(new TSPLIBParser(path));
    9497    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/HeuristicLab.Problems.Instances.VehicleRouting.Views-3.4.csproj

    r7923 r8192  
    115115    <Compile Include="Plugin.cs" />
    116116    <Compile Include="Properties\AssemblyInfo.cs" />
    117     <Compile Include="VRPInstanceProviderView.cs">
     117    <Compile Include="VRPInstanceConsumerView.cs">
    118118      <SubType>UserControl</SubType>
    119119    </Compile>
    120     <Compile Include="VRPInstanceProviderView.designer.cs">
    121       <DependentUpon>VRPInstanceProviderView.cs</DependentUpon>
     120    <Compile Include="VRPInstanceConsumerView.designer.cs">
     121      <DependentUpon>VRPInstanceConsumerView.cs</DependentUpon>
    122122    </Compile>
    123123    <Compile Include="VRPImportDialog.cs">
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting.Views/3.4/VRPInstanceConsumerView.cs

    r8189 r8192  
    2525using HeuristicLab.MainForm;
    2626using HeuristicLab.MainForm.WindowsForms;
     27using HeuristicLab.PluginInfrastructure;
    2728using HeuristicLab.Problems.Instances.Views;
    2829
     
    4142    }
    4243
     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
    4356    protected override void importButton_Click(object sender, EventArgs e) {
    4457      IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     
    4659        using (var dialog = new VRPImportDialog(SelectedProvider.Name)) {
    4760          if (dialog.ShowDialog() == DialogResult.OK) {
    48             var instance = provider.LoadData(dialog.VRPFileName, dialog.TourFileName);
     61            var instance = provider.Import(dialog.VRPFileName, dialog.TourFileName);
    4962            try {
    5063              GenericConsumer.Load(instance as T);
     
    5770      }
    5871    }
     72
     73    protected override void exportButton_Click(object sender, EventArgs e) {
     74      IVRPInstanceProvider provider = SelectedProvider as IVRPInstanceProvider;
     75      if (provider != null) {
     76        if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
     77          try {
     78            provider.Export(GenericExporter.Export(), saveFileDialog.FileName);
     79          }
     80          catch (Exception ex) {
     81            ErrorHandling.ShowErrorDialog(this, ex);
     82          }
     83        }
     84      }
     85    }
    5986  }
    6087}
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauFormatInstanceProvider.cs

    r7882 r8192  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    29 using HeuristicLab.Problems.Instances.TSPLIB;
    3023
    3124namespace HeuristicLab.Problems.Instances.VehicleRouting {
     
    3528    }
    3629
    37     public override MDCVRPTWData LoadData(string path) {
     30    public override bool CanImportData {
     31      get { return true; }
     32    }
     33    public override MDCVRPTWData ImportData(string path) {
    3834      return LoadInstance(new CordeauParser(path));
    3935    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/GoldenFormatInstanceProvider.cs

    r7887 r8192  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    29 using HeuristicLab.Problems.Instances.TSPLIB;
    3024
    3125namespace HeuristicLab.Problems.Instances.VehicleRouting {
     
    3529    }
    3630
    37     public override CVRPTWData LoadData(string path) {
     31    public override bool CanImportData {
     32      get { return true; }
     33    }
     34    public override CVRPTWData ImportData(string path) {
    3835      return LoadInstance(new GoldenParser(path));
    3936    }
     
    6663      }
    6764
    68       if(parser.Distance > 0)
     65      if (parser.Distance > 0)
    6966        instance.DueTimes[0] = parser.Distance;
    7067
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/IVRPInstanceProvider.cs

    r7956 r8192  
    2222namespace HeuristicLab.Problems.Instances.VehicleRouting {
    2323  public interface IVRPInstanceProvider {
    24     IVRPData LoadData(string vrpFile, string tourFile);
     24    bool CanImportData { get; }
     25    IVRPData Import(string vrpFile, string tourFile);
     26
     27    bool CanExportData { get; }
     28    void Export(IVRPData instance, string path);
    2529  }
    2630}
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/LiLimFormat/LiLimFormatInstanceProvider.cs

    r7882 r8192  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    29 using HeuristicLab.Problems.Instances.TSPLIB;
    3023
    3124namespace HeuristicLab.Problems.Instances.VehicleRouting {
     
    3528    }
    3629
    37     public override PDPTWData LoadData(string path) {
     30    public override bool CanImportData {
     31      get { return true; }
     32    }
     33    public override PDPTWData ImportData(string path) {
    3834      return LoadInstance(new LiLimParser(path));
    3935    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs

    r7882 r8192  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    29 using HeuristicLab.Problems.Instances.TSPLIB;
    3023
    3124namespace HeuristicLab.Problems.Instances.VehicleRouting {
     
    3528    }
    3629
    37     public override CVRPTWData LoadData(string path) {
     30    public override bool CanImportData {
     31      get { return true; }
     32    }
     33    public override CVRPTWData ImportData(string path) {
    3834      return LoadInstance(new SolomonParser(path));
    3935    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/TSPLibFormat/TSPLibFormatInstanceProvider.cs

    r7882 r8192  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    2924using HeuristicLab.Problems.Instances.TSPLIB;
    3025
     
    3530    }
    3631
    37     public override CVRPData LoadData(string path) {
     32    public override bool CanImportData {
     33      get { return true; }
     34    }
     35    public override CVRPData ImportData(string path) {
    3836      return LoadInstance(new TSPLIBParser(path));
    3937    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/TaillardFormat/TaillardFormatInstanceProvider.cs

    r7888 r8192  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    29 using HeuristicLab.Problems.Instances.TSPLIB;
    3023
    3124namespace HeuristicLab.Problems.Instances.VehicleRouting {
     
    3528    }
    3629
    37     public override CVRPData LoadData(string path) {
     30    public override bool CanImportData {
     31      get { return true; }
     32    }
     33    public override CVRPData ImportData(string path) {
    3834      return LoadInstance(new TaillardParser(path));
    3935    }
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/VRPInstanceProvider.cs

    r8180 r8192  
    107107    protected abstract T LoadData(Stream stream);
    108108
    109     public IVRPData LoadData(string vrpFile, string tourFile) {
    110       var data = LoadData(vrpFile);
     109    public IVRPData Import(string vrpFile, string tourFile) {
     110      var data = ImportData(vrpFile);
    111111      if (!String.IsNullOrEmpty(tourFile)) {
    112112        LoadSolution(tourFile, data);
    113113      }
    114114      return data;
     115    }
     116
     117    public void Export(IVRPData instance, string path) {
     118      ExportData((T)instance, path);
    115119    }
    116120
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerViewGeneric.Designer.cs

    r7967 r8192  
    5555      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    5656      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    57       this.problemInstanceProviderSplitContainer = new System.Windows.Forms.SplitContainer();
    58       ((System.ComponentModel.ISupportInitialize)(this.problemInstanceProviderSplitContainer)).BeginInit();
    59       this.problemInstanceProviderSplitContainer.Panel1.SuspendLayout();
    60       this.problemInstanceProviderSplitContainer.Panel2.SuspendLayout();
    61       this.problemInstanceProviderSplitContainer.SuspendLayout();
     57      this.ProviderExportSplitContainer = new System.Windows.Forms.SplitContainer();
     58      this.ProviderImportSplitContainer = new System.Windows.Forms.SplitContainer();
     59      ((System.ComponentModel.ISupportInitialize)(this.ProviderExportSplitContainer)).BeginInit();
     60      this.ProviderExportSplitContainer.Panel1.SuspendLayout();
     61      this.ProviderExportSplitContainer.Panel2.SuspendLayout();
     62      this.ProviderExportSplitContainer.SuspendLayout();
     63      ((System.ComponentModel.ISupportInitialize)(this.ProviderImportSplitContainer)).BeginInit();
     64      this.ProviderImportSplitContainer.Panel1.SuspendLayout();
     65      this.ProviderImportSplitContainer.Panel2.SuspendLayout();
     66      this.ProviderImportSplitContainer.SuspendLayout();
    6267      this.SuspendLayout();
    6368      //
    6469      // problemInstanceProviderComboBox
    6570      //
    66       this.problemInstanceProviderComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    67             | System.Windows.Forms.AnchorStyles.Right)));
     71      this.problemInstanceProviderComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     72                  | System.Windows.Forms.AnchorStyles.Right)));
    6873      this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    6974      this.problemInstanceProviderComboBox.FormattingEnabled = true;
    7075      this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 1);
    7176      this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox";
    72       this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(171, 21);
     77      this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(174, 21);
    7378      this.problemInstanceProviderComboBox.TabIndex = 16;
    7479      this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged);
     
    7782      //
    7883      this.libraryInfoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    79       this.libraryInfoButton.Location = new System.Drawing.Point(227, -1);
     84      this.libraryInfoButton.Location = new System.Drawing.Point(230, -1);
    8085      this.libraryInfoButton.Name = "libraryInfoButton";
    8186      this.libraryInfoButton.Size = new System.Drawing.Size(24, 24);
     
    8893      //
    8994      this.libraryLabel.AutoSize = true;
    90       this.libraryLabel.Location = new System.Drawing.Point(4, 4);
     95      this.libraryLabel.Location = new System.Drawing.Point(3, 5);
    9196      this.libraryLabel.Name = "libraryLabel";
    9297      this.libraryLabel.Size = new System.Drawing.Size(41, 13);
     
    96101      // problemInstanceProviderViewHost
    97102      //
    98       this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    99             | System.Windows.Forms.AnchorStyles.Right)));
     103      this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     104                  | System.Windows.Forms.AnchorStyles.Right)));
    100105      this.problemInstanceProviderViewHost.Caption = "View";
    101106      this.problemInstanceProviderViewHost.Content = null;
     
    112117      //
    113118      this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    114       this.importButton.Location = new System.Drawing.Point(257, -1);
     119      this.importButton.Location = new System.Drawing.Point(1, -1);
    115120      this.importButton.Name = "importButton";
    116121      this.importButton.Size = new System.Drawing.Size(24, 24);
     
    140145      this.saveFileDialog.Title = "Save RegressionInstance...";
    141146      //
    142       // problemInstanceProviderSplitContainer
    143       //
    144       this.problemInstanceProviderSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
    145       this.problemInstanceProviderSplitContainer.IsSplitterFixed = true;
    146       this.problemInstanceProviderSplitContainer.Location = new System.Drawing.Point(0, 0);
    147       this.problemInstanceProviderSplitContainer.Name = "problemInstanceProviderSplitContainer";
    148       //
    149       // problemInstanceProviderSplitContainer.Panel1
    150       //
    151       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox);
    152       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.importButton);
    153       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.libraryLabel);
    154       this.problemInstanceProviderSplitContainer.Panel1.Controls.Add(this.libraryInfoButton);
    155       //
    156       // problemInstanceProviderSplitContainer.Panel2
    157       //
    158       this.problemInstanceProviderSplitContainer.Panel2.Controls.Add(this.exportButton);
    159       this.problemInstanceProviderSplitContainer.Size = new System.Drawing.Size(312, 22);
    160       this.problemInstanceProviderSplitContainer.SplitterDistance = 280;
    161       this.problemInstanceProviderSplitContainer.TabIndex = 20;
     147      // ProviderExportSplitContainer
     148      //
     149      this.ProviderExportSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
     150      this.ProviderExportSplitContainer.IsSplitterFixed = true;
     151      this.ProviderExportSplitContainer.Location = new System.Drawing.Point(0, 0);
     152      this.ProviderExportSplitContainer.Name = "ProviderExportSplitContainer";
     153      //
     154      // ProviderExportSplitContainer.Panel1
     155      //
     156      this.ProviderExportSplitContainer.Panel1.Controls.Add(this.ProviderImportSplitContainer);
     157      //
     158      // ProviderExportSplitContainer.Panel2
     159      //
     160      this.ProviderExportSplitContainer.Panel2.Controls.Add(this.exportButton);
     161      this.ProviderExportSplitContainer.Size = new System.Drawing.Size(312, 22);
     162      this.ProviderExportSplitContainer.SplitterDistance = 283;
     163      this.ProviderExportSplitContainer.TabIndex = 20;
     164      //
     165      // ProviderImportSplitContainer
     166      //
     167      this.ProviderImportSplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     168                  | System.Windows.Forms.AnchorStyles.Right)));
     169      this.ProviderImportSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
     170      this.ProviderImportSplitContainer.IsSplitterFixed = true;
     171      this.ProviderImportSplitContainer.Location = new System.Drawing.Point(0, 0);
     172      this.ProviderImportSplitContainer.Name = "ProviderImportSplitContainer";
     173      //
     174      // ProviderImportSplitContainer.Panel1
     175      //
     176      this.ProviderImportSplitContainer.Panel1.Controls.Add(this.libraryLabel);
     177      this.ProviderImportSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox);
     178      this.ProviderImportSplitContainer.Panel1.Controls.Add(this.libraryInfoButton);
     179      //
     180      // ProviderImportSplitContainer.Panel2
     181      //
     182      this.ProviderImportSplitContainer.Panel2.Controls.Add(this.importButton);
     183      this.ProviderImportSplitContainer.Size = new System.Drawing.Size(282, 23);
     184      this.ProviderImportSplitContainer.SplitterDistance = 253;
     185      this.ProviderImportSplitContainer.TabIndex = 21;
    162186      //
    163187      // ProblemInstanceConsumerViewGeneric
    164188      //
    165       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    166189      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    167       this.Controls.Add(this.problemInstanceProviderSplitContainer);
     190      this.Controls.Add(this.ProviderExportSplitContainer);
    168191      this.Controls.Add(this.problemInstanceProviderViewHost);
    169192      this.Name = "ProblemInstanceConsumerViewGeneric";
    170       this.problemInstanceProviderSplitContainer.Panel1.ResumeLayout(false);
    171       this.problemInstanceProviderSplitContainer.Panel1.PerformLayout();
    172       this.problemInstanceProviderSplitContainer.Panel2.ResumeLayout(false);
    173       ((System.ComponentModel.ISupportInitialize)(this.problemInstanceProviderSplitContainer)).EndInit();
    174       this.problemInstanceProviderSplitContainer.ResumeLayout(false);
     193      this.ProviderExportSplitContainer.Panel1.ResumeLayout(false);
     194      this.ProviderExportSplitContainer.Panel2.ResumeLayout(false);
     195      ((System.ComponentModel.ISupportInitialize)(this.ProviderExportSplitContainer)).EndInit();
     196      this.ProviderExportSplitContainer.ResumeLayout(false);
     197      this.ProviderImportSplitContainer.Panel1.ResumeLayout(false);
     198      this.ProviderImportSplitContainer.Panel1.PerformLayout();
     199      this.ProviderImportSplitContainer.Panel2.ResumeLayout(false);
     200      ((System.ComponentModel.ISupportInitialize)(this.ProviderImportSplitContainer)).EndInit();
     201      this.ProviderImportSplitContainer.ResumeLayout(false);
    175202      this.ResumeLayout(false);
    176203
     
    180207
    181208    protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox;
    182     private System.Windows.Forms.Button libraryInfoButton;
    183     private System.Windows.Forms.Label libraryLabel;
     209    protected System.Windows.Forms.Button libraryInfoButton;
     210    protected System.Windows.Forms.Label libraryLabel;
    184211    protected MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost;
    185     private System.Windows.Forms.ToolTip toolTip;
    186     private System.Windows.Forms.Button importButton;
    187     private System.Windows.Forms.Button exportButton;
     212    protected System.Windows.Forms.ToolTip toolTip;
     213    protected System.Windows.Forms.Button importButton;
     214    protected System.Windows.Forms.Button exportButton;
    188215    protected System.Windows.Forms.SaveFileDialog saveFileDialog;
    189216    protected System.Windows.Forms.OpenFileDialog openFileDialog;
    190     private System.Windows.Forms.SplitContainer problemInstanceProviderSplitContainer;
     217    protected System.Windows.Forms.SplitContainer ProviderExportSplitContainer;
     218    protected System.Windows.Forms.SplitContainer ProviderImportSplitContainer;
    191219  }
    192220}
  • trunk/sources/HeuristicLab.Problems.Instances.Views/3.3/ProblemInstanceConsumerViewGeneric.cs

    r8180 r8192  
    9292      problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0;
    9393      libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null;
    94       importButton.Enabled = !ReadOnly && !Locked && Content != null && Consumer != null;
     94      importButton.Enabled = !ReadOnly && !Locked && Content != null && Consumer != null &&
     95                             GenericSelectedProvider != null && GenericSelectedProvider.CanImportData;
     96      ProviderImportSplitContainer.Panel2Collapsed = !importButton.Enabled;
    9597      exportButton.Enabled = !ReadOnly && !Locked && Content != null && Exporter != null &&
    96                              GenericSelectedProvider != null && GenericSelectedProvider.CanSaveData;
    97       problemInstanceProviderSplitContainer.Panel2Collapsed = !exportButton.Enabled;
     98                             GenericSelectedProvider != null && GenericSelectedProvider.CanExportData;
     99      ProviderExportSplitContainer.Panel2Collapsed = !exportButton.Enabled;
    98100    }
    99101
     
    132134        T instance = default(T);
    133135        try {
    134           instance = GenericSelectedProvider.LoadData(openFileDialog.FileName);
     136          instance = GenericSelectedProvider.ImportData(openFileDialog.FileName);
    135137        }
    136138        catch (Exception ex) {
     
    147149    }
    148150
    149     protected void exportButton_Click(object sender, EventArgs e) {
     151    protected virtual void exportButton_Click(object sender, EventArgs e) {
    150152      if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
    151153        try {
    152           GenericSelectedProvider.SaveData(GenericExporter.Export(), saveFileDialog.FileName);
     154          GenericSelectedProvider.ExportData(GenericExporter.Export(), saveFileDialog.FileName);
    153155        }
    154156        catch (Exception ex) {
  • trunk/sources/HeuristicLab.Problems.Instances/3.3/IProblemInstanceProvider.cs

    r8180 r8192  
    3535    IEnumerable<IDataDescriptor> GetDataDescriptors();
    3636    TData LoadData(IDataDescriptor descriptor);
    37     TData LoadData(string path);
    3837
    39     bool CanSaveData { get; }
    40     void SaveData(TData instance, string path);
     38    bool CanImportData { get; }
     39    TData ImportData(string path);
     40
     41    bool CanExportData { get; }
     42    void ExportData(TData instance, string path);
    4143  }
    4244}
  • trunk/sources/HeuristicLab.Problems.Instances/3.3/ProblemInstanceProvider.cs

    r8180 r8192  
    3333
    3434    public abstract TData LoadData(IDataDescriptor descriptor);
    35     public abstract TData LoadData(string path);
    3635
    37     public virtual bool CanSaveData {
     36    public virtual bool CanImportData {
    3837      get { return false; }
    3938    }
    40     public virtual void SaveData(TData instance, string path) {
     39    public virtual TData ImportData(string path) {
     40      throw new NotSupportedException();
     41    }
     42
     43    public virtual bool CanExportData {
     44      get { return false; }
     45    }
     46    public virtual void ExportData(TData instance, string path) {
    4147      throw new NotSupportedException();
    4248    }
Note: See TracChangeset for help on using the changeset viewer.