package org.simantics.district.network.ui.table; import java.util.Collection; import org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler; import org.eclipse.nebula.widgets.nattable.layer.DataLayer; import org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent; import org.eclipse.nebula.widgets.nattable.layer.event.StructuralRefreshEvent; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.swt.dnd.Clipboard; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PasteDataCommandHandler extends AbstractLayerCommandHandler { private static final Logger LOGGER = LoggerFactory.getLogger(PasteDataCommandHandler.class); private final SelectionLayer selectionLayer; private final DataLayer dataLayer; private final Clipboard cpb; private final TableDataProvider provider; public PasteDataCommandHandler(TableDataProvider provider, DataLayer dataLayer, SelectionLayer selectionLayer, Clipboard cpb) { this.provider = provider; this.dataLayer = dataLayer; this.selectionLayer = selectionLayer; this.cpb = cpb; } @Override public Class getCommandClass() { return CustomPasteDataCommand.class; } @Override protected boolean doCommand(CustomPasteDataCommand command) { String[][] fullData = command.data; int pasteRow = command.pasteRow; Collection pasteColumn = command.getColumnPositions(); if (pasteRow > -1) { provider.setDataValues(pasteColumn, pasteRow, fullData); dataLayer.fireLayerEvent(new StructuralRefreshEvent(dataLayer)); } return true; } }