Search in sources :

Example 61 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.

the class MultiColumnResizeCommandTest method testMultiResizeWithDownscaleOnSelection.

@Test
public void testMultiResizeWithDownscaleOnSelection() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // select columns
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 3, 1, false, false));
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 4, 1, false, true));
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 5, 1, false, true));
    // scaling enabled, therefore default width of 100 pixels is up scaled
    // to 125
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(125, gridLayer.getColumnWidthByPosition(3));
    assertEquals(125, gridLayer.getColumnWidthByPosition(4));
    assertEquals(125, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
    // resize one of the selected columns
    ColumnResizeCommand columnResizeCommand = new ColumnResizeCommand(gridLayer, 3, 150, true);
    gridLayer.doCommand(columnResizeCommand);
    // command executed with down scaling enabled, therefore set width 150
    // is first down scaled on setting the value and then up scaled to 150
    // again on accessing the width
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(150, gridLayer.getColumnWidthByPosition(3));
    assertEquals(150, gridLayer.getColumnWidthByPosition(4));
    assertEquals(150, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 62 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.

the class MultiColumnResizeCommandTest method testMultiResizeWithDownscale.

@Test
public void testMultiResizeWithDownscale() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // scaling enabled, therefore default width of 100 pixels is up scaled
    // to 125
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(125, gridLayer.getColumnWidthByPosition(3));
    assertEquals(125, gridLayer.getColumnWidthByPosition(4));
    assertEquals(125, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
    MultiColumnResizeCommand resizeCommand = new MultiColumnResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 150, true);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling enabled, therefore set width 150
    // is first down scaled on setting the value and then up scaled to 150
    // again on accessing the width
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(150, gridLayer.getColumnWidthByPosition(3));
    assertEquals(150, gridLayer.getColumnWidthByPosition(4));
    assertEquals(150, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 63 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.

the class MultiRowResizeCommandTest method testMultiResizeWithDownscale.

@Test
public void testMultiResizeWithDownscale() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // scaling enabled, therefore default height of 20 pixels is up scaled
    // to 25
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(25, gridLayer.getRowHeightByPosition(3));
    assertEquals(25, gridLayer.getRowHeightByPosition(4));
    assertEquals(25, gridLayer.getRowHeightByPosition(5));
    assertEquals(25, gridLayer.getRowHeightByPosition(6));
    MultiRowResizeCommand resizeCommand = new MultiRowResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 50, true);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling enabled, therefore set height 50
    // is first down scaled on setting the value and then up scaled to 50
    // again on accessing the height
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(50, gridLayer.getRowHeightByPosition(3));
    assertEquals(50, gridLayer.getRowHeightByPosition(4));
    assertEquals(50, gridLayer.getRowHeightByPosition(5));
    assertEquals(25, gridLayer.getRowHeightByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 64 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.

the class ConfigLabelProviderTest method testProvidedGridLabelsFilterHeader.

@Test
public void testProvidedGridLabelsFilterHeader() {
    SelectionLayer selectionLayer = new SelectionLayer(this.bodyDataLayer);
    GridLayer grid = new GridLayer(selectionLayer, new FilterRowHeaderComposite<Person>(new IFilterStrategy<Person>() {

        @Override
        public void applyFilter(Map<Integer, Object> filterIndexToObjectMap) {
        }
    }, new SortHeaderLayer<Person>(new ColumnHeaderLayer(this.columnHeaderDataLayer, this.bodyDataLayer, selectionLayer), new SortModelFixture()), this.columnHeaderDataLayer.getDataProvider(), new ConfigRegistry()), this.rowHeaderDataLayer, this.cornerDataLayer);
    Collection<String> labels = grid.getProvidedLabels();
    assertEquals(26, 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"));
    assertTrue(labels.contains("columnHeader"));
    assertTrue(labels.contains(GridRegion.FILTER_ROW));
    assertTrue(labels.contains(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + "0"));
    assertTrue(labels.contains(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + "1"));
    assertTrue(labels.contains(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + "2"));
    assertTrue(labels.contains(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + "3"));
    assertTrue(labels.contains(FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + "4"));
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) 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) IFilterStrategy(org.eclipse.nebula.widgets.nattable.filterrow.IFilterStrategy) SortHeaderLayer(org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Map(java.util.Map) Test(org.junit.Test)

Example 65 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.

the class ConfigLabelProviderTest method testProvidedRegionLabels.

@Test
public void testProvidedRegionLabels() {
    GridLayer grid = new GridLayer(this.bodyDataLayer, this.columnHeaderDataLayer, this.rowHeaderDataLayer, this.cornerDataLayer, false);
    Collection<String> labels = grid.getProvidedLabels();
    assertEquals(4, labels.size());
    assertTrue(labels.contains(GridRegion.CORNER));
    assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
    assertTrue(labels.contains(GridRegion.ROW_HEADER));
    assertTrue(labels.contains(GridRegion.BODY));
    NatTable natTable = new NatTableFixture(grid);
    labels = natTable.getProvidedLabels();
    assertEquals(4, labels.size());
    assertTrue(labels.contains(GridRegion.CORNER));
    assertTrue(labels.contains(GridRegion.COLUMN_HEADER));
    assertTrue(labels.contains(GridRegion.ROW_HEADER));
    assertTrue(labels.contains(GridRegion.BODY));
}
Also used : NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Test(org.junit.Test)

Aggregations

GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)98 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)75 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)74 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)74 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)73 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)73 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)72 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)69 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)67 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)66 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)62 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)61 HashMap (java.util.HashMap)57 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)54 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)54 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)46 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)39 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)34 PopupMenuBuilder (org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)32 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)31