Search in sources :

Example 1 with HorizontalAlignmentEnum

use of net.sourceforge.nattable.style.HorizontalAlignmentEnum 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 HorizontalAlignmentEnum

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

the class CellStyleEditorPanel method edit.

@Override
public void edit(Style style) throws Exception {
    Color bgColor = style.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR);
    backgroundColorPicker.setSelectedColor(bgColor != null ? bgColor : GUIHelper.COLOR_WHITE);
    Color fgColor = style.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR);
    foregroundColorPicker.setSelectedColor(fgColor != null ? fgColor : GUIHelper.COLOR_BLACK);
    fontPicker.setFont(style.getAttributeValue(CellStyleAttributes.FONT));
    HorizontalAlignmentEnum hAlign = style.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT);
    horizontalAlignmentPicker.setSelectedAlignment(hAlign != null ? hAlign : HorizontalAlignmentEnum.CENTER);
    VerticalAlignmentEnum vAlign = style.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT);
    verticalAlignmentPicker.setSelectedAlignment(vAlign != null ? vAlign : VerticalAlignmentEnum.MIDDLE);
}
Also used : HorizontalAlignmentEnum(net.sourceforge.nattable.style.HorizontalAlignmentEnum) Color(org.eclipse.swt.graphics.Color) VerticalAlignmentEnum(net.sourceforge.nattable.style.VerticalAlignmentEnum)

Aggregations

HorizontalAlignmentEnum (net.sourceforge.nattable.style.HorizontalAlignmentEnum)2 VerticalAlignmentEnum (net.sourceforge.nattable.style.VerticalAlignmentEnum)2 Color (org.eclipse.swt.graphics.Color)2 BorderStyle (net.sourceforge.nattable.style.BorderStyle)1 Style (net.sourceforge.nattable.style.Style)1 Font (org.eclipse.swt.graphics.Font)1