mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
Merge remote-tracking branch 'origin/dev747368_GT-2764_fsb_dbl_click_container'
This commit is contained in:
commit
b05cddfbaa
@ -18,6 +18,7 @@ package ghidra.plugins.fsbrowser;
|
||||
import java.awt.Component;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.TreePath;
|
||||
@ -42,7 +43,6 @@ import ghidra.plugin.importer.ImporterUtilities;
|
||||
import ghidra.plugin.importer.ProgramMappingService;
|
||||
import ghidra.plugins.fsbrowser.tasks.GFileSystemExtractAllTask;
|
||||
import ghidra.plugins.importer.batch.BatchImportDialog;
|
||||
import ghidra.plugins.importer.tasks.ImportBatchTask;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.SystemUtilities;
|
||||
@ -297,32 +297,34 @@ class FSBActionManager {
|
||||
private void openProgramFromFile(FSRL file, String suggestedDestinationPath) {
|
||||
ProgramManager pm = FSBUtils.getProgramManager(plugin.getTool(), false);
|
||||
if (pm != null) {
|
||||
TaskLauncher.launchNonModal("Open Programs", monitor -> {
|
||||
doOpenProgramFromFile(file, suggestedDestinationPath, pm, monitor);
|
||||
AtomicBoolean success = new AtomicBoolean();
|
||||
TaskLauncher.launchModal("Open Programs", monitor -> {
|
||||
success.set(doOpenProgramFromFile(file, suggestedDestinationPath, pm, monitor));
|
||||
});
|
||||
if (!success.get()) {
|
||||
ImporterUtilities.showImportDialog(file, null, suggestedDestinationPath,
|
||||
plugin.getTool(), pm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doOpenProgramFromFile(FSRL fsrl, String suggestedDestinationPath,
|
||||
private boolean doOpenProgramFromFile(FSRL fsrl, String suggestedDestinationPath,
|
||||
ProgramManager programManager, TaskMonitor monitor) {
|
||||
if (programManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object consumer = new Object();
|
||||
Program program = ProgramMappingService.findMatchingProgramOpenIfNeeded(fsrl, consumer,
|
||||
programManager, ProgramManager.OPEN_CURRENT);
|
||||
|
||||
if (program == null) {
|
||||
searchProjectForMatchingFileOrImport(fsrl, suggestedDestinationPath, programManager,
|
||||
monitor);
|
||||
return;
|
||||
return searchProjectForMatchingFileOrFail(fsrl, suggestedDestinationPath,
|
||||
programManager, monitor);
|
||||
}
|
||||
|
||||
program.release(consumer);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void searchProjectForMatchingFileOrImport(FSRL fsrl, String suggestedDestinationPath,
|
||||
private boolean searchProjectForMatchingFileOrFail(FSRL fsrl, String suggestedDestinationPath,
|
||||
ProgramManager programManager, TaskMonitor monitor) {
|
||||
boolean doSearch = isProjectSmallEnoughToSearchWithoutWarningUser() ||
|
||||
OptionDialog.showYesNoDialog(null, "Search Project for matching program?",
|
||||
@ -336,10 +338,9 @@ class FSBActionManager {
|
||||
if (domainFile != null) {
|
||||
ProgramMappingService.createAssociation(fsrl, domainFile);
|
||||
showProgramInProgramManager(fsrl, domainFile, programManager, true);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
ImporterUtilities.showImportDialog(fsrl, null, suggestedDestinationPath, plugin.getTool(),
|
||||
programManager);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -356,10 +357,19 @@ class FSBActionManager {
|
||||
*/
|
||||
private void openProgramsFromFiles(List<FSRL> files) {
|
||||
ProgramManager pm = FSBUtils.getProgramManager(plugin.getTool(), false);
|
||||
List<FSRL> unmatchedFiles = new ArrayList<>();
|
||||
if (pm != null) {
|
||||
TaskLauncher.launchNonModal("Open Programs", monitor -> {
|
||||
doOpenProgramsFromFiles(files, pm, monitor);
|
||||
TaskLauncher.launchModal("Open Programs", monitor -> {
|
||||
List<FSRL> tmpUnmatchedFiles = doOpenProgramsFromFiles(files, pm, monitor);
|
||||
unmatchedFiles.addAll(tmpUnmatchedFiles);
|
||||
});
|
||||
if (unmatchedFiles.size() == 1) {
|
||||
ImporterUtilities.showImportDialog(unmatchedFiles.get(0), null, null,
|
||||
plugin.getTool(), pm);
|
||||
}
|
||||
else if (unmatchedFiles.size() > 1) {
|
||||
BatchImportDialog.showAndImport(plugin.getTool(), null, unmatchedFiles, null, pm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,12 +383,10 @@ class FSBActionManager {
|
||||
* @param fsrls {@link List} of {@link FSRL}s of the files to search for.
|
||||
* @param programManager {@link ProgramManager} to use to open the programs, null ok.
|
||||
* @param monitor {@link TaskMonitor} to watch for cancel and update with progress.
|
||||
* @return list of unmatched files that need to be imported
|
||||
*/
|
||||
private void doOpenProgramsFromFiles(List<FSRL> fsrls, ProgramManager programManager,
|
||||
private List<FSRL> doOpenProgramsFromFiles(List<FSRL> fsrls, ProgramManager programManager,
|
||||
TaskMonitor monitor) {
|
||||
if (programManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int programsOpened = 0;
|
||||
List<FSRL> unmatchedFiles = new ArrayList<>();
|
||||
@ -400,12 +408,14 @@ class FSBActionManager {
|
||||
// UnmatchedFiles contains any files that had no association to a Program
|
||||
// Give the user a chance to search the project for it, and import it if not found
|
||||
if (!unmatchedFiles.isEmpty()) {
|
||||
searchProjectForMatchingFilesOrImport(unmatchedFiles, programManager, monitor,
|
||||
programsOpened);
|
||||
unmatchedFiles = searchProjectForMatchingFilesOrFail(unmatchedFiles, programManager,
|
||||
monitor, programsOpened);
|
||||
}
|
||||
|
||||
return unmatchedFiles;
|
||||
}
|
||||
|
||||
private void searchProjectForMatchingFilesOrImport(List<FSRL> fsrlList,
|
||||
private List<FSRL> searchProjectForMatchingFilesOrFail(List<FSRL> fsrlList,
|
||||
ProgramManager programManager, TaskMonitor monitor, int programsOpened) {
|
||||
boolean doSearch = isProjectSmallEnoughToSearchWithoutWarningUser() ||
|
||||
OptionDialog.showYesNoDialog(null, "Search Project for matching programs?",
|
||||
@ -430,16 +440,7 @@ class FSBActionManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (unmatchedFSRLs.size() == 1) {
|
||||
ProgramManager pmForImporter =
|
||||
programsOpened < ImportBatchTask.MAX_PROGRAMS_TO_OPEN ? programManager : null;
|
||||
ImporterUtilities.showImportDialog(unmatchedFSRLs.get(0), null, null, plugin.getTool(),
|
||||
pmForImporter);
|
||||
}
|
||||
else if (unmatchedFSRLs.size() > 1) {
|
||||
BatchImportDialog.showAndImport(plugin.getTool(), null, unmatchedFSRLs, null,
|
||||
programManager);
|
||||
}
|
||||
return unmatchedFSRLs;
|
||||
}
|
||||
|
||||
private boolean isProjectSmallEnoughToSearchWithoutWarningUser() {
|
||||
|
Loading…
Reference in New Issue
Block a user