use of org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowDataLayer method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
boolean handled = false;
if (command instanceof ClearFilterCommand && command.convertToTargetLayer(this)) {
int columnPosition = ((ClearFilterCommand) command).getColumnPosition();
setDataValueByPosition(columnPosition, 0, null);
handled = true;
} else if (command instanceof ClearAllFiltersCommand) {
getFilterRowDataProvider().clearAllFilters();
handled = true;
}
if (handled) {
fireLayerEvent(new RowStructuralRefreshEvent(this));
return true;
} else {
return super.doCommand(command);
}
}
use of org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowDataLayerTest method shouldHandleTheClearAllFiltersCommand.
@Test
public void shouldHandleTheClearAllFiltersCommand() throws Exception {
assertEquals(13, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 1, 0, "ford"));
assertEquals(1, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 0, 0, "XXX"));
assertEquals(0, this.filterList.size());
this.layerUnderTest.doCommand(new ClearAllFiltersCommand());
assertEquals(13, this.filterList.size());
this.listener.containsInstanceOf(RowStructuralRefreshEvent.class);
}
use of org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowHeaderCompositeTest method shouldHandleTheClearAllFiltersCommand.
@Test
public void shouldHandleTheClearAllFiltersCommand() throws Exception {
Assert.assertEquals(13, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 1, 2, "ford"));
Assert.assertEquals(1, this.filterList.size());
this.layerUnderTest.doCommand(new UpdateDataCommand(this.layerUnderTest, 0, 2, "XXX"));
Assert.assertEquals(0, this.filterList.size());
this.layerUnderTest.doCommand(new ClearAllFiltersCommand());
Assert.assertEquals(13, this.filterList.size());
this.listener.containsInstanceOf(RowStructuralRefreshEvent.class);
}
use of org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand 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.filterrow.command.ClearAllFiltersCommand in project nebula.widgets.nattable by eclipse.
the class MenuItemProviders method clearAllFiltersMenuItemProvider.
public static IMenuItemProvider clearAllFiltersMenuItemProvider(final String menuLabel) {
return new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
menuItem.setText(Messages.getLocalizedMessage(menuLabel));
// $NON-NLS-1$
menuItem.setImage(GUIHelper.getImage("remove_filter"));
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new ClearAllFiltersCommand());
}
});
}
};
}
Aggregations