Search in sources :

Example 66 with IStyle

use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.

the class LineBorderDecorator method getBorderStyle.

private BorderStyle getBorderStyle(ILayerCell cell, IConfigRegistry configRegistry) {
    IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
    BorderStyle borderStyle = cellStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE);
    if (borderStyle == null) {
        borderStyle = this.defaultBorderStyle;
    }
    return borderStyle;
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle)

Example 67 with IStyle

use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.

the class PaddingDecorator method getCellPainterAt.

@Override
public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, GC gc, Rectangle adjustedCellBounds, IConfigRegistry configRegistry) {
    // need to take the alignment into account
    IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
    HorizontalAlignmentEnum horizontalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT);
    int horizontalAlignmentPadding = 0;
    switch(horizontalAlignment) {
        case LEFT:
            horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding);
            break;
        case CENTER:
            horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding) / 2;
            break;
    }
    VerticalAlignmentEnum verticalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT);
    int verticalAlignmentPadding = 0;
    switch(verticalAlignment) {
        case TOP:
            verticalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.topPadding);
            break;
        case MIDDLE:
            verticalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.topPadding) / 2;
            break;
    }
    return super.getCellPainterAt(x - horizontalAlignmentPadding, y - verticalAlignmentPadding, cell, gc, adjustedCellBounds, configRegistry);
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) HorizontalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum) VerticalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum)

Example 68 with IStyle

use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.

the class SelectionLayerPainter method getBorderStyle.

/**
 * Get the border style that should be used to render the border for cells
 * that are currently selected. Checks the {@link IConfigRegistry} for a
 * registered {@link IStyle} for the
 * {@link SelectionConfigAttributes#SELECTION_GRID_LINE_STYLE} label or the
 * {@link SelectionStyleLabels#SELECTION_ANCHOR_GRID_LINE_STYLE} label. If
 * none is registered, a default line style will be returned.
 *
 * @param configRegistry
 *            The {@link IConfigRegistry} to retrieve the style information
 *            from.
 *
 * @return The border style that should be used
 *
 * @since 1.5
 */
protected BorderStyle getBorderStyle(IConfigRegistry configRegistry) {
    BorderStyle borderStyle = configRegistry.getConfigAttribute(SelectionConfigAttributes.SELECTION_GRID_LINE_STYLE, DisplayMode.SELECT);
    // check for backwards compatibility style configuration
    if (borderStyle == null) {
        // Note: If there is no style configured for the
        // SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE
        // label, the style configured for DisplayMode.SELECT will be
        // retrieved by this call.
        // Ensure that the selection style configuration does not contain a
        // border style configuration to avoid strange rendering behavior.
        // By default there is no border configuration added, so there
        // shouldn't be issues with backwards compatibility. And if there
        // are some, they can be solved easily by adding the necessary
        // border style configuration.
        IStyle cellStyle = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE);
        borderStyle = cellStyle != null ? cellStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE) : null;
    }
    // if there is no border style configured, use the default
    if (borderStyle == null) {
        borderStyle = new BorderStyle(1, GUIHelper.COLOR_BLACK, LineStyleEnum.DOTTED, BorderModeEnum.CENTERED);
    }
    return borderStyle;
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle)

Example 69 with IStyle

use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.

the class DefaultNatTableThemeConfiguration method getCornerSelectionStyle.

@Override
protected IStyle getCornerSelectionStyle() {
    IStyle cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.cornerSelectionBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.cornerSelectionFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, this.cornerSelectionGradientBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.cornerSelectionGradientFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.cornerSelectionHAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, this.cornerSelectionVAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.cornerSelectionFont);
    cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, this.cornerSelectionImage);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.cornerSelectionBorderStyle);
    cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, this.cornerSelectionPWEchoChar);
    cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, this.cornerSelectionTextDecoration);
    return cellStyle;
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) Style(org.eclipse.nebula.widgets.nattable.style.Style) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle)

Example 70 with IStyle

use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.

the class DefaultNatTableThemeConfiguration method getDefaultHoverSelectionStyle.

@Override
protected IStyle getDefaultHoverSelectionStyle() {
    IStyle cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.defaultHoverSelectionBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.defaultHoverSelectionFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, this.defaultHoverSelectionGradientBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.defaultHoverSelectionGradientFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.defaultHoverSelectionHAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, this.defaultHoverSelectionVAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.defaultHoverSelectionFont);
    cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, this.defaultHoverSelectionImage);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.defaultHoverSelectionBorderStyle);
    cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, this.defaultHoverSelectionPWEchoChar);
    cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, this.defaultHoverSelectionTextDecoration);
    return cellStyle;
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) Style(org.eclipse.nebula.widgets.nattable.style.Style) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle)

Aggregations

IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)97 BorderStyle (org.eclipse.nebula.widgets.nattable.style.BorderStyle)50 Style (org.eclipse.nebula.widgets.nattable.style.Style)49 ICellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)24 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)8 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)7 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 HashMap (java.util.HashMap)5 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)5 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)5 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)5 ExtendedPersonWithAddress (org.eclipse.nebula.widgets.nattable.dataset.person.ExtendedPersonWithAddress)5 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)5 VisualRefreshCommand (org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommand)4 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)4 ExtendedReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor)4 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)4 DefaultDoubleDisplayConverter (org.eclipse.nebula.widgets.nattable.data.convert.DefaultDoubleDisplayConverter)4 GroupByDataLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByDataLayer)4 GroupByHeaderLayer (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.GroupByHeaderLayer)4