Search in sources :

Example 76 with SelectionLayer

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"));
}
Also used : ITreeData(org.eclipse.nebula.widgets.nattable.tree.ITreeData) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) TreeLayer(org.eclipse.nebula.widgets.nattable.tree.TreeLayer) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Test(org.junit.Test)

Example 77 with SelectionLayer

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));
}
Also used : RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) RowGroupModel(org.eclipse.nebula.widgets.nattable.group.model.RowGroupModel) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Test(org.junit.Test)

Example 78 with SelectionLayer

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);
}
Also used : SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) SelectionModel(org.eclipse.nebula.widgets.nattable.selection.SelectionModel) Before(org.junit.Before)

Example 79 with 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));
}
Also used : DefaultEditConfiguration(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) SelectCellCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand) DummySpanningBodyDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummySpanningBodyDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) DefaultEditBindings(org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings) Test(org.junit.Test)

Example 80 with SelectionLayer

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);
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) RowReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer) DummyColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) Shell(org.eclipse.swt.widgets.Shell) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) RowHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer) Before(org.junit.Before)

Aggregations

SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)107 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)75 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)73 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)71 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)63 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)58 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)54 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)47 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)46 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)44 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)43 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)43 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)42 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)41 HashMap (java.util.HashMap)38 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)37 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)34 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)27 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)25 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)25