Package org.eclipse.nebula.widgets.nattable.layer.stack

Examples of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack


    public Control createExampleControl(Composite parent) {
        // Body
        final DummyBodyDataProvider bodyDataProvider = new DummyBodyDataProvider(
                20, 1000);
        final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
        final DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(
                bodyDataLayer);
        final SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
        final FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
        final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(
                freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);

        // Column header
        final IDataProvider columnHeaderDataProvider = new DummyColumnHeaderDataProvider(
                bodyDataProvider);
        final ILayer columnHeaderLayer = new ColumnHeaderLayer(
View Full Code Here


                propertyNames);
        ListDataProvider<Person> listDataProvider = new ListDataProvider<Person>(
                myList, columnPropertyAccessor);
        DefaultGridLayer gridLayer = new DefaultGridLayer(listDataProvider,
                new DummyColumnHeaderDataProvider(listDataProvider));
        final DefaultBodyLayerStack bodyLayer = gridLayer.getBodyLayer();

        // Custom label "FOO" for cell at column, row index (1, 5)
        IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {
            public void accumulateConfigLabels(LabelStack configLabels,
                    int columnPosition, int rowPosition) {
                int columnIndex = bodyLayer
                        .getColumnIndexByPosition(columnPosition);
                int rowIndex = bodyLayer.getRowIndexByPosition(rowPosition);
                if (columnIndex == 1 && rowIndex == 5) {
                    configLabels.addLabel(FOO_LABEL);
                }
                if (columnIndex == 1 && rowIndex == 10) {
                    configLabels.addLabel(BAR_LABEL);
                }

                // add labels for surrounding borders
                if (rowIndex == 13) {
                    configLabels
                            .addLabel(CustomLineBorderDecorator.TOP_LINE_BORDER_LABEL);
                    configLabels
                            .addLabel(CustomLineBorderDecorator.BOTTOM_LINE_BORDER_LABEL);

                    if (columnIndex == 0) {
                        configLabels
                                .addLabel(CustomLineBorderDecorator.LEFT_LINE_BORDER_LABEL);
                    }
                    if (columnIndex == 2) {
                        configLabels
                                .addLabel(CustomLineBorderDecorator.RIGHT_LINE_BORDER_LABEL);
                    }
                }
            }
        };
        bodyLayer.setConfigLabelAccumulator(cellLabelAccumulator);

        NatTable natTable = new NatTable(parent, gridLayer, false);

        natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
            {
View Full Code Here

        natTable.configure();
        return natTable;
    }

    private void configureColumnCategoriesInChooser() {
        DefaultBodyLayerStack bodyLayer = this.gridLayer.getBodyLayerStack();
        ColumnCategoriesModel model = new ColumnCategoriesModelFixture();

        bodyLayer
        .registerCommandHandler(new ChooseColumnsFromCategoriesCommandHandler(
                bodyLayer.getColumnHideShowLayer(), this.gridLayer
                .getColumnHeaderLayerStack()
                .getColumnHeaderLayer(), this.gridLayer
                .getColumnHeaderLayerStack().getDataLayer(),
                model));
    }
View Full Code Here

        // Register a command handler for the StyleEditorDialog
        DisplayColumnStyleEditorCommandHandler styleChooserCommandHandler = new DisplayColumnStyleEditorCommandHandler(
                gridLayer.getBodyLayer().getSelectionLayer(),
                columnLabelAccumulator, natTable.getConfigRegistry());

        DefaultBodyLayerStack bodyLayer = gridLayer.getBodyLayer();
        bodyLayer.registerCommandHandler(styleChooserCommandHandler);

        // Register the style editor as persistable
        // This will persist the style applied to the columns when
        // NatTable#saveState is invoked
        bodyLayer.registerPersistable(styleChooserCommandHandler);
        bodyLayer.registerPersistable(columnLabelAccumulator);

        return natTable;
    }
