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);
}
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);
}
}
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);
}
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;
}
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);
}
Aggregations