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