mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-19 16:40:38 -09:00
GP-3189 corrected tool launch issue when file(s) dragged onto tool icon in toolchest. Removed single-DomainFile launch methods on ToolServices API.
This commit is contained in:
@@ -1112,7 +1112,7 @@ public class FrontEndPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (toolServices.launchDefaultTool(domainFile) != null) {
|
||||
if (toolServices.launchDefaultTool(List.of(domainFile)) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -561,7 +561,11 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
|
||||
plugin.getActiveWorkspace().runTool(template);
|
||||
}
|
||||
else {
|
||||
toolServices.launchDefaultTool(domainFiles);
|
||||
PluginTool tool = toolServices.launchTool(template.getName(), domainFiles);
|
||||
if (tool == null) {
|
||||
Msg.showError(this, getParent(), "Failed to Launch Tool",
|
||||
"Failed to launch " + template.getName() + " tool.\nSee log for details.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,21 +573,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
|
||||
if (domainFiles == null) {
|
||||
return;
|
||||
}
|
||||
boolean accepted = tool.acceptDomainFiles(domainFiles.toArray(DomainFile[]::new));
|
||||
if (!accepted) {
|
||||
showFilesNotAcceptedMessage(domainFiles);
|
||||
}
|
||||
}
|
||||
|
||||
private void showFilesNotAcceptedMessage(List<DomainFile> domainFiles) {
|
||||
StringBuilder buffy = new StringBuilder("Tool did not accept files: ");
|
||||
for (int i = 0; i < domainFiles.size(); i++) {
|
||||
buffy.append(domainFiles.get(0).getName());
|
||||
if (i != domainFiles.size() - 1) {
|
||||
buffy.append(", ");
|
||||
}
|
||||
}
|
||||
Msg.showError(this, null, "Error", buffy.toString());
|
||||
tool.acceptDomainFiles(domainFiles.toArray(DomainFile[]::new));
|
||||
}
|
||||
|
||||
private void setUpDragDrop() {
|
||||
|
||||
@@ -344,10 +344,11 @@ public class VersionHistoryPanel extends JPanel implements Draggable {
|
||||
if (versionedObj != null) {
|
||||
try {
|
||||
if (toolName != null) {
|
||||
tool.getToolServices().launchTool(toolName, versionedObj.getDomainFile());
|
||||
tool.getToolServices()
|
||||
.launchTool(toolName, List.of(versionedObj.getDomainFile()));
|
||||
}
|
||||
else {
|
||||
tool.getToolServices().launchDefaultTool(versionedObj.getDomainFile());
|
||||
tool.getToolServices().launchDefaultTool(List.of(versionedObj.getDomainFile()));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -119,31 +119,25 @@ public interface ToolServices {
|
||||
public void setContentTypeToolAssociations(Set<ToolAssociationInfo> infos);
|
||||
|
||||
/**
|
||||
* Launch the default tool and open the specified domainFile.
|
||||
* Launch the default {@link PluginTool tool} and open the specified domainFiles.
|
||||
* NOTE: running tool reuse is implementation dependent
|
||||
* @param domainFile the file to open
|
||||
* @param domainFiles the files to open. A null or empty list will results in an immediate
|
||||
* return of a null {@link PluginTool}. Null entries are not permitted.
|
||||
* @return the launched tool. Null returned if a suitable default tool
|
||||
* for the file content type was not found.
|
||||
* for the file content type was not found or failed to launch.
|
||||
*/
|
||||
public PluginTool launchDefaultTool(DomainFile domainFile);
|
||||
public PluginTool launchDefaultTool(Collection<DomainFile> domainFiles);
|
||||
|
||||
/**
|
||||
* Launch the default tool and open the specified domainFiles.
|
||||
* NOTE: running tool reuse is implementation dependent
|
||||
* @param domainFile the file to open
|
||||
* @return the launched tool. Null returned if a suitable default tool
|
||||
* for the file content type was not found.
|
||||
* Launch the {@link PluginTool tool} with the given name and open the specified domainFiles.
|
||||
* Only those domainFiles with a content type supported by the specified tool will be opened.
|
||||
* NOTE: running tool reuse is implementation dependent.
|
||||
* @param toolName name of the {@link ToolTemplate tool template} to launch or re-use
|
||||
* @param domainFiles the files to open; may be null or empty. Null entries are not permitted.
|
||||
* @return the resulting {@link PluginTool tool} or null if the specified tool was not found
|
||||
* or failed to launch
|
||||
*/
|
||||
public PluginTool launchDefaultTool(Collection<DomainFile> domainFile);
|
||||
|
||||
/**
|
||||
* Launch the tool with the given name. A domainFile may be specified and will be opened
|
||||
* if its content type is supported by the tool.
|
||||
* @param toolName name of the tool to launch
|
||||
* @param domainFile the file to open; may be null
|
||||
* @return the requested tool or null if the specified tool not found.
|
||||
*/
|
||||
public PluginTool launchTool(String toolName, DomainFile domainFile);
|
||||
public PluginTool launchTool(String toolName, Collection<DomainFile> domainFiles);
|
||||
|
||||
/**
|
||||
* Launch the default tool and open the specified Ghidra URL resource.
|
||||
|
||||
@@ -74,18 +74,13 @@ public class ToolServicesAdapter implements ToolServices {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginTool launchDefaultTool(DomainFile domainFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginTool launchDefaultTool(Collection<DomainFile> domainFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginTool launchTool(String toolName, DomainFile domainFile) {
|
||||
public PluginTool launchTool(String toolName, Collection<DomainFile> domainFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,14 +236,6 @@ class ToolServicesImpl implements ToolServices {
|
||||
return tool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginTool launchDefaultTool(DomainFile domainFile) {
|
||||
ToolTemplate template = getDefaultToolTemplate(domainFile);
|
||||
return defaultLaunch(template, t -> {
|
||||
return t.acceptDomainFiles(new DomainFile[] { domainFile });
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginTool launchDefaultTool(Collection<DomainFile> domainFiles) {
|
||||
if (CollectionUtils.isBlank(domainFiles)) {
|
||||
@@ -256,21 +248,17 @@ class ToolServicesImpl implements ToolServices {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginTool launchTool(String toolName, DomainFile domainFile) {
|
||||
public PluginTool launchTool(String toolName, Collection<DomainFile> domainFiles) {
|
||||
ToolTemplate template = findToolChestToolTemplate(toolName);
|
||||
if (template == null) {
|
||||
return null;
|
||||
}
|
||||
Workspace workspace = toolManager.getActiveWorkspace();
|
||||
PluginTool tool = workspace.runTool(template);
|
||||
if (tool == null) {
|
||||
return null;
|
||||
}
|
||||
tool.setVisible(true);
|
||||
if (domainFile != null) {
|
||||
tool.acceptDomainFiles(new DomainFile[] { domainFile });
|
||||
}
|
||||
return tool;
|
||||
return defaultLaunch(template, t -> {
|
||||
if (CollectionUtils.isBlank(domainFiles)) {
|
||||
return true;
|
||||
}
|
||||
return t.acceptDomainFiles(domainFiles.toArray(DomainFile[]::new));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user