Merge branch 'GP-3281_ghidragon_followup_file_archive_test_failures'

This commit is contained in:
ghidragon
2023-04-11 15:37:35 -04:00
4 changed files with 63 additions and 35 deletions
@@ -18,6 +18,7 @@ package ghidra.app.plugin.core.datamgr.archive;
import java.awt.Component;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import javax.swing.Icon;
@@ -167,6 +168,26 @@ public class FileArchive implements Archive {
return archiveManager;
}
@Override
public int hashCode() {
return Objects.hash(archiveFile);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
FileArchive other = (FileArchive) obj;
return Objects.equals(archiveFile, other.archiveFile);
}
private void fireStateChanged() {
archiveManager.fireArchiveStateChanged(this);
}
@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.archive;
import java.awt.Component;
import java.io.IOException;
import java.util.Objects;
import javax.swing.Icon;
@@ -54,6 +55,26 @@ public class ProgramArchive implements DomainFileArchive {
return dataTypeManager.getName();
}
@Override
public int hashCode() {
return program.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ProgramArchive other = (ProgramArchive) obj;
return Objects.equals(program, other.program);
}
@Override
public int compareTo(Archive archive) {
if (archive instanceof BuiltInArchive) {
@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.datamgr.archive;
import java.awt.Component;
import java.io.IOException;
import java.util.Objects;
import javax.swing.Icon;
@@ -66,6 +67,26 @@ public class ProjectArchive implements DomainFileArchive {
return -1; // Project Archives appear between the ProgramArchive and FileArchives.
}
@Override
public int hashCode() {
return originalDomainFile.getFileID().hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ProjectArchive other = (ProjectArchive) obj;
return Objects.equals(originalDomainFile.getFileID(), other.originalDomainFile.getFileID());
}
@Override
public boolean isModifiable() {
DomainFile domainFile = getDomainObject().getDomainFile();
@@ -30,12 +30,10 @@ public class FileArchiveNode extends ArchiveNode {
new GIcon("icon.plugin.datatypes.tree.node.archive.file.checked.out.exclusive");
FileArchive fileArchive; // casted reference for easy access
String fullName;
public FileArchiveNode(FileArchive archive, ArrayPointerFilterState filterState) {
super(archive, filterState);
this.fileArchive = archive;
fullName = archive.getName() + ": " + archive.getFile().getAbsolutePath();
}
@Override
@@ -60,40 +58,7 @@ public class FileArchiveNode extends ArchiveNode {
return "[Unsaved New Archive]";
}
@Override
public String getName() {
return fullName;
}
@Override
public String getDisplayText() {
return archive.getName();
}
public boolean hasWriteLock() {
return fileArchive.hasWriteLock();
}
/**
* Overridden to avoid path conflicts that arise in CategoryNode.equals()
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (getClass() != o.getClass()) {
return false;
}
if (super.equals(o)) {
ResourceFile myFile = fileArchive.getFile();
ResourceFile otherFile = ((FileArchiveNode) o).fileArchive.getFile();
return myFile.equals(otherFile);
}
return false;
}
}