use of org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand in project nebula.widgets.nattable by eclipse.
the class GroupByDataLayer method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
if (command instanceof CalculateSummaryRowValuesCommand) {
// summary values
for (int i = 0; i < getRowCount(); i++) {
if (this.treeData.getDataAtIndex(i) instanceof GroupByObject) {
for (int j = 0; j < getColumnCount(); j++) {
LabelStack labelStack = getConfigLabelsByPosition(j, i);
final IGroupBySummaryProvider<T> summaryProvider = getGroupBySummaryProvider(labelStack);
if (summaryProvider != null) {
GroupByObject groupByObject = (GroupByObject) this.treeData.getDataAtIndex(i);
final List<T> children = getItemsInGroup(groupByObject);
final int col = j;
this.valueCache.getCalculatedValue(j, i, new GroupByValueCacheKey(j, i, groupByObject), false, new ICalculator() {
@Override
public Object executeCalculation() {
return summaryProvider.summarize(col, children);
}
});
}
}
}
}
// we do not return true here, as there might be other layers
// involved in the composition that also need to calculate the
// summary values immediately
} else if (command instanceof DisposeResourcesCommand) {
// ensure to clear the caches to avoid memory leaks
this.treeFormat.clearComparatorCache();
this.valueCache.killCache();
this.valueCache.dispose();
}
return super.doCommand(command);
}
use of org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand in project nebula.widgets.nattable by eclipse.
the class ComboBoxFilterRowHeaderComposite method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
boolean handled = false;
if (command instanceof ToggleFilterRowCommand) {
setFilterRowVisible(!this.filterRowVisible);
return true;
} else // to the FilterRowDataLayer
if (command instanceof ClearFilterCommand && command.convertToTargetLayer(this)) {
int columnPosition = ((ClearFilterCommand) command).getColumnPosition();
this.filterRowDataLayer.setDataValueByPosition(columnPosition, 0, getComboBoxDataProvider().getValues(columnPosition, 0));
handled = true;
} else if (command instanceof ClearAllFiltersCommand) {
setAllValuesSelected();
handled = true;
} else if (command instanceof DisposeResourcesCommand) {
this.comboBoxDataProvider.dispose();
}
if (handled) {
fireLayerEvent(new RowStructuralRefreshEvent(this));
return true;
} else {
return super.doCommand(command);
}
}
use of org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand in project nebula.widgets.nattable by eclipse.
the class GlazedListsEventLayerTest method shouldShutConflaterThreadDownWhenNatTableIsDisposed.
@Test
public void shouldShutConflaterThreadDownWhenNatTableIsDisposed() throws Exception {
Assert.assertFalse(this.layerUnderTest.isDisposed());
this.listFixture.add(RowDataFixture.getInstance("T1", "A"));
Thread.sleep(100);
this.listFixture.add(RowDataFixture.getInstance("T2", "A"));
Thread.sleep(100);
this.layerUnderTest.doCommand(new DisposeResourcesCommand());
Assert.assertTrue(this.layerUnderTest.isDisposed());
}
use of org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand in project nebula.widgets.nattable by eclipse.
the class NatTableTest method shouldFireDisposeCommandOnDisposal.
@Test
public void shouldFireDisposeCommandOnDisposal() throws Exception {
AnyCommandHandlerFixture commandHandler = new AnyCommandHandlerFixture();
this.underlyingLayerFixture.registerCommandHandler(commandHandler);
this.natTable.dispose();
assertEquals(1, commandHandler.getNumberOfCommandsHandled());
assertTrue(commandHandler.getCommadHandled() instanceof DisposeResourcesCommand);
}
Aggregations