Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization.Views/3.3/ConstrainedItemListView.cs @ 17282

Last change on this file since 17282 was 16996, checked in by gkronber, 6 years ago

#2520 Update plugin dependencies and references for HL.MetaOptimization for new persistence

File size: 1.3 KB
Line 
1using System;
2using HeuristicLab.Core.Views;
3using HeuristicLab.Core;
4using HeuristicLab.MainForm;
5using System.Windows.Forms;
6using HeuristicLab.PluginInfrastructure;
7
8namespace HeuristicLab.Problems.MetaOptimization.Views {
9  [View("Constrained Item List View")]
10  [Content(typeof(ConstrainedItemList<>), IsDefaultView = true)]
11  public sealed partial class ConstrainedItemListView<T> : ItemListView<T> where T : class, IItem {
12    public new ConstrainedItemList<T> Content {
13      get { return (ConstrainedItemList<T>)base.Content; }
14      set { base.Content = value; }
15    }
16
17    public ConstrainedItemListView() {
18      InitializeComponent();
19    }
20
21    protected override T CreateItem() {
22      if (typeSelectorDialog == null) {
23        typeSelectorDialog = new TypeSelectorDialog();
24        typeSelectorDialog.Caption = "Select Item";
25        typeSelectorDialog.TypeSelector.Caption = "Available Items";
26        typeSelectorDialog.TypeSelector.Configure(Content.Type, false, true);
27      }
28
29      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
30        try {
31          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
32        }
33        catch (Exception ex) {
34          ErrorHandling.ShowErrorDialog(this, ex);
35        }
36      }
37      return null;
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.