Search in sources :

Example 6 with NatEventData

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();
                }
            });
        }
    };
}
Also used : 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) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData) Menu(org.eclipse.swt.widgets.Menu) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 7 with NatEventData

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));
                }
            });
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IMenuItemProvider(org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) UngroupByColumnIndexCommand(org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.command.UngroupByColumnIndexCommand) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData) Menu(org.eclipse.swt.widgets.Menu) PopupMenuBuilder(org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)

Example 8 with NatEventData

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData)

Example 9 with NatEventData

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));
                }
            });
        }
    };
}
Also used : DisplayColumnGroupRenameDialogCommand(org.eclipse.nebula.widgets.nattable.group.command.DisplayColumnGroupRenameDialogCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IMenuItemProvider(org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData) Menu(org.eclipse.swt.widgets.Menu)

Example 10 with NatEventData

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);
    }
}
Also used : IMouseAction(org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction) Timer(java.util.Timer) NatEventData(org.eclipse.nebula.widgets.nattable.ui.NatEventData) CellVisualChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)

Aggregations

NatEventData (org.eclipse.nebula.widgets.nattable.ui.NatEventData)13 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Menu (org.eclipse.swt.widgets.Menu)7 MenuItem (org.eclipse.swt.widgets.MenuItem)7 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 IMenuItemProvider (org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemProvider)3 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)2 DisplayColumnGroupRenameDialogCommand (org.eclipse.nebula.widgets.nattable.group.command.DisplayColumnGroupRenameDialogCommand)2 RemoveColumnGroupCommand (org.eclipse.nebula.widgets.nattable.group.command.RemoveColumnGroupCommand)2 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)2 Timer (java.util.Timer)1 UngroupByColumnIndexCommand (org.eclipse.nebula.widgets.nattable.extension.glazedlists.groupBy.command.UngroupByColumnIndexCommand)1 CellVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)1 SortColumnCommand (org.eclipse.nebula.widgets.nattable.sort.command.SortColumnCommand)1 IMouseAction (org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction)1 PopupMenuBuilder (org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1