Search in sources :

Example 1 with ToggleFilterRowCommand

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

Example 2 with 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());
}
Also used : ToggleFilterRowCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand) Test(org.junit.Test)

Example 3 with ToggleFilterRowCommand

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

Example 4 with ToggleFilterRowCommand

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

Aggregations

ToggleFilterRowCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand)4 Test (org.junit.Test)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 DisposeResourcesCommand (org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand)1 ClearAllFiltersCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand)1 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)1 RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)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