Free cookie consent management tool by TermsFeed Policy Generator

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

Restricted types of child operators in MultiOperator (#979)

Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
17 edited

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    }
Note: See TracChangeset for help on using the changeset viewer.