/** Sets up rendering style used for selected areas and the selection anchor. */
public class DefaultSelectionStyleConfiguration extends AbstractRegistryConfiguration {

  // Selection style
  public Font selectionFont =
      GUIHelper.getFont(new FontData("Verdana", 8, SWT.BOLD | SWT.ITALIC)); // $NON-NLS-1$
  public Color selectionBgColor = GUIHelper.COLOR_TITLE_INACTIVE_BACKGROUND;
  public Color selectionFgColor = GUIHelper.COLOR_BLACK;

  // Anchor style
  public Color anchorBorderColor = GUIHelper.COLOR_DARK_GRAY;
  public BorderStyle anchorBorderStyle =
      new BorderStyle(1, this.anchorBorderColor, LineStyleEnum.SOLID);
  public Color anchorBgColor = GUIHelper.COLOR_GRAY;
  public Color anchorFgColor = GUIHelper.COLOR_WHITE;

  // Selected headers style
  public Color selectedHeaderBgColor = GUIHelper.COLOR_GRAY;
  public Color selectedHeaderFgColor = GUIHelper.COLOR_WHITE;
  public Font selectedHeaderFont =
      GUIHelper.getFont(new FontData("Verdana", 10, SWT.BOLD)); // $NON-NLS-1$
  public BorderStyle selectedHeaderBorderStyle =
      new BorderStyle(-1, this.selectedHeaderFgColor, LineStyleEnum.SOLID);

  public Color fullySelectedHeaderBgColor = GUIHelper.COLOR_WIDGET_NORMAL_SHADOW;

  // Anchor grid line style
  public Color anchorGridBorderColor = GUIHelper.COLOR_BLACK;
  public BorderStyle anchorGridBorderStyle =
      new BorderStyle(1, this.anchorGridBorderColor, LineStyleEnum.DOTTED);

  @Override
  public void configureRegistry(IConfigRegistry configRegistry) {
    configureSelectionStyle(configRegistry);
    configureSelectionAnchorStyle(configRegistry);
    configureSelectionAnchorGridLineStyle(configRegistry);
    configureHeaderHasSelectionStyle(configRegistry);
    configureHeaderFullySelectedStyle(configRegistry);
  }

