Search in sources :

Example 6 with ICellPainter

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

the class ThemeConfiguration method configureTreeStyle.

/**
 * This method is used to register style configurations for a tree
 * representation. It will only be applied in case a TreeLayer is involved,
 * which adds the configuration label {@link TreeLayer#TREE_COLUMN_CELL} to
 * the tree column.
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureTreeStyle(IConfigRegistry configRegistry) {
    IStyle treeStyle = getTreeStyle();
    if (!isStyleEmpty(treeStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, treeStyle, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
    }
    ICellPainter cellPainter = getTreeCellPainter();
    if (cellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
    }
    IStyle treeSelectionStyle = getTreeSelectionStyle();
    if (!isStyleEmpty(treeSelectionStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, treeSelectionStyle, DisplayMode.SELECT, TreeLayer.TREE_COLUMN_CELL);
    }
    ICellPainter selectionCellPainter = getTreeSelectionCellPainter();
    if (selectionCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, selectionCellPainter, DisplayMode.SELECT, TreeLayer.TREE_COLUMN_CELL);
    }
    ICellPainter treePainter = getTreeStructurePainter();
    if (treePainter != null) {
        configRegistry.registerConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, treePainter, DisplayMode.NORMAL);
    }
    ICellPainter treeSelectionPainter = getTreeStructureSelectionPainter();
    if (treeSelectionPainter != null) {
        configRegistry.registerConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, treeSelectionPainter, DisplayMode.SELECT);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 7 with ICellPainter

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

the class ThemeConfiguration method configureSelectionAnchorStyle.

/**
 * Register the style configurations to render the selection anchor.
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureSelectionAnchorStyle(IConfigRegistry configRegistry) {
    // Selection anchor style for normal display mode
    IStyle anchorStyle = getSelectionAnchorStyle();
    if (!isStyleEmpty(anchorStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, anchorStyle, DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
    }
    ICellPainter anchorPainter = getSelectionAnchorCellPainter();
    if (anchorPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, anchorPainter, DisplayMode.NORMAL, SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
    }
    // Selection anchor style for select display mode
    IStyle selectionAnchorStyle = getSelectionAnchorSelectionStyle();
    if (!isStyleEmpty(selectionAnchorStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, selectionAnchorStyle, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
    }
    ICellPainter selectionAnchorPainter = getSelectionAnchorSelectionCellPainter();
    if (selectionAnchorPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, selectionAnchorPainter, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
    }
    // configure selection anchor grid line style
    IStyle gridLineStyle = getSelectionAnchorGridLineStyle();
    if (!isStyleEmpty(gridLineStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, gridLineStyle, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 8 with ICellPainter

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

the class ThemeConfiguration method configureDefaultSelectionStyle.

/**
 * Register default selection style configurations. Typically these
 * configurations are used be the body region and will be overridden by more
 * specific configurations of the header regions or custom styling based on
 * labels.
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureDefaultSelectionStyle(IConfigRegistry configRegistry) {
    // register body cell style for every display mode
    IStyle defaultSelectionStyle = getDefaultSelectionCellStyle();
    if (!isStyleEmpty(defaultSelectionStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, defaultSelectionStyle, DisplayMode.SELECT);
    }
    // register body cell painter for every display mode
    ICellPainter defaultSelectionCellPainter = getDefaultSelectionCellPainter();
    if (defaultSelectionCellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, defaultSelectionCellPainter, DisplayMode.SELECT);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 9 with ICellPainter

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

the class ThemeConfiguration method configureColumnHeaderSelectionStyle.

/**
 * Register the style configurations for rendering the selection in a column
 * header in a NatTable.
 * <p>
 * By default this means to register the style configurations against
 * {@link DisplayMode#SELECT} and config/region label
 * {@link GridRegion#COLUMN_HEADER}. The styling for rendering full column
 * selection is configured against the label
 * {@link SelectionStyleLabels#COLUMN_FULLY_SELECTED_STYLE}.
 * </p>
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureColumnHeaderSelectionStyle(IConfigRegistry configRegistry) {
    IStyle columnHeaderStyle = getColumnHeaderSelectionStyle();
    if (!isStyleEmpty(columnHeaderStyle)) {
        // register column header cell style in select mode
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, columnHeaderStyle, DisplayMode.SELECT, GridRegion.COLUMN_HEADER);
    }
    ICellPainter columnHeaderCellPainter = getColumnHeaderSelectionCellPainter();
    if (columnHeaderCellPainter != null) {
        // register column header cell painter in select mode
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, columnHeaderCellPainter, DisplayMode.SELECT, GridRegion.COLUMN_HEADER);
    }
    IStyle fullSelectionColumnHeaderStyle = getColumnHeaderFullSelectionStyle();
    if (!isStyleEmpty(fullSelectionColumnHeaderStyle)) {
        // register column header cell style in select mode when all cells
        // in the column are selected
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, fullSelectionColumnHeaderStyle, DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE);
    }
    ICellPainter fullSelectionColumnHeaderCellPainter = getColumnHeaderFullSelectionCellPainter();
    if (fullSelectionColumnHeaderCellPainter != null) {
        // register column header cell painter in select mode when all cells
        // in the column are selected
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, fullSelectionColumnHeaderCellPainter, DisplayMode.SELECT, SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) ICellPainter(org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)

Example 10 with ICellPainter

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

the class ThemeConfiguration method configureSortHeaderStyle.

/**
 * This method is used to register styles for the sort header layer. It will
 * register the {@link IStyle} and the {@link ICellPainter} for both sort
 * states which cause adding the following labels to the configuration label
 * stack of a cell:
 * <ul>
 * <li>DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE</li>
 * <li>DefaultSortConfiguration.SORT_UP_CONFIG_TYPE</li>
 * </ul>
 * Typically the {@link ICellPainter} itself takes care about the sort
 * state. If this needs to be handled differently, this method needs to be
 * overridden.
 *
 * @param configRegistry
 *            The IConfigRegistry that is used by the NatTable instance to
 *            which the style configuration should be applied to.
 */
protected void configureSortHeaderStyle(IConfigRegistry configRegistry) {
    IStyle sortStyle = getSortHeaderStyle();
    if (!isStyleEmpty(sortStyle)) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, sortStyle, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE);
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, sortStyle, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE);
    }
    ICellPainter cellPainter = getSortHeaderCellPainter();
    if (cellPainter != null) {
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE);
        configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, DefaultSortConfiguration.SORT_UP_CONFIG_TYPE);
    }
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) 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