mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02:00
GT-2870 - Symbol Tree - fixed ClassCastException when clicking the
InProgressNode
This commit is contained in:
parent
8caff82460
commit
f0af82b021
2 changed files with 22 additions and 14 deletions
|
@ -1,6 +1,5 @@
|
||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -17,8 +16,6 @@
|
||||||
package ghidra.app.plugin.core.symboltree.actions;
|
package ghidra.app.plugin.core.symboltree.actions;
|
||||||
|
|
||||||
import static docking.KeyBindingPrecedence.ActionMapLevel;
|
import static docking.KeyBindingPrecedence.ActionMapLevel;
|
||||||
import ghidra.app.plugin.core.symboltree.*;
|
|
||||||
import ghidra.app.plugin.core.symboltree.nodes.SymbolTreeNode;
|
|
||||||
|
|
||||||
import java.awt.datatransfer.*;
|
import java.awt.datatransfer.*;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
|
@ -30,13 +27,15 @@ import javax.swing.Icon;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
import resources.ResourceManager;
|
|
||||||
import docking.action.KeyBindingData;
|
import docking.action.KeyBindingData;
|
||||||
import docking.action.MenuData;
|
import docking.action.MenuData;
|
||||||
import docking.widgets.tree.GTree;
|
import docking.widgets.tree.GTree;
|
||||||
import docking.widgets.tree.GTreeNode;
|
import docking.widgets.tree.GTreeNode;
|
||||||
import docking.widgets.tree.support.GTreeNodeTransferable;
|
import docking.widgets.tree.support.GTreeNodeTransferable;
|
||||||
import docking.widgets.tree.support.GTreeTransferHandler;
|
import docking.widgets.tree.support.GTreeTransferHandler;
|
||||||
|
import ghidra.app.plugin.core.symboltree.*;
|
||||||
|
import ghidra.app.plugin.core.symboltree.nodes.SymbolTreeNode;
|
||||||
|
import resources.ResourceManager;
|
||||||
|
|
||||||
public class CutAction extends SymbolTreeContextAction {
|
public class CutAction extends SymbolTreeContextAction {
|
||||||
private final static Icon CUT_ICON = ResourceManager.loadImage("images/edit-cut22.png");
|
private final static Icon CUT_ICON = ResourceManager.loadImage("images/edit-cut22.png");
|
||||||
|
@ -51,12 +50,10 @@ public class CutAction extends SymbolTreeContextAction {
|
||||||
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK);
|
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK);
|
||||||
setKeyBindingData(new KeyBindingData(keyStroke, ActionMapLevel));
|
setKeyBindingData(new KeyBindingData(keyStroke, ActionMapLevel));
|
||||||
|
|
||||||
clipboardOwner = new ClipboardOwner() {
|
clipboardOwner = (currentClipboard, transferable) -> {
|
||||||
public void lostOwnership(Clipboard currentClipboard, Transferable transferable) {
|
GTreeNodeTransferable gtTransferable = (GTreeNodeTransferable) transferable;
|
||||||
GTreeNodeTransferable gtTransferable = (GTreeNodeTransferable) transferable;
|
List<GTreeNode> nodeList = gtTransferable.getAllData();
|
||||||
List<GTreeNode> nodeList = gtTransferable.getAllData();
|
setNodesCut(nodeList, false);
|
||||||
setNodesCut(nodeList, false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +66,12 @@ public class CutAction extends SymbolTreeContextAction {
|
||||||
|
|
||||||
// only valid if all selected paths are of the correct type
|
// only valid if all selected paths are of the correct type
|
||||||
for (TreePath path : selectionPaths) {
|
for (TreePath path : selectionPaths) {
|
||||||
SymbolTreeNode node = (SymbolTreeNode) path.getLastPathComponent();
|
Object pathComponent = path.getLastPathComponent();
|
||||||
|
if (!(pathComponent instanceof SymbolTreeNode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SymbolTreeNode node = (SymbolTreeNode) pathComponent;
|
||||||
if (!node.canCut()) {
|
if (!node.canCut()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +110,7 @@ public class CutAction extends SymbolTreeContextAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<GTreeNode> createList(TreePath[] paths) {
|
private List<GTreeNode> createList(TreePath[] paths) {
|
||||||
ArrayList<GTreeNode> list = new ArrayList<GTreeNode>();
|
ArrayList<GTreeNode> list = new ArrayList<>();
|
||||||
if (paths != null) {
|
if (paths != null) {
|
||||||
for (TreePath element : paths) {
|
for (TreePath element : paths) {
|
||||||
GTreeNode node = (GTreeNode) element.getLastPathComponent();
|
GTreeNode node = (GTreeNode) element.getLastPathComponent();
|
||||||
|
@ -128,7 +130,8 @@ public class CutAction extends SymbolTreeContextAction {
|
||||||
// this class is just a marker interface so we can tell if we put the contents into the
|
// this class is just a marker interface so we can tell if we put the contents into the
|
||||||
// clipboard
|
// clipboard
|
||||||
class SymbolTreeNodeTransferable extends GTreeNodeTransferable {
|
class SymbolTreeNodeTransferable extends GTreeNodeTransferable {
|
||||||
public SymbolTreeNodeTransferable(GTreeTransferHandler handler, List<GTreeNode> selectedData) {
|
public SymbolTreeNodeTransferable(GTreeTransferHandler handler,
|
||||||
|
List<GTreeNode> selectedData) {
|
||||||
super(handler, selectedData);
|
super(handler, selectedData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,12 @@ public class PasteAction extends SymbolTreeContextAction {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolTreeNode node = (SymbolTreeNode) selectionPaths[0].getLastPathComponent();
|
Object pathComponent = selectionPaths[0].getLastPathComponent();
|
||||||
|
if (!(pathComponent instanceof SymbolTreeNode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SymbolTreeNode node = (SymbolTreeNode) pathComponent;
|
||||||
Clipboard clipboard = context.getSymbolTreeProvider().getClipboard();
|
Clipboard clipboard = context.getSymbolTreeProvider().getClipboard();
|
||||||
Transferable transferable = clipboard.getContents(this);
|
Transferable transferable = clipboard.getContents(this);
|
||||||
if (transferable == null) {
|
if (transferable == null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue