Пример #1
0
 public RowHeaderStyleConfiguration(final TableTheme theme) {
   this.font = theme.getFont();
   this.bgColor = theme.getHeadersBackground();
   this.fgColor = theme.getHeadersForeground();
   this.cellPainter =
       new UnderlinedCellBackgroundPainter(
           new TextPainter(false, false), Side.RIGHT, theme.getHeadersUnderlineColor().getRGB());
 }
Пример #2
0
  private NatTable createTable(
      final Composite parent,
      final TableTheme theme,
      final RedNattableLayersFactory factory,
      final GridLayer gridLayer,
      final DataLayer dataLayer,
      final ConfigRegistry configRegistry) {
    final int style =
        SWT.NO_BACKGROUND
            | SWT.NO_REDRAW_RESIZE
            | SWT.DOUBLE_BUFFERED
            | SWT.V_SCROLL
            | SWT.H_SCROLL;
    final NatTable table = new NatTable(parent, style, gridLayer, false);
    table.setConfigRegistry(configRegistry);
    table.setLayerPainter(
        new RedNatGridLayerPainter(
            table,
            theme.getGridBorderColor(),
            theme.getHeadersBackground(),
            theme.getHeadersUnderlineColor(),
            2,
            RedNattableLayersFactory.ROW_HEIGHT));
    table.setBackground(theme.getBodyBackgroundOddRowBackground());
    table.setForeground(parent.getForeground());

    // calculate columns width
    table.addListener(
        SWT.Paint,
        factory.getColumnsWidthCalculatingPaintListener(table, dataProvider, dataLayer, 270, 200));

    addCustomStyling(table, theme);

    final Supplier<HeaderFilterMatchesCollection> matchesSupplier =
        new Supplier<HeaderFilterMatchesCollection>() {

          @Override
          public HeaderFilterMatchesCollection get() {
            return matches;
          }
        };

    // find matches configuration
    table.addConfiguration(new TableMatchesSupplierRegistryConfiguration(matchesSupplier));

    // hyperlinks configuration
    final TableCellsStrings tableStrings = new TableCellsStrings();
    table.addConfiguration(new TableStringsPositionsRegistryConfiguration(tableStrings));
    final TableHyperlinksSupport detector =
        TableHyperlinksSupport.enableHyperlinksInTable(table, tableStrings);
    detector.addDetectors(
        new TableHyperlinksToKeywordsDetector(dataProvider),
        new TableHyperlinksToVariablesDetector(dataProvider));

    // sorting
    table.addConfiguration(new HeaderSortConfiguration());
    table.addConfiguration(new CasesTableSortingConfiguration(dataProvider));

    // popup menus
    table.addConfiguration(new CasesTableMenuConfiguration(site, table, selectionProvider));

    table.configure();
    GridDataFactory.fillDefaults().grab(true, true).applyTo(table);

    return table;
  }