mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-09-13 13:46:49 +00:00
GP-2321: Only exporters that support the current domain object are
presented in list now
This commit is contained in:
parent
db932d2228
commit
b14804b295
|
@ -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