Search in sources :

Example 16 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method exportToImageMenuItemProvider.

/**
 * Will create and return the {@link IMenuItemProvider} that adds the action
 * for executing the {@link ExportTableCommand} to a popup menu. This
 * command is intended to export the NatTable to image.
 * <p>
 * The {@link MenuItem} will be shown with the given menu label.
 * </p>
 * <p>
 * <b>IMPORTANT:</b> the {@link ImageExporter} needs to be configured for
 * the configuration attribute {@link ExportConfigAttributes#TABLE_EXPORTER}
 * to really export to an image. Also the {@link ExportTableCommandHandler}
 * needs to be registered on an {@link ILayer} in the layer stack, e.g. the
 * GridLayer.
 * </p>
 *
 * @param menuLabel
 *            The text that will be showed for the generated
 *            {@link MenuItem}
 * @return The {@link IMenuItemProvider} for the {@link MenuItem} that
 *         executes the {@link ExportTableCommand}.
 * @since 1.5
 */
public static IMenuItemProvider exportToImageMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        @Override
        public void addMenuItem(final NatTable natTable, Menu popupMenu) {
            MenuItem exportToImage = new MenuItem(popupMenu, SWT.PUSH);
            exportToImage.setText(Messages.getLocalizedMessage(menuLabel));
            // $NON-NLS-1$
            exportToImage.setImage(GUIHelper.getImage("export_image"));
            exportToImage.setEnabled(true);
            exportToImage.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    natTable.doCommand(new ExportTableCommand(natTable.getConfigRegistry(), natTable.getShell()));
                }
            });
        }
    };
}
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) Menu(org.eclipse.swt.widgets.Menu) ExportTableCommand(org.eclipse.nebula.widgets.nattable.export.command.ExportTableCommand)

Example 17 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method autoResizeAllSelectedColumnMenuItemProvider.

public static IMenuItemProvider autoResizeAllSelectedColumnMenuItemProvider(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));
            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 18 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable 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 19 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method categoriesBasedColumnChooserMenuItemProvider.

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

        @Override
        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem columnChooser = new MenuItem(popupMenu, SWT.PUSH);
            columnChooser.setText(Messages.getLocalizedMessage(menuLabel));
            // $NON-NLS-1$
            columnChooser.setImage(GUIHelper.getImage("column_categories_chooser"));
            columnChooser.setEnabled(true);
            columnChooser.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    natTable.doCommand(new ChooseColumnsFromCategoriesCommand(natTable));
                }
            });
        }
    };
}
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) Menu(org.eclipse.swt.widgets.Menu) ChooseColumnsFromCategoriesCommand(org.eclipse.nebula.widgets.nattable.columnCategories.ChooseColumnsFromCategoriesCommand)

Example 20 with NatTable

use of org.eclipse.nebula.widgets.nattable.NatTable in project nebula.widgets.nattable by eclipse.

the class MenuItemProviders method clearToggleFilterRowMenuItemProvider.

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

        @Override
        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
            menuItem.setText(Messages.getLocalizedMessage(menuLabel));
            // $NON-NLS-1$
            menuItem.setImage(GUIHelper.getImage("toggle_filter"));
            menuItem.setEnabled(true);
            menuItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    natTable.doCommand(new ToggleFilterRowCommand());
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToggleFilterRowCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand) 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)

Aggregations

NatTable (org.eclipse.nebula.widgets.nattable.NatTable)221 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)150 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)113 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)100 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)90 HashMap (java.util.HashMap)88 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)88 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)79 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)75 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)74 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)73 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)73 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)72 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)72 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)72 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)71 SelectionEvent (org.eclipse.swt.events.SelectionEvent)67 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)66 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)66 GridLayout (org.eclipse.swt.layout.GridLayout)64