Changeset 7487


Ignore:
Timestamp:
02/20/12 11:17:24 (8 years ago)
Author:
sforsten
Message:

#1758: changes according to mkommend's reviewing comments have been made and catch blocks now only catch specific exceptions

Location:
branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r7404 r7487  
    144144      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath>
    145145    </Reference>
     146    <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL" />
    146147    <Reference Include="System" />
    147148    <Reference Include="System.Core">
  • branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r7468 r7487  
    2727using HeuristicLab.Core;
    2828using HeuristicLab.MainForm;
     29using HeuristicLab.Persistence.Core;
    2930using HeuristicLab.Persistence.Default.Xml;
    3031using HeuristicLab.PluginInfrastructure;
     32using ICSharpCode.SharpZipLib.Zip;
    3133
    3234namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    6264    #endregion
    6365
    64     private void importButton_Click(object sender, EventArgs e) {
     66    protected void importButton_Click(object sender, EventArgs e) {
    6567      if (openFileDialog.ShowDialog(this) != DialogResult.OK) return;
     68      ImportProblemData(openFileDialog.FileName);
     69    }
    6670
     71    protected void ImportProblemData(string filename) {
    6772      object hlFile = null;
    6873      try {
    69         hlFile = XmlParser.Deserialize(openFileDialog.FileName);
     74        hlFile = XmlParser.Deserialize(filename);
    7075      }
    71       catch (Exception ex) {
     76      catch (PersistenceException ex) {
     77        ErrorHandling.ShowErrorDialog(this, ex);
     78        return;
     79      }
     80      catch (ZipException ex) {
    7281        ErrorHandling.ShowErrorDialog(this, ex);
    7382        return;
     
    8493
    8594      if (problemData == null) {
    86         ErrorHandling.ShowErrorDialog(this,
    87           new NullReferenceException("The problem data is null." + Environment.NewLine
    88                                    + "The .hl-file is no RegressionProblemData or RegressionProblem."));
     95        ErrorHandling.ShowErrorDialog(this, new NullReferenceException("The problem data is null." + Environment.NewLine
     96                                                                     + "The .hl-file is no RegressionProblemData or RegressionProblem."));
    8997        return;
    9098      }
    9199
     100      if (CheckCompatibilityOfProblemData(Content.ProblemData, problemData))
     101        Content.ProblemData = problemData;
     102    }
     103
     104    protected virtual bool CheckCompatibilityOfProblemData(IRegressionProblemData iRegressionProblemData, IRegressionProblemData problemData) {
    92105      StringBuilder message = new StringBuilder();
    93106      if (!problemData.TargetVariable.Equals(Content.ProblemData.TargetVariable))
     
    102115      }
    103116
    104       if (message.Length != 0)
    105         ErrorHandling.ShowErrorDialog(this, new Exception(message.ToString()));
    106       else
    107         Content.ProblemData = problemData;
    108 
     117      if (message.Length != 0) {
     118        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message.ToString()));
     119        return false;
     120      }
     121      return true;
    109122    }
    110123  }
Note: See TracChangeset for help on using the changeset viewer.