Search in sources :

Example 56 with Range

use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.

the class ViewportEventHandler method handleLayerEvent.

@Override
public void handleLayerEvent(IStructuralChangeEvent event) {
    IUniqueIndexLayer scrollableLayer = this.viewportLayer.getScrollableLayer();
    if (event.isHorizontalStructureChanged()) {
        this.viewportLayer.invalidateHorizontalStructure();
        int columnOffset = 0;
        int minimumOriginColumnPosition = this.viewportLayer.getMinimumOriginColumnPosition();
        Collection<StructuralDiff> columnDiffs = event.getColumnDiffs();
        if (columnDiffs != null) {
            if (minimumOriginColumnPosition < 0) {
                // this is for handling of hide/show behaviour
                // the value can only be -1 in case the column for which the
                // minimum origin was set before
                // was hidden, so we try to determine the correct value now
                // if it is shown again
                minimumOriginColumnPosition = scrollableLayer.getColumnPositionByX(this.viewportLayer.getMinimumOrigin().getX());
            }
            for (StructuralDiff columnDiff : columnDiffs) {
                switch(columnDiff.getDiffType()) {
                    case ADD:
                        Range afterPositionRange = columnDiff.getAfterPositionRange();
                        if (minimumOriginColumnPosition > 0) {
                            for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
                                if (i < minimumOriginColumnPosition) {
                                    minimumOriginColumnPosition++;
                                }
                            }
                        }
                        break;
                    case DELETE:
                        Range beforePositionRange = columnDiff.getBeforePositionRange();
                        if (minimumOriginColumnPosition > 0) {
                            for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
                                if (i < minimumOriginColumnPosition) {
                                    columnOffset -= 1;
                                }
                            }
                        }
                        break;
                }
            }
        }
        int minimumOriginColumn = minimumOriginColumnPosition + columnOffset;
        // of the calculated value
        if (this.viewportLayer.getMinColumnPosition() >= 0) {
            minimumOriginColumn = this.viewportLayer.getMinColumnPosition();
        }
        // if the new origin is out of range (e.g. the last column in the
        // viewport is moved
        // to the frozen region, the minimum origin need to be updated in
        // another way
        int startX = scrollableLayer.getStartXOfColumnPosition(minimumOriginColumn);
        if (startX < 0 && minimumOriginColumnPosition > 0) {
            int columnCount = scrollableLayer.getColumnCount();
            if (columnCount == 0) {
                // special case when all columns are hidden
                startX = 0;
            } else {
                startX = scrollableLayer.getStartXOfColumnPosition(columnCount - 1) + scrollableLayer.getColumnWidthByPosition(columnCount - 1);
            }
        }
        this.viewportLayer.setMinimumOriginX(startX);
    }
    if (event.isVerticalStructureChanged()) {
        this.viewportLayer.invalidateVerticalStructure();
        int rowOffset = 0;
        int minimumOriginRowPosition = this.viewportLayer.getMinimumOriginRowPosition();
        Collection<StructuralDiff> rowDiffs = event.getRowDiffs();
        if (rowDiffs != null) {
            if (minimumOriginRowPosition < 0) {
                // this is for handling of hide/show behaviour
                // the value can only be -1 in case the row for which the
                // minimum origin was set before
                // was hidden, so we try to determine the correct value now
                // if it is shown again
                minimumOriginRowPosition = scrollableLayer.getRowPositionByY(this.viewportLayer.getMinimumOrigin().getY());
            }
            for (StructuralDiff rowDiff : rowDiffs) {
                switch(rowDiff.getDiffType()) {
                    case ADD:
                        Range afterPositionRange = rowDiff.getAfterPositionRange();
                        if (minimumOriginRowPosition > 0) {
                            for (int i = afterPositionRange.start; i < afterPositionRange.end; i++) {
                                if (i < minimumOriginRowPosition) {
                                    minimumOriginRowPosition++;
                                }
                            }
                        }
                        break;
                    case DELETE:
                        Range beforePositionRange = rowDiff.getBeforePositionRange();
                        if (minimumOriginRowPosition > 0) {
                            for (int i = beforePositionRange.start; i < beforePositionRange.end; i++) {
                                if (i < minimumOriginRowPosition) {
                                    rowOffset -= 1;
                                }
                            }
                        }
                        break;
                }
            }
        }
        int minimumOriginRow = minimumOriginRowPosition + rowOffset;
        // the calculated value
        if (this.viewportLayer.getMinRowPosition() >= 0) {
            minimumOriginRow = this.viewportLayer.getMinRowPosition();
        }
        // if the new origin is out of range (e.g. the last row in the
        // viewport is moved
        // to the frozen region, the minimum origin need to be updated in
        // another way
        int startY = scrollableLayer.getStartYOfRowPosition(minimumOriginRow);
        if (startY < 0 && minimumOriginRowPosition > 0) {
            int rowCount = scrollableLayer.getRowCount();
            if (rowCount == 0) {
                // special case when all rows are hidden
                startY = 0;
            } else {
                startY = scrollableLayer.getStartYOfRowPosition(rowCount - 1) + scrollableLayer.getRowHeightByPosition(rowCount - 1);
            }
        }
        this.viewportLayer.setMinimumOriginY(startY);
    }
}
Also used : StructuralDiff(org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff) IUniqueIndexLayer(org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range)

