Search in sources :

Example 1 with ClearAllFiltersCommand

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);
    }
}
Also used : ClearFilterCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand) ClearAllFiltersCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 2 with ClearAllFiltersCommand

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);
}
Also used : ClearAllFiltersCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 3 with ClearAllFiltersCommand

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);
}
Also used : ClearAllFiltersCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 4 with ClearAllFiltersCommand

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);
    }
}
Also used : DisposeResourcesCommand(org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand) ClearFilterCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand) ClearAllFiltersCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand) ToggleFilterRowCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 5 with ClearAllFiltersCommand

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());
                }
            });
        }
    };
}
Also used : ClearAllFiltersCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

ClearAllFiltersCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand)5 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)2 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)2 RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)2 Test (org.junit.Test)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 DisposeResourcesCommand (org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand)1 ToggleFilterRowCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1