mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-08-27 13:03:12 +00:00
Merge remote-tracking branch 'origin/GP-2321_ryanmkurtz_exporter'
This commit is contained in:
commit
55fc27177e
|
@ -295,13 +295,12 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
|||
return comboBox;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Exporter> getApplicableExporters() {
|
||||
List<Exporter> list = new ArrayList<>(ClassSearcher.getInstances(Exporter.class));
|
||||
Class<?> domainObjectClass = domainFile.getDomainObjectClass();
|
||||
DomainObject domainObj = getDomainObject(TaskMonitor.DUMMY);
|
||||
if (DomainObject.class.isAssignableFrom(domainObjectClass)) {
|
||||
list.removeIf(exporter -> !exporter
|
||||
.canExportDomainObject((Class<? extends DomainObject>) domainObjectClass));
|
||||
list.removeIf(exporter -> !exporter.canExportDomainObject(domainObj));
|
||||
Collections.sort(list, (o1, o2) -> o1.toString().compareTo(o2.toString()));
|
||||
}
|
||||
return list;
|
||||
|
|
|
@ -101,16 +101,27 @@ abstract public class Exporter implements ExtensionPoint {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if this exporter knows how to export the given domain object. For example,
|
||||
* Returns true if this exporter knows how to export the given domain object type. For example,
|
||||
* some exporters know how to export programs, other exporters can export project data type
|
||||
* archives.
|
||||
* @param domainObjectClass the class of the domain object to test for exporting.
|
||||
* @return true if this exporter knows how to export the given domain object.
|
||||
* @return true if this exporter knows how to export the given domain object type.
|
||||
* @deprecated use {@link #canExportDomainObject(DomainObject)}
|
||||
*/
|
||||
@Deprecated(since = "10.3", forRemoval = true)
|
||||
public boolean canExportDomainObject(Class<? extends DomainObject> domainObjectClass) {
|
||||
return Program.class.isAssignableFrom(domainObjectClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this exporter knows how to export the given domain object.
|
||||
* @param domainObject the domain object to test for exporting.
|
||||
* @return true if this exporter knows how to export the given domain object.
|
||||
*/
|
||||
public boolean canExportDomainObject(DomainObject domainObject) {
|
||||
return canExportDomainObject(domainObject.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this exporter can export less than the entire domain file.
|
||||
* @return true if this exporter can export less than the entire domain file.
|
||||
|
|
|
@ -62,6 +62,14 @@ public class OriginalFileExporter extends Exporter {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExportDomainObject(DomainObject domainObject) {
|
||||
if (domainObject instanceof Program program) {
|
||||
return !program.getMemory().getAllFileBytes().isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean export(File file, DomainObject domainObj, AddressSetView addrSet,
|
||||
TaskMonitor monitor) throws IOException, ExporterException {
|
||||
|
|
Loading…
Reference in a new issue