mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 06:27:59 -05:00
Merge remote-tracking branch 'origin/GP-1467_ghidravore_fixing_stack_trace_in_datatypes_tree' into Ghidra_10.1
This commit is contained in:
@@ -57,14 +57,6 @@ public class ArchiveNode extends CategoryNode {
|
||||
nodeChanged(); // notify that this nodes display data has changed
|
||||
}
|
||||
|
||||
// override clone to install the needed listeners
|
||||
@Override
|
||||
public GTreeNode clone() throws CloneNotSupportedException {
|
||||
ArchiveNode clone = (ArchiveNode) super.clone();
|
||||
clone.installDataTypeManagerListener();
|
||||
return clone;
|
||||
}
|
||||
|
||||
protected void installDataTypeManagerListener() {
|
||||
if (dataTypeManager == null) {
|
||||
return; // some nodes do not have DataTypeManagers, like InvalidFileArchives
|
||||
|
||||
@@ -48,14 +48,6 @@ public class ArchiveRootNode extends DataTypeTreeNode {
|
||||
return archiveManager;
|
||||
}
|
||||
|
||||
// override clone to install the needed listeners
|
||||
@Override
|
||||
public GTreeNode clone() throws CloneNotSupportedException {
|
||||
ArchiveRootNode clone = (ArchiveRootNode) super.clone();
|
||||
clone.init();
|
||||
return clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
archiveManager.removeArchiveManagerListener(archiveListener);
|
||||
|
||||
@@ -81,6 +81,14 @@ abstract class CoreGTreeNode implements Cloneable {
|
||||
return localParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a root node of a GTree
|
||||
* @return true if this is a root node of a GTree
|
||||
*/
|
||||
public final boolean isRoot() {
|
||||
return parent instanceof GTreeRootParentNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent of this node. This method should only be used by a parent
|
||||
* node when a new child is added to that parent node.
|
||||
|
||||
@@ -318,23 +318,18 @@ public abstract class GTreeNode extends CoreGTreeNode implements Comparable<GTre
|
||||
|
||||
/**
|
||||
* Returns the rootNode for this tree or null if there is no parent path to a
|
||||
* GTRootNode
|
||||
* @return the rootNode for this tree
|
||||
* root node.
|
||||
* @return the rootNode for a tree of nodes in a {@link GTree}
|
||||
*/
|
||||
public GTreeNode getRoot() {
|
||||
GTreeNode myParent = getParent();
|
||||
if (myParent == null || myParent instanceof GTreeRootParentNode) {
|
||||
if (isRoot()) {
|
||||
return this;
|
||||
}
|
||||
return myParent.getRoot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a root node
|
||||
* @return true if this is a root node
|
||||
*/
|
||||
public boolean isRoot() {
|
||||
return getRoot() == this;
|
||||
GTreeNode myParent = getParent();
|
||||
if (myParent != null) {
|
||||
return myParent.getRoot();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +362,7 @@ public abstract class GTreeNode extends CoreGTreeNode implements Comparable<GTre
|
||||
}
|
||||
}
|
||||
|
||||
if (isRoot() || !list.isEmpty() || filter.acceptsNode(this) || getParent() == null) {
|
||||
if (isRoot() || !list.isEmpty() || filter.acceptsNode(this)) {
|
||||
GTreeNode clone = clone();
|
||||
clone.doSetChildren(list);
|
||||
return clone;
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package docking.widgets.tree.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.event.TreeModelEvent;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
@@ -125,19 +124,25 @@ public class GTreeModel implements TreeModel {
|
||||
SystemUtilities.assertThisIsTheSwingThread(
|
||||
"GTreeModel.fireNodeStructuredChanged() must be " + "called from the AWT thread");
|
||||
|
||||
GTreeNode node = convertToViewNode(changedNode);
|
||||
if (node == null) {
|
||||
// If the tree is filtered and this is called on the original node, we have to
|
||||
// translate the node to a view node (one the jtree knows).
|
||||
GTreeNode viewNode = convertToViewNode(changedNode);
|
||||
if (viewNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node != changedNode) {
|
||||
// Note: calling setChildren() here triggers another call to this method. But,
|
||||
// the 'isFiringNodeStructureChanged' flag prevents that notification from
|
||||
// happening. So, we still have to fire the event below.
|
||||
node.setChildren(null);
|
||||
if (viewNode != changedNode) {
|
||||
// This means we are filtered and since the original node's children are invalid,
|
||||
// then the filtered children are invalid also. So clear out the children by
|
||||
// setting an empty list as we don't want to trigger the node to regenerate its
|
||||
// children which happens if you set the children to null.
|
||||
//
|
||||
// This won't cause a second event to the jtree because we are protected
|
||||
// by the isFiringNodeStructureChanged variable
|
||||
viewNode.setChildren(Collections.emptyList());
|
||||
}
|
||||
|
||||
TreeModelEvent event = new TreeModelEvent(this, node.getTreePath());
|
||||
TreeModelEvent event = new TreeModelEvent(this, viewNode.getTreePath());
|
||||
for (TreeModelListener listener : listeners) {
|
||||
listener.treeStructureChanged(event);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ public class GTreeNodeTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
root = new TestNode("root");
|
||||
root.setParent(new GTreeRootParentNode(null));
|
||||
|
||||
node0 = new TestNode("Node0");
|
||||
node1 = new TestNode("Node1");
|
||||
node2 = new TestNode("Node2");
|
||||
@@ -354,7 +356,7 @@ public class GTreeNodeTest {
|
||||
assertEquals(root, node0_1.getRoot());
|
||||
assertEquals(root, root.getRoot());
|
||||
TestNode testNode = new TestNode("test");
|
||||
assertEquals(testNode, testNode.getRoot());
|
||||
assertEquals(null, testNode.getRoot());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -133,9 +133,8 @@ public class StandAloneDataTypeManager extends DataTypeManagerDB {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (dbHandle != null) {
|
||||
if (!dbHandle.isClosed()) {
|
||||
dbHandle.close();
|
||||
dbHandle = null;
|
||||
}
|
||||
super.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user