  protected void configureSelectionStyle(IConfigRegistry configRegistry) {
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.selectionFont);
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.selectionBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.selectionFgColor);

    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT);
  }

  protected void configureSelectionAnchorStyle(IConfigRegistry configRegistry) {
    // Selection anchor style for normal display mode
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.anchorBorderStyle);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE,
        cellStyle,
        DisplayMode.NORMAL,
        SelectionStyleLabels.SELECTION_ANCHOR_STYLE);

    // Selection anchor style for select display mode
    cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.anchorBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.anchorFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.anchorBorderStyle);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE,
        cellStyle,
        DisplayMode.SELECT,
        SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
  }

  protected void configureSelectionAnchorGridLineStyle(IConfigRegistry configRegistry) {
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.anchorGridBorderStyle);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE,
        cellStyle,
        DisplayMode.SELECT,
        SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE);
  }

  protected void configureHeaderHasSelectionStyle(IConfigRegistry configRegistry) {
    Style cellStyle = new Style();

    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.selectedHeaderFgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.selectedHeaderBgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.selectedHeaderFont);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.selectedHeaderBorderStyle);

    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, GridRegion.COLUMN_HEADER);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, GridRegion.CORNER);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.SELECT, GridRegion.ROW_HEADER);
  }

  protected void configureHeaderFullySelectedStyle(IConfigRegistry configRegistry) {
    // Header fully selected
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(
        CellStyleAttributes.BACKGROUND_COLOR, this.fullySelectedHeaderBgColor);

    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE,
        cellStyle,
        DisplayMode.SELECT,
        SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE);
    configRegistry.registerConfigAttribute(
        CellConfigAttributes.CELL_STYLE,
        cellStyle,
        DisplayMode.SELECT,
        SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE);
  }
}
  {
    this.defaultHAlign = HorizontalAlignmentEnum.LEFT;
    this.defaultCellPainter =
        new BackgroundPainter(
            new PaddingDecorator(new TextPainter(false, false), 0, 5, 0, 5, false));

    // column header styling
    this.cHeaderHAlign = HorizontalAlignmentEnum.LEFT;
    this.cHeaderFont = GUIHelper.DEFAULT_FONT;
    this.cHeaderCellPainter = new PaddingDecorator(new TextPainter(), 0, 5, 0, 5);

    // column header selection style
    this.cHeaderSelectionFont = GUIHelper.DEFAULT_FONT;
    this.cHeaderSelectionCellPainter =
        new BackgroundPainter(
            new PaddingDecorator(new TextPainter(false, false), 0, 5, 0, 5, false));

    // row header styling
    this.rHeaderFont = GUIHelper.DEFAULT_FONT;

    // row header selection style
    this.rHeaderSelectionFont = GUIHelper.DEFAULT_FONT;
    this.rHeaderSelectionCellPainter = new TextPainter();

    // no alternate row styling
    this.evenRowBgColor = GUIHelper.COLOR_WHITE;
    this.oddRowBgColor = GUIHelper.COLOR_WHITE;

    // default selection style
    this.defaultSelectionBgColor = GUIHelper.COLOR_LIST_SELECTION;
    this.defaultSelectionFgColor = GUIHelper.COLOR_WHITE;
    this.defaultSelectionFont = GUIHelper.DEFAULT_FONT;

    // selection anchor
    this.selectionAnchorSelectionBgColor = GUIHelper.COLOR_LIST_SELECTION;
    this.selectionAnchorSelectionFgColor = GUIHelper.COLOR_WHITE;
    this.selectionAnchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_BLUE, LineStyleEnum.SOLID);

    // column/row group header style
    this.cGroupHeaderHAlign = HorizontalAlignmentEnum.CENTER;
    this.cGroupHeaderCellPainter = new ColumnGroupHeaderTextPainter();
    this.rGroupHeaderCellPainter =
        new BackgroundPainter(
            new PaddingDecorator(
                new RowGroupHeaderTextPainter(
                    new VerticalTextPainter(false, false), CellEdgeEnum.BOTTOM, false, 2, true),
                0,
                0,
                2,
                0,
                false));

    // sort header styling
    this.sortHeaderCellPainter =
        new BackgroundPainter(
            new PaddingDecorator(
                new SortableHeaderTextPainter(
                    new TextPainter(false, false),
                    CellEdgeEnum.RIGHT,
                    new SortIconPainter(false),
                    false,
                    0,
                    false),
                0,
                2,
                0,
                5,
                false));
    this.selectedSortHeaderCellPainter =
        new BackgroundPainter(
            new PaddingDecorator(
                new SortableHeaderTextPainter(
                    new TextPainter(false, false),
                    CellEdgeEnum.RIGHT,
                    new SortIconPainter(false, true),
                    false,
                    0,
                    false),
                0,
                2,
                0,
                5,
                false));

    TreeImagePainter treeImagePainter =
        new TreeImagePainter(
            false,
            GUIHelper.getImage("right"),
            GUIHelper.getImage("right_down"),
            null); //$NON-NLS-1$//$NON-NLS-2$
    this.treeStructurePainter =
        new BackgroundPainter(
            new PaddingDecorator(
                new IndentedTreeImagePainter(
                    10, null, CellEdgeEnum.LEFT, treeImagePainter, false, 2, true),
                0,
                5,
                0,
                5,
                false));

    TreeImagePainter treeSelectionImagePainter =
        new TreeImagePainter(
            false,
            GUIHelper.getImage("right_inv"),
            GUIHelper.getImage("right_down_inv"),
            null); //$NON-NLS-1$//$NON-NLS-2$
    this.treeStructureSelectionPainter =
        new BackgroundPainter(
            new PaddingDecorator(
                new IndentedTreeImagePainter(
                    10, null, CellEdgeEnum.LEFT, treeSelectionImagePainter, false, 2, true),
                0,
                5,
                0,
                5,
                false));

    FontData summaryRowFontData = GUIHelper.DEFAULT_FONT.getFontData()[0];
    summaryRowFontData.setStyle(SWT.BOLD);
    this.summaryRowFont = GUIHelper.getFont(summaryRowFontData);
    this.summaryRowHAlign = HorizontalAlignmentEnum.RIGHT;
    this.summaryRowBgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW;

    this.summaryRowSelectionFont = GUIHelper.getFont(summaryRowFontData);
    this.summaryRowSelectionBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW;

    this.renderCornerGridLines = true;
    this.renderColumnHeaderGridLines = true;
  }