Search in sources :

Example 16 with AggregationMethod

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

the class AggregationColumnTableModel method setValue.

/**
 * {@inheritDoc}
 */
@Override
public void setValue(final Object aValue, final int row, final int columnIdx) {
    if (aValue == null) {
        return;
    }
    if (aValue instanceof AggregationMethod) {
        assert columnIdx == 1;
        final AggregationMethod newMethod = (AggregationMethod) aValue;
        updateMethod(row, newMethod);
    }
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod)

Example 17 with AggregationMethod

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

the class AggregationColumnTableModel method updateMethod.

/**
 * @param row the row to update
 * @param method the {@link AggregationMethod} to use
 */
private void updateMethod(final int row, final AggregationMethod method) {
    final ColumnAggregator old = getRow(row);
    if (old.getMethodTemplate().getId().equals(method.getId())) {
        // check if the method has changed
        return;
    }
    // create a new operator each time it is updated to guarantee that
    // each column has its own operator instance
    AggregationMethod methodClone = AggregationMethods.getMethod4Id(method.getId());
    final ColumnAggregator newRow = new ColumnAggregator(old.getOriginalColSpec(), methodClone, old.inclMissingCells());
    newRow.setValid(old.isValid());
    updateRow(row, newRow);
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator)

Example 18 with AggregationMethod

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

the class PatternAggregator method loadAggregators.

/**
 * Creates a {@link List} with all {@link PatternAggregator}s that were
 * stored in the settings.
 *
 * @param settings the settings object to read from
 * @param key the unique settings key
 * @param spec {@link DataTableSpec} of the input table if available
 * @return {@link List} with the {@link PatternAggregator}s
 * @throws InvalidSettingsException if the settings are invalid
 */
public static List<PatternAggregator> loadAggregators(final NodeSettingsRO settings, final String key, final DataTableSpec spec) throws InvalidSettingsException {
    if (settings == null) {
        throw new IllegalArgumentException("settings must not be null");
    }
    if (key == null || key.isEmpty()) {
        throw new IllegalArgumentException("key must not be empty");
    }
    if (!settings.containsKey(key)) {
        return Collections.EMPTY_LIST;
    }
    final NodeSettingsRO root = settings.getNodeSettings(key);
    final Set<String> settingsKeys = root.keySet();
    final List<PatternAggregator> aggrList = new ArrayList<>(settingsKeys.size());
    for (String settingsKey : settingsKeys) {
        final NodeSettingsRO cfg = root.getNodeSettings(settingsKey);
        final String inputPattern = cfg.getString(CNFG_INPUT_PATTERN);
        final boolean isRegex = cfg.getBoolean(CNFG_IS_REGEX);
        final boolean inclMissing = cfg.getBoolean(CNFG_INCL_MISSING_VALS);
        final AggregationMethod method = AggregationMethodDecorator.loadMethod(spec, cfg);
        aggrList.add(new PatternAggregator(inputPattern, isRegex, method, inclMissing));
    }
    return aggrList;
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) ArrayList(java.util.ArrayList) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 19 with AggregationMethod

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

the class DataTypeAggregationTableModel method updateMethod.

/**
 * @param row the row to update
 * @param method the {@link AggregationMethod} to use
 */
private void updateMethod(final int row, final AggregationMethod method) {
    final DataTypeAggregator old = getRow(row);
    if (old.getMethodTemplate().getId().equals(method.getId())) {
        // check if the method has changed
        return;
    }
    // create a new operator each time it is updated to guarantee that
    // each column has its own operator instance
    final AggregationMethod methodClone = AggregationMethods.getMethod4Id(method.getId());
    final DataTypeAggregator newRow = new DataTypeAggregator(old.getDataType(), methodClone, old.inclMissingCells());
    newRow.setValid(old.isValid());
    updateRow(row, newRow);
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod)

Example 20 with AggregationMethod

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

the class AbstractAggregationMethodTableCellEditor method getTableCellEditorComponent.

/**
 * {@inheritDoc}
 */
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
    final DataType type = getDataType(table, value, isSelected, row, column);
    final AggregationMethod selectedMethod = getSelectedAggregationMethod(table, value, isSelected, row, column);
    final List<AggregationMethod> compatibleMethods = getCompatibleMethods(type);
    if (type != null) {
        getBox().update(type, compatibleMethods, selectedMethod);
    }
    return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) DataType(org.knime.core.data.DataType)

Aggregations

AggregationMethod (org.knime.base.data.aggregation.AggregationMethod)27 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)8 ArrayList (java.util.ArrayList)6 Entry (java.util.Map.Entry)4 DataType (org.knime.core.data.DataType)4 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 Component (java.awt.Component)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 List (java.util.List)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)2 Container (java.awt.Container)1 Frame (java.awt.Frame)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 JTable (javax.swing.JTable)1 AggregationOperator (org.knime.base.data.aggregation.AggregationOperator)1