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()));
}
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;
}
}
};
}
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());
}
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());
}
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));
}
Aggregations