GP-0 Minor cleanup

This commit is contained in:
ghidra1 2025-04-08 15:15:53 -04:00
parent b5ccf1f063
commit 2c5669dbd0
4 changed files with 33 additions and 25 deletions

View file

@ -31,7 +31,7 @@ public interface Archive extends DataTypeManagerOwner, Comparable<Archive> {
/**
* Gets the name for this data type archive.
* This is the name to be presented to the user for this archive.
* @return the name
* @return the name or null if closed
*/
public String getName();

View file

@ -24,6 +24,7 @@ import generic.theme.GIcon;
import ghidra.framework.model.DomainFile;
import ghidra.program.model.data.*;
import ghidra.program.model.listing.DataTypeArchive;
import ghidra.util.exception.ClosedException;
public class ProjectArchive implements DomainFileArchive {
@ -34,7 +35,7 @@ public class ProjectArchive implements DomainFileArchive {
private DomainFile sourceDomainFile;
private DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
private DataTypeManagerHandler archiveManager;
private DataTypeManager dataTypeManager;
private StandAloneDataTypeManager dataTypeManager;
ProjectArchive(DataTypeManagerHandler archiveManager, DataTypeArchive dataTypeArchive,
DomainFile sourceDomainFile) {
@ -53,6 +54,9 @@ public class ProjectArchive implements DomainFileArchive {
@Override
public String getName() {
if (dataTypeManager == null) {
return null;
}
return dataTypeManager.getName();
}
@ -74,6 +78,9 @@ public class ProjectArchive implements DomainFileArchive {
@Override
public boolean isModifiable() {
if (dataTypeManager == null) {
return false;
}
DomainFile df = getDomainObject().getDomainFile();
return df.canSave();
}
@ -90,6 +97,9 @@ public class ProjectArchive implements DomainFileArchive {
@Override
public boolean isChanged() {
if (dataTypeManager == null) {
return false;
}
DomainFile df = dataTypeArchive.getDomainFile();
long lastModifiedTime = df.getLastModifiedTime();
return (lastModifiedTime == 0) || dataTypeArchive.isChanged();
@ -97,26 +107,35 @@ public class ProjectArchive implements DomainFileArchive {
@Override
public boolean isSavable() {
return !dataTypeArchive.getDomainFile().isReadOnly() && dataTypeArchive.isChangeable();
return dataTypeManager != null && !dataTypeArchive.getDomainFile().isReadOnly() &&
dataTypeArchive.isChangeable();
}
@Override
public void save() throws IOException {
if (dataTypeManager == null) {
throw new ClosedException();
}
archiveManager.save(getDomainObject());
}
@Override
public void close() {
dataTypeManager.close();
archiveManager.archiveClosed(this);
dataTypeManager = null;
if (dataTypeManager != null) {
dataTypeManager.close();
archiveManager.archiveClosed(this);
dataTypeManager = null;
}
}
@Override
public void saveAs(Component component) throws IOException {
if (dataTypeManager == null) {
throw new ClosedException();
}
archiveManager.saveAs(dataTypeArchive);
sourceDomainFile = dataTypeArchive.getDomainFile(); // update with new domain file
dataTypeArchive.updateID();
dataTypeManager.updateID();
}
@Override

View file

@ -570,11 +570,6 @@ public class DataTypeArchiveDB extends DomainObjectAdapterDB implements DataType
super.updateMetadata();
}
@Override
public void updateID() {
dataTypeManager.updateID();
}
@Override
protected void domainObjectRestored() {
super.domainObjectRestored();

View file

@ -38,22 +38,18 @@ public interface DataTypeArchive extends DataTypeManagerDomainObject {
public static final Date JANUARY_1_1970 = new Date(0);
/**
* Gets the associated standalone data type manager.
* @return the data type manager.
* {@return the associated standalone data type manager.}
*/
@Override
public StandAloneDataTypeManager getDataTypeManager();
/**
* Gets the default pointer size as it may be stored within the data type archive.
* @return default pointer size.
* {@return the default pointer size as it may be stored within the data type archive.}
*/
public int getDefaultPointerSize();
/**
* Returns the creation date of this data type archive.
* existed, then Jan 1, 1970 is returned.
* @return the creation date of this data type archive
* {@return the creation date of this data type archive or Jan 1, 1970 if unknown.}
*/
public Date getCreationDate();
@ -69,6 +65,4 @@ public interface DataTypeArchive extends DataTypeManagerDomainObject {
*/
public void invalidate();
public void updateID();
}