mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
8ae8334dad
4 changed files with 22 additions and 21 deletions
|
@ -1,6 +1,5 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,10 +15,6 @@
|
|||
*/
|
||||
package ghidra.app.plugin.core.datamgr.actions;
|
||||
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
|
||||
|
||||
import java.awt.datatransfer.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
@ -36,6 +31,9 @@ import docking.widgets.tree.GTree;
|
|||
import docking.widgets.tree.GTreeNode;
|
||||
import docking.widgets.tree.support.GTreeNodeTransferable;
|
||||
import docking.widgets.tree.support.GTreeTransferHandler;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
|
||||
import ghidra.app.plugin.core.datamgr.tree.DataTypeTreeNode;
|
||||
|
||||
public class CutAction extends DockingAction {
|
||||
private Clipboard clipboard;
|
||||
|
@ -50,6 +48,7 @@ public class CutAction extends DockingAction {
|
|||
setEnabled(true);
|
||||
|
||||
clipboardOwner = new ClipboardOwner() {
|
||||
@Override
|
||||
public void lostOwnership(Clipboard currentClipboard, Transferable transferable) {
|
||||
GTreeNodeTransferable gtTransferable = (GTreeNodeTransferable) transferable;
|
||||
List<GTreeNode> nodeList = gtTransferable.getAllData();
|
||||
|
@ -86,7 +85,7 @@ public class CutAction extends DockingAction {
|
|||
|
||||
// cut to clipboard
|
||||
TreePath[] paths = gTree.getSelectionPaths();
|
||||
List<GTreeNode> nodeList = createList(paths);
|
||||
List<GTreeNode> nodeList = createList(gTree, paths);
|
||||
|
||||
clearClipboard();
|
||||
|
||||
|
@ -103,12 +102,13 @@ public class CutAction extends DockingAction {
|
|||
}
|
||||
}
|
||||
|
||||
private ArrayList<GTreeNode> createList(TreePath[] paths) {
|
||||
ArrayList<GTreeNode> list = new ArrayList<GTreeNode>();
|
||||
private ArrayList<GTreeNode> createList(GTree gTree, TreePath[] paths) {
|
||||
ArrayList<GTreeNode> list = new ArrayList<>();
|
||||
if (paths != null) {
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
GTreeNode node = (GTreeNode) paths[i].getLastPathComponent();
|
||||
list.add(node);
|
||||
for (TreePath path : paths) {
|
||||
GTreeNode node = (GTreeNode) path.getLastPathComponent();
|
||||
GTreeNode modelNode = gTree.getModelNode(node);
|
||||
list.add(modelNode);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -19,8 +19,7 @@ import java.awt.datatransfer.*;
|
|||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
@ -124,7 +123,7 @@ public class PasteAction extends DockingAction {
|
|||
for (GTreeNode cutNode : nodeList) {
|
||||
DataTypeTreeNode dataTypeTreeNode = (DataTypeTreeNode) cutNode;
|
||||
ArchiveNode archiveNode = dataTypeTreeNode.getArchiveNode();
|
||||
if (archiveNode != destinationArchiveNode) {
|
||||
if (!Objects.equals(archiveNode, destinationArchiveNode)) {
|
||||
return true; // is invalid
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public class CutAction extends SymbolTreeContextAction {
|
|||
|
||||
clearClipboardFromPreviousCut();
|
||||
|
||||
List<GTreeNode> transferableList = createList(selectionPaths);
|
||||
List<GTreeNode> transferableList = createList(context.getSymbolTree(), selectionPaths);
|
||||
setClipboardContents(context.getSymbolTree(), provider.getClipboard(), transferableList);
|
||||
|
||||
setNodesCut(transferableList, true);
|
||||
|
@ -109,12 +109,13 @@ public class CutAction extends SymbolTreeContextAction {
|
|||
}
|
||||
}
|
||||
|
||||
private List<GTreeNode> createList(TreePath[] paths) {
|
||||
private List<GTreeNode> createList(GTree gTree, TreePath[] paths) {
|
||||
ArrayList<GTreeNode> list = new ArrayList<>();
|
||||
if (paths != null) {
|
||||
for (TreePath element : paths) {
|
||||
GTreeNode node = (GTreeNode) element.getLastPathComponent();
|
||||
list.add(node);
|
||||
GTreeNode modelNode = gTree.getModelNode(node);
|
||||
list.add(modelNode);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -94,6 +94,7 @@ public class SymbolNode extends SymbolTreeNode {
|
|||
@Override
|
||||
public void setNodeCut(boolean isCut) {
|
||||
this.isCut = isCut;
|
||||
fireNodeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue