1 package org.simantics.district.network.ui.table;
3 import java.util.Collection;
5 import org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler;
6 import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
7 import org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent;
8 import org.eclipse.nebula.widgets.nattable.layer.event.StructuralRefreshEvent;
9 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
10 import org.eclipse.swt.dnd.Clipboard;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
14 public class PasteDataCommandHandler extends AbstractLayerCommandHandler<CustomPasteDataCommand> {
16 private static final Logger LOGGER = LoggerFactory.getLogger(PasteDataCommandHandler.class);
18 private final SelectionLayer selectionLayer;
19 private final DataLayer dataLayer;
20 private final Clipboard cpb;
21 private final TableDataProvider provider;
23 public PasteDataCommandHandler(TableDataProvider provider, DataLayer dataLayer, SelectionLayer selectionLayer, Clipboard cpb) {
24 this.provider = provider;
25 this.dataLayer = dataLayer;
26 this.selectionLayer = selectionLayer;
31 public Class<CustomPasteDataCommand> getCommandClass() {
32 return CustomPasteDataCommand.class;
36 protected boolean doCommand(CustomPasteDataCommand command) {
37 String[][] fullData = command.data;
38 int pasteRow = command.pasteRow;
39 Collection<Integer> pasteColumn = command.getColumnPositions();
41 provider.setDataValues(pasteColumn, pasteRow, fullData);
42 dataLayer.fireLayerEvent(new StructuralRefreshEvent(dataLayer));