Search in sources :

Example 31 with BorderStyle

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

the class BorderStyleEditorPanel method getNewValue.

@Override
public BorderStyle getNewValue() {
    if (!this.noBordersCheckBox.getSelection()) {
        Color borderColor = this.colorPicker.getSelectedColor();
        LineStyleEnum lineStyle = this.lineStylePicker.getSelectedLineStyle();
        int borderThickness = this.thicknessPicker.getSelectedThickness();
        return new BorderStyle(borderThickness, borderColor, lineStyle);
    }
    return null;
}
Also used : BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) Color(org.eclipse.swt.graphics.Color) LineStyleEnum(org.eclipse.nebula.widgets.nattable.style.BorderStyle.LineStyleEnum)

Example 32 with BorderStyle

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

the class DefaultNatTableThemeConfiguration method getSelectionAnchorSelectionStyle.

@Override
protected IStyle getSelectionAnchorSelectionStyle() {
    IStyle cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.selectionAnchorSelectionBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.selectionAnchorSelectionFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, this.selectionAnchorSelectionGradientBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.selectionAnchorSelectionGradientFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.selectionAnchorSelectionHAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, this.selectionAnchorSelectionVAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.selectionAnchorSelectionFont);
    cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, this.selectionAnchorSelectionImage);
    // if there is not explicitly another border style configured use the
    // same as in getSelectionAnchorStyle()
    BorderStyle border = this.selectionAnchorSelectionBorderStyle != null ? this.selectionAnchorSelectionBorderStyle : this.selectionAnchorBorderStyle;
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, border);
    cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, this.selectionAnchorSelectionPWEchoChar);
    cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, this.selectionAnchorSelectionTextDecoration);
    return cellStyle;
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) 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 33 with BorderStyle

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

the class _000_Styled_grid method addCustomStyling.

private void addCustomStyling(NatTable natTable) {
    // Setup NatTable default styling
    // NOTE: Getting the colors and fonts from the GUIHelper ensures that
    // they are disposed properly (required by SWT)
    DefaultNatTableStyleConfiguration natTableConfiguration = new DefaultNatTableStyleConfiguration();
    natTableConfiguration.bgColor = GUIHelper.getColor(249, 172, 7);
    natTableConfiguration.fgColor = GUIHelper.getColor(30, 76, 19);
    natTableConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;
    natTableConfiguration.vAlign = VerticalAlignmentEnum.TOP;
    // A custom painter can be plugged in to paint the cells differently
    natTableConfiguration.cellPainter = new PaddingDecorator(new TextPainter(), 1);
    // Setup even odd row colors - row colors override the NatTable default
    // colors
    DefaultRowStyleConfiguration rowStyleConfiguration = new DefaultRowStyleConfiguration();
    rowStyleConfiguration.oddRowBgColor = GUIHelper.getColor(254, 251, 243);
    rowStyleConfiguration.evenRowBgColor = GUIHelper.COLOR_WHITE;
    // Setup selection styling
    DefaultSelectionStyleConfiguration selectionStyle = new DefaultSelectionStyleConfiguration();
    selectionStyle.selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.NORMAL));
    selectionStyle.selectionBgColor = GUIHelper.getColor(217, 232, 251);
    selectionStyle.selectionFgColor = GUIHelper.COLOR_BLACK;
    selectionStyle.anchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID);
    selectionStyle.anchorBgColor = GUIHelper.getColor(65, 113, 43);
    selectionStyle.selectedHeaderBgColor = GUIHelper.getColor(156, 209, 103);
    // Add all style configurations to NatTable
    natTable.addConfiguration(natTableConfiguration);
    natTable.addConfiguration(rowStyleConfiguration);
    natTable.addConfiguration(selectionStyle);
    // Column/Row header style and custom painters
    natTable.addConfiguration(new StyledRowHeaderConfiguration());
    natTable.addConfiguration(new StyledColumnHeaderConfiguration());
    // Add popup menu - build your own popup menu using the PopupMenuBuilder
    natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
}
Also used : StyledRowHeaderConfiguration(org.eclipse.nebula.widgets.nattable.examples.fixtures.StyledRowHeaderConfiguration) DefaultRowStyleConfiguration(org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration) DefaultSelectionStyleConfiguration(org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionStyleConfiguration) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) BorderStyle(org.eclipse.nebula.widgets.nattable.style.BorderStyle) FontData(org.eclipse.swt.graphics.FontData) HeaderMenuConfiguration(org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration) StyledColumnHeaderConfiguration(org.eclipse.nebula.widgets.nattable.examples.fixtures.StyledColumnHeaderConfiguration) PaddingDecorator(org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator) TextPainter(org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)

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