Search in sources :

Example 1 with InitializeAutoResizeColumnsCommand

use of net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand in project translationstudio8 by heartsome.

the class AutoResizeColumnAction method run.

public void run(NatTable natTable, MouseEvent event) {
    if (gc == null) {
        gc = new GC(natTable);
        natTable.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                gc.dispose();
            }
        });
    }
    Point clickPoint = new Point(event.x, event.y);
    int column = CellEdgeDetectUtil.getColumnPositionToResize(natTable, clickPoint);
    InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(natTable, column, natTable.getConfigRegistry(), gc);
    natTable.doCommand(command);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) InitializeAutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point)

Example 2 with InitializeAutoResizeColumnsCommand

use of net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand in project translationstudio8 by heartsome.

the class InitializeAutoResizeColumnsCommandHandler method doCommand.

@Override
protected boolean doCommand(InitializeAutoResizeColumnsCommand initCommand) {
    int columnPosition = initCommand.getColumnPosition();
    if (selectionLayer.isColumnFullySelected(columnPosition)) {
        initCommand.setSelectedColumnPositions(selectionLayer.getFullySelectedColumnPositions());
    } else {
        initCommand.setSelectedColumnPositions(new int[] { columnPosition });
    }
    // Fire command carrying the selected columns
    initCommand.getSourceLayer().doCommand(new AutoResizeColumnsCommand(initCommand));
    return true;
}
Also used : InitializeAutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand) AutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.AutoResizeColumnsCommand)

Example 3 with InitializeAutoResizeColumnsCommand

use of net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand in project translationstudio8 by heartsome.

the class MenuItemProviders method autoResizeColumnMenuItemProvider.

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

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH);
            autoResizeColumns.setText("Auto resize column");
            autoResizeColumns.setImage(GUIHelper.getImage("auto_resize"));
            autoResizeColumns.setEnabled(true);
            autoResizeColumns.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    int columnPosition = getNatEventData(event).getColumnPosition();
                    natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, columnPosition, natTable.getConfigRegistry(), new GC(natTable)));
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) InitializeAutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) GC(org.eclipse.swt.graphics.GC)

Example 4 with InitializeAutoResizeColumnsCommand

use of net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand in project translationstudio8 by heartsome.

the class MenuItemProviders method autoResizeAllSelectedColumnMenuItemProvider.

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

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH);
            autoResizeColumns.setText("Auto resize all selected columns");
            autoResizeColumns.setEnabled(true);
            autoResizeColumns.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    int columnPosition = getNatEventData(event).getColumnPosition();
                    natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, columnPosition, natTable.getConfigRegistry(), new GC(natTable)));
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) InitializeAutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) GC(org.eclipse.swt.graphics.GC)

Aggregations

InitializeAutoResizeColumnsCommand (net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand)4 GC (org.eclipse.swt.graphics.GC)3 NatTable (net.sourceforge.nattable.NatTable)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 AutoResizeColumnsCommand (net.sourceforge.nattable.resize.command.AutoResizeColumnsCommand)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 Point (org.eclipse.swt.graphics.Point)1