avoid adding duplicate bundles and fix a typo

This commit is contained in:
Jason P. Leasure
2020-07-16 19:19:16 -04:00
parent 72ecf05ab2
commit 49998a8235
2 changed files with 15 additions and 6 deletions

View File

@@ -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,

View File

@@ -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);