use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testTreeLabels.
@Test
public void testTreeLabels() {
SelectionLayer selectionLayer = new SelectionLayer(this.bodyDataLayer);
TreeLayer treeLayer = new TreeLayer(selectionLayer, new TreeRowModel<Person>(new ITreeData<Person>() {
@Override
public String formatDataForDepth(int depth, Person object) {
return null;
}
@Override
public String formatDataForDepth(int depth, int index) {
return null;
}
@Override
public int getDepthOfData(Person object) {
return 0;
}
@Override
public int getDepthOfData(int index) {
return 0;
}
@Override
public Person getDataAtIndex(int index) {
return null;
}
@Override
public int indexOf(Person child) {
return 0;
}
@Override
public boolean hasChildren(Person object) {
return false;
}
@Override
public boolean hasChildren(int index) {
return false;
}
@Override
public List<Person> getChildren(Person object) {
return null;
}
@Override
public List<Person> getChildren(Person object, boolean fullDepth) {
return null;
}
@Override
public List<Person> getChildren(int index) {
return null;
}
@Override
public int getElementCount() {
return 0;
}
@Override
public boolean isValidIndex(int index) {
return false;
}
}));
Collection<String> labels = treeLayer.getProvidedLabels();
assertEquals(16, labels.size());
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_CELL));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_REGION));
assertTrue(labels.contains(SelectionStyleLabels.COPY_BORDER_STYLE));
assertTrue(labels.contains(TreeLayer.TREE_COLUMN_CELL));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_LEAF_CONFIG_TYPE));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_COLLAPSED_CONFIG_TYPE));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_EXPANDED_CONFIG_TYPE));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + "0"));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + "1"));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + "2"));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + "3"));
assertTrue(labels.contains(DefaultTreeLayerConfiguration.TREE_DEPTH_CONFIG_TYPE + "4"));
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testProvidedGridLabelsRowGroupHeader.
@Test
public void testProvidedGridLabelsRowGroupHeader() {
SelectionLayer selectionLayer = new SelectionLayer(this.bodyDataLayer);
GridLayer grid = new GridLayer(selectionLayer, this.columnHeaderDataLayer, new RowGroupHeaderLayer<Person>(new RowHeaderLayer(this.rowHeaderDataLayer, this.bodyDataLayer, selectionLayer), selectionLayer, new RowGroupModel<Person>()), this.cornerDataLayer);
Collection<String> labels = grid.getProvidedLabels();
assertEquals(16, labels.size());
assertTrue(labels.contains(GridRegion.CORNER));
assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
assertTrue(labels.contains(GridRegion.ROW_HEADER));
assertTrue(labels.contains(GridRegion.ROW_GROUP_HEADER));
assertTrue(labels.contains(GridRegion.BODY));
assertTrue(labels.contains(AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE));
assertTrue(labels.contains(AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE));
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_CELL));
assertTrue(labels.contains(SelectionStyleLabels.FILL_HANDLE_REGION));
assertTrue(labels.contains(SelectionStyleLabels.COPY_BORDER_STYLE));
assertTrue(labels.contains(DefaultRowGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE));
assertTrue(labels.contains(DefaultRowGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE));
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class SelectionModelTest method before.
@Before
public void before() {
SelectionLayer selectionLayer = new SelectionLayer(new DataLayerFixture(100, 100, 100, 40));
this.model = new SelectionModel(selectionLayer);
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class EditIntegrationTest method updateAllUnderlyingCellsIfSpanned.
@Test
public void updateAllUnderlyingCellsIfSpanned() throws Exception {
CompositeLayer layer = new CompositeLayer(1, 1);
DummySpanningBodyDataProvider dataProvider = new DummySpanningBodyDataProvider(100, 100);
SelectionLayer selectionLayer = new SelectionLayer(new SpanningDataLayer(dataProvider));
layer.setChildLayer(GridRegion.BODY, new ViewportLayer(selectionLayer), 0, 0);
this.natTable = new NatTableFixture(layer, 1200, 300, false);
layer.addConfiguration(new DefaultEditBindings());
layer.addConfiguration(new DefaultEditConfiguration());
this.natTable.enableEditingOnAllCells();
this.natTable.configure();
assertEquals("Col: 1, Row: 1", dataProvider.getDataValue(0, 0));
assertEquals("Col: 1, Row: 2", dataProvider.getDataValue(0, 1));
assertEquals("Col: 2, Row: 1", dataProvider.getDataValue(1, 0));
assertEquals("Col: 2, Row: 2", dataProvider.getDataValue(1, 1));
this.natTable.doCommand(new SelectCellCommand(this.natTable, 1, 1, false, false));
this.natTable.notifyListeners(SWT.KeyDown, SWTUtils.keyEventWithChar('C'));
assertNotNull(this.natTable.getActiveCellEditor());
this.natTable.getActiveCellEditor().getEditorControl().notifyListeners(SWT.KeyDown, SWTUtils.keyEvent(SWT.CR));
assertEquals("C", dataProvider.getDataValue(0, 0));
assertEquals("C", dataProvider.getDataValue(0, 1));
assertEquals("C", dataProvider.getDataValue(1, 0));
assertEquals("C", dataProvider.getDataValue(1, 1));
}
use of org.eclipse.nebula.widgets.nattable.selection.SelectionLayer in project nebula.widgets.nattable by eclipse.
the class RowStructuralChangeEventIntegrationTest method setUp.
@Before
public void setUp() {
this.contents = new ArrayList<String>(Arrays.asList("one", "two", "three", "four", "five"));
IDataProvider bodyDataProvider = new ListDataProvider<String>(this.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;
}
});
this.underlyingLayer = new DataLayer(bodyDataProvider);
this.rowReorderLayer = new RowReorderLayer(this.underlyingLayer);
this.rowHideShowLayer = new RowHideShowLayer(this.rowReorderLayer);
this.selectionLayer = new SelectionLayer(this.rowHideShowLayer);
this.viewportLayer = new ViewportLayer(this.selectionLayer);
IDataProvider colDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider);
ColumnHeaderLayer colHeader = new ColumnHeaderLayer(new DataLayer(colDataProvider), this.viewportLayer, this.selectionLayer);
IDataProvider rowDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowDataProvider), this.viewportLayer, this.selectionLayer);
CornerLayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(colDataProvider, rowDataProvider)), rowHeaderLayer, colHeader);
GridLayer grid = new GridLayer(this.viewportLayer, colHeader, rowHeaderLayer, cornerLayer);
this.natTable = new NatTable(new Shell(), grid);
this.natTable.setSize(600, 600);
}
Aggregations