Search in sources :

Example 1 with InitializeAutoResizeRowsCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand in project nebula.widgets.nattable by eclipse.

the class InitializeAutoResizeRowsCommandHandler method doCommand.

@Override
protected boolean doCommand(InitializeAutoResizeRowsCommand initCommand) {
    int rowPosition = initCommand.getRowPosition();
    if (this.selectionLayer.isRowPositionFullySelected(rowPosition)) {
        initCommand.setSelectedRowPositions(this.selectionLayer.getFullySelectedRowPositions());
    } else {
        initCommand.setSelectedRowPositions(new int[] { rowPosition });
    }
    // Fire command carrying the selected columns
    initCommand.getSourceLayer().doCommand(new AutoResizeRowsCommand(initCommand));
    return true;
}
Also used : AutoResizeRowsCommand(org.eclipse.nebula.widgets.nattable.resize.command.AutoResizeRowsCommand) InitializeAutoResizeRowsCommand(org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand)

Example 2 with InitializeAutoResizeRowsCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand in project nebula.widgets.nattable by eclipse.

the class AutoResizeRowAction method run.

@Override
public void run(NatTable natTable, MouseEvent event) {
    Point clickPoint = new Point(event.x, event.y);
    int row = CellEdgeDetectUtil.getRowPositionToResize(natTable, clickPoint);
    InitializeAutoResizeRowsCommand command = new InitializeAutoResizeRowsCommand(natTable, row, natTable.getConfigRegistry(), new GCFactory(natTable));
    natTable.doCommand(command);
}
Also used : GCFactory(org.eclipse.nebula.widgets.nattable.util.GCFactory) InitializeAutoResizeRowsCommand(org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 3 with InitializeAutoResizeRowsCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method autoResizeRowMenuItemProvider.

public static IMenuItemProvider autoResizeRowMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        @Override
        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem autoResizeRows = new MenuItem(popupMenu, SWT.PUSH);
            autoResizeRows.setText(Messages.getLocalizedMessage(menuLabel));
            autoResizeRows.setEnabled(true);
            autoResizeRows.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    int rowPosition = getNatEventData(event).getRowPosition();
                    natTable.doCommand(new InitializeAutoResizeRowsCommand(natTable, rowPosition, natTable.getConfigRegistry(), new GCFactory(natTable)));
                }
            });
        }
    };
}
Also used : GCFactory(org.eclipse.nebula.widgets.nattable.util.GCFactory) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) InitializeAutoResizeRowsCommand(org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

InitializeAutoResizeRowsCommand (org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand)3 GCFactory (org.eclipse.nebula.widgets.nattable.util.GCFactory)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 AutoResizeRowsCommand (org.eclipse.nebula.widgets.nattable.resize.command.AutoResizeRowsCommand)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Point (org.eclipse.swt.graphics.Point)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1