-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathNatTableAdvancedExample.java
42 lines (29 loc) · 1.61 KB
/
NatTableAdvancedExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.vogella.nattable.parts;
import java.util.List;
import jakarta.annotation.PostConstruct;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnLabelAccumulator;
import org.eclipse.swt.widgets.Composite;
import com.vogella.tasks.model.Task;
import com.vogella.tasks.model.TaskService;
public class NatTableAdvancedExample {
@PostConstruct
public void postConstruct(Composite parent, TaskService taskService) {
List<Task> tasks = taskService.getAll();
IColumnPropertyAccessor<Task> columnPropertyAccessor = new TaskColumnPropertyAccessor();
ListDataProvider<Task> dataProvider = new ListDataProvider<>(tasks, columnPropertyAccessor);
TaskHeaderDataProvider headerDataProvider = new TaskHeaderDataProvider();
DefaultGridLayer gridLayer = new DefaultGridLayer(dataProvider, headerDataProvider);
ColumnLabelAccumulator columnLabelAccumulator = new ColumnLabelAccumulator(dataProvider);
((DataLayer) gridLayer.getBodyDataLayer()).setConfigLabelAccumulator(columnLabelAccumulator);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new EditConfiguration());
natTable.configure();
}
}