Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3729 for trunk


Ignore:
Timestamp:
05/10/10 00:51:36 (15 years ago)
Author:
swagner
Message:

Fixed exception thrown in OperatorGraph views when removing one of the operator parameters of a MultiOperator (#1004)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs

    r3566 r3729  
    225225      else {
    226226        IValueParameter opParam = (IValueParameter)sender;
    227         foreach (TreeNode node in opParamNodeTable[opParam].ToArray())
    228           ClearTreeNode(node);
    229         foreach (TreeNode node in opParamNodeTable[opParam]) {
    230           node.Text = opParam.Name + ": ";
    231           FillTreeNode(node, (IOperator)opParam.Value);
     227        if (opParamNodeTable.ContainsKey(opParam)) {
     228          foreach (TreeNode node in opParamNodeTable[opParam].ToArray())
     229            ClearTreeNode(node);
     230          foreach (TreeNode node in opParamNodeTable[opParam]) {
     231            node.Text = opParam.Name + ": ";
     232            FillTreeNode(node, (IOperator)opParam.Value);
     233          }
    232234        }
    233235      }
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs

    r3407 r3729  
    142142
    143143      // remove edges to removed operator
    144       var opParams = from o in Operators
    145                      from p in o.Parameters
    146                      where p is IValueParameter
    147                      where typeof(IOperator).IsAssignableFrom(((IValueParameter)p).DataType)
    148                      where (((IValueParameter)p).Value != null) && (((IValueParameter)p).Value == op)
    149                      select (IValueParameter)p;
     144      IValueParameter[] opParams = (from o in Operators
     145                                    from p in o.Parameters
     146                                    where p is IValueParameter
     147                                    where typeof(IOperator).IsAssignableFrom(((IValueParameter)p).DataType)
     148                                    where (((IValueParameter)p).Value != null) && (((IValueParameter)p).Value == op)
     149                                    select (IValueParameter)p).ToArray();
    150150      foreach (IValueParameter opParam in opParams)
    151151        opParam.Value = null;
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs

    r3514 r3729  
    363363    private void opParam_ValueChanged(object sender, EventArgs e) {
    364364      IValueParameter opParam = (IValueParameter)sender;
    365       IOperator op = this.parameterOperatorMapping[opParam];
    366       IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op);
    367       KeyValuePair<IOperatorShapeInfo, string> connectionFrom = new KeyValuePair<IOperatorShapeInfo, string>(shapeInfoFrom, opParam.Name);
    368 
    369       this.connectionInfos.RemoveWhere(c => c.From == shapeInfoFrom && c.ConnectorFrom == opParam.Name);
    370       if (opParam.Value != null) {
    371         if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value))
    372           this.AddOperator((IOperator)opParam.Value);
    373         IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value);
    374         base.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector));
     365      if (this.parameterOperatorMapping.ContainsKey(opParam)) {
     366        IOperator op = this.parameterOperatorMapping[opParam];
     367        IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op);
     368        KeyValuePair<IOperatorShapeInfo, string> connectionFrom = new KeyValuePair<IOperatorShapeInfo, string>(shapeInfoFrom, opParam.Name);
     369
     370        this.connectionInfos.RemoveWhere(c => c.From == shapeInfoFrom && c.ConnectorFrom == opParam.Name);
     371        if (opParam.Value != null) {
     372          if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value))
     373            this.AddOperator((IOperator)opParam.Value);
     374          IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value);
     375          base.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector));
     376        }
    375377      }
    376378    }
  • trunk/sources/HeuristicLab.Operators/3.3/MultiOperator.cs

    r3591 r3729  
    8686      operatorParameters.Clear();
    8787      for (int i = 0; i < Operators.Count; i++) {
    88         IValueParameter<T> opParam = new ValueParameter<T>(i.ToString(), string.Empty, Operators[i]);
     88        IValueParameter<T> opParam = new OptionalValueParameter<T>(i.ToString(), string.Empty, Operators[i]);
    8989        opParam.ValueChanged += new EventHandler(opParam_ValueChanged);
    9090        Parameters.Add(opParam);
     
    127127    private void opParam_ValueChanged(object sender, EventArgs e) {
    128128      IValueParameter<T> opParam = (IValueParameter<T>)sender;
    129       operators[operatorParameters.IndexOf(opParam)] = opParam.Value;
     129      if (opParam.Value == null)
     130        operators.RemoveAt(operatorParameters.IndexOf(opParam));
     131      else
     132        operators[operatorParameters.IndexOf(opParam)] = opParam.Value;
    130133    }
    131134    #endregion
Note: See TracChangeset for help on using the changeset viewer.