use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.
the class PreserveSelectionModelStructuralChangeEventHandlerTest method shouldRemovePartialCellSelectionOnColumnDelete.
@Test
public void shouldRemovePartialCellSelectionOnColumnDelete() {
assertTrue("selection is not empty", this.selectionLayer.getSelectedCells().isEmpty());
this.nattable.doCommand(new SelectCellCommand(this.nattable, 1, 1, false, false));
assertEquals(1, this.selectionLayer.getSelectedCells().size());
this.nattable.doCommand(new SelectCellCommand(this.nattable, 1, 2, false, true));
this.nattable.doCommand(new SelectCellCommand(this.nattable, 2, 1, false, true));
this.nattable.doCommand(new SelectCellCommand(this.nattable, 2, 2, false, true));
assertEquals(4, this.selectionLayer.getSelectedCells().size());
this.nattable.doCommand(new ColumnHideCommand(this.nattable, 1));
Collection<ILayerCell> selectedCells = this.selectionLayer.getSelectedCells();
assertEquals(2, selectedCells.size());
// moved to the left
for (ILayerCell cell : selectedCells) {
assertEquals(0, cell.getColumnPosition());
}
// insert again to verify the column position shift
this.nattable.doCommand(new ShowAllColumnsCommand());
// the deselected cells shouldn't get automatically selected again
selectedCells = this.selectionLayer.getSelectedCells();
assertEquals(2, selectedCells.size());
// moved to the right
for (ILayerCell cell : selectedCells) {
assertEquals(1, cell.getColumnPosition());
}
}
use of org.eclipse.nebula.widgets.nattable.hideshow.command.ShowAllColumnsCommand in project nebula.widgets.nattable by eclipse.
the class MenuItemProviders method showAllColumnsMenuItemProvider.
/**
* Will create and return the {@link IMenuItemProvider} that adds the action
* for executing the {@link ShowAllColumnsCommand} to a popup menu. This
* command is intended to show all columns of the NatTable and is used to
* unhide previous hidden columns.
* <p>
* The {@link MenuItem} will be shown with the given menu label.
*
* @param menuLabel
* The text that will be showed for the generated
* {@link MenuItem}
* @return The {@link IMenuItemProvider} for the {@link MenuItem} that
* executes the {@link ShowAllColumnsCommand}.
*/
public static IMenuItemProvider showAllColumnsMenuItemProvider(final String menuLabel) {
return new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, Menu popupMenu) {
MenuItem showAllColumns = new MenuItem(popupMenu, SWT.PUSH);
showAllColumns.setText(Messages.getLocalizedMessage(menuLabel));
// $NON-NLS-1$
showAllColumns.setImage(GUIHelper.getImage("show_column"));
showAllColumns.setEnabled(true);
showAllColumns.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new ShowAllColumnsCommand());
}
});
}
};
}
Aggregations