Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3614 for trunk


Ignore:
Timestamp:
05/05/10 00:10:13 (15 years ago)
Author:
mkommend
Message:

implemented first version of RunConstraints (ticket #970)

Location:
trunk/sources
Files:
15 added
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj

    r3437 r3614  
    100100      <DependentUpon>BatchRunView.cs</DependentUpon>
    101101    </Compile>
     102    <Compile Include="RunCollectioComparisonConstraintView.cs">
     103      <SubType>UserControl</SubType>
     104    </Compile>
     105    <Compile Include="RunCollectioComparisonConstraintView.Designer.cs">
     106      <DependentUpon>RunCollectioComparisonConstraintView.cs</DependentUpon>
     107    </Compile>
     108    <Compile Include="RunCollectionTypeCompatibilityConstraintView.cs">
     109      <SubType>UserControl</SubType>
     110    </Compile>
     111    <Compile Include="RunCollectionTypeCompatibilityConstraintView.Designer.cs">
     112      <DependentUpon>RunCollectionTypeCompatibilityConstraintView.cs</DependentUpon>
     113    </Compile>
     114    <Compile Include="RunCollectionConstraintCollectionView.cs">
     115      <SubType>UserControl</SubType>
     116    </Compile>
     117    <Compile Include="RunCollectionConstraintCollectionView.Designer.cs">
     118      <DependentUpon>RunCollectionConstraintCollectionView.cs</DependentUpon>
     119    </Compile>
     120    <Compile Include="RunCollectionConstraintView.cs">
     121      <SubType>UserControl</SubType>
     122    </Compile>
     123    <Compile Include="RunCollectionConstraintView.Designer.cs">
     124      <DependentUpon>RunCollectionConstraintView.cs</DependentUpon>
     125    </Compile>
    102126    <Compile Include="OptimizerListView.cs">
    103127      <SubType>UserControl</SubType>
     
    117141    <Compile Include="RunCollectionBubbleChartView.Designer.cs">
    118142      <DependentUpon>RunCollectionBubbleChartView.cs</DependentUpon>
     143    </Compile>
     144    <Compile Include="RunCollectionEqualityConstraintView.cs">
     145      <SubType>UserControl</SubType>
     146    </Compile>
     147    <Compile Include="RunCollectionEqualityConstraintView.Designer.cs">
     148      <DependentUpon>RunCollectionEqualityConstraintView.cs</DependentUpon>
    119149    </Compile>
    120150    <Compile Include="RunCollectionTabularView.cs">
     
    222252      <Name>HeuristicLab.PluginInfrastructure</Name>
    223253    </ProjectReference>
     254  </ItemGroup>
     255  <ItemGroup>
     256    <EmbeddedResource Include="RunCollectioComparisonConstraintView.resx">
     257      <DependentUpon>RunCollectioComparisonConstraintView.cs</DependentUpon>
     258    </EmbeddedResource>
    224259  </ItemGroup>
    225260  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs

    r3566 r3614  
    6363      this.isSelecting = false;
    6464
    65 
    6665      this.chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
    6766      this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
     
    122121    private void run_Changed(object sender, EventArgs e) {
    123122      IRun run = (IRun)sender;
     123      UpdateRun(run);
     124    }
     125
     126    private void UpdateRun(IRun run) {
    124127      DataPoint point = this.chart.Series[0].Points.Where(p => p.Tag == run).SingleOrDefault();
    125128      if (point != null) {
     
    129132      } else
    130133        AddDataPoint(run);
     134
     135      if (this.chart.Series[0].Points.Count == 0)
     136        noRunsLabel.Visible = true;
     137      else
     138        noRunsLabel.Visible = false;
    131139    }
    132140
     
    136144      UpdateComboBoxes();
    137145      UpdateDataPoints();
     146      foreach(IRun run in Content)
     147        UpdateRun(run);
    138148    }
    139149    private void Content_ColumnNamesChanged(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs

    r3604 r3614  
    2424using HeuristicLab.Collections;
    2525using HeuristicLab.MainForm;
     26using HeuristicLab.Optimization;
     27using System.Drawing;
    2628
    2729namespace HeuristicLab.Core.Views {
    2830  [View("ConstraintCollection View")]
    29   [Content(typeof(ConstraintCollection), true)]
    30   [Content(typeof(IItemCollection<IConstraint>), false)]
    31   public partial class ConstraintCollectionView : ItemCollectionView<IConstraint> {
     31  [Content(typeof(RunCollectionConstraintCollection), true)]
     32  [Content(typeof(IItemCollection<IRunCollectionConstraint>), false)]
     33  public partial class RunCollectionConstraintCollectionView : ItemCollectionView<IRunCollectionConstraint> {
    3234    protected CreateParameterDialog createParameterDialog;
    3335    /// <summary>
    3436    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
    3537    /// </summary>
    36     public ConstraintCollectionView() {
     38    public RunCollectionConstraintCollectionView() {
    3739      InitializeComponent();
    38       Caption = "ConstraintCollection";
    39       itemsGroupBox.Text = "Constraints";
     40      Caption = "RunCollectionConstraintCollection";
     41      itemsGroupBox.Text = "RunCollection Constraints";
    4042    }
    4143
    42     protected override IConstraint CreateItem() {
     44    protected override IRunCollectionConstraint CreateItem() {
    4345      if (typeSelectorDialog == null) {
    4446        typeSelectorDialog = new TypeSelectorDialog();
    45         typeSelectorDialog.Caption = "Select Operator";
    46         typeSelectorDialog.TypeSelector.Caption = "Available Operators";
    47         typeSelectorDialog.TypeSelector.Configure(typeof(IConstraint), false, true);
     47        typeSelectorDialog.Caption = "Select RunCollection Constraint";
     48        typeSelectorDialog.TypeSelector.Caption = "Available Constraints";
     49        typeSelectorDialog.TypeSelector.Configure(typeof(IRunCollectionConstraint), false, true);
    4850      }
    4951
    5052      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    5153        try {
    52           return (IConstraint)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     54          return (IRunCollectionConstraint)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    5355        }
    5456        catch (Exception ex) {
     
    5860      return null;
    5961    }
     62
     63    protected override void RegisterContentEvents() {
     64      base.RegisterContentEvents();
     65      foreach (IRunCollectionConstraint constraint in Content)
     66        constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     67    }
     68    protected override void DeregisterContentEvents() {
     69      base.DeregisterContentEvents();
     70      foreach (IRunCollectionConstraint constraint in Content)
     71        constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
     72    }
     73    protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     74      base.Content_ItemsAdded(sender, e);
     75      foreach (IRunCollectionConstraint constraint in e.Items)
     76        constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     77    }
     78    protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     79      base.Content_ItemsRemoved(sender, e);
     80      foreach (IRunCollectionConstraint constraint in e.Items)
     81        constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
     82    }
     83    protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     84      base.Content_CollectionReset(sender, e);
     85      foreach (IRunCollectionConstraint constraint in e.OldItems)
     86        constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
     87      foreach (IRunCollectionConstraint constraint in e.Items)
     88        constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     89    }
     90
     91    protected virtual void constraint_ActiveChanged(object sender, EventArgs e) {
     92      IRunCollectionConstraint constraint = sender as IRunCollectionConstraint;
     93      if (constraint != null) {
     94        foreach (ListViewItem listViewItem in GetListViewItemsForItem(constraint)) {
     95          if (constraint.Active)
     96            listViewItem.Font = new Font(listViewItem.Font, FontStyle.Bold);
     97          else
     98            listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
     99        }
     100      }
     101    }
     102
     103
    60104  }
    61105}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs

    r3566 r3614  
    5454    }
    5555
     56    protected override void OnContentChanged() {
     57      base.OnContentChanged();
     58      if (Content != null) {
     59        foreach (IRun run in Content)
     60          UpdateRun(run);
     61      }
     62    }
     63
    5664    protected override void RegisterContentEvents() {
    5765      base.RegisterContentEvents();
     
    8896    private void run_Changed(object sender, EventArgs e) {
    8997      IRun run = (IRun)sender;
     98      UpdateRun(run);
     99    }
     100
     101    private void UpdateRun(IRun run) {
    90102      int rowIndex = Content.ToList().IndexOf(run);
    91103      rowIndex = virtualRowIndizes[rowIndex];
     
    104116      }
    105117    }
    106 
    107118
    108119    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs

    r3507 r3614  
    5454    private void InitializeComponent() {
    5555      this.components = new System.ComponentModel.Container();
     56      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RunCollectionView));
    5657      this.splitContainer = new System.Windows.Forms.SplitContainer();
     58      this.toolStrip = new System.Windows.Forms.ToolStrip();
     59      this.analyzeRunsToolStripDropDownButton = new System.Windows.Forms.ToolStripDropDownButton();
    5760      this.itemsListView = new System.Windows.Forms.ListView();
    5861      this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
     
    6366      this.itemsGroupBox = new System.Windows.Forms.GroupBox();
    6467      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    65       this.toolStrip = new System.Windows.Forms.ToolStrip();
    66       this.analyzeRunsToolStripDropDownButton = new System.Windows.Forms.ToolStripDropDownButton();
     68      this.tabControl = new System.Windows.Forms.TabControl();
     69      this.runPage = new System.Windows.Forms.TabPage();
     70      this.constraintPage = new System.Windows.Forms.TabPage();
     71      this.runCollectionConstraintCollectionView = new HeuristicLab.Core.Views.RunCollectionConstraintCollectionView();
    6772      this.splitContainer.Panel1.SuspendLayout();
    6873      this.splitContainer.Panel2.SuspendLayout();
    6974      this.splitContainer.SuspendLayout();
     75      this.toolStrip.SuspendLayout();
    7076      this.detailsGroupBox.SuspendLayout();
    7177      this.itemsGroupBox.SuspendLayout();
    72       this.toolStrip.SuspendLayout();
     78      this.tabControl.SuspendLayout();
     79      this.runPage.SuspendLayout();
     80      this.constraintPage.SuspendLayout();
    7381      this.SuspendLayout();
    7482      //
     
    9098      //
    9199      this.splitContainer.Panel2.Controls.Add(this.detailsGroupBox);
    92       this.splitContainer.Size = new System.Drawing.Size(526, 364);
     100      this.splitContainer.Size = new System.Drawing.Size(512, 332);
    93101      this.splitContainer.SplitterDistance = 250;
    94102      this.splitContainer.TabIndex = 0;
     103      //
     104      // toolStrip
     105      //
     106      this.toolStrip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     107                  | System.Windows.Forms.AnchorStyles.Right)));
     108      this.toolStrip.AutoSize = false;
     109      this.toolStrip.Dock = System.Windows.Forms.DockStyle.None;
     110      this.toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
     111      this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     112            this.analyzeRunsToolStripDropDownButton});
     113      this.toolStrip.Location = new System.Drawing.Point(30, 3);
     114      this.toolStrip.Name = "toolStrip";
     115      this.toolStrip.Size = new System.Drawing.Size(217, 24);
     116      this.toolStrip.TabIndex = 1;
     117      this.toolStrip.Text = "toolStrip1";
     118      //
     119      // analyzeRunsToolStripDropDownButton
     120      //
     121      this.analyzeRunsToolStripDropDownButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
     122      this.analyzeRunsToolStripDropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
     123      this.analyzeRunsToolStripDropDownButton.Name = "analyzeRunsToolStripDropDownButton";
     124      this.analyzeRunsToolStripDropDownButton.Size = new System.Drawing.Size(99, 21);
     125      this.analyzeRunsToolStripDropDownButton.Text = "&Analyze Runs...";
     126      this.analyzeRunsToolStripDropDownButton.ToolTipText = "Show Run Analysis Views";
    95127      //
    96128      // itemsListView
     
    107139      this.itemsListView.Name = "itemsListView";
    108140      this.itemsListView.ShowItemToolTips = true;
    109       this.itemsListView.Size = new System.Drawing.Size(244, 327);
     141      this.itemsListView.Size = new System.Drawing.Size(244, 295);
    110142      this.itemsListView.SmallImageList = this.imageList;
    111143      this.itemsListView.TabIndex = 1;
     
    147179      this.detailsGroupBox.Location = new System.Drawing.Point(3, 27);
    148180      this.detailsGroupBox.Name = "detailsGroupBox";
    149       this.detailsGroupBox.Size = new System.Drawing.Size(266, 335);
     181      this.detailsGroupBox.Size = new System.Drawing.Size(252, 303);
    150182      this.detailsGroupBox.TabIndex = 0;
    151183      this.detailsGroupBox.TabStop = false;
     
    162194      this.viewHost.Name = "viewHost";
    163195      this.viewHost.ReadOnly = false;
    164       this.viewHost.Size = new System.Drawing.Size(254, 310);
     196      this.viewHost.Size = new System.Drawing.Size(240, 278);
    165197      this.viewHost.TabIndex = 0;
    166198      this.viewHost.ViewType = null;
     
    170202      this.itemsGroupBox.Controls.Add(this.splitContainer);
    171203      this.itemsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    172       this.itemsGroupBox.Location = new System.Drawing.Point(0, 0);
     204      this.itemsGroupBox.Location = new System.Drawing.Point(3, 3);
    173205      this.itemsGroupBox.Name = "itemsGroupBox";
    174       this.itemsGroupBox.Size = new System.Drawing.Size(532, 383);
     206      this.itemsGroupBox.Size = new System.Drawing.Size(518, 351);
    175207      this.itemsGroupBox.TabIndex = 0;
    176208      this.itemsGroupBox.TabStop = false;
    177209      this.itemsGroupBox.Text = "Items";
    178210      //
    179       // toolStrip
    180       //
    181       this.toolStrip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    182                   | System.Windows.Forms.AnchorStyles.Right)));
    183       this.toolStrip.AutoSize = false;
    184       this.toolStrip.Dock = System.Windows.Forms.DockStyle.None;
    185       this.toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
    186       this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    187             this.analyzeRunsToolStripDropDownButton});
    188       this.toolStrip.Location = new System.Drawing.Point(30, 3);
    189       this.toolStrip.Name = "toolStrip";
    190       this.toolStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode;
    191       this.toolStrip.Size = new System.Drawing.Size(217, 24);
    192       this.toolStrip.TabIndex = 1;
    193       this.toolStrip.Text = "toolStrip1";
    194       //
    195       // analyzeRunsToolStripDropDownButton
    196       //
    197       this.analyzeRunsToolStripDropDownButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
    198       this.analyzeRunsToolStripDropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
    199       this.analyzeRunsToolStripDropDownButton.Name = "analyzeRunsToolStripDropDownButton";
    200       this.analyzeRunsToolStripDropDownButton.Size = new System.Drawing.Size(45, 21);
    201       this.analyzeRunsToolStripDropDownButton.Text = "&Analyze Runs...";
    202       this.analyzeRunsToolStripDropDownButton.ToolTipText = "Show Run Analysis Views";
     211      // tabControl
     212      //
     213      this.tabControl.Controls.Add(this.runPage);
     214      this.tabControl.Controls.Add(this.constraintPage);
     215      this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
     216      this.tabControl.Location = new System.Drawing.Point(0, 0);
     217      this.tabControl.Name = "tabControl";
     218      this.tabControl.SelectedIndex = 0;
     219      this.tabControl.Size = new System.Drawing.Size(532, 383);
     220      this.tabControl.TabIndex = 1;
     221      //
     222      // runPage
     223      //
     224      this.runPage.Controls.Add(this.itemsGroupBox);
     225      this.runPage.Location = new System.Drawing.Point(4, 22);
     226      this.runPage.Name = "runPage";
     227      this.runPage.Padding = new System.Windows.Forms.Padding(3);
     228      this.runPage.Size = new System.Drawing.Size(524, 357);
     229      this.runPage.TabIndex = 0;
     230      this.runPage.Text = "Runs";
     231      this.runPage.UseVisualStyleBackColor = true;
     232      //
     233      // constraintPage
     234      //
     235      this.constraintPage.Controls.Add(this.runCollectionConstraintCollectionView);
     236      this.constraintPage.Location = new System.Drawing.Point(4, 22);
     237      this.constraintPage.Name = "constraintPage";
     238      this.constraintPage.Padding = new System.Windows.Forms.Padding(3);
     239      this.constraintPage.Size = new System.Drawing.Size(524, 357);
     240      this.constraintPage.TabIndex = 1;
     241      this.constraintPage.Text = "Filtering";
     242      this.constraintPage.UseVisualStyleBackColor = true;
     243      //
     244      // runCollectionConstraintCollectionView
     245      //
     246      this.runCollectionConstraintCollectionView.Caption = "Filter";
     247      this.runCollectionConstraintCollectionView.Content = null;
     248      this.runCollectionConstraintCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     249      this.runCollectionConstraintCollectionView.Location = new System.Drawing.Point(3, 3);
     250      this.runCollectionConstraintCollectionView.Name = "runCollectionConstraintCollectionView";
     251      this.runCollectionConstraintCollectionView.ReadOnly = false;
     252      this.runCollectionConstraintCollectionView.Size = new System.Drawing.Size(518, 351);
     253      this.runCollectionConstraintCollectionView.TabIndex = 0;
    203254      //
    204255      // RunCollectionView
    205256      //
    206257      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    207       this.Controls.Add(this.itemsGroupBox);
     258      this.Controls.Add(this.tabControl);
    208259      this.Name = "RunCollectionView";
    209260      this.Size = new System.Drawing.Size(532, 383);
     
    211262      this.splitContainer.Panel2.ResumeLayout(false);
    212263      this.splitContainer.ResumeLayout(false);
     264      this.toolStrip.ResumeLayout(false);
     265      this.toolStrip.PerformLayout();
    213266      this.detailsGroupBox.ResumeLayout(false);
    214267      this.itemsGroupBox.ResumeLayout(false);
    215       this.toolStrip.ResumeLayout(false);
    216       this.toolStrip.PerformLayout();
     268      this.tabControl.ResumeLayout(false);
     269      this.runPage.ResumeLayout(false);
     270      this.constraintPage.ResumeLayout(false);
    217271      this.ResumeLayout(false);
    218272
     
    232286    protected ToolStrip toolStrip;
    233287    protected ToolStripDropDownButton analyzeRunsToolStripDropDownButton;
     288    private TabControl tabControl;
     289    private TabPage runPage;
     290    private TabPage constraintPage;
     291    private HeuristicLab.Core.Views.RunCollectionConstraintCollectionView runCollectionConstraintCollectionView;
    234292  }
    235293}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs

    r3566 r3614  
    4242    }
    4343
     44    public RunCollection RunCollection {
     45      get { return Content as RunCollection; }
     46    }
     47
    4448    public ListView ItemsListView {
    4549      get { return itemsListView; }
     
    9498      while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]);
    9599      viewHost.Content = null;
     100      runCollectionConstraintCollectionView.Content = null;
     101      tabControl.TabPages.Remove(constraintPage);
    96102
    97103      if (Content != null) {
     104        if (RunCollection != null) {
     105          tabControl.TabPages.Add(constraintPage);
     106          runCollectionConstraintCollectionView.Content = RunCollection.Constraints;
     107          runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     108        }
    98109        Caption += " (" + Content.GetType().Name + ")";
    99         foreach (IRun item in Content)
     110        foreach (IRun item in Content) {
    100111          AddListViewItem(CreateListViewItem(item));
     112          UpdateRun(item);
     113        }
    101114      }
    102115      SetEnabledStateOfControls();
     
    110123      if (Content == null) {
    111124        analyzeRunsToolStripDropDownButton.Enabled = false;
     125        runCollectionConstraintCollectionView.ReadOnly = true;
    112126        itemsListView.Enabled = false;
    113127        detailsGroupBox.Enabled = false;
     
    116130      } else {
    117131        analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     132        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
    118133        itemsListView.Enabled = true;
    119134        detailsGroupBox.Enabled = true;
     
    262277          AddListViewItem(CreateListViewItem(item));
    263278        analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     279        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
    264280      }
    265281    }
     
    276292        }
    277293        analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     294        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
    278295      }
    279296    }
     
    293310          AddListViewItem(CreateListViewItem(item));
    294311        analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     312        runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
    295313      }
    296314    }
     
    318336    protected virtual void Run_Changed(object sender, EventArgs e) {
    319337      IRun run = (IRun)sender;
     338      UpdateRun(run);
     339    }
     340
     341    protected virtual void UpdateRun(IRun run) {
    320342      foreach (ListViewItem listViewItem in GetListViewItemsForItem(run)) {
    321343        if (run.Visible) {
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3601 r3614  
    8787    <Compile Include="Algorithm.cs" />
    8888    <Compile Include="BatchRun.cs" />
     89    <Compile Include="RunCollectionComparisonConstraint.cs" />
     90    <Compile Include="RunCollectionConstraintCollection.cs" />
     91    <Compile Include="RunCollectionTypeCompatiblityConstraint.cs" />
     92    <Compile Include="RunCollectionEqualityConstraint.cs" />
    8993    <Compile Include="Interfaces\ISingleObjectiveReplacer.cs" />
    9094    <Compile Include="Interfaces\IMigrator.cs" />
     
    97101    <Compile Include="Interfaces\IStrategyParameterCreator.cs" />
    98102    <Compile Include="Interfaces\IRun.cs" />
     103    <Compile Include="IRunCollectionConstraint.cs" />
    99104    <Compile Include="OptimizerList.cs" />
    100105    <Compile Include="Experiment.cs" />
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r3492 r3614  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.Collections;
    2930
    3031namespace HeuristicLab.Optimization {
     
    3839      parameterNames = new List<string>();
    3940      resultNames = new List<string>();
    40     }
    41 
    42     protected static Type[] viewableDataTypes = new Type[]{typeof(BoolValue), typeof(DoubleValue), typeof(IntValue),
    43       typeof(PercentValue), typeof(StringValue)};
     41      dataTypes = new Dictionary<string, HashSet<Type>>();
     42      constraints = new RunCollectionConstraintCollection();
     43      constraints.ItemsAdded += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsAdded);
     44      constraints.ItemsRemoved += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsRemoved);
     45      constraints.CollectionReset += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_CollectionReset);
     46    }
     47    private Dictionary<string, HashSet<Type>> dataTypes;
     48    public IEnumerable<Type> GetDataType(string columnName) {
     49      if (!dataTypes.ContainsKey(columnName))
     50        return new Type[0];
     51      return dataTypes[columnName];
     52    }
     53    private RunCollectionConstraintCollection constraints;
     54    public RunCollectionConstraintCollection Constraints {
     55      get { return constraints;}
     56    }
    4457
    4558    protected override void OnCollectionReset(IEnumerable<IRun> items, IEnumerable<IRun> oldItems) {
     
    90103        return false;
    91104      if (!parameterNames.Contains(name)) {
    92         // && viewableDataTypes.Any(x => x.IsAssignableFrom(value.GetType()))) {
    93105        parameterNames.Add(name);
    94         return true;
    95       }
     106        dataTypes[name] = new HashSet<Type>();
     107        dataTypes[name].Add(value.GetType());
     108        return true;
     109      }
     110      dataTypes[name].Add(value.GetType());
    96111      return false;
    97112    }
     
    100115        return false;
    101116      if (!resultNames.Contains(name)) {
    102         // && viewableDataTypes.Any(x => x.IsAssignableFrom(value.GetType()))) {
    103117        resultNames.Add(name);
    104         return true;
    105       }
     118        dataTypes[name] = new HashSet<Type>();
     119        dataTypes[name].Add(value.GetType());
     120        return true;
     121      }
     122      dataTypes[name].Add(value.GetType());
    106123      return false;
    107124    }
     
    221238    public bool SetValue(string value, int rowIndex, int columnIndex) { throw new NotSupportedException(); }
    222239    #endregion
     240
     241    #region filtering
     242    private void UpdateFiltering() {
     243      list.ForEach(r => r.Visible = true);
     244      foreach (IRunCollectionConstraint constraint in this.constraints)
     245        constraint.Check();
     246    }
     247
     248    protected virtual void RegisterConstraintEvents(IEnumerable<IRunCollectionConstraint> constraints) {
     249      foreach (IRunCollectionConstraint constraint in constraints) {
     250        constraint.ActiveChanged += new EventHandler(Constraint_ActiveChanged);
     251        constraint.ConstrainedValueChanged += new EventHandler(Constraint_ConstrainedValueChanged);
     252        constraint.ConstraintOperationChanged += new EventHandler(Constraint_ConstraintOperationChanged);
     253        constraint.ConstraintDataChanged += new EventHandler(Constraint_ConstraintDataChanged);
     254      }
     255    }
     256    protected virtual void DeregisterConstraintEvents(IEnumerable<IRunCollectionConstraint> constraints) {
     257      foreach (IRunCollectionConstraint constraint in constraints) {
     258        constraint.ActiveChanged -= new EventHandler(Constraint_ActiveChanged);
     259        constraint.ConstrainedValueChanged -= new EventHandler(Constraint_ConstrainedValueChanged);
     260        constraint.ConstraintOperationChanged -= new EventHandler(Constraint_ConstraintOperationChanged);
     261        constraint.ConstraintDataChanged -= new EventHandler(Constraint_ConstraintDataChanged);
     262      }
     263    }
     264
     265    protected virtual void Constraints_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     266      DeregisterConstraintEvents(e.OldItems);
     267      RegisterConstraintEvents(e.Items);
     268      this.UpdateFiltering();
     269    }
     270    protected virtual void Constraints_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     271      RegisterConstraintEvents(e.Items);
     272      foreach (IRunCollectionConstraint constraint in e.Items)
     273        constraint.ConstrainedValue = this;
     274      this.UpdateFiltering();
     275    }
     276    protected virtual void Constraints_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     277      DeregisterConstraintEvents(e.Items);
     278      this.UpdateFiltering();
     279    }
     280    protected virtual void Constraint_ActiveChanged(object sender, EventArgs e) {
     281      this.UpdateFiltering();
     282    }
     283    protected virtual void Constraint_ConstrainedValueChanged(object sender, EventArgs e) {
     284      //mkommend: this method is intentionally left empty, because the constrainedValue is set in the ItemsAdded method
     285    }
     286    protected virtual void Constraint_ConstraintOperationChanged(object sender, EventArgs e) {
     287      this.UpdateFiltering();
     288    }
     289    protected virtual void Constraint_ConstraintDataChanged(object sender, EventArgs e) {
     290      this.UpdateFiltering();
     291    }
     292    #endregion
    223293  }
    224294}
Note: See TracChangeset for help on using the changeset viewer.