use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.
the class ViewportIntegrationTest method shouldInitWithNoScroll.
@Test
public void shouldInitWithNoScroll() {
List<String> contents = new ArrayList<>(Arrays.asList("one", "two", "three", "four", "five"));
IDataProvider bodyDataProvider = new ListDataProvider<>(contents, new IColumnAccessor<String>() {
@Override
public Object getDataValue(String rowObject, int columnIndex) {
return rowObject;
}
@Override
public void setDataValue(String rowObject, int columnIndex, Object newValue) {
// ignore
}
@Override
public int getColumnCount() {
return 1;
}
});
SelectionLayer selectionLayer = new SelectionLayer(new DataLayer(bodyDataProvider));
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
IDataProvider colDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider);
ColumnHeaderLayer colHeader = new ColumnHeaderLayer(new DataLayer(colDataProvider), viewportLayer, selectionLayer);
IDataProvider rowDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowDataProvider), viewportLayer, selectionLayer);
CornerLayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(colDataProvider, rowDataProvider)), rowHeaderLayer, colHeader);
GridLayer grid = new GridLayer(viewportLayer, colHeader, rowHeaderLayer, cornerLayer);
// create the table with no scrollbars
NatTable natTable = new NatTable(new Shell(), SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED, grid);
// this caused a NPE for scrollbar initialization
natTable.setSize(600, 600);
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.
the class PercentageExample method postConstruct.
@PostConstruct
public void postConstruct(Composite parent) {
// Setup the layer stack
final MyDataProvider myDataProvider = new MyDataProvider();
SelectionLayer selectionLayer = new SelectionLayer(new DataLayer(myDataProvider));
ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(new DummyColumnHeaderDataProvider(myDataProvider)), selectionLayer, selectionLayer);
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, selectionLayer, 0, 1);
NatTable natTable = new NatTable(parent, compositeLayer);
natTable.setData(CSSSWTConstants.CSS_CLASS_NAME_KEY, "percentage");
parent.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
showSourceLinks(parent, getClass().getName());
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.
the class _001_Custom_styling_of_specific_cells method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
List<SimplePerson> myList = new ArrayList<>();
for (int i = 1; i <= 100; i++) {
myList.add(new SimplePerson(i, "Joe" + i, new Date()));
}
String[] propertyNames = { "id", "name", "birthDate" };
IColumnPropertyAccessor<SimplePerson> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
ListDataProvider<SimplePerson> listDataProvider = new ListDataProvider<>(myList, columnPropertyAccessor);
DefaultGridLayer gridLayer = new DefaultGridLayer(listDataProvider, new DummyColumnHeaderDataProvider(listDataProvider));
final DefaultBodyLayerStack bodyLayer = gridLayer.getBodyLayer();
// Custom label "FOO" for cell at column, row index (1, 5)
IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
int columnIndex = bodyLayer.getColumnIndexByPosition(columnPosition);
int rowIndex = bodyLayer.getRowIndexByPosition(rowPosition);
if (columnIndex == 1 && rowIndex == 5) {
configLabels.addLabel(FOO_LABEL);
}
if (columnIndex == 1 && rowIndex == 10) {
configLabels.addLabel(BAR_LABEL);
}
// add labels for surrounding borders
if (rowIndex == 13) {
configLabels.addLabel(CustomLineBorderDecorator.TOP_LINE_BORDER_LABEL);
configLabels.addLabel(CustomLineBorderDecorator.BOTTOM_LINE_BORDER_LABEL);
if (columnIndex == 0) {
configLabels.addLabel(CustomLineBorderDecorator.LEFT_LINE_BORDER_LABEL);
}
if (columnIndex == 2) {
configLabels.addLabel(CustomLineBorderDecorator.RIGHT_LINE_BORDER_LABEL);
}
}
}
};
bodyLayer.setConfigLabelAccumulator(cellLabelAccumulator);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
// override the LineBorderDecorator here to show how to paint
// borders on single sides of a cell
this.cellPainter = new CustomLineBorderDecorator(new TextPainter());
// set a border style
this.borderStyle = new BorderStyle(2, GUIHelper.COLOR_BLUE, LineStyleEnum.DASHDOT);
}
});
// Custom style for label "FOO"
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
Style cellStyle = new Style();
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_GREEN);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, FOO_LABEL);
cellStyle = new Style();
cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, TextDecorationEnum.UNDERLINE_STRIKETHROUGH);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle, DisplayMode.NORMAL, BAR_LABEL);
}
});
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.
the class TextPainter_Examples method createNatTable3.
@SuppressWarnings("unused")
private void createNatTable3(Composite parent, final ICellPainter painter) {
IDataProvider bodyDataProvider = new ExampleHeaderDataProvider();
DataLayer dataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(new DummyColumnHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
NatTable natTable = new NatTable(parent, compositeLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.vAlign = VerticalAlignmentEnum.TOP;
this.hAlign = HorizontalAlignmentEnum.LEFT;
this.cellPainter = new LineBorderDecorator(painter);
this.font = GUIHelper.getFont(new FontData("Arial", 20, SWT.NORMAL));
}
});
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
}
use of org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider in project nebula.widgets.nattable by eclipse.
the class TextPainter_Examples method createNatTable.
private void createNatTable(Composite parent, final ICellPainter painter) {
IDataProvider bodyDataProvider = new ExampleTextBodyDataProvider();
DataLayer dataLayer = new DataLayer(bodyDataProvider);
dataLayer.setRowHeightByPosition(0, 32);
SelectionLayer selectionLayer = new SelectionLayer(dataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(new DummyColumnHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
NatTable natTable = new NatTable(parent, compositeLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.vAlign = VerticalAlignmentEnum.TOP;
this.hAlign = HorizontalAlignmentEnum.LEFT;
this.cellPainter = new LineBorderDecorator(painter);
}
});
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
}
Aggregations