Search in sources :

Example 1 with ValueRenderer

use of org.knime.base.data.aggregation.dialogutil.AggregationMethodDecoratorTableCellRenderer.ValueRenderer 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);
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) AggregationMethodDecorator(org.knime.base.data.aggregation.AggregationMethodDecorator) ColumnAggregatorTableCellEditor(org.knime.base.data.aggregation.dialogutil.column.ColumnAggregatorTableCellEditor) ValueRenderer(org.knime.base.data.aggregation.dialogutil.AggregationMethodDecoratorTableCellRenderer.ValueRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Aggregations

DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1 AggregationMethodDecorator (org.knime.base.data.aggregation.AggregationMethodDecorator)1 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)1 ValueRenderer (org.knime.base.data.aggregation.dialogutil.AggregationMethodDecoratorTableCellRenderer.ValueRenderer)1 ColumnAggregatorTableCellEditor (org.knime.base.data.aggregation.dialogutil.column.ColumnAggregatorTableCellEditor)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1