mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-18 08:30:11 +00:00
Merge remote-tracking branch 'origin/GP-4373-dragonmacher-tree-cut-fix'
into patch (Closes #6137)
This commit is contained in:
commit
b8a41c76cf
@ -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;
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -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
|
||||
@ -223,7 +224,7 @@ public class SymbolNode extends SymbolTreeNode {
|
||||
|
||||
int transactionID = program.startTransaction("Rename Symbol");
|
||||
try {
|
||||
// The symbol node rename does not support moving symbols into the
|
||||
// The symbol node rename does not support moving symbols into the
|
||||
// Global space since this implies a simple rename
|
||||
Namespace namespace = createNewNamespace(symbolPath.getParent());
|
||||
if (!namespace.isGlobal()) {
|
||||
@ -292,7 +293,7 @@ public class SymbolNode extends SymbolTreeNode {
|
||||
return nameCompare;
|
||||
}
|
||||
|
||||
// sort alphabetically first
|
||||
// sort alphabetically first
|
||||
if (nameCompare != 0) {
|
||||
return nameCompare;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user