use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.
the class ZoomedViewportSelectionDataLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
ZoomLayer zoomLayer = new ZoomLayer(new DummyGridLayerStack());
zoomLayer.setZoomFactor(3.0f);
return new NatTable(parent, zoomLayer);
}
use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.
the class Derived_or_computed_column_data method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
List<Person> myList = new ArrayList<>();
myList.add(new Person("Homer", "Simpson", "Sargeant", 1234567890L));
myList.add(new Person("Waylon", "Smithers", "Admiral", 6666666666L));
myList.add(new Person("Bart", "Smithers", "General", 9125798342L));
myList.add(new Person("Nelson", "Muntz", "Private", 0000000001L));
myList.add(new Person("John", "Frink", "Lieutenant", 3141592654L));
String[] propertyNames = { "firstName", "lastName", "rank", "serialNumber" };
final IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
// Add derived 'fullName' column
final IColumnPropertyAccessor<Person> derivedColumnPropertyAccessor = new IColumnPropertyAccessor<Person>() {
@Override
public Object getDataValue(Person rowObject, int columnIndex) {
if (columnIndex < columnPropertyAccessor.getColumnCount()) {
return columnPropertyAccessor.getDataValue(rowObject, columnIndex);
} else if (columnIndex == columnPropertyAccessor.getColumnCount()) {
return columnPropertyAccessor.getDataValue(rowObject, 0) + " " + columnPropertyAccessor.getDataValue(rowObject, 1);
} else {
return null;
}
}
@Override
public void setDataValue(Person rowObject, int columnIndex, Object newValue) {
columnPropertyAccessor.setDataValue(rowObject, columnIndex, newValue);
}
@Override
public int getColumnCount() {
return columnPropertyAccessor.getColumnCount() + 1;
}
@Override
public String getColumnProperty(int columnIndex) {
if (columnIndex < columnPropertyAccessor.getColumnCount()) {
return columnPropertyAccessor.getColumnProperty(columnIndex);
} else if (columnIndex == columnPropertyAccessor.getColumnCount()) {
return "fullName";
} else {
return null;
}
}
@Override
public int getColumnIndex(String propertyName) {
if ("fullName".equals(propertyName)) {
return columnPropertyAccessor.getColumnCount() + 1;
} else {
return columnPropertyAccessor.getColumnIndex(propertyName);
}
}
};
final IDataProvider listDataProvider = new ListDataProvider<>(myList, derivedColumnPropertyAccessor);
// Column header data provider includes derived properties
IDataProvider columnHeaderDataProvider = new IDataProvider() {
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
return derivedColumnPropertyAccessor.getColumnProperty(columnIndex);
}
@Override
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
// noop
}
@Override
public int getColumnCount() {
return derivedColumnPropertyAccessor.getColumnCount();
}
@Override
public int getRowCount() {
return 1;
}
};
ILayer layer = new DefaultGridLayer(listDataProvider, columnHeaderDataProvider);
return new NatTable(parent, layer);
}
use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.
the class AutomaticRowHeightExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
GridData layoutData = GridDataFactory.fillDefaults().grab(true, true).create();
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginWidth = 0;
layout.marginHeight = 0;
panel.setLayout(layout);
panel.setLayoutData(layoutData);
loadMessages();
ListDataProvider<LogRecord> dataProvider = new ListDataProvider<>(this.logMessages, // $NON-NLS-1$
new ReflectiveColumnPropertyAccessor<LogRecord>(new String[] { "message" }));
DataLayer dataLayer = new DataLayer(dataProvider);
dataLayer.setColumnPercentageSizing(true);
dataLayer.setColumnWidthPercentageByPosition(0, 100);
dataLayer.setConfigLabelAccumulator(new ValidatorMessageLabelAccumulator());
ViewportLayer layer = new ViewportLayer(dataLayer);
layer.setRegionName(GridRegion.BODY);
NatTable natTable = new NatTable(panel, NatTable.DEFAULT_STYLE_OPTIONS | SWT.BORDER, layer, false);
natTable.addConfiguration(new ValidationMessageTableStyleConfiguration());
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
return panel;
}
use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.
the class _001_Vertical_layer_composition method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
ViewportLayer layer = new ViewportLayer(new SelectionLayer(new DataLayer(new DummyBodyDataProvider(1000000, 1000000))));
layer.setRegionName(GridRegion.BODY);
return new NatTable(parent, layer);
}
use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderViewportSelectionDataLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(500, 1000000);
SelectionLayer selectionLayer = new SelectionLayer(new DataLayer(bodyDataProvider));
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);
return new NatTable(parent, compositeLayer);
}
Aggregations