Example 57 with Range

use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.

the class _5053_SelectionEventsExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("birthday", "Birthday");
    IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    final List<Person> data = PersonService.getPersons(10);
    // create the body layer stack
    final IRowDataProvider<Person> bodyDataProvider = new ListDataProvider<>(data, columnPropertyAccessor);
    final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    final SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    // create the column header layer stack
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    ILayer columnHeaderLayer = new ColumnHeaderLayer(new DataLayer(columnHeaderDataProvider), viewportLayer, selectionLayer);
    // create the row header layer stack
    IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    ILayer rowHeaderLayer = new RowHeaderLayer(new DefaultRowHeaderDataLayer(new DefaultRowHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
    // create the corner layer stack
    ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, columnHeaderLayer);
    // create the grid layer composed with the prior created layer stacks
    GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
    final NatTable natTable = new NatTable(parent, gridLayer);
    // Events are fired whenever selection occurs. These can be use to
    // trigger external actions as required.
    // 
    // This adds a custom ILayerListener that will listen and handle
    // selection events on NatTable level
    natTable.addLayerListener(new ILayerListener() {

        // Default selection behavior selects cells by default.
        @Override
        public void handleLayerEvent(ILayerEvent event) {
            if (event instanceof CellSelectionEvent) {
                CellSelectionEvent cellEvent = (CellSelectionEvent) event;
                log("Selected cell: [" + cellEvent.getRowPosition() + ", " + cellEvent.getColumnPosition() + "], " + natTable.getDataValueByPosition(cellEvent.getColumnPosition(), cellEvent.getRowPosition()));
            } else if (event instanceof ColumnSelectionEvent) {
                ColumnSelectionEvent columnEvent = (ColumnSelectionEvent) event;
                log("Selected Column: " + columnEvent.getColumnPositionRanges());
            } else if (event instanceof RowSelectionEvent) {
                // directly ask the SelectionLayer about the selected rows
                // and access the data via IRowDataProvider
                Collection<Range> selections = selectionLayer.getSelectedRowPositions();
                StringBuilder builder = new StringBuilder("Selected Persons: ").append(selectionLayer.getSelectedRowPositions()).append("[");
                for (Range r : selections) {
                    for (int i = r.start; i < r.end; i++) {
                        Person p = bodyDataProvider.getRowObject(i);
                        if (p != null) {
                            if (!builder.toString().endsWith("[")) {
                                builder.append(", ");
                            }
                            builder.append(p.getFirstName()).append(" ").append(p.getLastName());
                        }
                    }
                }
                builder.append("]");
                log(builder.toString());
            }
        }
    });
    // Layout widgets
    parent.setLayout(new GridLayout(1, true));
    natTable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    // add a log area to the example to show the log entries
    setupTextArea(parent);
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) GridLayout(org.eclipse.swt.layout.GridLayout) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) ColumnSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.ColumnSelectionEvent) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) CellSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) RowSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent) GridData(org.eclipse.swt.layout.GridData) Collection(java.util.Collection) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person)

Example 58 with Range

use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.

the class DetailGlazedListsEventLayer method listChanged.

/*
     * (non-Javadoc)
     *
     * @see
     * ca.odell.glazedlists.event.ListEventListener#listChanged(ca.odell.glazedlists
     * .event.ListEvent)
     */
/**
 * GlazedLists event handling. Will transform received GlazedLists
 * ListEvents into corresponding NatTable RowStructuralChangeEvents. Ensures
 * that no other changes can be made to the GlazedLists instance until the
 * events are processed in NatTable itself. This is necessary to avoid
 * concurrent modifications which will lead to asynchronous states of
 * NatTable and GlazedLists.
 */
