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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) {
Note: See TracChangeset for help on using the changeset viewer.