Search in sources :

Example 1 with NamedAggregationOperator

use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.

the class NamedAggregationMethodNameTableCellEditor method getTableCellEditorComponent.

/**
 * {@inheritDoc}
 */
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
    final String val;
    if (value instanceof NamedAggregationOperator) {
        final NamedAggregationOperator method = (NamedAggregationOperator) value;
        val = method.getName();
    } else {
        val = value.toString();
    }
    return super.getTableCellEditorComponent(table, val, isSelected, row, column);
}
Also used : NamedAggregationOperator(org.knime.base.data.aggregation.NamedAggregationOperator)

Example 2 with NamedAggregationOperator

use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.

the class ColumnAggregationTableModel method revertOperatorNames.

/**
 * @param indices of the rows to change
 */
protected void revertOperatorNames(final int[] indices) {
    int firstRow = Integer.MAX_VALUE;
    int lastRow = -1;
    for (final int row : indices) {
        final NamedAggregationOperator operator = getRow(row);
        final String origName = operator.getColumnLabel();
        if (!origName.equals(operator.getName())) {
            if (row < firstRow) {
                firstRow = row;
            }
            if (row > lastRow) {
                lastRow = row;
            }
            // change the operator name only if we have to
            final String uniqueName = getUniqueName(origName);
            operator.setName(uniqueName);
        }
    }
    if (lastRow > -1 && firstRow < getRowCount()) {
        fireTableRowsUpdated(firstRow, lastRow);
    }
}
Also used : NamedAggregationOperator(org.knime.base.data.aggregation.NamedAggregationOperator)

Example 3 with NamedAggregationOperator

use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.

the class ColumnAggregationTableModel method updateOperatorName.

/**
 * @param row row index to change the name for
 * @param name the new name
 */
private void updateOperatorName(final int row, final String name) {
    final NamedAggregationOperator operator = getRow(row);
    if (operator.getName().equals(name)) {
        // the name hasn't changed
        return;
    }
    final String uniqueName = getUniqueName(name);
    operator.setName(uniqueName);
    fireTableCellUpdated(row, 0);
}
Also used : NamedAggregationOperator(org.knime.base.data.aggregation.NamedAggregationOperator)

Example 4 with NamedAggregationOperator

use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.

the class ColumnAggregationTableModel method getOperatorNames.

/**
 * @return {@link Set} with all method names
 */
private Set<String> getOperatorNames() {
    final List<NamedAggregationOperator> operators = getRows();
    final Set<String> methodNames = new HashSet<>(operators.size());
    for (final NamedAggregationOperator op : operators) {
        methodNames.add(op.getName());
    }
    return methodNames;
}
Also used : NamedAggregationOperator(org.knime.base.data.aggregation.NamedAggregationOperator) HashSet(java.util.HashSet)

Example 5 with NamedAggregationOperator

use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.

the class ColumnAggregationTableModel method add.

/**
 * {@inheritDoc}
 */
@Override
public void add(final List<NamedAggregationOperator> operators) {
    final Set<String> names = getOperatorNames();
    final List<NamedAggregationOperator> uniqueOperators = new ArrayList<>(operators.size());
    for (final NamedAggregationOperator op : operators) {
        // check if the name of the operator is already used and
        // make it unique
        final String name = op.getName();
        final String uniqueName = getUniqueName(name, names);
        if (!name.equals(uniqueName)) {
            // update the operator name if it is not unique
            op.setName(uniqueName);
        }
        names.add(op.getName());
        uniqueOperators.add(op);
    }
    // add the operators also to the super class after making them unique
    super.add(uniqueOperators);
}
Also used : NamedAggregationOperator(org.knime.base.data.aggregation.NamedAggregationOperator) ArrayList(java.util.ArrayList)

Aggregations

NamedAggregationOperator (org.knime.base.data.aggregation.NamedAggregationOperator)7 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)1 SettingsModelInteger (org.knime.core.node.defaultnodesettings.SettingsModelInteger)1 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)1