@Override
public void listChanged(final ListEvent<T> event) {
    try {
        this.eventList.getReadWriteLock().readLock().lock();
        int currentEventType = -1;
        // as the delete events in GlazedLists are containing indexes that
        // are related
        // to prior deletes we need to ensure index consistency within
        // NatTable,
        // e.g. filtering so the complete list would be empty would result
        // in getting
        // events that all tell that index 0 is deleted
        int deleteCount = 0;
        final List<Range> deleteRanges = new ArrayList<Range>();
        final List<Range> insertRanges = new ArrayList<Range>();
        while (event.next()) {
            int eventType = event.getType();
            // first event, go ahead
            if (currentEventType == -1) {
                currentEventType = eventType;
            } else if (currentEventType != eventType) {
                // there is a new event type, fire the collected events
                internalFireEvents(deleteRanges, insertRanges);
                // and clear for clean further processing
                deleteRanges.clear();
                deleteCount = 0;
                insertRanges.clear();
            }
            if (eventType == ListEvent.DELETE) {
                int index = event.getIndex() + deleteCount;
                deleteRanges.add(new Range(index, index + 1));
                deleteCount++;
            } else if (eventType == ListEvent.INSERT) {
                insertRanges.add(new Range(event.getIndex(), event.getIndex() + 1));
            }
        }
        internalFireEvents(deleteRanges, insertRanges);
    } finally {
        this.eventList.getReadWriteLock().readLock().unlock();
    }
}
Also used : ArrayList(java.util.ArrayList) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range)

Example 59 with Range

use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project tdq-studio-se by Talend.

the class DataSampleTable method addCustomSelectionBehaviour.