View Full Code Here

    private SelectionLayer selectionLayer;

    @Before
    public void setup() {
        dataLayer = new DataLayerFixture(10, 10);
        DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(dataLayer);

        selectionLayer = bodyLayer.getSelectionLayer();
        selectionModel = selectionLayer.getSelectionModel();
    }
View Full Code Here

    /**
     * Fix for http://nattable.org/jira/browse/NTBL-476
     */
    @Test
    public void reorderEventMustPropagateToTheTop() throws Exception {
        DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(
                new DataLayerFixture(20, 10, 100, 20));
        NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer);

        // Add listener
        LayerListenerFixture listenerFixture = new LayerListenerFixture();
View Full Code Here

        assertEquals(4, natTableFixture.getColumnIndexByPosition(1));
    }

    @Test
    public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
        DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(
                new DataLayerFixture(10, 10, 100, 20));
        NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer,
                1000, 400, true);

        // Add listener
        LayerListenerFixture listenerFixture = new LayerListenerFixture();
        natTableFixture.addLayerListener(listenerFixture);

        assertEquals(10, natTableFixture.getColumnCount());

        // hide some columns
        natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture,
                new int[] { 2, 5, 8 }));

        assertEquals(7, natTableFixture.getColumnCount());

        List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
        int destinationPosition = 0;
        natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer
                .getColumnReorderLayer(), columnToMove, destinationPosition));

        // verify the event
        ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture
                .getReceivedEvent(ColumnReorderEvent.class);
        assertNotNull(event);

        assertTrue(StructuralChangeEventHelper
                .isReorder(event.getColumnDiffs()));

        assertEquals(7, natTableFixture.getColumnCount());

        assertEquals(0, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(3));
        assertEquals(1, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(4));
        assertEquals(2, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(6));
        assertEquals(3, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(7));
        assertEquals(4, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(0));
        assertEquals(5, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(1));
        assertEquals(6, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(2));
        assertEquals(7, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(5));
        assertEquals(8, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(8));
        assertEquals(9, underlyingLayer.getColumnReorderLayer()
                .getColumnPositionByIndex(9));
    }
View Full Code Here

                .getReceivedEvent(RowReorderEvent.class));
    }

    @Test
    public void reorderEventMustPropagateToTheTop() throws Exception {
        DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(
                new RowReorderLayer(new DataLayerFixture(10, 10, 100, 20)));
        NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer);

        // Add listener
        LayerListenerFixture listenerFixture = new LayerListenerFixture();
View Full Code Here

        // create the body layer stack
        IDataProvider bodyDataProvider = new ListDataProvider<Map<String, String>>(
                values, new MyColumnPropertyAccessor());
        final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
        DefaultBodyLayerStack bodyLayerStack = new DefaultBodyLayerStack(
                bodyDataLayer);

        // create the column header layer stack
        IDataProvider columnHeaderDataProvider = new SimpleColumnHeaderDataProvider();
        ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(
                columnHeaderDataProvider), bodyLayerStack.getViewportLayer(),
                bodyLayerStack.getSelectionLayer());

        // create the row header layer stack
        IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
                bodyDataProvider);
        ILayer rowHeaderLayer = new RowHeaderLayer(
                new DefaultRowHeaderDataLayer(new DefaultRowHeaderDataProvider(
                        bodyDataProvider)), bodyLayerStack.getViewportLayer(),
                bodyLayerStack.getSelectionLayer());

        // create the corner layer stack
        ILayer cornerLayer = new CornerLayer(new DataLayer(
                new DefaultCornerDataProvider(columnHeaderDataProvider,
                        rowHeaderDataProvider)), rowHeaderLayer,
View Full Code Here

                        1000000, 1000000))))));
    }

    @Test
    public void testDefaultBodyLayerStackPerformance() {
        layer = new DefaultBodyLayerStack(new DataLayer(
                new DummyBodyDataProvider(1000000, 1000000)));
    }
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.