Search in sources :

Example 1 with NatEventData

use of net.sourceforge.nattable.ui.NatEventData in project translationstudio8 by heartsome.

the class SortColumnAction method run.

public void run(NatTable natTable, MouseEvent event) {
    int columnPosition = ((NatEventData) event.data).getColumnPosition();
    natTable.doCommand(new SortColumnCommand(natTable, columnPosition, accumulate));
}
Also used : SortColumnCommand(net.sourceforge.nattable.sort.command.SortColumnCommand) NatEventData(net.sourceforge.nattable.ui.NatEventData)

Example 2 with NatEventData

use of net.sourceforge.nattable.ui.NatEventData in project translationstudio8 by heartsome.

the class CellLabelMouseEventMatcher method matches.

@Override
public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
    NatEventData eventData = NatEventData.createInstanceFromEvent(event);
    LabelStack customLabels = natTable.getConfigLabelsByPosition(eventData.getColumnPosition(), eventData.getRowPosition());
    return super.matches(natTable, event, regionLabels) && customLabels.getLabels().contains(labelToMatch);
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack) NatEventData(net.sourceforge.nattable.ui.NatEventData)

Example 3 with NatEventData

use of net.sourceforge.nattable.ui.NatEventData in project translationstudio8 by heartsome.

the class ButtonCellPainter method run.

/**
	 * Respond to mouse click. Simulate button press.
	 */
public void run(final NatTable natTable, MouseEvent event) {
    NatEventData eventData = (NatEventData) event.data;
    columnPosClicked = eventData.getColumnPosition();
    rowPosClicked = eventData.getRowPosition();
    recentlyClicked = true;
    new Timer().schedule(getButtonFlashTimerTask(natTable), buttonFlashTime);
    natTable.fireLayerEvent(new CellVisualChangeEvent(natTable, columnPosClicked, rowPosClicked));
    for (IMouseAction listener : clickLiseners) {
        listener.run(natTable, event);
    }
}
Also used : IMouseAction(net.sourceforge.nattable.ui.action.IMouseAction) Timer(java.util.Timer) NatEventData(net.sourceforge.nattable.ui.NatEventData) CellVisualChangeEvent(net.sourceforge.nattable.layer.event.CellVisualChangeEvent)

Example 4 with NatEventData

use of net.sourceforge.nattable.ui.NatEventData in project translationstudio8 by heartsome.

the class MenuItemProviders method inspectLabelsMenuItemProvider.

public static IMenuItemProvider inspectLabelsMenuItemProvider() {
    return new IMenuItemProvider() {

        public void addMenuItem(NatTable natTable, Menu popupMenu) {
            MenuItem inspectLabelsMenuItem = new MenuItem(popupMenu, SWT.PUSH);
            inspectLabelsMenuItem.setText("Debug info");
            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 = "Display mode: " + natTable.getDisplayModeByPosition(columnPosition, rowPosition) + "\nConfig labels: " + natTable.getConfigLabelsByPosition(columnPosition, rowPosition) + "\nData value: " + natTable.getDataValueByPosition(columnPosition, rowPosition) + "\n\nColumn position: " + columnPosition + "\nColumn index: " + natTable.getColumnIndexByPosition(columnPosition) + "\n\nRow position: " + rowPosition + "\nRow index: " + natTable.getRowIndexByPosition(rowPosition);
                    MessageBox messageBox = new MessageBox(natTable.getShell(), SWT.ICON_INFORMATION | SWT.OK);
                    messageBox.setText("Debug Information");
                    messageBox.setMessage(msg);
                    messageBox.open();
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) NatEventData(net.sourceforge.nattable.ui.NatEventData) Menu(org.eclipse.swt.widgets.Menu) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

NatEventData (net.sourceforge.nattable.ui.NatEventData)4 Timer (java.util.Timer)1 NatTable (net.sourceforge.nattable.NatTable)1 LabelStack (net.sourceforge.nattable.layer.LabelStack)1 CellVisualChangeEvent (net.sourceforge.nattable.layer.event.CellVisualChangeEvent)1 SortColumnCommand (net.sourceforge.nattable.sort.command.SortColumnCommand)1 IMouseAction (net.sourceforge.nattable.ui.action.IMouseAction)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 MessageBox (org.eclipse.swt.widgets.MessageBox)1