use of org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer in project nebula.widgets.nattable by eclipse.
the class FreezeLayerTest method setup.
@Before
public void setup() {
this.reorderLayer = new ColumnReorderLayer(new BaseDataLayerFixture(10, 10));
this.hideShowLayer = new ColumnHideShowLayer(this.reorderLayer);
this.freezeLayer = new FreezeLayer(this.hideShowLayer);
this.freezeLayer.setTopLeftPosition(1, 0);
this.freezeLayer.setBottomRightPosition(3, 3);
}
use of org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer in project nebula.widgets.nattable by eclipse.
the class FreezeHandlerTest method setUp.
@Before
public void setUp() {
final DataLayer bodyDataLayer = new DataLayer(new DummyBodyDataProvider(10, 10));
final DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(bodyDataLayer);
this.selectionLayer = bodyLayer.getSelectionLayer();
this.freezeLayer = new FreezeLayer(this.selectionLayer);
this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, bodyLayer.getViewportLayer(), bodyLayer.getSelectionLayer());
this.viewportLayer = bodyLayer.getViewportLayer();
this.commandHandler = new FreezeCommandHandler(this.freezeLayer, this.viewportLayer, this.selectionLayer);
this.compositeFreezeLayer.registerCommandHandler(this.commandHandler);
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 600, 400);
}
});
// Shoot this command so that the viewport can be initialized
this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
}
use of org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer in project nebula.widgets.nattable by eclipse.
the class _513_FreezeExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
// property names of the Person class
String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("firstName", "Firstname");
propertyToLabelMap.put("lastName", "Lastname");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("married", "Married");
propertyToLabelMap.put("birthday", "Birthday");
// build the body layer stack
// Usually you would create a new layer stack by extending
// AbstractIndexLayerTransform and setting the ViewportLayer as
// underlying layer. But in this case using the ViewportLayer directly
// as body layer is also working.
IDataProvider bodyDataProvider = new DefaultBodyDataProvider<>(PersonService.getPersons(10), propertyNames);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
final SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
final ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
final FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer, selectionLayer);
// build the column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, compositeFreezeLayer, selectionLayer);
// build the row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, compositeFreezeLayer, selectionLayer);
// build the corner layer
IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(compositeFreezeLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
// turn the auto configuration off as we want to add our header menu
// configuration
final NatTable natTable = new NatTable(panel, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the DefaultNatTableStyleConfiguration manually
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new DefaultFreezeGridBindings());
// add the corner menu configuration for adding the view management
// action
natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {
@Override
protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
return super.createColumnHeaderMenu(natTable).withHideColumnMenuItem().withShowAllColumnsMenuItem().withColumnChooserMenuItem();
}
@Override
protected PopupMenuBuilder createCornerMenu(NatTable natTable) {
return super.createCornerMenu(natTable).withShowAllColumnsMenuItem().withStateManagerMenuItemProvider();
}
});
natTable.configure();
panel.setLayout(new GridLayout());
GridDataFactory.fillDefaults().grab(true, true).applyTo(panel);
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
gridLayer.registerCommandHandler(new DisplayPersistenceDialogCommandHandler(natTable));
DisplayColumnChooserCommandHandler columnChooserCommandHandler = new DisplayColumnChooserCommandHandler(selectionLayer, columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer, null, null);
gridLayer.registerCommandHandler(columnChooserCommandHandler);
return panel;
}
use of org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer in project nebula.widgets.nattable by eclipse.
the class CompositeFreezeLayerTest method setup.
@Before
public void setup() {
TestLayer dataLayer = new TestLayer(4, 4, "0:0;100 | 1:1;100 | 2:2;100 | 3:3;100", "0:0;40 | 1:1;40 | 2:2;40 | 3:3;40", "A0 | B0 | C0 | D0 \n" + "A1 | B1 | C1 | D1 \n" + "A2 | B2 | C2 | D2 \n" + "A3 | B3 | C3 | D3 \n");
this.reorderLayer = new ColumnReorderLayer(dataLayer);
this.hideShowLayer = new ColumnHideShowLayer(this.reorderLayer);
this.selectionLayer = new SelectionLayer(this.hideShowLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
this.freezeLayer = new FreezeLayer(this.selectionLayer);
this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, this.viewportLayer, this.selectionLayer);
this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {
@Override
public Rectangle getClientArea() {
return new Rectangle(0, 0, 400, 160);
}
});
this.compositeFreezeLayer.doCommand(new InitializeClientAreaCommandFixture());
}
use of org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer in project nebula.widgets.nattable by eclipse.
the class FreezeLayerTest2 method setup.
@Before
public void setup() {
TestLayer dataLayer = new TestLayer(4, 4, "0:0;100 | 1:1;100 | 2:2;100 | 3:3;100", "0:0;40 | 1:1;40 | 2:2;40 | 3:3;40", "A0 | B0 | C0 | D0 \n" + "A1 | B1 | C1 | D1 \n" + "A2 | B2 | C2 | D2 \n" + "A3 | B3 | C3 | D3 \n");
this.freezeLayer = new FreezeLayer(dataLayer);
}
Aggregations