All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.odell.glazedlists.swt.TableItemConfigurer Maven / Gradle / Ivy

The newest version!
/* Glazed Lists                                                 (c) 2003-2007 */
/* http://publicobject.com/glazedlists/                      publicobject.com,*/
/*                                                     O'Dell Engineering Ltd.*/

package ca.odell.glazedlists.swt;

import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.gui.TableFormat;

import org.eclipse.swt.widgets.TableItem;

/**
 * A TableItemConfigurer can be provided to an
 * {@link DefaultEventTableViewer} to customize the initial format and appearance of
 * column values, each represented by a {@link TableItem}.
 *
 * @see DefaultEventTableViewer#setTableItemConfigurer(TableItemConfigurer)
 *
 * @author hbrands
 */
public interface TableItemConfigurer {

    /**
     * Default configurer that converts the column value to a string and sets it
     * as the text of the TableItem.
     */
    public static final TableItemConfigurer DEFAULT = new DefaultTableItemConfigurer();

    /**
     * Callback method that allows the configuration of the TableItem properties
     * for the specified row and column.
     *
     * @param item the TableItem at index row
     * @param rowValue the list element from the source {@link EventList} at
     *        index row
     * @param columnValue the column value, e.g. the value returned by
     *        {@link TableFormat#getColumnValue(Object, int)}
     * @param row the row index
     * @param column the column index
     */
    void configure(TableItem item, E rowValue, Object columnValue, int row, int column);

    /**
     * Default configurer that converts the column value to a string and sets it
     * as the text of the TableItem.
     */
    class DefaultTableItemConfigurer implements TableItemConfigurer {

        /** {@inheritDoc} */
        public void configure(TableItem item, E rowValue, Object columnValue, int row, int column) {
            item.setText(column, columnValue == null ? "" : columnValue.toString());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy