Merge remote-tracking branch 'origin/GT-3332_GTree_fixes'

This commit is contained in:
Ryan Kurtz 2019-11-18 08:20:35 -05:00
commit bb0a3d9f52
4 changed files with 90 additions and 15 deletions

View file

@ -91,6 +91,10 @@ public class CategoryNode extends DataTypeTreeNode {
return -1; // CategoryNodes are always come before ****everything else****
}
@Override
public int hashCode() {
return name.hashCode();
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
@ -164,8 +168,14 @@ public class CategoryNode extends DataTypeTreeNode {
}
CategoryNode node = new CategoryNode(newCategory, filterState);
List<GTreeNode> allChildrenList = getChildren();
int index = Collections.binarySearch(allChildrenList, node);
List<GTreeNode> children = getChildren();
int index = Collections.binarySearch(children, node);
if (index >= 0) {
// if a node with that name exists, then we don't need to add one for the new category
if (node.getName().equals(children.get(index).getName())) {
return;
}
}
if (index < 0) {
index = -index - 1;
}

View file

@ -31,13 +31,17 @@ import ghidra.util.task.TaskMonitor;
public class DataTypeTreeDeleteTask extends Task {
// if the total number of nodes is small, we won't need to collapse the tree before deleting
// the nodes to avoid excess tree events
private static final int NODE_COUNT_FOR_COLLAPSING_TREE = 100;
private Map<ArchiveNode, List<GTreeNode>> nodesByArchive;
private DataTypeManagerPlugin plugin;
private int nodeCount;
public DataTypeTreeDeleteTask(DataTypeManagerPlugin plugin, List<GTreeNode> nodes) {
super("Delete Nodes", true, true, true);
this.plugin = plugin;
nodeCount = nodes.size();
nodes = filterList(nodes);
nodesByArchive = groupNodeByArchive(nodes);
@ -105,7 +109,9 @@ public class DataTypeTreeDeleteTask extends Task {
DataTypeArchiveGTree tree = provider.getGTree();
GTreeState treeState = tree.getTreeState();
try {
collapseArchives(tree);
if (nodeCount > NODE_COUNT_FOR_COLLAPSING_TREE) {
collapseArchives(tree);
}
Set<Entry<ArchiveNode, List<GTreeNode>>> entries = nodesByArchive.entrySet();
for (Entry<ArchiveNode, List<GTreeNode>> entry : entries) {