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()));
}
});
}
};
}
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)));
}
});
}
};
}
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();
}
});
}
};
}
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));
}
});
}
};
}
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());
}
});
}
};
}
Aggregations