mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02: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
3 changed files with 23 additions and 5 deletions
|
@ -295,13 +295,12 @@ public class ExporterDialog extends DialogComponentProvider implements AddressFa
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private List<Exporter> getApplicableExporters() {
|
private List<Exporter> getApplicableExporters() {
|
||||||
List<Exporter> list = new ArrayList<>(ClassSearcher.getInstances(Exporter.class));
|
List<Exporter> list = new ArrayList<>(ClassSearcher.getInstances(Exporter.class));
|
||||||
Class<?> domainObjectClass = domainFile.getDomainObjectClass();
|
Class<?> domainObjectClass = domainFile.getDomainObjectClass();
|
||||||
|
DomainObject domainObj = getDomainObject(TaskMonitor.DUMMY);
|
||||||
if (DomainObject.class.isAssignableFrom(domainObjectClass)) {
|
if (DomainObject.class.isAssignableFrom(domainObjectClass)) {
|
||||||
list.removeIf(exporter -> !exporter
|
list.removeIf(exporter -> !exporter.canExportDomainObject(domainObj));
|
||||||
.canExportDomainObject((Class<? extends DomainObject>) domainObjectClass));
|
|
||||||
Collections.sort(list, (o1, o2) -> o1.toString().compareTo(o2.toString()));
|
Collections.sort(list, (o1, o2) -> o1.toString().compareTo(o2.toString()));
|
||||||
}
|
}
|
||||||
return list;
|
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
|
* some exporters know how to export programs, other exporters can export project data type
|
||||||
* archives.
|
* archives.
|
||||||
* @param domainObjectClass the class of the domain object to test for exporting.
|
* @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) {
|
public boolean canExportDomainObject(Class<? extends DomainObject> domainObjectClass) {
|
||||||
return Program.class.isAssignableFrom(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.
|
* 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.
|
* @return true if this exporter can export less than the entire domain file.
|
||||||
|
|
|
@ -62,6 +62,14 @@ public class OriginalFileExporter extends Exporter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canExportDomainObject(DomainObject domainObject) {
|
||||||
|
if (domainObject instanceof Program program) {
|
||||||
|
return !program.getMemory().getAllFileBytes().isEmpty();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean export(File file, DomainObject domainObj, AddressSetView addrSet,
|
public boolean export(File file, DomainObject domainObj, AddressSetView addrSet,
|
||||||
TaskMonitor monitor) throws IOException, ExporterException {
|
TaskMonitor monitor) throws IOException, ExporterException {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue