import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
+import org.eclipse.nebula.widgets.nattable.export.command.ExportCommand;
+import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider;
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
//add default configuration because autoconfigure is set to false in constructor
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
-
// add custom configuration for data conversion
viewportLayer.addConfiguration(new AbstractRegistryConfiguration() {
}
});
+ // add the ExportCommandHandler to the ViewportLayer in order to make
+ // exporting work
+ viewportLayer.registerCommandHandler(new ExportCommandHandler(viewportLayer));
+
//propagate single cell selection
natTable.addLayerListener(new ILayerListener() {
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
+ //excel export
+ Button addColumnButton = new Button(parent, SWT.PUSH);
+ addColumnButton.setText("Export");
+ addColumnButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ natTable.doCommand(
+ new ExportCommand(
+ natTable.getConfigRegistry(),
+ natTable.getShell()));
+ }
+ });
+
parent.layout();
}