mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-5914-dragonmacher-symbol-tree-nav-fix'
This commit is contained in:
commit
16a2e78806
1 changed files with 29 additions and 12 deletions
|
@ -19,6 +19,7 @@ import static ghidra.framework.model.DomainObjectEvent.*;
|
|||
import static ghidra.program.util.ProgramEvent.*;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.event.MouseAdapter;
|
||||
|
@ -167,7 +168,8 @@ public class SymbolTreeProvider extends ComponentProviderAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
maybeGoToSymbol();
|
||||
SymbolNode symbolNode = getSelectedSymbolNode();
|
||||
maybeGoToSymbol(symbolNode);
|
||||
contextChanged();
|
||||
});
|
||||
|
||||
|
@ -175,14 +177,24 @@ public class SymbolTreeProvider extends ComponentProviderAdapter {
|
|||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
// This code serves to perform navigation in the case that the selection handler
|
||||
// above does not, as is the case when the node is already selected. This code
|
||||
// will get called on the mouse release, whereas the selection handler gets called
|
||||
// on the mouse pressed.
|
||||
// This code serves to perform navigation in the case that the selection handler
|
||||
// above does not, as is the case when the clicked node is already selected. This
|
||||
// code will get called on the mouse clicked, whereas the selection handler gets
|
||||
// called on the mouse pressed.
|
||||
// For now, just attempt to perform the goto. It may get called twice, but this
|
||||
// should have no real impact on performance.
|
||||
Point p = e.getPoint();
|
||||
GTreeNode clickedNode = newTree.getNodeForLocation(p.x, p.y);
|
||||
if (clickedNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
maybeGoToSymbol();
|
||||
SymbolNode symbolNode = getSelectedSymbolNode();
|
||||
if (!clickedNode.equals(symbolNode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
maybeGoToSymbol(symbolNode);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -211,19 +223,24 @@ public class SymbolTreeProvider extends ComponentProviderAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
private void maybeGoToSymbol() {
|
||||
|
||||
private SymbolNode getSelectedSymbolNode() {
|
||||
TreePath[] paths = tree.getSelectionPaths();
|
||||
if (paths == null || paths.length != 1) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
Object object = paths[0].getLastPathComponent();
|
||||
if (!(object instanceof SymbolNode)) {
|
||||
return;
|
||||
if (object instanceof SymbolNode symbolNode) {
|
||||
return symbolNode;
|
||||
}
|
||||
|
||||
SymbolNode node = (SymbolNode) object;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void maybeGoToSymbol(SymbolNode node) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
Symbol symbol = node.getSymbol();
|
||||
SymbolType type = symbol.getSymbolType();
|
||||
if (!type.isNamespace() || type == SymbolType.FUNCTION) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue