Search in sources :

Example 11 with RowStructuralRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.

the class GroupByHeaderLayer method setVisible.

public void setVisible(boolean visible) {
    this.visible = visible;
    fireLayerEvent(new RowStructuralRefreshEvent(getBaseLayer()));
}
Also used : RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 12 with RowStructuralRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.

the class GlazedListsEventLayer method getEventNotifier.

/**
 * Fires a NatTable refresh event, if any glazed list events have occurred.
 */
protected Runnable getEventNotifier() {
    return new Runnable() {

        @Override
        public void run() {
            if (GlazedListsEventLayer.this.eventsToProcess && GlazedListsEventLayer.this.active) {
                ILayerEvent layerEvent;
                if (GlazedListsEventLayer.this.structuralChangeEventsToProcess) {
                    layerEvent = new RowStructuralRefreshEvent(getUnderlyingLayer());
                } else {
                    layerEvent = new VisualRefreshEvent(getUnderlyingLayer());
                }
                fireEventFromSWTDisplayThread(layerEvent);
                GlazedListsEventLayer.this.eventsToProcess = false;
                GlazedListsEventLayer.this.structuralChangeEventsToProcess = false;
            }
        }
    };
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 13 with RowStructuralRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerIdIndexTest method shouldUpdateChangeOnSortAndDiscard.

@Test
public void shouldUpdateChangeOnSortAndDiscard() {
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 2));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 2, "Zoolander"));
    assertEquals("Zoolander", this.dataLayer.getDataValue(1, 2));
    // sort
    Collections.sort(this.dataModel, new Comparator<Person>() {

        @Override
        public int compare(Person o1, Person o2) {
            return o1.getLastName().compareTo(o2.getLastName());
        }
    });
    // fire event to trigger update of cached row indexes
    this.dataLayer.fireLayerEvent(new RowStructuralRefreshEvent(this.dataLayer));
    // now the dirty state should be on the last row
    assertEquals("Zoolander", this.dataLayer.getDataValue(1, 17));
    assertEquals("Zoolander", this.dataChangeLayer.getDataValueByPosition(1, 17));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 17).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 2 is dirty", this.dataChangeLayer.isRowDirty(2));
    assertTrue("Row 17 is not dirty", this.dataChangeLayer.isRowDirty(17));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 17));
    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());
    // check if discard is applied correctly
    this.dataChangeLayer.doCommand(new DiscardDataChangesCommand());
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 17));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 17));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 2).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 17).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 2 is dirty", this.dataChangeLayer.isRowDirty(2));
    assertFalse("Row 17 is dirty", this.dataChangeLayer.isRowDirty(17));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 17));
    assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
    assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : DiscardDataChangesCommand(org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person) Test(org.junit.Test)

Example 14 with RowStructuralRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.

the class RowSelectionModelStructuralChangeEventHandlerTest method shouldClearSelectionOnClearingTableWithRowStructuralRefresh.

@Test
public void shouldClearSelectionOnClearingTableWithRowStructuralRefresh() throws Exception {
    assertEquals(0, this.selectionLayer.getFullySelectedRowPositions().length);
    assertEquals(0, this.selectionLayer.getSelectedRowCount());
    this.nattable.doCommand(new SelectRowsCommand(this.nattable, 1, 1, false, false));
    assertEquals(1, this.selectionLayer.getFullySelectedRowPositions().length);
    assertEquals(1, this.selectionLayer.getSelectedRowCount());
    // Ford motor at top and selected
    assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 1).toString());
    assertEquals("B Ford Motor", getSelected().getSecurity_description());
    // clear the table
    this.listFixture.clear();
    // fire event to trigger structural refresh
    this.bodyDataLayer.fireLayerEvent(new RowStructuralRefreshEvent(this.bodyDataLayer));
    // row count of 1 for NatTable because of header
    assertEquals(1, this.nattable.getRowCount());
    assertEquals(0, this.selectionLayer.getSelectedRowCount());
    assertTrue("selection model is not empty", this.selectionLayer.getSelectionModel().getSelections().isEmpty());
}
Also used : RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Example 15 with RowStructuralRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.

the class FilterRowHeaderComposite method setFilterRowVisible.

public void setFilterRowVisible(boolean filterRowVisible) {
    this.filterRowVisible = filterRowVisible;
    fireLayerEvent(new RowStructuralRefreshEvent(this.filterRowDataLayer));
}
Also used : RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Aggregations

RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)16 Test (org.junit.Test)5 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)3 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)2 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)2 ClearAllFiltersCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand)2 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 DisposeResourcesCommand (org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand)1 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)1 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1 DiscardDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand)1 SaveDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand)1 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)1 ToggleFilterRowCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand)1 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)1