mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
avoid adding duplicate bundles and fix a typo
This commit is contained in:
@@ -197,13 +197,22 @@ public class BundleHost {
|
||||
* Create new GhidraBundles and add to the list of managed bundles. All GhidraBundles created
|
||||
* with the same {@code enabled} and {@code systemBundle} values.
|
||||
*
|
||||
* @param bundleFiles a list of bundle files
|
||||
* @param bundleFileList a list of bundle files
|
||||
* @param enabled if the new bundle should be enabled
|
||||
* @param systemBundle if the new bundle is a system bundle
|
||||
* @return the new bundle objects
|
||||
*/
|
||||
public Collection<GhidraBundle> add(List<ResourceFile> bundleFiles, boolean enabled,
|
||||
public Collection<GhidraBundle> add(List<ResourceFile> bundleFileList, boolean enabled,
|
||||
boolean systemBundle) {
|
||||
Set<ResourceFile> bundleFiles = new HashSet<>(bundleFileList);
|
||||
Iterator<ResourceFile> bundleFileIterator = bundleFiles.iterator();
|
||||
while (bundleFileIterator.hasNext()) {
|
||||
ResourceFile bundleFile = bundleFileIterator.next();
|
||||
if (fileToBundleMap.containsKey(bundleFile)) {
|
||||
bundleFileIterator.remove();
|
||||
Msg.warn(this, "adding an already managed bundle: " + bundleFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
Map<ResourceFile, GhidraBundle> newBundleMap = bundleFiles.stream()
|
||||
.collect(Collectors.toUnmodifiableMap(Function.identity(),
|
||||
bundleFile -> createGhidraBundle(BundleHost.this, bundleFile, enabled,
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
|
||||
static final String BUNDLE_GROUP = "0bundle group";
|
||||
static final String BUNDLE_LIST_GROUP = "1bundle list group";
|
||||
|
||||
static final String PREFENCE_LAST_SELECTED_BUNDLE = "LastGhidraBundle";
|
||||
static final String PREFERENCE_LAST_SELECTED_BUNDLE = "LastGhidraBundle";
|
||||
|
||||
private JPanel panel;
|
||||
private LessFreneticGTable bundleStatusTable;
|
||||
@@ -266,14 +266,14 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
|
||||
}
|
||||
});
|
||||
}
|
||||
String lastSelected = Preferences.getProperty(PREFENCE_LAST_SELECTED_BUNDLE);
|
||||
String lastSelected = Preferences.getProperty(PREFERENCE_LAST_SELECTED_BUNDLE);
|
||||
if (lastSelected != null) {
|
||||
File lastSelectedFile = new File(lastSelected);
|
||||
fileChooser.setSelectedFile(lastSelectedFile);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String lastSelected = Preferences.getProperty(PREFENCE_LAST_SELECTED_BUNDLE);
|
||||
String lastSelected = Preferences.getProperty(PREFERENCE_LAST_SELECTED_BUNDLE);
|
||||
if (lastSelected != null) {
|
||||
File lastSelectedFile = new File(lastSelected);
|
||||
fileChooser.setSelectedFile(lastSelectedFile);
|
||||
@@ -283,7 +283,7 @@ public class BundleStatusComponentProvider extends ComponentProviderAdapter {
|
||||
|
||||
List<File> files = fileChooser.getSelectedFiles();
|
||||
if (!files.isEmpty()) {
|
||||
Preferences.setProperty(PREFENCE_LAST_SELECTED_BUNDLE, files.get(0).getAbsolutePath());
|
||||
Preferences.setProperty(PREFERENCE_LAST_SELECTED_BUNDLE, files.get(0).getAbsolutePath());
|
||||
List<ResourceFile> resourceFiles =
|
||||
files.stream().map(ResourceFile::new).collect(Collectors.toUnmodifiableList());
|
||||
Collection<GhidraBundle> bundles = bundleHost.add(resourceFiles, true, false);
|
||||
|
||||
Reference in New Issue
Block a user