コード例 #1
0
 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);
   }
 }
コード例 #2
0
  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;
  }
コード例 #3
0
  /**
   * 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;
  }