Search in sources :

Example 6 with GCFactory

use of org.eclipse.nebula.widgets.nattable.util.GCFactory in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method autoResizeColumnMenuItemProvider.

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

        @Override
        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH);
            autoResizeColumns.setText(Messages.getLocalizedMessage(menuLabel));
            // $NON-NLS-1$
            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 GCFactory(natTable)));
                }
            });
        }
    };
}
Also used : GCFactory(org.eclipse.nebula.widgets.nattable.util.GCFactory) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) InitializeAutoResizeColumnsCommand(org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeColumnsCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 7 with GCFactory

use of org.eclipse.nebula.widgets.nattable.util.GCFactory in project nebula.widgets.nattable by eclipse.

the class AutoResizeColumnAction method run.

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

Example 8 with GCFactory

use of org.eclipse.nebula.widgets.nattable.util.GCFactory 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

GCFactory (org.eclipse.nebula.widgets.nattable.util.GCFactory)8 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)3 InitializeAutoResizeColumnsCommand (org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeColumnsCommand)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Menu (org.eclipse.swt.widgets.Menu)3 MenuItem (org.eclipse.swt.widgets.MenuItem)3 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 TextPainter (org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter)2 InitializeAutoResizeRowsCommand (org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeRowsCommand)2 CellFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.CellFixture)2 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)2 GC (org.eclipse.swt.graphics.GC)2 Point (org.eclipse.swt.graphics.Point)2 Test (org.junit.Test)2 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1