-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change copy/paste of rows in NatTable to also handle imports
- Loading branch information
1 parent
71d87e5
commit e82d618
Showing
11 changed files
with
223 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
...eclipse.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/widget/CopyDataFromTableAction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../org.eclipse.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/widget/DataObjectTransfer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Primetals Technologies Austria GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Sebastian Hollersbacher - initial API and implementation and/or initial documentation | ||
*******************************************************************************/ | ||
package org.eclipse.fordiac.ide.ui.widget; | ||
|
||
import org.eclipse.gef.dnd.SimpleObjectTransfer; | ||
|
||
public class DataObjectTransfer extends SimpleObjectTransfer { | ||
private static final DataObjectTransfer INSTANCE = new DataObjectTransfer(); | ||
private static final String TYPE_NAME = "org.eclipse.4diac.clipboard.transfer.dataObject"; //$NON-NLS-1$ | ||
private static final int TYPE_ID = registerType(TYPE_NAME); | ||
|
||
private DataObjectTransfer() { | ||
} | ||
|
||
public static DataObjectTransfer getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
protected int[] getTypeIds() { | ||
return new int[] { TYPE_ID }; | ||
} | ||
|
||
@Override | ||
protected String[] getTypeNames() { | ||
return new String[] { TYPE_NAME }; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...e.fordiac.ide.ui/src/org/eclipse/fordiac/ide/ui/widget/FordiacCopyDataCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Primetals Technologies Austria GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Sebastian Hollersbacher - initial API and implementation and/or initial documentation | ||
*******************************************************************************/ | ||
package org.eclipse.fordiac.ide.ui.widget; | ||
|
||
import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataCommandHandler; | ||
import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataToClipboardCommand; | ||
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; | ||
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; | ||
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; | ||
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; | ||
import org.eclipse.swt.dnd.Clipboard; | ||
import org.eclipse.swt.dnd.Transfer; | ||
import org.eclipse.swt.widgets.Display; | ||
|
||
public class FordiacCopyDataCommandHandler extends CopyDataCommandHandler { | ||
public FordiacCopyDataCommandHandler(final SelectionLayer selectionLayer) { | ||
super(selectionLayer); | ||
} | ||
|
||
@Override | ||
protected void internalDoCommand(final CopyDataToClipboardCommand command, | ||
final ILayerCell[][] assembledCopiedDataStructure) { | ||
super.internalDoCommand(command, assembledCopiedDataStructure); | ||
|
||
final Clipboard clipboard = new Clipboard(Display.getDefault()); | ||
final int[] rows = selectionLayer.getFullySelectedRowPositions(); | ||
if (rows.length > 0) { | ||
final ListDataProvider<?> provider = (ListDataProvider<?>) ((DataLayer) selectionLayer | ||
.getUnderlyingLayerByPosition(0, 0)).getDataProvider(); | ||
|
||
int i = 0; | ||
final Object[] objects = new Object[rows.length]; | ||
for (final int row : rows) { | ||
objects[i] = provider.getRowObject(row); | ||
i++; | ||
} | ||
|
||
clipboard.setContents(new Object[] { objects }, new Transfer[] { DataObjectTransfer.getInstance() }); | ||
} | ||
|
||
clipboard.dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.