private void addCustomSelectionBehaviour() {
    natTable.addLayerListener(new ILayerListener() {

        @Override
        public void handleLayerEvent(ILayerEvent event) {
            if (event instanceof ColumnHeaderSelectionEvent) {
                ColumnHeaderSelectionEvent columnEvent = (ColumnHeaderSelectionEvent) event;
                Collection<Range> ranges = columnEvent.getColumnPositionRanges();
                if (ranges.size() > 0) {
                    Range range = ranges.iterator().next();
                    handleColumnSelectionChange(range.start);
                }
            } else if (event instanceof ColumnReorderEvent) {
                if (ColumnIndexMap == null) {
                    ColumnIndexMap = new HashMap<String, Integer>();
                } else {
                    ColumnIndexMap.clear();
                }
                // save propertyNames oder into lastTimePropertyNameOrder
                initPropertyNameOrder();
                // Fill elements into ColumnIndexMap before the order change ones.
                fillPreElement();
                // Fill the oder all of elements which display on the table into ColumnIndexMap
                fillElementWhichDisplayOnTable();
                // Fill the oder all of elements which after the order change ones.
                fillEndElement();
                // update newest order state on the lastTimePropertyNameOrder list
                savePropertyNameState();
                notifyObservers();
            }
        }

        /**
         * DOC talend Comment method "fillElementWhichDisplayOnTable". copy by #fillElementWhichDisplayOnTable
         */
        private void fillElementWhichDisplayOnTable() {
            for (int index = 1; index < natTable.getColumnCount(); index++) {
                int columnIndexByPosition = natTable.getColumnIndexByPosition(index);
                ColumnIndexMap.put(propertyNames[columnIndexByPosition], ColumnIndexMap.size());
            }
        }

        private void fillEndElement() {
            for (int index = ColumnIndexMap.size(); index < propertyNames.length; index++) {
                ColumnIndexMap.put(lastTimePropertyNameOrder.get(index), index);
            }
        }

        private void fillPreElement() {
            int disColumnCount = natTable.getColumnCount() - 1;
            // display all case so that no preElement one need to be filled
            if (disColumnCount >= lastTimePropertyNameOrder.size()) {
                return;
            }
            // not all display
            String endName = propertyNames[natTable.getColumnIndexByPosition(1)];
            int firstOneLastPosition = lastTimePropertyNameOrder.indexOf(endName);
            endName = propertyNames[natTable.getColumnIndexByPosition(2)];
            int secondOneLastPosition = lastTimePropertyNameOrder.indexOf(endName);
            if (secondOneLastPosition - firstOneLastPosition > 0) {
                // 1 is not be change order case
                endName = lastTimePropertyNameOrder.get(firstOneLastPosition);
                // For example 1->2+
                if (secondOneLastPosition - firstOneLastPosition == 1) {
                    String moveColName = findMoveColumnName(firstOneLastPosition - 1);
                    if (moveColName != null) {
                        endName = moveColName;
                    }
                }
            // For example 1->2,2+->1
            } else if (secondOneLastPosition - firstOneLastPosition < 0) {
                // in fact the value shoud be
                // firstOneLastPosition+secondOneLastPosition-firstOneLastPosition
                endName = lastTimePropertyNameOrder.get(secondOneLastPosition);
            }
            // ~ not all display
            int index = 0;
            for (String propertyName : lastTimePropertyNameOrder) {
                if (endName.equals(propertyName)) {
                    break;
                }
                ColumnIndexMap.put(propertyName, index++);
            }
        }

        /**
         * Find the column name which be moved on the ui
         *
         * @param spacing
         * @return
         */
        private String findMoveColumnName(int spacing) {
            for (int index = 3; index < natTable.getColumnCount() - 1; index++) {
                String propertyName = propertyNames[natTable.getColumnIndexByPosition(index)];
                int lastPosition = lastTimePropertyNameOrder.indexOf(propertyName);
                if (spacing > lastPosition - index) {
                    return propertyName;
                } else if (spacing == lastPosition - index) {
                    continue;
                } else {
                    break;
                }
            }
            return null;
        }
    });
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ColumnHeaderSelectionEvent(org.eclipse.nebula.widgets.nattable.grid.layer.event.ColumnHeaderSelectionEvent) Collection(java.util.Collection) ColumnReorderEvent(org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range)

Example 60 with Range

use of org.eclipse.nebula.widgets.nattable.coordinate.Range in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldUpdateOnMultiRowInsert.

@Test
public void shouldUpdateOnMultiRowInsert() {
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 3, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 5, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 7, "Lovejoy"));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 9, "Lovejoy"));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 0));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 2));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 3));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 4));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 5));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 6));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 7));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 8));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 9));
    this.dataModel.add(9, new Person(44, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(7, new Person(43, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(5, new Person(42, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(3, new Person(41, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataModel.add(1, new Person(40, "Nelson", "Muntz", Gender.MALE, false, new Date(), 100d));
    this.dataLayer.fireLayerEvent(new RowInsertEvent(this.dataLayer, new Range(1, 1), new Range(3, 3), new Range(5, 5), new Range(7, 7), new Range(9, 9)));
    assertEquals(23, this.dataModel.size());
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 0));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 2));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 3));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 4));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 5));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 6));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 7));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 8));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 9));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 10));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 11));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 12));
    assertEquals("Muntz", this.dataLayer.getDataValue(1, 13));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 14));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 0));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 2));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 3));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 4));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 5));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 6));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 7));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 8));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 9));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 10));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 11));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 12));
    assertEquals("Muntz", this.dataChangeLayer.getDataValueByPosition(1, 13));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 14));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 0).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 3).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 4).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 5).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 6).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 7).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 9).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 10).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 11).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 12).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 13).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 14).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 15).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 0 is not dirty", this.dataChangeLayer.isRowDirty(0));
    assertFalse("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
    assertTrue("Row 2 is not dirty", this.dataChangeLayer.isRowDirty(2));
    assertFalse("Row 3 is not dirty", this.dataChangeLayer.isRowDirty(3));
    assertFalse("Row 4 is not dirty", this.dataChangeLayer.isRowDirty(4));
    assertTrue("Row 5 is not dirty", this.dataChangeLayer.isRowDirty(5));
    assertFalse("Row 6 is not dirty", this.dataChangeLayer.isRowDirty(6));
    assertFalse("Row 7 is not dirty", this.dataChangeLayer.isRowDirty(7));
    assertTrue("Row 8 is not dirty", this.dataChangeLayer.isRowDirty(8));
    assertFalse("Row 9 is not dirty", this.dataChangeLayer.isRowDirty(9));
    assertFalse("Row 10 is not dirty", this.dataChangeLayer.isRowDirty(10));
    assertTrue("Row 11 is not dirty", this.dataChangeLayer.isRowDirty(11));
    assertFalse("Row 12 is not dirty", this.dataChangeLayer.isRowDirty(12));
    assertFalse("Row 13 is not dirty", this.dataChangeLayer.isRowDirty(13));
    assertTrue("Row 14 is not dirty", this.dataChangeLayer.isRowDirty(14));
    assertFalse("Row 15 is not dirty", this.dataChangeLayer.isRowDirty(15));
    assertFalse("Row 16 is not dirty", this.dataChangeLayer.isRowDirty(16));
    assertFalse("Row 17 is not dirty", this.dataChangeLayer.isRowDirty(17));
    assertFalse("Row 18 is not dirty", this.dataChangeLayer.isRowDirty(18));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 2));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 5));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 8));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 11));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 14));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 4));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(0, 2));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(2, 3));
    assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
    assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : RowInsertEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)115 Test (org.junit.Test)54 ArrayList (java.util.ArrayList)40 StructuralDiff (org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff)23 HashSet (java.util.HashSet)12 Rectangle (org.eclipse.swt.graphics.Rectangle)12 RowDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent)9 RowSelectionEvent (org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent)9 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 RenameColumnHeaderCommand (org.eclipse.nebula.widgets.nattable.columnRename.RenameColumnHeaderCommand)6 HideRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent)6 ColumnResizeEvent (org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent)6 ShowRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)5 ColumnReorderEvent (org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent)5 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)5 Point (org.eclipse.swt.graphics.Point)5 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)4