Changeset 3407


Ignore:
Timestamp:
04/19/10 03:28:16 (11 years ago)
Author:
swagner
Message:

Restricted types of child operators in MultiOperator (#979)

Location:
trunk/sources
Files:
28 edited
3 moved

Legend:

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

    r3362 r3407  
    279279      }
    280280
    281       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    282         AddItem((T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType());
     281      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     282        try {
     283          AddItem((T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType());
     284        }
     285        catch (Exception ex) {
     286          Auxiliary.ShowErrorMessageBox(ex);
     287        }
     288      }
    283289    }
    284290    private void sortAscendingButton_Click(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs

    r3362 r3407  
    3636    protected override void Dispose(bool disposing) {
    3737      if (disposing) {
     38        if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    3839        foreach (ListViewItem listViewItem in itemsListView.Items) {
    3940          T item = listViewItem.Tag as T;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs

    r3393 r3407  
    3636  [Content(typeof(IItemArray<>), false)]
    3737  public partial class ItemArrayView<T> : AsynchronousContentView where T : class, IItem {
     38    protected TypeSelectorDialog typeSelectorDialog;
     39
    3840    /// <summary>
    3941    /// Gets or sets the scope whose variables to represent visually.
     
    128130
    129131    protected virtual T CreateItem() {
    130       try {
    131         return (T)Activator.CreateInstance(typeof(T));
    132       }
    133       catch (Exception ex) {
    134         Auxiliary.ShowErrorMessageBox(ex);
    135         return null;
    136       }
     132      if (typeSelectorDialog == null) {
     133        typeSelectorDialog = new TypeSelectorDialog();
     134        typeSelectorDialog.Caption = "Select Item";
     135        typeSelectorDialog.TypeSelector.Caption = "Available Items";
     136        typeSelectorDialog.TypeSelector.Configure(typeof(T), false, false);
     137      }
     138
     139      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     140        try {
     141          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     142        }
     143        catch (Exception ex) {
     144          Auxiliary.ShowErrorMessageBox(ex);
     145        }
     146      }
     147      return null;
    137148    }
    138149    protected virtual ListViewItem CreateListViewItem(T item) {
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.Designer.cs

    r3362 r3407  
    3737    protected override void Dispose(bool disposing) {
    3838      if (disposing) {
     39        if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    3940        foreach (ListViewItem item in itemsListView.Items) {
    4041          ((T)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r3393 r3407  
    3333  [Content(typeof(IItemCollection<>), false)]
    3434  public partial class ItemCollectionView<T> : AsynchronousContentView where T : class, IItem {
     35    protected TypeSelectorDialog typeSelectorDialog;
     36
    3537    public new IItemCollection<T> Content {
    3638      get { return (IItemCollection<T>)base.Content; }
     
    103105
    104106    protected virtual T CreateItem() {
    105       try {
    106         return (T)Activator.CreateInstance(typeof(T));
    107       } catch(Exception ex) {
    108         Auxiliary.ShowErrorMessageBox(ex);
    109         return null;
    110       }
     107      if (typeSelectorDialog == null) {
     108        typeSelectorDialog = new TypeSelectorDialog();
     109        typeSelectorDialog.Caption = "Select Item";
     110        typeSelectorDialog.TypeSelector.Caption = "Available Items";
     111        typeSelectorDialog.TypeSelector.Configure(typeof(T), false, false);
     112      }
     113
     114      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     115        try {
     116          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     117        }
     118        catch (Exception ex) {
     119          Auxiliary.ShowErrorMessageBox(ex);
     120        }
     121      }
     122      return null;
    111123    }
    112124    protected virtual ListViewItem CreateListViewItem(T item) {
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.Designer.cs

    r3362 r3407  
    3636    protected override void Dispose(bool disposing) {
    3737      if (disposing) {
     38        if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    3839        foreach (ListViewItem item in itemsListView.Items) {
    3940          ((T)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r3393 r3407  
    3636  [Content(typeof(IItemList<>), false)]
    3737  public partial class ItemListView<T> : AsynchronousContentView where T : class, IItem {
     38    protected TypeSelectorDialog typeSelectorDialog;
     39
    3840    /// <summary>
    3941    /// Gets or sets the scope whose variables to represent visually.
     
    131133
    132134    protected virtual T CreateItem() {
    133       try {
    134         return (T)Activator.CreateInstance(typeof(T));
    135       }
    136       catch (Exception ex) {
    137         Auxiliary.ShowErrorMessageBox(ex);
    138         return null;
    139       }
     135      if (typeSelectorDialog == null) {
     136        typeSelectorDialog = new TypeSelectorDialog();
     137        typeSelectorDialog.Caption = "Select Item";
     138        typeSelectorDialog.TypeSelector.Caption = "Available Items";
     139        typeSelectorDialog.TypeSelector.Configure(typeof(T), false, false);
     140      }
     141
     142      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     143        try {
     144          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     145        }
     146        catch (Exception ex) {
     147          Auxiliary.ShowErrorMessageBox(ex);
     148        }
     149      }
     150      return null;
    140151    }
    141152    protected virtual ListViewItem CreateListViewItem(T item) {
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorCollectionView.Designer.cs

    r2655 r3407  
    1 namespace HeuristicLab.Core.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Core.Views {
    223  partial class OperatorCollectionView {
    324    /// <summary>
     
    1233    protected override void Dispose(bool disposing) {
    1334      if (disposing) {
    14         if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    1535        if (components != null) components.Dispose();
    1636      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorCollectionView.cs

    r3393 r3407  
    1 using System.Windows.Forms;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
     23using System.Windows.Forms;
    224using HeuristicLab.Collections;
    325using HeuristicLab.MainForm;
     
    830  [Content(typeof(IItemCollection<IOperator>), false)]
    931  public partial class OperatorCollectionView : ItemCollectionView<IOperator> {
    10     protected TypeSelectorDialog typeSelectorDialog;
    11 
    1232    /// <summary>
    1333    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    3252      if (typeSelectorDialog == null) {
    3353        typeSelectorDialog = new TypeSelectorDialog();
     54        typeSelectorDialog.Caption = "Select Operator";
    3455        typeSelectorDialog.TypeSelector.Caption = "Available Operators";
    3556        typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false);
    3657      }
    3758
    38       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    39         return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    40       else
    41         return null;
     59      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     60        try {
     61          return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     62        }
     63        catch (Exception ex) {
     64          Auxiliary.ShowErrorMessageBox(ex);
     65        }
     66      }
     67      return null;
    4268    }
    4369  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorListView.Designer.cs

    r2655 r3407  
    1 namespace HeuristicLab.Core.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Core.Views {
    223  partial class OperatorListView {
    324    /// <summary>
     
    1233    protected override void Dispose(bool disposing) {
    1334      if (disposing) {
    14         if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    1535        if (components != null) components.Dispose();
    1636      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorListView.cs

    r3393 r3407  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Collections;
     
    2930  [Content(typeof(IItemList<IOperator>), false)]
    3031  public partial class OperatorListView : ItemListView<IOperator> {
    31     protected TypeSelectorDialog typeSelectorDialog;
    32 
    3332    /// <summary>
    3433    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    5352      if (typeSelectorDialog == null) {
    5453        typeSelectorDialog = new TypeSelectorDialog();
     54        typeSelectorDialog.Caption = "Select Operator";
    5555        typeSelectorDialog.TypeSelector.Caption = "Available Operators";
    5656        typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false);
    5757      }
    5858
    59       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    60         return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    61       else
    62         return null;
     59      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     60        try {
     61          return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     62        }
     63        catch (Exception ex) {
     64          Auxiliary.ShowErrorMessageBox(ex);
     65        }
     66      }
     67      return null;
    6368    }
    6469  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorSetView.Designer.cs

    r2655 r3407  
    1 namespace HeuristicLab.Core.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Core.Views {
    223  partial class OperatorSetView {
    324    /// <summary>
     
    1233    protected override void Dispose(bool disposing) {
    1334      if (disposing) {
    14         if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    1535        if (components != null) components.Dispose();
    1636      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorSetView.cs

    r3393 r3407  
    1 using System.Windows.Forms;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
     23using System.Windows.Forms;
    224using HeuristicLab.Collections;
    325using HeuristicLab.MainForm;
     
    830  [Content(typeof(IItemSet<IOperator>), false)]
    931  public partial class OperatorSetView : ItemSetView<IOperator> {
    10     protected TypeSelectorDialog typeSelectorDialog;
    11 
    1232    /// <summary>
    1333    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    3252      if (typeSelectorDialog == null) {
    3353        typeSelectorDialog = new TypeSelectorDialog();
     54        typeSelectorDialog.Caption = "Select Operator";
    3455        typeSelectorDialog.TypeSelector.Caption = "Available Operators";
    3556        typeSelectorDialog.TypeSelector.Configure(typeof(IOperator), false, false);
    3657      }
    3758
    38       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    39         return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    40       else
    41         return null;
     59      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     60        try {
     61          return (IOperator)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     62        }
     63        catch (Exception ex) {
     64          Auxiliary.ShowErrorMessageBox(ex);
     65        }
     66      }
     67      return null;
    4268    }
    4369  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs

    r3393 r3407  
    2424using System.ComponentModel;
    2525using System.Drawing;
     26using System.Linq;
    2627using System.Windows.Forms;
    2728using HeuristicLab.Collections;
     
    3536  [Content(typeof(IOperator), false)]
    3637  public sealed partial class OperatorTreeView : ItemView {
    37     private Dictionary<IValueParameter<IOperator>, List<TreeNode>> opParamNodeTable;
     38    private Dictionary<IValueParameter, List<TreeNode>> opParamNodeTable;
    3839    private Dictionary<IOperator, List<TreeNode>> operatorNodeTable;
    3940    private Dictionary<IKeyedItemCollection<string, IParameter>, IOperator> parametersOperatorTable;
     
    6667      InitializeComponent();
    6768      graphTreeView.Sorted = true;
    68       opParamNodeTable = new Dictionary<IValueParameter<IOperator>, List<TreeNode>>();
     69      opParamNodeTable = new Dictionary<IValueParameter, List<TreeNode>>();
    6970      operatorNodeTable = new Dictionary<IOperator, List<TreeNode>>();
    7071      parametersOperatorTable = new Dictionary<IKeyedItemCollection<string, IParameter>, IOperator>();
     
    116117
    117118    #region TreeNode Management
    118     private TreeNode CreateTreeNode(IValueParameter<IOperator> opParam) {
     119    private TreeNode CreateTreeNode(IValueParameter opParam) {
    119120      TreeNode node = new TreeNode();
    120121      node.Text = opParam.Name + ": ";
     
    127128      opParamNodeTable[opParam].Add(node);
    128129
    129       FillTreeNode(node, opParam.Value);
     130      FillTreeNode(node, (IOperator)opParam.Value);
    130131      return node;
    131132    }
     
    162163        else node.ForeColor = graphTreeView.ForeColor;
    163164
    164         foreach (IParameter param in op.Parameters) {
    165           if (param is IValueParameter<IOperator>)
     165        foreach (IValueParameter param in op.Parameters.OfType<IValueParameter>()) {
     166          if (typeof(IOperator).IsAssignableFrom(param.DataType))
    166167            node.Nodes.Add(new TreeNode());
    167168        }
     
    199200      ClearTreeNode(node);
    200201
    201       IValueParameter<IOperator> opParam = GetOperatorParameterTag(node);
     202      IValueParameter opParam = GetOperatorParameterTag(node);
    202203      if (opParam != null) {
    203204        opParamNodeTable[opParam].Remove(node);
     
    211212    }
    212213    private void AddParameterNodes(IOperator op, IEnumerable<IParameter> parameters) {
    213       foreach (IParameter param in parameters) {
    214         IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    215         if (opParam != null) {
     214      foreach (IValueParameter param in parameters.OfType<IValueParameter>()) {
     215        if (typeof(IOperator).IsAssignableFrom(param.DataType)) {
    216216          foreach (TreeNode node in operatorNodeTable[op])
    217             node.Nodes.Add(CreateTreeNode(opParam));
     217            node.Nodes.Add(CreateTreeNode(param));
    218218        }
    219219      }
    220220    }
    221221    private void RemoveParameterNodes(IEnumerable<IParameter> parameters) {
    222       foreach (IParameter param in parameters) {
    223         IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    224         if (opParam != null) {
    225           while (opParamNodeTable.ContainsKey(opParam))
    226             RemoveTreeNode(opParamNodeTable[opParam][0]);
     222      foreach (IValueParameter param in parameters.OfType<IValueParameter>()) {
     223        if (typeof(IOperator).IsAssignableFrom(param.DataType)) {
     224          while (opParamNodeTable.ContainsKey(param))
     225            RemoveTreeNode(opParamNodeTable[param][0]);
    227226        }
    228227      }
     
    235234        Invoke(new EventHandler(opParam_ValueChanged), sender, e);
    236235      else {
    237         IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender;
     236        IValueParameter opParam = (IValueParameter)sender;
    238237        foreach (TreeNode node in opParamNodeTable[opParam].ToArray())
    239238          ClearTreeNode(node);
    240239        foreach (TreeNode node in opParamNodeTable[opParam]) {
    241240          node.Text = opParam.Name + ": ";
    242           FillTreeNode(node, opParam.Value);
     241          FillTreeNode(node, (IOperator)opParam.Value);
    243242        }
    244243      }
     
    265264        IOperator op = (IOperator)sender;
    266265        foreach (TreeNode node in operatorNodeTable[op]) {
    267           IValueParameter<IOperator> opParam = GetOperatorParameterTag(node);
     266          IValueParameter opParam = GetOperatorParameterTag(node);
    268267          if (opParam == null)
    269268            node.Text = op.Name + " (" + op.ItemName + ")";
     
    330329        node.Nodes.Clear();
    331330        IOperator op = GetOperatorTag(node);
    332         foreach (IParameter param in op.Parameters) {
    333           IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    334           if (opParam != null) node.Nodes.Add(CreateTreeNode(opParam));
     331        foreach (IValueParameter param in op.Parameters.OfType<IValueParameter>()) {
     332          if (typeof(IOperator).IsAssignableFrom(param.DataType)) node.Nodes.Add(CreateTreeNode(param));
    335333        }
    336334      }
     
    343341    private void graphTreeView_KeyDown(object sender, KeyEventArgs e) {
    344342      if (!ReadOnly && (e.KeyCode == Keys.Delete) && (graphTreeView.SelectedNode != null)) {
    345         IValueParameter<IOperator> opParam = GetOperatorParameterTag(graphTreeView.SelectedNode);
     343        IValueParameter opParam = GetOperatorParameterTag(graphTreeView.SelectedNode);
    346344        if (opParam != null) opParam.Value = null;
    347345      }
     
    371369    private void graphTreeView_ItemDrag(object sender, ItemDragEventArgs e) {
    372370      TreeNode node = (TreeNode)e.Item;
    373       IValueParameter<IOperator> opParam = GetOperatorParameterTag(node);
     371      IValueParameter opParam = GetOperatorParameterTag(node);
    374372      IOperator op = GetOperatorTag(node);
    375373      DataObject data = new DataObject();
     
    404402        if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) op = (IOperator)op.Clone();
    405403        TreeNode node = graphTreeView.GetNodeAt(graphTreeView.PointToClient(new Point(e.X, e.Y)));
    406         IValueParameter<IOperator> opParam = GetOperatorParameterTag(node);
     404        IValueParameter opParam = GetOperatorParameterTag(node);
    407405        opParam.Value = op;
    408406      }
     
    436434    }
    437435
    438     private IValueParameter<IOperator> GetOperatorParameterTag(TreeNode node) {
     436    private IValueParameter GetOperatorParameterTag(TreeNode node) {
    439437      if (node.Tag != null)
    440         return ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item1;
     438        return ((Tuple<IValueParameter, IOperator>)node.Tag).Item1;
    441439      else
    442440        return null;
    443441    }
    444     private void SetOperatorParameterTag(TreeNode node, IValueParameter<IOperator> opParam) {
     442    private void SetOperatorParameterTag(TreeNode node, IValueParameter opParam) {
    445443      if (node.Tag == null)
    446         node.Tag = new Tuple<IValueParameter<IOperator>, IOperator>(opParam, null);
     444        node.Tag = new Tuple<IValueParameter, IOperator>(opParam, null);
    447445      else
    448         ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item1 = opParam;
     446        ((Tuple<IValueParameter, IOperator>)node.Tag).Item1 = opParam;
    449447    }
    450448    private IOperator GetOperatorTag(TreeNode node) {
    451449      if (node.Tag != null)
    452         return ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item2;
     450        return ((Tuple<IValueParameter, IOperator>)node.Tag).Item2;
    453451      else
    454452        return null;
     
    456454    private void SetOperatorTag(TreeNode node, IOperator op) {
    457455      if (node.Tag == null)
    458         node.Tag = new Tuple<IValueParameter<IOperator>, IOperator>(null, op);
     456        node.Tag = new Tuple<IValueParameter, IOperator>(null, op);
    459457      else
    460         ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item2 = op;
     458        ((Tuple<IValueParameter, IOperator>)node.Tag).Item2 = op;
    461459    }
    462460
  • trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs

    r3393 r3407  
    5555      if (createParameterDialog.ShowDialog(this) == DialogResult.OK) {
    5656        IParameter param = createParameterDialog.Parameter;
    57         if (Content.ContainsKey(param.Name))
     57        if ((param != null) && Content.ContainsKey(param.Name))
    5858          param = (IParameter)Activator.CreateInstance(param.GetType(), GetUniqueName(param.Name), param.Description);
    5959        return param;
    60       } else
    61         return null;
     60      }
     61      return null;
    6262    }
    6363  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ValueParameterCollectionView.cs

    r3393 r3407  
    5858      if (createParameterDialog.ShowDialog(this) == DialogResult.OK) {
    5959        IValueParameter param = (IValueParameter)createParameterDialog.Parameter;
    60         if (Content.ContainsKey(param.Name))
     60        if ((param != null) && Content.ContainsKey(param.Name))
    6161          param = (IValueParameter)Activator.CreateInstance(param.GetType(), GetUniqueName(param.Name), param.Description);
    6262        return param;
    63       } else
    64         return null;
     63      }
     64      return null;
    6565    }
    6666  }
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs

    r3362 r3407  
    123123      if (typeSelectorDialog == null) {
    124124        typeSelectorDialog = new TypeSelectorDialog();
    125         typeSelectorDialog.Caption = "Select Value Type";
     125        typeSelectorDialog.Caption = "Select Value";
    126126        typeSelectorDialog.TypeSelector.Configure(typeof(IItem), false, false);
    127127      }
    128128      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    129         Content.Value = (IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     129        try {
     130          Content.Value = (IItem)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     131        }
     132        catch (Exception ex) {
     133          Auxiliary.ShowErrorMessageBox(ex);
     134        }
    130135      }
    131136    }
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs

    r3386 r3407  
    9090    protected OperatorGraph(bool deserializing) : base(deserializing) { }
    9191
    92     //mkommend: IMPROTANT DO NOT REMOVE THIS PRIVATE EVENT
     92    //mkommend: IMPORTANT DO NOT REMOVE THIS PRIVATE EVENT
    9393    //needed to register OperatorGraph events in GraphVisualizationInfo
    9494    public event EventHandler DeserializationFinished;
     
    144144      var opParams = from o in Operators
    145145                     from p in o.Parameters
    146                      where p is IValueParameter<IOperator>
    147                      where (((IValueParameter<IOperator>)p).Value != null) && (((IValueParameter<IOperator>)p).Value == op)
    148                      select (IValueParameter<IOperator>)p;
    149       foreach (IValueParameter<IOperator> opParam in opParams)
     146                     where p is IValueParameter
     147                     where typeof(IOperator).IsAssignableFrom(((IValueParameter)p).DataType)
     148                     where (((IValueParameter)p).Value != null) && (((IValueParameter)p).Value == op)
     149                     select (IValueParameter)p;
     150      foreach (IValueParameter opParam in opParams)
    150151        opParam.Value = null;
    151152    }
    152153    private void AddParameter(IParameter param) {
    153       IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    154       if (opParam != null) {
    155         RegisterOperatorParameterEvents(opParam);
    156         if (opParam.Value != null) Operators.Add(opParam.Value);
     154      IValueParameter valueParam = param as IValueParameter;
     155      if ((valueParam != null) && (typeof(IOperator).IsAssignableFrom(valueParam.DataType))) {
     156        RegisterOperatorParameterEvents(valueParam);
     157        if (valueParam.Value != null) Operators.Add((IOperator)valueParam.Value);
    157158      }
    158159    }
    159160    private void RemoveParameter(IParameter param) {
    160       IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    161       if (opParam != null) {
    162         DeregisterOperatorParameterEvents(opParam);
     161      IValueParameter valueParam = param as IValueParameter;
     162      if ((valueParam != null) && (typeof(IOperator).IsAssignableFrom(valueParam.DataType))) {
     163        DeregisterOperatorParameterEvents(valueParam);
    163164      }
    164165    }
     
    171172        foreach (IOperator op in operators) {
    172173          RegisterOperatorEvents(op);
    173           foreach (IParameter param in op.Parameters) {
    174             IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    175             if (opParam != null) RegisterOperatorParameterEvents(opParam);
    176           }
     174          var opParams = from p in op.Parameters
     175                         where p is IValueParameter
     176                         where typeof(IOperator).IsAssignableFrom(((IValueParameter)p).DataType)
     177                         select (IValueParameter)p;
     178          foreach (IValueParameter opParam in opParams)
     179            RegisterOperatorParameterEvents(opParam);
    177180        }
    178181      }
     
    190193      op.Parameters.CollectionReset -= new CollectionItemsChangedEventHandler<IParameter>(Parameters_CollectionReset);
    191194    }
    192     private void RegisterOperatorParameterEvents(IValueParameter<IOperator> opParam) {
     195    private void RegisterOperatorParameterEvents(IValueParameter opParam) {
    193196      opParam.ValueChanged += new EventHandler(opParam_ValueChanged);
    194197    }
    195     private void DeregisterOperatorParameterEvents(IValueParameter<IOperator> opParam) {
     198    private void DeregisterOperatorParameterEvents(IValueParameter opParam) {
    196199      opParam.ValueChanged -= new EventHandler(opParam_ValueChanged);
    197200    }
     
    234237    }
    235238    private void opParam_ValueChanged(object sender, EventArgs e) {
    236       IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender;
    237       if (opParam.Value != null) Operators.Add(opParam.Value);
     239      IValueParameter opParam = (IValueParameter)sender;
     240      if (opParam.Value != null) Operators.Add((IOperator)opParam.Value);
    238241    }
    239242    #endregion
  • trunk/sources/HeuristicLab.Operators.Views/3.3/HeuristicLab.Operators.Views-3.3.csproj

    r3384 r3407  
    9292    </Compile>
    9393    <None Include="HeuristicLabOperatorsViewsPlugin.cs.frame" />
    94     <Compile Include="MultipleCallsOperatorView.cs">
     94    <Compile Include="MultiOperatorView.cs">
    9595      <SubType>UserControl</SubType>
    9696    </Compile>
    97     <Compile Include="MultipleCallsOperatorView.Designer.cs">
    98       <DependentUpon>MultipleCallsOperatorView.cs</DependentUpon>
     97    <Compile Include="MultiOperatorView.Designer.cs">
     98      <DependentUpon>MultiOperatorView.cs</DependentUpon>
    9999    </Compile>
    100100    <Compile Include="OperatorView.cs">
  • trunk/sources/HeuristicLab.Operators.Views/3.3/MultiOperatorView.Designer.cs

    r3401 r3407  
    2121
    2222namespace HeuristicLab.Operators.Views {
    23   partial class MultipleCallsOperatorView {
     23  partial class MultiOperatorView<T> {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4747      this.tabControl = new System.Windows.Forms.TabControl();
    4848      this.operatorsTabPage = new System.Windows.Forms.TabPage();
    49       this.operatorListView = new HeuristicLab.Core.Views.OperatorListView();
     49      this.operatorListView = new HeuristicLab.Core.Views.ItemListView<T>();
    5050      this.parametersTabPage = new System.Windows.Forms.TabPage();
    5151      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
     
    147147      this.breakpointLabel.Text = "&Breakpoint:";
    148148      //
    149       // MultipleCallsOperatorView
     149      // MultiOperatorView
    150150      //
    151151      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     
    154154      this.Controls.Add(this.breakpointLabel);
    155155      this.Controls.Add(this.tabControl);
    156       this.Name = "MultipleCallsOperatorView";
     156      this.Name = "MultiOperatorView";
    157157      this.Size = new System.Drawing.Size(486, 482);
    158158      this.Controls.SetChildIndex(this.tabControl, 0);
     
    178178    protected System.Windows.Forms.TabPage parametersTabPage;
    179179    protected HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
    180     protected HeuristicLab.Core.Views.OperatorListView operatorListView;
     180    protected HeuristicLab.Core.Views.ItemListView<T> operatorListView;
    181181    protected System.Windows.Forms.CheckBox breakpointCheckBox;
    182182    protected System.Windows.Forms.Label breakpointLabel;
  • trunk/sources/HeuristicLab.Operators.Views/3.3/MultiOperatorView.cs

    r3401 r3407  
    3030  /// The base class for visual representations of items.
    3131  /// </summary>
    32   [View("MultipleCallsOperator View")]
    33   [Content(typeof(MultipleCallsOperator), true)]
    34   public partial class MultipleCallsOperatorView : NamedItemView {
    35     public new MultipleCallsOperator Content {
    36       get { return (MultipleCallsOperator)base.Content; }
     32  [View("MultiOperator View")]
     33  [Content(typeof(MultiOperator<>), true)]
     34  public partial class MultiOperatorView<T> : NamedItemView where T : class, IOperator {
     35    public new MultiOperator<T> Content {
     36      get { return (MultiOperator<T>)base.Content; }
    3737      set { base.Content = value; }
    3838    }
     
    4141    /// Initializes a new instance of <see cref="ItemBaseView"/>.
    4242    /// </summary>
    43     public MultipleCallsOperatorView() {
     43    public MultiOperatorView() {
    4444      InitializeComponent();
    4545    }
     
    4848    /// </summary>
    4949    /// <param name="item">The item that should be displayed.</param>
    50     public MultipleCallsOperatorView(MultipleCallsOperator content)
     50    public MultiOperatorView(MultiOperator<T> content)
    5151      : this() {
    5252      Content = content;
  • trunk/sources/HeuristicLab.Operators/3.3/HeuristicLab.Operators-3.3.csproj

    r3404 r3407  
    9191    <Compile Include="Assigner.cs" />
    9292    <Compile Include="AlgorithmOperator.cs" />
    93     <Compile Include="MultipleCallsOperator.cs" />
     93    <Compile Include="MultiOperator.cs" />
    9494    <Compile Include="Operator.cs" />
    9595    <Compile Include="Placeholder.cs" />
  • trunk/sources/HeuristicLab.Operators/3.3/MultiOperator.cs

    r3401 r3407  
    3131namespace HeuristicLab.Operators {
    3232  /// <summary>
    33   /// A base class for operators which apply multiple user-defined operators.
     33  /// A base class for operators which apply arbitrary many other operators of a specific type.
    3434  /// </summary>
    35   [Item("MultipleCallsOperator", "A base class for operators which apply multiple user-defined operators.")]
     35  [Item("MultiOperator<T>", "A base class for operators which apply arbitrary many other operators of a specific type.")]
    3636  [StorableClass]
    37   public abstract class MultipleCallsOperator : SingleSuccessorOperator {
    38     private List<IValueParameter<IOperator>> operatorParameters;
     37  public abstract class MultiOperator<T> : SingleSuccessorOperator where T : class, IOperator {
     38    private List<IValueParameter<T>> operatorParameters;
    3939
    4040    [Storable]
    41     private OperatorList operators;
    42     public OperatorList Operators {
     41    private ItemList<T> operators;
     42    public ItemList<T> Operators {
    4343      get { return operators; }
    4444    }
    4545
    46     public MultipleCallsOperator()
     46    public MultiOperator()
    4747      : base() {
    48       operators = new OperatorList();
     48      operators = new ItemList<T>();
    4949      Initialize();
    5050    }
    5151    [StorableConstructor]
    52     protected MultipleCallsOperator(bool deserializing) : base(deserializing) { }
     52    protected MultiOperator(bool deserializing) : base(deserializing) { }
    5353
    5454    [StorableHook(HookType.AfterDeserialization)]
    5555    private void Initialize() {
    5656      if (operators != null) RegisterOperatorsEvents();
    57       operatorParameters = new List<IValueParameter<IOperator>>();
     57      operatorParameters = new List<IValueParameter<T>>();
    5858      for (int i = 0; i < Operators.Count; i++) {
    59         IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)Parameters[i.ToString()];
     59        IValueParameter<T> opParam = (IValueParameter<T>)Parameters[i.ToString()];
    6060        operatorParameters.Add(opParam);
    6161        opParam.ValueChanged += new EventHandler(opParam_ValueChanged);
     
    6464
    6565    public override IDeepCloneable Clone(Cloner cloner) {
    66       MultipleCallsOperator clone = (MultipleCallsOperator)base.Clone(cloner);
    67       clone.operators = (OperatorList)cloner.Clone(operators);
     66      MultiOperator<T> clone = (MultiOperator<T>)base.Clone(cloner);
     67      clone.operators = (ItemList<T>)cloner.Clone(operators);
    6868      clone.Initialize();
    6969      return clone;
     
    7171
    7272    private void UpdateOperatorParameters() {
    73       foreach (IValueParameter<IOperator> opParam in operatorParameters) {
     73      foreach (IValueParameter<T> opParam in operatorParameters) {
    7474        opParam.ValueChanged -= new EventHandler(opParam_ValueChanged);
    7575        Parameters.Remove(opParam.Name);
     
    7777      operatorParameters.Clear();
    7878      for (int i = 0; i < Operators.Count; i++) {
    79         IValueParameter<IOperator> opParam = new ValueParameter<IOperator>(i.ToString(), string.Empty, Operators[i]);
     79        IValueParameter<T> opParam = new ValueParameter<T>(i.ToString(), string.Empty, Operators[i]);
    8080        opParam.ValueChanged += new EventHandler(opParam_ValueChanged);
    8181        Parameters.Add(opParam);
     
    8686    #region Events
    8787    private void RegisterOperatorsEvents() {
    88       operators.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsAdded);
    89       operators.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsRemoved);
    90       operators.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsReplaced);
    91       operators.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsMoved);
    92       operators.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_CollectionReset);
     88      operators.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsAdded);
     89      operators.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsRemoved);
     90      operators.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsReplaced);
     91      operators.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsMoved);
     92      operators.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_CollectionReset);
    9393    }
    9494    private void DeregisterOperatorsEvents() {
    95       operators.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsAdded);
    96       operators.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsRemoved);
    97       operators.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsReplaced);
    98       operators.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_ItemsMoved);
    99       operators.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(operators_CollectionReset);
     95      operators.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsAdded);
     96      operators.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsRemoved);
     97      operators.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsReplaced);
     98      operators.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_ItemsMoved);
     99      operators.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(operators_CollectionReset);
    100100    }
    101     private void operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) {
     101    private void operators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
    102102      UpdateOperatorParameters();
    103103    }
    104     private void operators_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) {
     104    private void operators_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
    105105      UpdateOperatorParameters();
    106106    }
    107     private void operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) {
    108       foreach (IndexedItem<IOperator> item in e.Items)
     107    private void operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
     108      foreach (IndexedItem<T> item in e.Items)
    109109        operatorParameters[item.Index].Value = item.Value;
    110110    }
    111     private void operators_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) {
    112       foreach (IndexedItem<IOperator> item in e.Items)
     111    private void operators_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
     112      foreach (IndexedItem<T> item in e.Items)
    113113        operatorParameters[item.Index].Value = item.Value;
    114114    }
    115     private void operators_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOperator>> e) {
     115    private void operators_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
    116116      UpdateOperatorParameters();
    117117    }
    118118    private void opParam_ValueChanged(object sender, EventArgs e) {
    119       IValueParameter<IOperator> opParam = (IValueParameter<IOperator>)sender;
     119      IValueParameter<T> opParam = (IValueParameter<T>)sender;
    120120      operators[operatorParameters.IndexOf(opParam)] = opParam.Value;
    121121    }
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesProcessor.cs

    r3376 r3407  
    3232  [Item("SubScopesProcessor", "An operator which contains multiple operators of which each is applied on one sub-scope of the current scope. The first operator is applied on the first sub-scope, the second on the second, and so on.")]
    3333  [StorableClass]
    34   public sealed class SubScopesProcessor : MultipleCallsOperator {
     34  public sealed class SubScopesProcessor : MultiOperator<IOperator> {
    3535    public ValueLookupParameter<BoolValue> ParallelParameter {
    3636      get { return (ValueLookupParameter<BoolValue>)Parameters["Parallel"]; }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3367 r3407  
    176176        problemTypeSelectorDialog = new TypeSelectorDialog();
    177177        problemTypeSelectorDialog.Caption = "Select Problem";
     178        problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
    178179        problemTypeSelectorDialog.TypeSelector.Configure(Content.ProblemType, false, false);
    179180      }
    180181      if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    181         Content.Problem = (IProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     182        try {
     183          Content.Problem = (IProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     184        }
     185        catch (Exception ex) {
     186          Auxiliary.ShowErrorMessageBox(ex);
     187        }
    182188      }
    183189    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r3367 r3407  
    166166        algorithmTypeSelectorDialog = new TypeSelectorDialog();
    167167        algorithmTypeSelectorDialog.Caption = "Select Algorithm";
     168        algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms";
    168169        algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, false);
    169170      }
    170171      if (algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    171         Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     172        try {
     173          Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     174        }
     175        catch (Exception ex) {
     176          Auxiliary.ShowErrorMessageBox(ex);
     177        }
    172178      }
    173179    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/OptimizerListView.Designer.cs

    r3274 r3407  
    3333    protected override void Dispose(bool disposing) {
    3434      if (disposing) {
    35         if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
    3635        if (components != null) components.Dispose();
    3736      }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/OptimizerListView.cs

    r3393 r3407  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Collections;
     
    3132  [Content(typeof(IItemList<IOptimizer>), false)]
    3233  public partial class OptimizerListView : ItemListView<IOptimizer> {
    33     protected TypeSelectorDialog typeSelectorDialog;
    34 
    3534    /// <summary>
    3635    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    5554      if (typeSelectorDialog == null) {
    5655        typeSelectorDialog = new TypeSelectorDialog();
     56        typeSelectorDialog.Caption = "Select Optimizer";
    5757        typeSelectorDialog.TypeSelector.Caption = "Available Optimizers";
    5858        typeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, false);
    5959      }
    6060
    61       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    62         return typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType() as IOptimizer;
    63       else
    64         return null;
     61      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     62        try {
     63          return (IOptimizer)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     64        }
     65        catch (Exception ex) {
     66          Auxiliary.ShowErrorMessageBox(ex);
     67        }
     68      }
     69      return null;
    6570    }
    6671  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultCollectionView.cs

    r3393 r3407  
    5656
    5757    protected override IResult CreateItem() {
    58       IResult item = new Result();
    59       if (Content.ContainsKey(item.Name))
    60         item = new Result(GetUniqueName(item.Name), typeof(IItem));
    61       return item;
     58      return null;
    6259    }
    6360  }
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs

    r3376 r3407  
    138138        typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false);
    139139      }
    140       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    141         Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     140      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     141        try {
     142          Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     143        }
     144        catch (Exception ex) {
     145          Auxiliary.ShowErrorMessageBox(ex);
     146        }
     147      }
    142148    }
    143149    protected virtual void clearValueButton_Click(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs

    r3376 r3407  
    126126        typeSelectorDialog.TypeSelector.Configure(Content.DataType, false, false);
    127127      }
    128       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK)
    129         Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     128      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     129        try {
     130          Content.Value = (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     131        }
     132        catch (Exception ex) {
     133          Auxiliary.ShowErrorMessageBox(ex);
     134        }
     135      }
    130136    }
    131137    protected virtual void setValueButton_Click(object sender, EventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.