Search in sources :

Example 1 with ColumnHeaderLayer

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());
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) ColumnHeaderLayerFixture.getDataLayer(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ColumnHeaderLayerFixture.getDataLayer) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ColumnEntry(org.eclipse.nebula.widgets.nattable.columnChooser.ColumnEntry) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) Test(org.junit.Test)

Example 2 with ColumnHeaderLayer

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"));
}
Also used : SortModelFixture(org.eclipse.nebula.widgets.nattable.test.fixture.SortModelFixture) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Test(org.junit.Test)

Example 3 with ColumnHeaderLayer

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());
}
Also used : ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 4 with ColumnHeaderLayer

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());
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Set(java.util.Set) HashSet(java.util.HashSet) IConfigLabelProvider(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) Collection(java.util.Collection) Test(org.junit.Test)

Example 5 with ColumnHeaderLayer

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));
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ViewportSelectColumnCommand(org.eclipse.nebula.widgets.nattable.viewport.command.ViewportSelectColumnCommand) Test(org.junit.Test)

Aggregations

ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)101 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)93 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)88 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)82 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)77 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)73 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)73 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)73 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)73 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)72 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)66 HashMap (java.util.HashMap)63 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)63 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)62 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)61 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)58 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)53 GridLayout (org.eclipse.swt.layout.GridLayout)34 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)33 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)32