mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch
'origin/GP-4386_ghidra1_ProjectArchiveNullFileID--SQUASHED' into patch (Closes #6254, Closes #6206)
This commit is contained in:
@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.datamgr.archive;
|
|||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
|
|
||||||
@@ -30,18 +29,19 @@ public class ProjectArchive implements DomainFileArchive {
|
|||||||
|
|
||||||
private static Icon CLOSED_ICON = new GIcon("icon.plugin.datatypes.archive.project.closed");
|
private static Icon CLOSED_ICON = new GIcon("icon.plugin.datatypes.archive.project.closed");
|
||||||
private static Icon OPEN_ICON = new GIcon("icon.plugin.datatypes.archive.project.open");
|
private static Icon OPEN_ICON = new GIcon("icon.plugin.datatypes.archive.project.open");
|
||||||
|
|
||||||
private DataTypeArchive dataTypeArchive;
|
private DataTypeArchive dataTypeArchive;
|
||||||
private DomainFile originalDomainFile;
|
private DomainFile sourceDomainFile;
|
||||||
DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
|
private DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
|
||||||
private DataTypeManagerHandler archiveManager;
|
private DataTypeManagerHandler archiveManager;
|
||||||
private DataTypeManager dataTypeManager;
|
private DataTypeManager dataTypeManager;
|
||||||
|
|
||||||
ProjectArchive(DataTypeManagerHandler archiveManager, DataTypeArchive dataTypeArchive,
|
ProjectArchive(DataTypeManagerHandler archiveManager, DataTypeArchive dataTypeArchive,
|
||||||
DomainFile originalDomainFile) {
|
DomainFile sourceDomainFile) {
|
||||||
this.archiveManager = archiveManager;
|
this.archiveManager = archiveManager;
|
||||||
this.dataTypeArchive = dataTypeArchive;
|
this.dataTypeArchive = dataTypeArchive;
|
||||||
this.dataTypeManager = dataTypeArchive.getDataTypeManager();
|
this.dataTypeManager = dataTypeArchive.getDataTypeManager();
|
||||||
this.originalDomainFile = originalDomainFile;
|
this.sourceDomainFile = sourceDomainFile;
|
||||||
categoryListener = new ArchiveCategoryChangeListener();
|
categoryListener = new ArchiveCategoryChangeListener();
|
||||||
dataTypeManager.addDataTypeManagerListener(categoryListener);
|
dataTypeManager.addDataTypeManagerListener(categoryListener);
|
||||||
}
|
}
|
||||||
@@ -67,39 +67,19 @@ public class ProjectArchive implements DomainFileArchive {
|
|||||||
return -1; // Project Archives appear between the ProgramArchive and FileArchives.
|
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasExclusiveAccess() {
|
public boolean hasExclusiveAccess() {
|
||||||
return dataTypeArchive.hasExclusiveAccess();
|
return dataTypeArchive.hasExclusiveAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isModifiable() {
|
public boolean isModifiable() {
|
||||||
DomainFile domainFile = getDomainObject().getDomainFile();
|
DomainFile df = getDomainObject().getDomainFile();
|
||||||
return domainFile.canSave();
|
return df.canSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DomainFile getDomainFile() {
|
public DomainFile getDomainFile() {
|
||||||
return originalDomainFile;
|
return sourceDomainFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -109,8 +89,8 @@ public class ProjectArchive implements DomainFileArchive {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChanged() {
|
public boolean isChanged() {
|
||||||
DomainFile domainFile = dataTypeArchive.getDomainFile();
|
DomainFile df = dataTypeArchive.getDomainFile();
|
||||||
long lastModifiedTime = domainFile.getLastModifiedTime();
|
long lastModifiedTime = df.getLastModifiedTime();
|
||||||
return (lastModifiedTime == 0) || dataTypeArchive.isChanged();
|
return (lastModifiedTime == 0) || dataTypeArchive.isChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +114,7 @@ public class ProjectArchive implements DomainFileArchive {
|
|||||||
@Override
|
@Override
|
||||||
public void saveAs(Component component) throws IOException {
|
public void saveAs(Component component) throws IOException {
|
||||||
archiveManager.saveAs(dataTypeArchive);
|
archiveManager.saveAs(dataTypeArchive);
|
||||||
originalDomainFile = dataTypeArchive.getDomainFile();
|
sourceDomainFile = dataTypeArchive.getDomainFile(); // update with new domain file
|
||||||
dataTypeArchive.updateID();
|
dataTypeArchive.updateID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,8 +218,8 @@ public class GhidraFileData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a unique file-ID
|
* Returns a unique file-ID if one has been established or null
|
||||||
* @return the ID
|
* @return the file-ID or null if failed to obtain ID
|
||||||
*/
|
*/
|
||||||
String getFileID() {
|
String getFileID() {
|
||||||
return fileID;
|
return fileID;
|
||||||
|
|||||||
@@ -65,8 +65,13 @@ public interface DomainFile extends Comparable<DomainFile> {
|
|||||||
public boolean exists();
|
public boolean exists();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a unique file-ID
|
* Returns a unique file-ID if one has been established or null. Examples which may result in
|
||||||
* @return the ID
|
* null ID:
|
||||||
|
* <ul>
|
||||||
|
* <li>Very old project file which pre-dates introduction of file ID, or</li>
|
||||||
|
* <li>Remote versioned file with lost connection</li>
|
||||||
|
* </ul>
|
||||||
|
* @return the file-ID or null if failed to obtain ID.
|
||||||
*/
|
*/
|
||||||
public String getFileID();
|
public String getFileID();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user