mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Adding hashmap to get library from import header
This commit is contained in:
@@ -43,6 +43,7 @@ public class ContributionListing {
|
||||
ArrayList<ContributionChangeListener> listeners;
|
||||
ArrayList<AvailableContribution> advertisedContributions;
|
||||
Map<String, List<Contribution>> librariesByCategory;
|
||||
Map<String, Contribution> librariesByImportHeader;
|
||||
ArrayList<Contribution> allContributions;
|
||||
boolean hasDownloadedLatestList;
|
||||
boolean hasListDownloadFailed;
|
||||
@@ -53,6 +54,7 @@ public class ContributionListing {
|
||||
listeners = new ArrayList<ContributionChangeListener>();
|
||||
advertisedContributions = new ArrayList<AvailableContribution>();
|
||||
librariesByCategory = new HashMap<String, List<Contribution>>();
|
||||
librariesByImportHeader = new HashMap<String, Contribution>();
|
||||
allContributions = new ArrayList<Contribution>();
|
||||
downloadingListingLock = new ReentrantLock();
|
||||
|
||||
@@ -118,6 +120,12 @@ public class ContributionListing {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oldLib.getImports() != null) {
|
||||
for (String importName : oldLib.getImports()) {
|
||||
librariesByImportHeader.replace(importName, newLib);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < allContributions.size(); i++) {
|
||||
if (allContributions.get(i) == oldLib) {
|
||||
@@ -131,6 +139,11 @@ public class ContributionListing {
|
||||
|
||||
|
||||
private void addContribution(Contribution contribution) {
|
||||
if (contribution.getImports() != null) {
|
||||
for (String importName : contribution.getImports()) {
|
||||
librariesByImportHeader.put(importName, contribution);
|
||||
}
|
||||
}
|
||||
for (String category : contribution.getCategories()) {
|
||||
if (librariesByCategory.containsKey(category)) {
|
||||
List<Contribution> list = librariesByCategory.get(category);
|
||||
@@ -155,6 +168,11 @@ public class ContributionListing {
|
||||
librariesByCategory.get(category).remove(contribution);
|
||||
}
|
||||
}
|
||||
if (contribution.getImports() != null) {
|
||||
for (String importName : contribution.getImports()) {
|
||||
librariesByImportHeader.remove(importName);
|
||||
}
|
||||
}
|
||||
allContributions.remove(contribution);
|
||||
notifyRemove(contribution);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user