Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2024-03-07 09:27:31 -05:00
commit 14177c5374
4 changed files with 33 additions and 35 deletions

View File

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.datamgr.archive;
import java.awt.Component;
import java.io.IOException;
import java.util.Objects;
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 OPEN_ICON = new GIcon("icon.plugin.datatypes.archive.project.open");
private DataTypeArchive dataTypeArchive;
private DomainFile originalDomainFile;
DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
private DomainFile sourceDomainFile;
private DataTypeManagerChangeListener categoryListener; // hold on to since it is stored in a weak set
private DataTypeManagerHandler archiveManager;
private DataTypeManager dataTypeManager;
ProjectArchive(DataTypeManagerHandler archiveManager, DataTypeArchive dataTypeArchive,
DomainFile originalDomainFile) {
DomainFile sourceDomainFile) {
this.archiveManager = archiveManager;
this.dataTypeArchive = dataTypeArchive;
this.dataTypeManager = dataTypeArchive.getDataTypeManager();
this.originalDomainFile = originalDomainFile;
this.sourceDomainFile = sourceDomainFile;
categoryListener = new ArchiveCategoryChangeListener();
dataTypeManager.addDataTypeManagerListener(categoryListener);
}
@ -67,39 +67,19 @@ 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());
}
public boolean hasExclusiveAccess() {
return dataTypeArchive.hasExclusiveAccess();
}
@Override
public boolean isModifiable() {
DomainFile domainFile = getDomainObject().getDomainFile();
return domainFile.canSave();
DomainFile df = getDomainObject().getDomainFile();
return df.canSave();
}
@Override
public DomainFile getDomainFile() {
return originalDomainFile;
return sourceDomainFile;
}
@Override
@ -109,8 +89,8 @@ public class ProjectArchive implements DomainFileArchive {
@Override
public boolean isChanged() {
DomainFile domainFile = dataTypeArchive.getDomainFile();
long lastModifiedTime = domainFile.getLastModifiedTime();
DomainFile df = dataTypeArchive.getDomainFile();
long lastModifiedTime = df.getLastModifiedTime();
return (lastModifiedTime == 0) || dataTypeArchive.isChanged();
}
@ -134,7 +114,7 @@ public class ProjectArchive implements DomainFileArchive {
@Override
public void saveAs(Component component) throws IOException {
archiveManager.saveAs(dataTypeArchive);
originalDomainFile = dataTypeArchive.getDomainFile();
sourceDomainFile = dataTypeArchive.getDomainFile(); // update with new domain file
dataTypeArchive.updateID();
}

View File

@ -218,8 +218,8 @@ public class GhidraFileData {
}
/**
* Returns a unique file-ID
* @return the ID
* Returns a unique file-ID if one has been established or null
* @return the file-ID or null if failed to obtain ID
*/
String getFileID() {
return fileID;

View File

@ -65,8 +65,13 @@ public interface DomainFile extends Comparable<DomainFile> {
public boolean exists();
/**
* Returns a unique file-ID
* @return the ID
* Returns a unique file-ID if one has been established or null. Examples which may result in
* 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();

View File

@ -270,6 +270,14 @@ public class AnsiBufferedInputStream extends InputStream {
execSetGraphicsRendition();
mode = Mode.CHARS;
break;
case 'h':
execPrivateSequence(true);
mode = Mode.CHARS;
break;
case 'l':
execPrivateSequence(false);
mode = Mode.CHARS;
break;
}
}
@ -473,4 +481,9 @@ public class AnsiBufferedInputStream extends InputStream {
// TODO: Maybe a callback. Otherwise, don't care
titleBuf.clear();
}
protected void execPrivateSequence(boolean enable) {
// These don't matter for input buffering.
escBuf.clear();
}
}