Search in sources :

Example 11 with ICellPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.

the class ThemeConfiguration method configureHoverStyle.

/**
 * Register the style configurations for hovering.
 * <p>
 * This means to register the style configurations against
 * {@link DisplayMode#HOVER}. Additionally the GridRegion labels are used to
 * register hover styles per region.
 * </p>
 * <p>
 * Note: This configuration is only working if the {@link HoverLayer} is
 * part of the layer stack. Otherwise the configuration will not have any
 * effect.
 * </p>
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureHoverStyle(IConfigRegistry configRegistry) {
    IStyle defaultHoverStyle = getDefaultHoverStyle();
    if (!isStyleEmpty(defaultHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, defaultHoverStyle, DisplayMode.HOVER);
    }
    ICellPainter defaultHoverCellPainter = getDefaultHoverCellPainter();
    if (defaultHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, defaultHoverCellPainter, DisplayMode.HOVER);
    }
    IStyle bodyHoverStyle = getBodyHoverStyle();
    if (!isStyleEmpty(bodyHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, bodyHoverStyle, DisplayMode.HOVER, GridRegion.BODY);
    }
    ICellPainter bodyHoverCellPainter = getBodyHoverCellPainter();
    if (bodyHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, bodyHoverCellPainter, DisplayMode.HOVER, GridRegion.BODY);
    }
    IStyle columnHeaderHoverStyle = getColumnHeaderHoverStyle();
    if (!isStyleEmpty(columnHeaderHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, columnHeaderHoverStyle, DisplayMode.HOVER, GridRegion.COLUMN_HEADER);
    }
    ICellPainter columnHeaderHoverCellPainter = getColumnHeaderHoverCellPainter();
    if (columnHeaderHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, columnHeaderHoverCellPainter, DisplayMode.HOVER, GridRegion.COLUMN_HEADER);
    }
    IStyle rowHeaderHoverStyle = getRowHeaderHoverStyle();
    if (!isStyleEmpty(rowHeaderHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, rowHeaderHoverStyle, DisplayMode.HOVER, GridRegion.ROW_HEADER);
    }
    ICellPainter rowHeaderHoverCellPainter = getRowHeaderHoverCellPainter();
    if (rowHeaderHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, rowHeaderHoverCellPainter, DisplayMode.HOVER, GridRegion.ROW_HEADER);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 12 with ICellPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.

the class ThemeConfiguration method configureColumnHeaderStyle.

/**
 * Register the style configurations for rendering the column header in a
 * NatTable.
 * <p>
 * By default this means to register the style configurations against
 * {@link DisplayMode#NORMAL} and config/region label
 * {@link GridRegion#COLUMN_HEADER}.
 * </p>
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureColumnHeaderStyle(IConfigRegistry configRegistry) {
    IStyle columnHeaderStyle = getColumnHeaderStyle();
    if (!isStyleEmpty(columnHeaderStyle)) {
        // register column header cell style in normal mode
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, columnHeaderStyle, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
    }
    ICellPainter columnHeaderCellPainter = getColumnHeaderCellPainter();
    if (columnHeaderCellPainter != null) {
        // register column header cell painter in normal mode
        // will also be used in other modes if no other cell painter is
        // registered explicitly
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, columnHeaderCellPainter, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 13 with ICellPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.

the class ThemeConfiguration method configureCornerSelectionStyle.

/**
 * Register the style configurations for rendering the selection in the
 * corner of a NatTable.
 * <p>
 * By default this means to register the style configurations against
 * {@link DisplayMode#SELECT} and config/region label
 * {@link GridRegion#CORNER}.
 * </p>
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureCornerSelectionStyle(IConfigRegistry configRegistry) {
    IStyle cornerStyle = this.styleCornerLikeColumnHeader ? getColumnHeaderSelectionStyle() : getCornerSelectionStyle();
    if (!isStyleEmpty(cornerStyle)) {
        // register corner cell style in select mode
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cornerStyle, DisplayMode.SELECT, GridRegion.CORNER);
    }
    ICellPainter cornerCellPainter = this.styleCornerLikeColumnHeader ? getColumnHeaderSelectionCellPainter() : getCornerSelectionCellPainter();
    if (cornerCellPainter != null) {
        // register corner cell painter in select mode
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cornerCellPainter, DisplayMode.SELECT, GridRegion.CORNER);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 14 with ICellPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.

the class ThemeConfiguration method configureHoverSelectionStyle.

/**
 * Register the style configurations for hovering selections.
 * <p>
 * This means to register the style configurations against
 * {@link DisplayMode#SELECT_HOVER}. Additionally the GridRegion labels are
 * used to register hover styles per region.
 * </p>
 * <p>
 * Note: This configuration is only working if the {@link HoverLayer} is
 * part of the layer stack. Otherwise the configuration will not have any
 * effect.
 * </p>
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureHoverSelectionStyle(IConfigRegistry configRegistry) {
    IStyle defaultHoverStyle = getDefaultHoverSelectionStyle();
    if (!isStyleEmpty(defaultHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, defaultHoverStyle, DisplayMode.SELECT_HOVER);
    }
    ICellPainter defaultHoverCellPainter = getDefaultHoverSelectionCellPainter();
    if (defaultHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, defaultHoverCellPainter, DisplayMode.SELECT_HOVER);
    }
    IStyle bodyHoverStyle = getBodyHoverSelectionStyle();
    if (!isStyleEmpty(bodyHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, bodyHoverStyle, DisplayMode.SELECT_HOVER, GridRegion.BODY);
    }
    ICellPainter bodyHoverCellPainter = getBodyHoverSelectionCellPainter();
    if (bodyHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, bodyHoverCellPainter, DisplayMode.SELECT_HOVER, GridRegion.BODY);
    }
    IStyle columnHeaderHoverStyle = getColumnHeaderHoverSelectionStyle();
    if (!isStyleEmpty(columnHeaderHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, columnHeaderHoverStyle, DisplayMode.SELECT_HOVER, GridRegion.COLUMN_HEADER);
    }
    ICellPainter columnHeaderHoverCellPainter = getColumnHeaderHoverSelectionCellPainter();
    if (columnHeaderHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, columnHeaderHoverCellPainter, DisplayMode.SELECT_HOVER, GridRegion.COLUMN_HEADER);
    }
    IStyle rowHeaderHoverStyle = getRowHeaderHoverSelectionStyle();
    if (!isStyleEmpty(rowHeaderHoverStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, rowHeaderHoverStyle, DisplayMode.SELECT_HOVER, GridRegion.ROW_HEADER);
    }
    ICellPainter rowHeaderHoverCellPainter = getRowHeaderHoverSelectionCellPainter();
    if (rowHeaderHoverCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, rowHeaderHoverCellPainter, DisplayMode.SELECT_HOVER, GridRegion.ROW_HEADER);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 15 with ICellPainter

use of org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter in project nebula.widgets.nattable by eclipse.

the class TreeLayer method getCellPainter.

@Override
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) {
    ICellPainter cellPainter = super.getCellPainter(columnPosition, rowPosition, cell, configRegistry);
    if (cell.getConfigLabels().hasLabel(TREE_COLUMN_CELL)) {
        ICellPainter treeCellPainter = configRegistry.getConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, cell.getDisplayMode(), cell.getConfigLabels().getLabels());
        if (treeCellPainter != null) {
            IndentedTreeImagePainter treePainter = findIndentedTreeImagePainter(treeCellPainter);
            if (treePainter != null) {
                treePainter.setBaseCellPainter(cellPainter);
                cellPainter = treeCellPainter;
            } else {
                // log error
                LOG.warn(// $NON-NLS-1$
                "There is no IndentedTreeImagePainter found for TREE_STRUCTURE_PAINTER, " + // $NON-NLS-1$
                "using local configured IndentedTreeImagePainter as fallback");
                // fallback
                this.indentedTreeImagePainter.setBaseCellPainter(cellPainter);
                cellPainter = new BackgroundPainter(this.indentedTreeImagePainter);
            }
        } else {
            // backwards compatibility fallback
            this.indentedTreeImagePainter.setBaseCellPainter(cellPainter);
            cellPainter = new BackgroundPainter(this.indentedTreeImagePainter);
        }
    }
    return cellPainter;
}
Also used : BackgroundPainter(org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter) IndentedTreeImagePainter(org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Aggregations

ICellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)50 IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)24 TextPainter (org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)11 Image (org.eclipse.swt.graphics.Image)10 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)9 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)9 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)9 BackgroundImagePainter (org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundImagePainter)8 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)6 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)6 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)6 Rectangle (org.eclipse.swt.graphics.Rectangle)6 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)5 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)5 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)5 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)5 SortableHeaderTextPainter (org.eclipse.nebula.widgets.nattable.sort.painter.SortableHeaderTextPainter)5 HashMap (java.util.HashMap)4 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)4 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)4