use of org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand in project nebula.widgets.nattable by eclipse.
the class MenuItemProviders method clearToggleFilterRowMenuItemProvider.
public static IMenuItemProvider clearToggleFilterRowMenuItemProvider(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("toggle_filter"));
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new ToggleFilterRowCommand());
}
});
}
};
}
use of org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowDataLayerTest method shouldHandleTheToggeleFilterRowCommand.
@Test
public void shouldHandleTheToggeleFilterRowCommand() throws Exception {
assertEquals(1, this.layerUnderTest.getRowCount());
this.layerUnderTest.doCommand(new ToggleFilterRowCommand());
// as the command is handled by the FilterRowHeaderComposite now, it
// should
// have no effect to do the command on the FilterRowDataLayer
assertEquals(1, this.layerUnderTest.getRowCount());
}
use of org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand in project nebula.widgets.nattable by eclipse.
the class FilterRowHeaderCompositeTest method shouldHandleTheToggeleFilterRowCommand.
@Test
public void shouldHandleTheToggeleFilterRowCommand() throws Exception {
Assert.assertEquals(3, this.layerUnderTest.getRowCount());
this.layerUnderTest.doCommand(new ToggleFilterRowCommand());
Assert.assertEquals(2, this.layerUnderTest.getRowCount());
this.layerUnderTest.doCommand(new ToggleFilterRowCommand());
Assert.assertEquals(3, this.layerUnderTest.getRowCount());
}
use of org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand 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);
}
}
Aggregations