Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3758


Ignore:
Timestamp:
05/11/10 04:26:09 (14 years ago)
Author:
swagner
Message:

Implemented ErrorDialog and OperatorExecutionException (#1007)

Location:
trunk/sources
Files:
7 added
1 deleted
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs

    r3694 r3758  
    2828using HeuristicLab.MainForm;
    2929using HeuristicLab.Persistence.Default.Xml;
     30using HeuristicLab.PluginInfrastructure;
    3031
    3132namespace HeuristicLab.Core.Views {
     
    279280        }
    280281        catch (Exception ex) {
    281           Auxiliary.ShowErrorMessageBox(ex);
     282          ErrorHandling.ShowErrorDialog(this, ex);
    282283        }
    283284      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/CreateParameterDialog.cs

    r2818 r3758  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.PluginInfrastructure;
    2425
    2526namespace HeuristicLab.Core.Views {
     
    4041        }
    4142        catch (Exception ex) {
    42           Auxiliary.ShowErrorMessageBox(ex);
     43          ErrorHandling.ShowErrorDialog(this, ex);
    4344        }
    4445        return null;
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj

    r3702 r3758  
    153153      <DependentUpon>CreateParameterDialog.cs</DependentUpon>
    154154    </Compile>
    155     <Compile Include="Auxiliary.cs" />
    156155    <Compile Include="EngineView.cs">
    157156      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs

    r3709 r3758  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Core.Views {
     
    137138        }
    138139        catch (Exception ex) {
    139           Auxiliary.ShowErrorMessageBox(ex);
     140          ErrorHandling.ShowErrorDialog(this, ex);
    140141        }
    141142      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r3709 r3758  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Core.Views {
     
    112113        }
    113114        catch (Exception ex) {
    114           Auxiliary.ShowErrorMessageBox(ex);
     115          ErrorHandling.ShowErrorDialog(this, ex);
    115116        }
    116117      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r3709 r3758  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Core.Views {
     
    140141        }
    141142        catch (Exception ex) {
    142           Auxiliary.ShowErrorMessageBox(ex);
     143          ErrorHandling.ShowErrorDialog(this, ex);
    143144        }
    144145      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorCollectionView.cs

    r3588 r3758  
    2424using HeuristicLab.Collections;
    2525using HeuristicLab.MainForm;
     26using HeuristicLab.PluginInfrastructure;
    2627
    2728namespace HeuristicLab.Core.Views {
     
    5253        }
    5354        catch (Exception ex) {
    54           Auxiliary.ShowErrorMessageBox(ex);
     55          ErrorHandling.ShowErrorDialog(this, ex);
    5556        }
    5657      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorListView.cs

    r3588 r3758  
    2424using HeuristicLab.Collections;
    2525using HeuristicLab.MainForm;
     26using HeuristicLab.PluginInfrastructure;
    2627
    2728namespace HeuristicLab.Core.Views {
     
    5253        }
    5354        catch (Exception ex) {
    54           Auxiliary.ShowErrorMessageBox(ex);
     55          ErrorHandling.ShowErrorDialog(this, ex);
    5556        }
    5657      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorSetView.cs

    r3588 r3758  
    2424using HeuristicLab.Collections;
    2525using HeuristicLab.MainForm;
     26using HeuristicLab.PluginInfrastructure;
    2627
    2728namespace HeuristicLab.Core.Views {
     
    5253        }
    5354        catch (Exception ex) {
    54           Auxiliary.ShowErrorMessageBox(ex);
     55          ErrorHandling.ShowErrorDialog(this, ex);
    5556        }
    5657      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs

    r3694 r3758  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.MainForm;
     26using HeuristicLab.PluginInfrastructure;
    2627
    2728namespace HeuristicLab.Core.Views {
     
    121122        }
    122123        catch (Exception ex) {
    123           Auxiliary.ShowErrorMessageBox(ex);
     124          ErrorHandling.ShowErrorDialog(this, ex);
    124125        }
    125126      }
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r3702 r3758  
    136136    <Compile Include="Constraints\IConstraint.cs" />
    137137    <Compile Include="Constraints\TypeCompatibilityConstraint.cs" />
     138    <Compile Include="OperatorExecutionException.cs" />
    138139    <Compile Include="Interfaces\IScopeTreeLookupParameter.cs" />
    139140    <Compile Include="Interfaces\ICheckedItemList.cs" />
  • trunk/sources/HeuristicLab.Core/3.3/Log.cs

    r3289 r3758  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.PluginInfrastructure;
    2728
    2829namespace HeuristicLab.Core {
     
    6364    }
    6465    public virtual void LogException(Exception ex) {
    65       string s = DateTime.Now.ToString() + "\t" + "Exception occurred:" + Environment.NewLine + BuildErrorMessage(ex);
     66      string s = DateTime.Now.ToString() + "\t" + "Exception occurred:" + Environment.NewLine + ErrorHandling.BuildErrorMessage(ex);
    6667      messages.Add(s);
    6768      OnMessageAdded(s);
     
    7879      if (handler != null) handler(this, EventArgs.Empty);
    7980    }
    80 
    81     public static string BuildErrorMessage(Exception ex) {
    82       string nl = Environment.NewLine;
    83       string message = ex.Message + nl + ex.StackTrace;
    84 
    85       while (ex.InnerException != null) {
    86         ex = ex.InnerException;
    87         message += nl + "-----" + nl + ex.Message + nl + ex.StackTrace;
    88       }
    89       return message;
    90     }
    9181  }
    9282}
  • trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperatorView.cs

    r3455 r3758  
    3737using HeuristicLab.Operators.Views;
    3838using HeuristicLab.MainForm;
     39using HeuristicLab.PluginInfrastructure;
    3940
    4041namespace HeuristicLab.Operators.Programmable {
     
    134135        MessageBox.Show("Compilation successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
    135136      } catch (Exception ex) {
    136         Auxiliary.ShowErrorMessageBox(ex);
     137        ErrorHandling.ShowErrorDialog(this, ex);
    137138      }
    138139      OnContentChanged();
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3716 r3758  
    2828using HeuristicLab.MainForm;
    2929using HeuristicLab.Persistence.Default.Xml;
     30using HeuristicLab.PluginInfrastructure;
    3031
    3132namespace HeuristicLab.Optimization.Views {
     
    155156        Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    156157      else
    157         Auxiliary.ShowErrorMessageBox(e.Value);
     158        ErrorHandling.ShowErrorDialog(this, e.Value);
    158159    }
    159160    #endregion
     
    172173        }
    173174        catch (Exception ex) {
    174           Auxiliary.ShowErrorMessageBox(ex);
     175          ErrorHandling.ShowErrorDialog(this, ex);
    175176        }
    176177      }
     
    196197          }
    197198          catch (Exception ex) {
    198             Invoke(new Action(() => Auxiliary.ShowErrorMessageBox(ex)));
     199            Invoke(new Action(() => ErrorHandling.ShowErrorDialog(this, ex)));
    199200          }
    200201          finally {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r3716 r3758  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Persistence.Default.Xml;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Optimization.Views {
     
    120121        Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    121122      else
    122         Auxiliary.ShowErrorMessageBox(e.Value);
     123        ErrorHandling.ShowErrorDialog(this, e.Value);
    123124    }
    124125    private void Content_AlgorithmChanged(object sender, EventArgs e) {
     
    157158        }
    158159        catch (Exception ex) {
    159           Auxiliary.ShowErrorMessageBox(ex);
     160          ErrorHandling.ShowErrorDialog(this, ex);
    160161        }
    161162      }
     
    177178          }
    178179          catch (Exception ex) {
    179             Auxiliary.ShowErrorMessageBox(ex);
     180            ErrorHandling.ShowErrorDialog(this, ex);
    180181          }
    181182          finally {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs

    r3716 r3758  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Optimization.Views {
     
    110111        Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    111112      else
    112         Auxiliary.ShowErrorMessageBox(e.Value);
     113        ErrorHandling.ShowErrorDialog(this, e.Value);
    113114    }
    114115    #endregion
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/OptimizerListView.cs

    r3588 r3758  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Optimization.Views {
     
    5455        }
    5556        catch (Exception ex) {
    56           Auxiliary.ShowErrorMessageBox(ex);
     57          ErrorHandling.ShowErrorDialog(this, ex);
    5758        }
    5859      }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs

    r3632 r3758  
    2626using HeuristicLab.Optimization;
    2727using System.Drawing;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Core.Views {
     
    5455        }
    5556        catch (Exception ex) {
    56           Auxiliary.ShowErrorMessageBox(ex);
     57          ErrorHandling.ShowErrorDialog(this, ex);
    5758        }
    5859      }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/UserDefinedAlgorithmView.cs

    r3725 r3758  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Persistence.Default.Xml;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Optimization.Views {
     
    9091          }
    9192          catch (Exception ex) {
    92             Auxiliary.ShowErrorMessageBox(ex);
     93            ErrorHandling.ShowErrorDialog(this, ex);
    9394          }
    9495          finally {
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r3557 r3758  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Optimizer {
     
    7374      }
    7475      catch (Exception ex) {
    75         Auxiliary.ShowErrorMessageBox(ex);
     76        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot open file.", ex);
    7677      }
    7778      finally {
     
    133134      }
    134135      catch (Exception ex) {
    135         Auxiliary.ShowErrorMessageBox(ex);
     136        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, "Cannot save file.", ex);
    136137      }
    137138      finally {
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs

    r3694 r3758  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Parameters.Views {
     
    133134        }
    134135        catch (Exception ex) {
    135           Auxiliary.ShowErrorMessageBox(ex);
     136          ErrorHandling.ShowErrorDialog(this, ex);
    136137        }
    137138      }
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs

    r3694 r3758  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Parameters.Views {
     
    121122        }
    122123        catch (Exception ex) {
    123           Auxiliary.ShowErrorMessageBox(ex);
     124          ErrorHandling.ShowErrorDialog(this, ex);
    124125        }
    125126      }
  • trunk/sources/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj

    r3754 r3758  
    194194    <Compile Include="BaseClasses\PluginBase.cs" />
    195195    <Compile Include="DefaultApplicationManager.cs" />
     196    <Compile Include="ErrorHandling\ErrorDialog.cs">
     197      <SubType>Form</SubType>
     198    </Compile>
     199    <Compile Include="ErrorHandling\ErrorDialog.Designer.cs">
     200      <DependentUpon>ErrorDialog.cs</DependentUpon>
     201    </Compile>
     202    <Compile Include="ErrorHandling\ErrorHandling.cs">
     203    </Compile>
    196204    <Compile Include="LightweightApplicationManager.cs" />
    197205    <Compile Include="Interfaces\IPluginFile.cs" />
     
    260268      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    261269    </Content>
     270    <None Include="Resources\Error.ico" />
    262271    <Content Include="Resources\HeuristicLab.ico" />
    263272    <Content Include="Resources\Logo_white.gif" />
     
    265274    <Content Include="Resources\VS2008ImageLibrary_Actions_PublishToWebHS.png" />
    266275    <Content Include="Resources\VS2008ImageLibrary_Actions_RepeatHS.png" />
     276    <None Include="Resources\VS2008ImageLibrary_Annotations_Error.png" />
    267277    <Content Include="Resources\VS2008ImageLibrary_CommonElements_Actions_Add.png" />
    268278    <Content Include="Resources\VS2008ImageLibrary_Objects_Plugin.png" />
  • trunk/sources/HeuristicLab.PluginInfrastructure/Main.cs

    r3745 r3758  
    4444      }
    4545      catch (Exception ex) {
    46         ShowErrorMessageBox(ex);
     46        ErrorHandling.ShowErrorDialog(ex);
    4747      }
    48     }
    49 
    50     private static void ShowErrorMessageBox(Exception ex) {
    51       MessageBox.Show(null,
    52         BuildErrorMessage(ex),
    53         "Error - " + ex.GetType().Name,
    54         MessageBoxButtons.OK,
    55         MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
    56     }
    57 
    58     private static string BuildErrorMessage(Exception ex) {
    59       string nl = Environment.NewLine;
    60       StringBuilder sb = new StringBuilder();
    61       sb.Append(ex.Message + nl + ex.StackTrace);
    62 
    63       while (ex.InnerException != null) {
    64         ex = ex.InnerException;
    65         sb.Append(nl + "-----" + nl + ex.Message + nl + ex.StackTrace);
    66       }
    67       return sb.ToString();
    6848    }
    6949  }
  • trunk/sources/HeuristicLab.PluginInfrastructure/Resources.Designer.cs

    r3752 r3758  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:2.0.50727.4200
     4//     Runtime Version:2.0.50727.4927
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    9696        }
    9797       
     98        internal static System.Drawing.Bitmap Error {
     99            get {
     100                object obj = ResourceManager.GetObject("Error", resourceCulture);
     101                return ((System.Drawing.Bitmap)(obj));
     102            }
     103        }
     104       
     105        internal static System.Drawing.Icon ErrorIcon {
     106            get {
     107                object obj = ResourceManager.GetObject("ErrorIcon", resourceCulture);
     108                return ((System.Drawing.Icon)(obj));
     109            }
     110        }
     111       
    98112        internal static System.Drawing.Bitmap File {
    99113            get {
  • trunk/sources/HeuristicLab.PluginInfrastructure/Resources.resx

    r3752 r3758  
    134134    <value>Resources\VS2008ImageLibrary_Objects_Document.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
    135135  </data>
     136  <data name="Error" type="System.Resources.ResXFileRef, System.Windows.Forms">
     137    <value>Resources\VS2008ImageLibrary_Annotations_Error.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
     138  </data>
     139  <data name="ErrorIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
     140    <value>Resources\Error.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
     141  </data>
    136142  <data name="File" type="System.Resources.ResXFileRef, System.Windows.Forms">
    137143    <value>Resources\VS2008ImageLibrary_Objects_File.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  • trunk/sources/HeuristicLab.PluginInfrastructure/Starter/StarterForm.cs

    r3748 r3758  
    153153          catch (Exception ex) {
    154154            stopped = false;
    155             ThreadPool.QueueUserWorkItem(delegate(object exception) { ShowErrorMessageBox((Exception)exception); }, ex);
     155            ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
    156156            Thread.Sleep(5000); // sleep 5 seconds before autorestart
    157157          }
     
    179179    }
    180180
    181     private void ShowErrorMessageBox(Exception ex) {
    182       MessageBoxOptions options = RightToLeft == RightToLeft.Yes ? MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading : MessageBoxOptions.DefaultDesktopOnly;
    183       MessageBox.Show(null,
    184          BuildErrorMessage(ex),
    185          "Error - " + ex.GetType().Name,
    186          MessageBoxButtons.OK,
    187          MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, options);
    188     }
    189     private static string BuildErrorMessage(Exception ex) {
    190       string nl = Environment.NewLine;
    191       StringBuilder sb = new StringBuilder();
    192       sb.Append(ex.Message + nl + ex.StackTrace);
    193 
    194       while (ex.InnerException != null) {
    195         ex = ex.InnerException;
    196         sb.Append(nl + "-----" + nl + ex.Message + nl + ex.StackTrace);
    197       }
    198       return sb.ToString();
    199     }
    200 
    201181    private void MainForm_FormClosing(object sender, FormClosingEventArgs e) {
    202182      abortRequested = true;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/DataAnalysisProblemDataView.cs

    r3742 r3758  
    3030using HeuristicLab.Core.Views;
    3131using HeuristicLab.MainForm;
     32using HeuristicLab.PluginInfrastructure;
    3233
    3334namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    5657        }
    5758        catch (Exception ex) {
    58           Auxiliary.ShowErrorMessageBox(ex);
     59          ErrorHandling.ShowErrorDialog(this, ex);
    5960        }
    6061      }
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/TravelingSalesmanProblemView.cs

    r3712 r3758  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Problems.TravelingSalesman.Views {
     
    9596        }
    9697        catch (Exception ex) {
    97           Auxiliary.ShowErrorMessageBox(ex);
     98          ErrorHandling.ShowErrorDialog(this, ex);
    9899        }
    99100      }
  • trunk/sources/HeuristicLab.SequentialEngine/3.3/SequentialEngine.cs

    r3376 r3758  
    6060        catch (Exception ex) {
    6161          ExecutionStack.Push(operation);
    62           OnExceptionOccurred(ex);
     62          OnExceptionOccurred(new OperatorExecutionException(operation.Operator, ex));
    6363          Pause();
    6464        }
Note: See TracChangeset for help on using the changeset viewer.