use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class MenuItemProviders method inspectLabelsMenuItemProvider.
public static IMenuItemProvider inspectLabelsMenuItemProvider() {
return new IMenuItemProvider() {
@Override
public void addMenuItem(NatTable natTable, Menu popupMenu) {
MenuItem inspectLabelsMenuItem = new MenuItem(popupMenu, SWT.PUSH);
// $NON-NLS-1$
inspectLabelsMenuItem.setText(Messages.getString("MenuItemProviders.debugInfo"));
inspectLabelsMenuItem.setEnabled(true);
inspectLabelsMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
NatEventData natEventData = getNatEventData(e);
NatTable natTable = natEventData.getNatTable();
int columnPosition = natEventData.getColumnPosition();
int rowPosition = natEventData.getRowPosition();
String msg = // $NON-NLS-1$ //$NON-NLS-2$
"Display mode: " + natTable.getDisplayModeByPosition(columnPosition, rowPosition) + "\nConfig labels: " + natTable.getConfigLabelsByPosition(columnPosition, rowPosition) + // $NON-NLS-1$
"\nData value: " + natTable.getDataValueByPosition(columnPosition, rowPosition) + "\n\nColumn position: " + columnPosition + // $NON-NLS-1$ //$NON-NLS-2$
"\nColumn index: " + natTable.getColumnIndexByPosition(columnPosition) + "\n\nRow position: " + rowPosition + // $NON-NLS-1$ //$NON-NLS-2$
"\nRow index: " + natTable.getRowIndexByPosition(rowPosition);
MessageBox messageBox = new MessageBox(natTable.getShell(), SWT.ICON_INFORMATION | SWT.OK);
// $NON-NLS-1$
messageBox.setText(Messages.getString("MenuItemProviders.debugInformation"));
messageBox.setMessage(msg);
messageBox.open();
}
});
}
};
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class GroupByHeaderMenuConfiguration method createGroupByHeaderMenu.
/**
* Creates the {@link PopupMenuBuilder} for the groupBy header menu with the
* menu items to ungroup.
*
* @param natTable
* The NatTable where the menu should be attached.
* @return The {@link PopupMenuBuilder} that is used to build the groupBy
* header menu.
*/
protected PopupMenuBuilder createGroupByHeaderMenu(NatTable natTable) {
return new PopupMenuBuilder(natTable).withMenuItemProvider(UNGROUP_BY_MENU_ITEM_ID, new IMenuItemProvider() {
@Override
public void addMenuItem(final NatTable natTable, Menu popupMenu) {
MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
// $NON-NLS-1$
menuItem.setText(Messages.getLocalizedMessage("%GroupByHeaderMenuConfiguration.ungroupBy"));
menuItem.setEnabled(true);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
NatEventData natEventData = MenuItemProviders.getNatEventData(event);
MouseEvent originalEvent = natEventData.getOriginalEvent();
int groupByColumnIndex = GroupByHeaderMenuConfiguration.this.groupByHeaderLayer.getGroupByColumnIndexAtXY(originalEvent.x, originalEvent.y);
natTable.doCommand(new UngroupByColumnIndexCommand(groupByColumnIndex));
}
});
}
});
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class FilterRowMouseEventMatcher method matches.
@Override
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
NatEventData eventData = NatEventData.createInstanceFromEvent(event);
LabelStack labels = eventData.getRegionLabels();
if (isNotNull(labels)) {
return labels.getLabels().contains(GridRegion.FILTER_ROW);
}
return false;
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class ColumnGroupMenuItemProviders method renameColumnGroupMenuItemProvider.
public static IMenuItemProvider renameColumnGroupMenuItemProvider(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();
natTable.doCommand(new DisplayColumnGroupRenameDialogCommand(natTable, columnPosition));
}
});
}
};
}
use of org.eclipse.nebula.widgets.nattable.ui.NatEventData in project nebula.widgets.nattable by eclipse.
the class ButtonCellPainter method run.
/**
* Respond to mouse click. Simulate button press.
*/
@Override
public void run(final NatTable natTable, MouseEvent event) {
NatEventData eventData = (NatEventData) event.data;
this.columnPosClicked = eventData.getColumnPosition();
this.rowPosClicked = eventData.getRowPosition();
this.recentlyClicked = true;
new Timer().schedule(getButtonFlashTimerTask(natTable), this.buttonFlashTime);
natTable.fireLayerEvent(new CellVisualChangeEvent(natTable, this.columnPosClicked, this.rowPosClicked));
for (IMouseAction listener : this.clickLiseners) {
listener.run(natTable, event);
}
}
Aggregations