mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-5550 Revised GTreeStartEditingTask node re-selection
This commit is contained in:
parent
1a80aff30a
commit
168fce3eda
1 changed files with 9 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
|||
package docking.widgets.tree.tasks;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.swing.CellEditor;
|
||||
import javax.swing.JTree;
|
||||
|
@ -68,10 +69,16 @@ public class GTreeStartEditingTask extends GTreeTask {
|
|||
String newName = Objects.toString(cellEditor.getCellEditorValue());
|
||||
cellEditor.removeCellEditorListener(this);
|
||||
|
||||
// note: this call only works when the parent cannot have duplicate named nodes
|
||||
tree.whenNodeIsReady(modelParent, newName, newNode -> {
|
||||
// NOTE: there may be cases where this node search fails to correctly
|
||||
// identify the renamed node when name and node class is insufficient to match.
|
||||
Class<?> nodeClass = editNode.getClass();
|
||||
Predicate<GTreeNode> nodeMatches = n -> {
|
||||
return nodeClass == n.getClass() && n.getName().equals(newName);
|
||||
};
|
||||
tree.whenNodeIsReady(modelParent, nodeMatches, newNode -> {
|
||||
tree.setSelectedNode(newNode);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue