use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class MenuItemProvidersTest method shouldGetDataFromParentForNestedMenus.
@Test
public void shouldGetDataFromParentForNestedMenus() throws Exception {
Display display = Display.getDefault();
Shell shell = new Shell(display);
Menu menu = new Menu(shell, SWT.POP_UP);
menu.setData(MenuItemProviders.NAT_EVENT_DATA_KEY, new NatEventData(null, null, 5, 1, null));
MenuItem item1 = new MenuItem(menu, SWT.PUSH);
item1.setText("Push Item");
MenuItem item2 = new MenuItem(menu, SWT.CASCADE);
item2.setText("Cascade Item");
Menu subMenu = new Menu(menu);
item2.setMenu(subMenu);
MenuItem subItem1 = new MenuItem(subMenu, SWT.PUSH);
subItem1.setText("Subitem 1");
MenuItem subItem2 = new MenuItem(subMenu, SWT.PUSH);
subItem2.setText("Subitem 2");
Event testEvent = new Event();
testEvent.widget = shell;
SelectionEvent selectionEvent = new SelectionEvent(testEvent);
selectionEvent.widget = subItem2;
NatEventData natEventData = MenuItemProviders.getNatEventData(selectionEvent);
Assert.assertNotNull(natEventData);
Assert.assertEquals(5, natEventData.getColumnPosition());
Assert.assertEquals(1, natEventData.getRowPosition());
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class ClearAllFiltersAction method run.
@Override
public void run(NatTable natTable, MouseEvent event) {
NatEventData natEventData = (NatEventData) event.data;
natTable.doCommand(new ClearFilterCommand(natTable, natEventData.getColumnPosition()));
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class ClearFilterAction method run.
@Override
public void run(NatTable natTable, MouseEvent event) {
NatEventData natEventData = (NatEventData) event.data;
natTable.doCommand(new ClearFilterCommand(natTable, natEventData.getColumnPosition()));
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class ColumnGroupMenuItemProviders method removeColumnGroupMenuItemProvider.
public static IMenuItemProvider removeColumnGroupMenuItemProvider(final String menuLabel) {
return new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
columnStyleEditor.setText(menuLabel);
columnStyleEditor.setEnabled(true);
columnStyleEditor.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
NatEventData natEventData = MenuItemProviders.getNatEventData(e);
int columnPosition = natEventData.getColumnPosition();
int columnIndex = natEventData.getNatTable().getColumnIndexByPosition(columnPosition);
natTable.doCommand(new RemoveColumnGroupCommand(columnIndex));
}
});
}
};
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class SortColumnAction method run.
@Override
public void run(NatTable natTable, MouseEvent event) {
int columnPosition = ((NatEventData) event.data).getColumnPosition();
natTable.doCommand(new SortColumnCommand(natTable, columnPosition, this.accumulate));
}
Aggregations