use of org.knime.base.data.aggregation.AggregationMethodDecorator in project knime-core by knime.
the class AggregationMethodDecoratorTableCellRenderer method getTableCellRendererComponent.
/**
* {@inheritDoc}
*/
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
assert (c == this);
if (value instanceof AggregationMethodDecorator) {
final AggregationMethodDecorator method = (AggregationMethodDecorator) value;
m_renderer.renderComponent(this, method);
if (m_checkValidFlag && !method.isValid()) {
// set a red border for invalid methods
setBorder(BorderFactory.createLineBorder(Color.RED));
} else {
setBorder(null);
}
}
return this;
}
use of org.knime.base.data.aggregation.AggregationMethodDecorator in project knime-core by knime.
the class AggregationColumnPanel method adaptTableColumnModel.
/**
* {@inheritDoc}
*/
@Override
protected void adaptTableColumnModel(final TableColumnModel columnModel) {
columnModel.getColumn(0).setCellRenderer(new AggregationMethodDecoratorTableCellRenderer(new ValueRenderer() {
@Override
public void renderComponent(final DefaultTableCellRenderer c, final AggregationMethodDecorator method) {
if (method instanceof ColumnAggregator) {
final ColumnAggregator aggregator = (ColumnAggregator) method;
final DataColumnSpec spec = aggregator.getOriginalColSpec();
c.setText(spec.getName());
c.setIcon(spec.getType().getIcon());
}
}
}, true, "Double click to remove column. Right mouse click for context menu."));
columnModel.getColumn(1).setCellEditor(new ColumnAggregatorTableCellEditor());
columnModel.getColumn(1).setCellRenderer(new AggregationMethodDecoratorTableCellRenderer(new ValueRenderer() {
@Override
public void renderComponent(final DefaultTableCellRenderer c, final AggregationMethodDecorator method) {
c.setText(method.getLabel());
}
}, false));
columnModel.getColumn(0).setPreferredWidth(170);
columnModel.getColumn(1).setPreferredWidth(150);
}
Aggregations