Search in sources :

Example 1 with Style

use of net.sourceforge.nattable.style.Style in project translationstudio8 by heartsome.

the class StylePersistor method loadStyle.

// Load
public static Style loadStyle(String prefix, Properties properties) {
    Style style = new Style();
    prefix = prefix + DOT + STYLE_PERSISTENCE_PREFIX;
    // BG Color
    String bgColorPrefix = prefix + DOT + BG_COLOR_PREFIX;
    Color bgColor = loadColor(bgColorPrefix, properties);
    if (bgColor != null) {
        style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor);
    }
    // FG Color
    String fgColorPrefix = prefix + DOT + FG_COLOR_PREFIX;
    Color fgColor = loadColor(fgColorPrefix, properties);
    if (fgColor != null) {
        style.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor);
    }
    // Alignment
    String hAlignPrefix = prefix + DOT + H_ALIGNMENT_PREFIX;
    HorizontalAlignmentEnum hAlign = loadHAlignment(hAlignPrefix, properties);
    if (hAlign != null) {
        style.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
    }
    String vAlignPrefix = prefix + DOT + V_ALIGNMENT_PREFIX;
    VerticalAlignmentEnum vAlign = loadVAlignment(vAlignPrefix, properties);
    if (vAlign != null) {
        style.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
    }
    // Font
    String fontPrefix = prefix + DOT + FONT_PREFIX;
    Font font = loadFont(fontPrefix, properties);
    if (font != null) {
        style.setAttributeValue(CellStyleAttributes.FONT, font);
    }
    // Border Style
    String borderPrefix = prefix + DOT + BORDER_PREFIX;
    BorderStyle borderStyle = loadBorderStyle(borderPrefix, properties);
    if (borderStyle != null) {
        style.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
    }
    return style;
}
Also used : HorizontalAlignmentEnum(net.sourceforge.nattable.style.HorizontalAlignmentEnum) BorderStyle(net.sourceforge.nattable.style.BorderStyle) Color(org.eclipse.swt.graphics.Color) Style(net.sourceforge.nattable.style.Style) BorderStyle(net.sourceforge.nattable.style.BorderStyle) VerticalAlignmentEnum(net.sourceforge.nattable.style.VerticalAlignmentEnum) Font(org.eclipse.swt.graphics.Font)

Example 2 with Style

use of net.sourceforge.nattable.style.Style in project translationstudio8 by heartsome.

the class DefaultColumnHeaderStyleConfiguration method configureRegistry.

public void configureRegistry(IConfigRegistry configRegistry) {
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.CORNER);
    // Normal
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, font);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.CORNER);
}
Also used : Style(net.sourceforge.nattable.style.Style) BorderStyle(net.sourceforge.nattable.style.BorderStyle)

Example 3 with Style

use of net.sourceforge.nattable.style.Style in project translationstudio8 by heartsome.

the class DefaultRowHeaderStyleConfiguration method configureRowHeaderStyle.

protected void configureRowHeaderStyle(IConfigRegistry configRegistry) {
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, font);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, GridRegion.ROW_HEADER);
}
Also used : Style(net.sourceforge.nattable.style.Style) BorderStyle(net.sourceforge.nattable.style.BorderStyle)

Example 4 with Style

use of net.sourceforge.nattable.style.Style in project translationstudio8 by heartsome.

the class DisplayColumnStyleEditorCommandHandler method doCommand.

@Override
public boolean doCommand(DisplayColumnStyleEditorCommand command) {
    ILayer nattableLayer = command.getNattableLayer();
    int columnIndex = nattableLayer.getColumnIndexByPosition(command.columnPosition);
    // Column style
    Style slectedCellStyle = (Style) configRegistry.getConfigAttribute(CELL_STYLE, NORMAL, USER_EDITED_STYLE_LABEL + columnIndex);
    dialog = new ColumnStyleEditorDialog(Display.getCurrent().getActiveShell(), slectedCellStyle);
    dialog.open();
    if (dialog.isCancelPressed()) {
        return true;
    }
    applySelectedStyleToColumn(command, columnIndex);
    return true;
}
Also used : ColumnStyleEditorDialog(net.sourceforge.nattable.style.editor.ColumnStyleEditorDialog) ILayer(net.sourceforge.nattable.layer.ILayer) Style(net.sourceforge.nattable.style.Style)

Example 5 with Style

use of net.sourceforge.nattable.style.Style in project translationstudio8 by heartsome.

the class DisplayColumnStyleEditorCommandHandler method applySelectedStyleToColumn.

protected void applySelectedStyleToColumn(DisplayColumnStyleEditorCommand command, int columnIndex) {
    // Read the edited styles
    Style newColumnCellStyle = dialog.getNewColumCellStyle();
    if (newColumnCellStyle == null) {
        stylesToPersist.remove(getConfigLabel(columnIndex));
    } else {
        newColumnCellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, dialog.getNewColumnBorderStyle());
        stylesToPersist.put(getConfigLabel(columnIndex), newColumnCellStyle);
    }
    configRegistry.registerConfigAttribute(CELL_STYLE, newColumnCellStyle, NORMAL, getConfigLabel(columnIndex));
    columnLabelAccumulator.registerColumnOverrides(columnIndex, getConfigLabel(columnIndex));
}
Also used : Style(net.sourceforge.nattable.style.Style)

Aggregations

Style (net.sourceforge.nattable.style.Style)19 BorderStyle (net.sourceforge.nattable.style.BorderStyle)9 TagStyle (net.heartsome.cat.common.innertag.TagStyle)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 XLIFFEditorCompositeLayerConfiguration (net.heartsome.cat.ts.ui.xliffeditor.nattable.config.XLIFFEditorCompositeLayerConfiguration)1 LineNumberPainter (net.heartsome.cat.ts.ui.xliffeditor.nattable.painter.LineNumberPainter)1 StatusPainter (net.heartsome.cat.ts.ui.xliffeditor.nattable.painter.StatusPainter)1 DefaultDisplayConverter (net.sourceforge.nattable.data.convert.DefaultDisplayConverter)1 ILayer (net.sourceforge.nattable.layer.ILayer)1 HorizontalAlignmentEnum (net.sourceforge.nattable.style.HorizontalAlignmentEnum)1 VerticalAlignmentEnum (net.sourceforge.nattable.style.VerticalAlignmentEnum)1 ColumnStyleEditorDialog (net.sourceforge.nattable.style.editor.ColumnStyleEditorDialog)1 Color (org.eclipse.swt.graphics.Color)1 Font (org.eclipse.swt.graphics.Font)1 FontData (org.eclipse.swt.graphics.FontData)1