public void apply(Process process, Map<String, String> nameTranslation) {
   String opName = null;
   if (nameTranslation != null) {
     opName = nameTranslation.get(this.operator);
   }
   if (opName == null) {
     opName = this.operator;
   }
   process
       .getLogger()
       .fine(
           "Setting parameter '"
               + parameterKey
               + "' of operator '"
               + opName
               + "' to '"
               + parameterValue
               + "'.");
   Operator operator = process.getOperator(opName);
   if (operator == null) {
     process.getLogger().warning("No such operator: '" + opName + "'.");
   } else {
     operator.getParameters().setParameter(parameterKey, parameterValue);
   }
 }
 @Override
 public void update(Observable<String> observable, String key) {
   PropertyValueCellEditor editor = getEditorForKey(key);
   if (editor != null) {
     ParameterType type = operator.getParameters().getParameterType(key);
     String editorValue = type.toString(editor.getCellEditorValue());
     String opValue = operator.getParameters().getParameterOrNull(key);
     if (((opValue != null) && (editorValue == null))
         || ((opValue == null) && (editorValue != null))
         || ((opValue != null) && (editorValue != null) && !opValue.equals(editorValue))) {
       editor.getTableCellEditorComponent(null, opValue, false, 0, 1);
     }
   } else {
     setupComponents();
   }
 }
  @Override
  protected List<ParameterType> getProperties() {
    List<ParameterType> visible = new LinkedList<ParameterType>();
    int hidden = 0;
    if (operator != null) {
      for (ParameterType type : operator.getParameters().getParameterTypes()) {
        if (type.isHidden()) {
          continue;
        }
        if (!isExpertMode() && type.isExpert()) {
          hidden++;
          continue;
        }
        visible.add(type);
      }
    }

    if (hidden > 0) {
      expertModeHintLabel.setText(hidden + " hidden expert parameter" + (hidden == 1 ? "" : "s"));
      expertModeHintLabel.setVisible(true);
    } else {
      expertModeHintLabel.setVisible(false);
    }
    return visible;
  }
  @Override
  protected String conditionedApply(
      Operator operator, String operatorTypeName, XMLImporter importer) {
    if (operator.getParameters().isSpecified(parameterName)) {
      try {
        String attributeName = operator.getParameterAsString(parameterName);

        ChangeAttributeRole setRoleOp = OperatorService.createOperator(ChangeAttributeRole.class);

        // inserting operator into process
        ExecutionUnit process = operator.getExecutionUnit();
        int operatorIndex = process.getOperators().indexOf(operator);
        process.addOperator(setRoleOp, operatorIndex + 1);

        // setting parameter
        setRoleOp.setParameter(ChangeAttributeRole.PARAMETER_NAME, attributeName);
        setRoleOp.setParameter(ChangeAttributeRole.PARAMETER_TARGET_ROLE, targetRole);
        return "Inserted operator for explicitly setting attribute <code>"
            + attributeName
            + "</code> to role <code>"
            + targetRole
            + "</code>";
      } catch (UndefinedParameterError e) {
        return null;
      } catch (OperatorCreationException e) {
        return null;
      }
    }
    return null;
  }
  private JComboBox createParameterCombo(String operatorName, PropertyTable propertyTable) {
    JComboBox combo = new JComboBox();

    Operator operator = process.getOperator((String) operatorCombo.getSelectedItem());
    if (operator != null) {
      Iterator<ParameterType> i = operator.getParameters().getParameterTypes().iterator();
      while (i.hasNext()) {
        combo.addItem(i.next().getKey());
      }
    }

    if (combo.getItemCount() == 0) combo.addItem("no parameters");

    combo.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            fireParameterChangedEvent();
            fireEditingStopped();
          }
        });

    combo.setSelectedIndex(0);

    return combo;
  }
 private static ParameterType getParameterType(Operator operator, String key) {
   Iterator i = operator.getParameters().getParameterTypes().iterator();
   while (i.hasNext()) {
     ParameterType type = (ParameterType) i.next();
     if (type.getKey().equals(key)) return type;
   }
   return null;
 }
  /**
   * Sets the process and the editable parameters.
   *
   * @param parameters A list of String[2] where the first String is the name of the operator and
   *     the second is the name of the parameter.
   */
  public boolean setProcess(Process process, Collection<OperatorParameterPair> parameters) {
    if (process == null) {
      parameters = new LinkedList<OperatorParameterPair>(); // enforce arraylengths = 0
    }
    updateTableData(parameters.size());

    operators = new Operator[parameters.size()];
    parameterTypes = new ParameterType[parameters.size()];

    Iterator<OperatorParameterPair> i = parameters.iterator();
    int j = 0;
    while (i.hasNext()) {
      OperatorParameterPair parameter = i.next();
      Operator operator = process.getOperator(parameter.getOperator());
      operators[j] = operator;
      ParameterType parameterType = getParameterType(operator, parameter.getParameter());
      if (operator == null || parameterType == null) {
        updateTableData(0); // enforce size of 0
        return false;
      }
      parameterTypes[j] = parameterType;
      getModel().setValueAt(operator.getName() + "." + parameterTypes[j].getKey(), j, 0);
      Object value = parameterTypes[j].getDefaultValue();
      try {
        value = operator.getParameters().getParameter(parameterTypes[j].getKey());
      } catch (UndefinedParameterError e) {
        // tries non default value. Fail --> default
      }
      getModel().setValueAt(value, j, 1);
      j++;
    }
    updateEditorsAndRenderers();

    getModel()
        .addTableModelListener(
            new TableModelListener() {
              public void tableChanged(TableModelEvent e) {
                setValue(e.getFirstRow(), getModel().getValueAt(e.getFirstRow(), 1));
              }
            });
    return true;
  }
 /** Parses a parameter list and creates the corresponding data structures. */
 public List<ParameterValues> parseParameterValues(List<String[]> parameterList)
     throws OperatorException {
   if (getProcess() == null) {
     getLogger().warning("Cannot parse parameters while operator is not attached to a process.");
     return Collections.<ParameterValues>emptyList();
   }
   List<ParameterValues> parameterValuesList = new LinkedList<ParameterValues>();
   for (String[] pair : parameterList) {
     String[] operatorParameter = ParameterTypeTupel.transformString2Tupel(pair[0]);
     if (operatorParameter.length != 2) throw new UserError(this, 907, pair[0]);
     Operator operator = lookupOperator(operatorParameter[0]);
     if (operator == null) throw new UserError(this, 109, operatorParameter[0]);
     ParameterType parameterType = operator.getParameters().getParameterType(operatorParameter[1]);
     if (parameterType == null) {
       throw new UserError(this, 906, operatorParameter[0] + "." + operatorParameter[1]);
     }
     String parameterValuesString = pair[1];
     ParameterValues parameterValues = null;
     try {
       int startIndex = parameterValuesString.indexOf("[");
       if (startIndex >= 0) {
         int endIndex = parameterValuesString.indexOf("]");
         if (endIndex > startIndex) {
           String[] parameterValuesArray =
               parameterValuesString.substring(startIndex + 1, endIndex).trim().split("[;:,]");
           switch (parameterValuesArray.length) {
             case PARAMETER_VALUES_ARRAY_LENGTH_RANGE:
               { // value range: [minValue;maxValue]
                 //							double min = Double.parseDouble(parameterValuesArray[0]);
                 //							double max = Double.parseDouble(parameterValuesArray[1]);
                 parameterValues =
                     new ParameterValueRange(
                         operator,
                         parameterType,
                         parameterValuesArray[0],
                         parameterValuesArray[1]);
               }
               break;
             case PARAMETER_VALUES_ARRAY_LENGTH_GRID:
               { // value grid: [minValue;maxValue;stepSize]
                 //							double min = Double.parseDouble(parameterValuesArray[0]);
                 //							double max = Double.parseDouble(parameterValuesArray[1]);
                 //							double stepSize = Double.parseDouble(parameterValuesArray[2]);
                 //							if (stepSize == 0) {
                 //								throw new Exception("step size of 0 is not allowed");
                 //							}
                 //							if (min <= max + stepSize) {
                 //								throw new Exception("end value must at least be as large as start value
                 // plus step size");
                 //							}
                 parameterValues =
                     new ParameterValueGrid(
                         operator,
                         parameterType,
                         parameterValuesArray[0],
                         parameterValuesArray[1],
                         parameterValuesArray[2]);
               }
               break;
             case PARAMETER_VALUES_ARRAY_LENGTH_SCALED_GRID:
               { // value grid: [minValue;maxValue;noOfSteps;scale]
                 //							double min = Double.parseDouble(parameterValuesArray[0]);
                 //							double max = Double.parseDouble(parameterValuesArray[1]);
                 //							int steps = Integer.parseInt(parameterValuesArray[2]);
                 //							if (steps == 0) {
                 //								throw new Exception("step size of 0 is not allowed");
                 //							}
                 //							String scaleName = parameterValuesArray[3];
                 parameterValues =
                     new ParameterValueGrid(
                         operator,
                         parameterType,
                         parameterValuesArray[0],
                         parameterValuesArray[1],
                         parameterValuesArray[2],
                         parameterValuesArray[3]);
               }
               break;
             default:
               throw new Exception(
                   "parameter values string could not be parsed (too many arguments)");
           }
         } else {
           throw new Exception("']' was missing");
         }
       } else {
         int colonIndex = parameterValuesString.indexOf(":");
         if (colonIndex >= 0) {
           // maintain compatibility for evolutionary parameter optimization (old format:
           // startValue:endValue without parantheses)
           String[] parameterValuesArray = parameterValuesString.trim().split(":");
           if (parameterValuesArray.length != 2) {
             throw new Exception("wrong parameter range format");
           } else {
             //							double min = Double.parseDouble(parameterValuesArray[0]);
             //							double max = Double.parseDouble(parameterValuesArray[1]);
             parameterValues =
                 new ParameterValueRange(
                     operator, parameterType, parameterValuesArray[0], parameterValuesArray[1]);
           }
         } else {
           // usual parameter value list: value1,value2,value3,...
           if (parameterValuesString.length() != 0) {
             String[] values = parameterValuesString.split(",");
             parameterValues = new ParameterValueList(operator, parameterType, values);
           }
         }
       }
     } catch (Throwable e) {
       throw new UserError(
           this,
           116,
           pair[0],
           "Unknown parameter value specification format: '"
               + pair[1]
               + "'. Error: "
               + e.getMessage());
     }
     if (parameterValues != null) {
       parameterValuesList.add(parameterValues);
     }
   }
   return parameterValuesList;
 }
 @Override
 protected String getValue(ParameterType type) {
   return operator.getParameters().getParameterOrNull(type.getKey());
 }