Changeset 8648


Ignore:
Timestamp:
09/14/12 10:01:48 (8 years ago)
Author:
jkarder
Message:

#1853: fixed loss of valid values caused by setting optimize to true

Location:
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/OptimizableView.cs

    r8535 r8648  
    5858        Invoke(new EventHandler(Content_OptimizeChanged), sender, e);
    5959      } else {
    60         this.optimizeCheckBox.Checked = Content.Optimize;
     60        optimizeCheckBox.Checked = Content.Optimize;
    6161        if (Content.Optimize) {
    62           this.viewHost.ViewType = null;
     62          viewHost.ViewType = null;
    6363
    6464          var pc = Content as IParameterConfiguration;
     
    6767          if (pc != null) {
    6868            if (pc is SingleValuedParameterConfiguration) {
    69               this.viewHost.Content = ((ParameterizedValueConfiguration)pc.ValueConfigurations.Single()).ParameterConfigurations;
     69              viewHost.Content = ((ParameterizedValueConfiguration)pc.ValueConfigurations.Single()).ParameterConfigurations;
    7070            } else {
    71               this.viewHost.Content = pc.ValueConfigurations;
     71              viewHost.Content = pc.ValueConfigurations;
    7272            }
    7373          } else if (vc != null) {
     
    7777                Content.ActualValue.ValueDataType == typeof(DoubleValue) ||
    7878                Content.ActualValue.ValueDataType == typeof(PercentValue)) {
    79                 this.viewHost.ViewsLabelVisible = true;
    80                 this.viewHost.Content = rvc.RangeConstraint;
     79                viewHost.ViewsLabelVisible = true;
     80                viewHost.Content = rvc.RangeConstraint;
    8181              } else if (Content.ActualValue.ValueDataType == typeof(BoolValue)) {
    82                 this.viewHost.Content = null; // no configuration required
     82                viewHost.Content = null; // no configuration required
    8383              }
    8484            }
     
    8686            var pvc = Content as ParameterizedValueConfiguration;
    8787            if (pvc != null) {
    88               this.viewHost.ViewsLabelVisible = false;
    89               this.viewHost.Content = pvc.ParameterConfigurations;
     88              viewHost.ViewsLabelVisible = false;
     89              viewHost.Content = pvc.ParameterConfigurations;
    9090            }
    9191          } else {
     
    9393          }
    9494        } else {
    95           this.viewHost.ViewsLabelVisible = false;
     95          viewHost.ViewsLabelVisible = false;
    9696          if (Content.ValuesReadOnly) {
    97             this.viewHost.Content = new MessageItem("Cannot modify value directly. Please modify the value in the list of problems.");
     97            viewHost.Content = new MessageItem("Cannot modify value directly. Please modify the value in the list of problems.");
    9898          } else {
    99             this.viewHost.Content = Content.ActualValue;
     99            // the content's valid values get lost after optimize is set to true because the constrained value
     100            // does not contain the earlier valid values; therefore, the same constrained value with the correct
     101            // set of valid values is created before the assignment below
     102            var configuration = viewHost.Content as CheckedValueConfigurationList;
     103            if (configuration != null) {
     104              Content.ActualValue = new ConstrainedValue(Content.ActualValue.Value,
     105                Content.ActualValue.ValueDataType,
     106                configuration.ValidValues,
     107                Content.ActualValue.IsNullable);
     108            }
     109            viewHost.Content = Content.ActualValue;
    100110          }
    101111        }
     
    117127        Content_OptimizeChanged(this, EventArgs.Empty);
    118128      } else {
    119         this.viewHost.Content = null;
     129        viewHost.Content = null;
    120130      }
    121131    }
     
    124134      base.SetEnabledStateOfControls();
    125135      if (Content != null) {
    126         this.optimizeCheckBox.Enabled = !this.ReadOnly && Content.IsOptimizable;
     136        optimizeCheckBox.Enabled = !ReadOnly && Content.IsOptimizable;
    127137      }
    128138    }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ValueConfigurationViews/ValueView.cs

    r8544 r8648  
    6565
    6666    private void setValueButton_Click(object sender, EventArgs e) {
    67       // TODO: valid values get lost if the value was set to be optimized before
    6867      var withoutNullValue = Content.ValidValues.Where(x => x != null && !(x is NullValue));
    6968      var typeSelectorDialog = new TypeSelectorDialog();
Note: See TracChangeset for help on using the changeset viewer.