use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class PatternAggregationTableModel method updateRegex.
private void updateRegex(final int row, final String pattern, final boolean isRegex, final PatternAggregator old) {
// create a new operator each time it is updated to guarantee that
// each column has its own operator instance
final AggregationMethod methodClone = AggregationMethods.getMethod4Id(old.getMethodTemplate().getId());
final PatternAggregator regexAggregator = new PatternAggregator(pattern, isRegex, methodClone, old.inclMissingCells());
if (!regexAggregator.isValid()) {
try {
Pattern.compile(pattern);
} catch (PatternSyntaxException e) {
final Component root = SwingUtilities.getRoot(m_panel);
JOptionPane.showMessageDialog(root, "<html><body><p>Invalid regular expression:</p><p>" + pattern + "</p><p>" + e.getDescription() + " at position " + e.getIndex() + "</p>", "Invalid regular expression", JOptionPane.ERROR_MESSAGE);
}
}
updateRow(row, regexAggregator);
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class AggregationColumnPanel method createAggregationSection.
/**
* Adds the aggregation method section to the given menu.
* This section allows the user to set an aggregation method for
* all selected columns.
* @param menu the menu to append the aggregation section
*/
private void createAggregationSection(final JPopupMenu menu) {
if (getSelectedRows().length <= 0) {
final JMenuItem noneSelected = new JMenuItem("Select a column to change method");
noneSelected.setEnabled(false);
menu.add(noneSelected);
return;
}
final List<Entry<String, List<AggregationMethod>>> methodList = getMethods4SelectedItems();
if (methodList.size() == 1) {
// we need no sub menu for a single group
for (final AggregationMethod method : methodList.get(0).getValue()) {
final JMenuItem methodItem = new JMenuItem(method.getLabel());
methodItem.setToolTipText(method.getDescription());
methodItem.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
changeAggregationMethod(method.getId());
}
});
menu.add(methodItem);
}
} else {
for (final Entry<String, List<AggregationMethod>> entry : methodList) {
final String type = entry.getKey();
final List<AggregationMethod> methods = entry.getValue();
final JMenu menuItem = new JMenu(type + " Methods");
final JMenuItem subMenu = menu.add(menuItem);
for (final AggregationMethod method : methods) {
final JMenuItem methodItem = new JMenuItem(method.getLabel());
methodItem.setToolTipText(method.getDescription());
methodItem.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
changeAggregationMethod(method.getId());
}
});
subMenu.add(methodItem);
}
}
}
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class DataTypeAggregationTableModel method setValue.
/**
* {@inheritDoc}
*/
@Override
protected 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);
}
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class SettingsModelAggregationMethod method createClone.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
protected SettingsModelAggregationMethod createClone() {
AggregationOperator operator = (AggregationOperator) m_method;
final AggregationMethod clone;
if (!operator.hasOptionalSettings()) {
clone = operator;
} else {
clone = operator.createInstance(operator.getGlobalSettings(), operator.getOperatorColumnSettings());
}
return new SettingsModelAggregationMethod(m_configName, m_inputPortIndex, m_valueDelimiter, m_maxUniqueValues, clone);
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class AggregationColumnTableModel method addColumn.
/**
* @param specs the {@link DataColumnSpec}s of the columns to add
* @see #add(List)
*/
@Deprecated
protected void addColumn(final DataColumnSpec... specs) {
if (specs == null || specs.length < 1) {
return;
}
final List<ColumnAggregator> aggregators = new ArrayList<>(specs.length);
for (final DataColumnSpec spec : specs) {
final AggregationMethod defaultMethod = AggregationMethods.getDefaultMethod(spec);
aggregators.add(new ColumnAggregator(spec, defaultMethod));
}
add(aggregators);
}
Aggregations