use of org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnChooserUtilsTest method getVisibleColumnEntries.
@Test
public void getVisibleColumnEntries() throws Exception {
DefaultGridLayer gridLayer = new DefaultGridLayer(RowDataListFixture.getList(), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap());
ColumnHideShowLayer columnHideShowLayer = gridLayer.getBodyLayer().getColumnHideShowLayer();
ColumnHeaderLayer columnHeaderLayer = gridLayer.getColumnHeaderLayer();
DataLayer columnHeaderDataLayer = (DataLayer) gridLayer.getColumnHeaderDataLayer();
List<ColumnEntry> visibleEntries = ColumnChooserUtils.getVisibleColumnsEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer);
// All columns shown
assertEquals(RowDataListFixture.getPropertyNames().length, visibleEntries.size());
// Hide a few columns
gridLayer.getBodyLayer().getColumnHideShowLayer().hideColumnPositions(Arrays.asList(1, 2, 3));
visibleEntries = ColumnChooserUtils.getVisibleColumnsEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer);
assertEquals(RowDataListFixture.getPropertyNames().length - 3, visibleEntries.size());
// Check the hidden entries
List<ColumnEntry> hiddenEntries = ColumnChooserUtils.getHiddenColumnEntries(columnHideShowLayer, columnHeaderLayer, columnHeaderDataLayer);
assertEquals(3, hiddenEntries.size());
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer in project nebula.widgets.nattable by eclipse.
the class ConfigLabelProviderTest method testProvidedGridLabelsSortHeader.
@Test
public void testProvidedGridLabelsSortHeader() {
SelectionLayer selectionLayer = new SelectionLayer(this.bodyDataLayer);
GridLayer grid = new GridLayer(selectionLayer, new SortHeaderLayer<Person>(new ColumnHeaderLayer(this.columnHeaderDataLayer, this.bodyDataLayer, selectionLayer), new SortModelFixture()), this.rowHeaderDataLayer, this.cornerDataLayer);
Collection<String> labels = grid.getProvidedLabels();
assertEquals(19, labels.size());
assertTrue(labels.contains(GridRegion.CORNER));
assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
assertTrue(labels.contains(GridRegion.ROW_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(DefaultSortConfiguration.SORT_CONFIG_TYPE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + "0"));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + "1"));
assertTrue(labels.contains(DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + "2"));
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderLayerSelectionTest method willSelectBodyCellAndShouldHaveColumnHeaderSelected.
@Test
public void willSelectBodyCellAndShouldHaveColumnHeaderSelected() {
// Select body cell
// The column position is a grid layer position
this.gridLayer.doCommand(new SelectCellCommand(this.gridLayer, 2, 2, false, false));
// Get column header cell corresponding to the selected body cell
ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
// The column position is 1 because it takes into account the offset of
// the row header
ILayerCell cell = columnHeaderLayer.getCellByPosition(1, 0);
// Assert the cell is in selected state
assertEquals(DisplayMode.SELECT, cell.getDisplayMode());
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderLayerSelectionTest method shouldReturnProvidedLabels.
@Test
public void shouldReturnProvidedLabels() {
ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
columnHeaderLayer.setConfigLabelAccumulator(new IConfigLabelProvider() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
if (columnPosition == 2) {
configLabels.addLabel("test");
}
}
@Override
public Collection<String> getProvidedLabels() {
Set<String> result = new HashSet<String>();
result.add("test");
return result;
}
});
Collection<String> labels = columnHeaderLayer.getProvidedLabels();
assertEquals(1, labels.size());
assertEquals("test", labels.iterator().next());
}
use of org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnHeaderLayerSelectionTest method shouldReturnFullySelectedStyle.
@Test
public void shouldReturnFullySelectedStyle() {
// Select full column
this.gridLayer.doCommand(new ViewportSelectColumnCommand(this.gridLayer, 2, false, false));
ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
// Since I selected using grid coordinates, the column position should
// be 1 rather than 2
int columnPosition = this.gridLayer.localToUnderlyingColumnPosition(2);
final LabelStack labelStack = columnHeaderLayer.getConfigLabelsByPosition(columnPosition, 0);
assertTrue(labelStack.hasLabel(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE));
columnPosition = this.gridLayer.localToUnderlyingColumnPosition(3);
assertFalse(SelectionStyleLabels.COLUMN_FULLY_SELECTED_STYLE.equals(labelStack));
}
Aggregations