Search in sources :

Example 26 with BorderStyle

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

the class FillHandleLayerPainter method applyHandleBorderStyle.

/**
 * Apply the border style that should be used to render the border for cells
 * that are currently part of the fill handle region. Checks the
 * {@link IConfigRegistry} for a registered {@link IStyle} for the
 * {@link FillHandleConfigAttributes#FILL_HANDLE_REGION_BORDER_STYLE} label.
 * If none is registered, a default line style will be used to render the
 * border.
 *
 * @param gc
 *            The current {@link GC} that is used for rendering.
 * @param configRegistry
 *            The {@link IConfigRegistry} to retrieve the style information
 *            from.
 * @deprecated Use {@link #getHandleRegionBorderStyle} instead.
 */
@Deprecated
protected void applyHandleBorderStyle(GC gc, IConfigRegistry configRegistry) {
    BorderStyle borderStyle = configRegistry.getConfigAttribute(FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE, DisplayMode.NORMAL);
    // if there is no border style configured, use the default
    if (borderStyle == null) {
        gc.setLineStyle(SWT.LINE_SOLID);
        gc.setLineWidth(2);
        gc.setForeground(GUIHelper.getColor(0, 125, 10));
    } else {
        gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle()));
        gc.setLineWidth(borderStyle.getThickness());
        gc.setForeground(borderStyle.getColor());
    }
}
Also used : BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle)

Example 27 with BorderStyle

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

the class CustomLineBorderDecorator method getPreferredWidth.

@Override
public int getPreferredWidth(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
    BorderStyle borderStyle = getBorderStyle(cell, configRegistry);
    int borderThickness = borderStyle != null ? borderStyle.getThickness() : 0;
    int borderLineCount = 0;
    // check how many border lines are configured for that cell
    List<String> labels = cell.getConfigLabels().getLabels();
    if (labels.contains(RIGHT_LINE_BORDER_LABEL))
        borderLineCount++;
    if (labels.contains(LEFT_LINE_BORDER_LABEL))
        borderLineCount++;
    return super.getPreferredWidth(cell, gc, configRegistry) + (borderThickness * borderLineCount);
}
Also used : BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) Point(org.eclipse.swt.graphics.Point)

Example 28 with BorderStyle

use of org.eclipse.nebula.widgets.nattable.style.BorderStyle 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 29 with BorderStyle

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

the class LineBorderDecorator method getPreferredHeight.

@Override
public int getPreferredHeight(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
    BorderStyle borderStyle = getBorderStyle(cell, configRegistry);
    int borderThickness = borderStyle != null ? borderStyle.getThickness() : 0;
    return super.getPreferredHeight(cell, gc, configRegistry) + (borderThickness * 2);
}
Also used : BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle)

Example 30 with BorderStyle

use of org.eclipse.nebula.widgets.nattable.style.BorderStyle 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)

Aggregations

BorderStyle (org.eclipse.nebula.widgets.nattable.style.BorderStyle)33 Color (org.eclipse.swt.graphics.Color)11 IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)9 Style (org.eclipse.nebula.widgets.nattable.style.Style)6 Rectangle (org.eclipse.swt.graphics.Rectangle)5 Test (org.junit.Test)5 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)4 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)3 ICellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)3 HorizontalAlignmentEnum (org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum)3 VerticalAlignmentEnum (org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum)3 Font (org.eclipse.swt.graphics.Font)3 Point (org.eclipse.swt.graphics.Point)3 List (java.util.List)2 CSSStylableElement (org.eclipse.e4.ui.css.core.dom.CSSStylableElement)2 CSS2FontProperties (org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties)2 CSSElementContext (org.eclipse.e4.ui.css.core.engine.CSSElementContext)2 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)2 IOverlayPainter (org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter)2 BorderPainter (org.eclipse.nebula.widgets.nattable.painter.cell.BorderPainter)2