mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 21:29:17 +01:00
fix nasty sync problem w/ contrib list; other cleaning while debugging
This commit is contained in:
@@ -26,6 +26,7 @@ import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import processing.app.Base;
|
||||
@@ -62,7 +63,7 @@ public class ContributionListing {
|
||||
listPanels = new HashSet<>();
|
||||
advertisedContributions = new ArrayList<>();
|
||||
librariesByImportHeader = new HashMap<>();
|
||||
allContributions = new LinkedHashSet<>();
|
||||
allContributions = ConcurrentHashMap.newKeySet();
|
||||
downloadingLock = new ReentrantLock();
|
||||
|
||||
listingFile = Base.getSettingsFile(LOCAL_FILENAME);
|
||||
@@ -97,6 +98,48 @@ public class ContributionListing {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the installed libraries to the listing of libraries, replacing
|
||||
* any pre-existing libraries by the same name as one in the list.
|
||||
*/
|
||||
protected void updateInstalled(Set<Contribution> installed) {
|
||||
// Map<Contribution, Contribution> replacements = new HashMap<>();
|
||||
// Set<Contribution> additions = new HashSet<>();
|
||||
|
||||
for (Contribution contribution : installed) {
|
||||
Contribution existingContribution = findContribution(contribution);
|
||||
if (existingContribution != null) {
|
||||
if (existingContribution != contribution) {
|
||||
// don't replace contrib with itself
|
||||
replaceContribution(existingContribution, contribution);
|
||||
// replacements.put(existingContribution, contribution);
|
||||
}
|
||||
} else {
|
||||
addContribution(contribution);
|
||||
// additions.add(contribution);
|
||||
}
|
||||
}
|
||||
|
||||
// for (Contribution existing : replacements.keySet()) {
|
||||
// replaceContribution(existing, replacements.get(existing));
|
||||
// }
|
||||
// for (Contribution adding : additions) {
|
||||
// addContribution(adding);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
private Contribution findContribution(Contribution contribution) {
|
||||
for (Contribution c : allContributions) {
|
||||
if (c.getName().equals(contribution.getName()) &&
|
||||
c.getType() == contribution.getType()) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected void replaceContribution(Contribution oldLib, Contribution newLib) {
|
||||
if (oldLib != null && newLib != null) {
|
||||
if (oldLib.getImports() != null) {
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ContributionTab extends JPanel {
|
||||
category = null;
|
||||
}
|
||||
//filterLibraries(category, filterField.filterWords);
|
||||
filterLibraries();
|
||||
updateFilter();
|
||||
});
|
||||
|
||||
filterField = new FilterField();
|
||||
@@ -316,9 +316,11 @@ public class ContributionTab extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
//protected void filterLibraries(String category, List<String> filters) {
|
||||
protected void filterLibraries() {
|
||||
listPanel.filterLibraries(category, filterField.filterWords);
|
||||
/**
|
||||
* Filter the libraries based on category and filter words.
|
||||
*/
|
||||
protected void updateFilter() {
|
||||
listPanel.updateFilter(category, filterField.filterWords);
|
||||
}
|
||||
|
||||
|
||||
@@ -475,7 +477,7 @@ public class ContributionTab extends JPanel {
|
||||
|
||||
filterWords = Arrays.asList(filter.split(" "));
|
||||
//filterLibraries(category, filterWords);
|
||||
filterLibraries();
|
||||
updateFilter();
|
||||
}
|
||||
|
||||
protected void updateTheme() {
|
||||
|
||||
@@ -704,28 +704,19 @@ public class ListPanel extends JPanel implements Scrollable {
|
||||
|
||||
// Thread: EDT
|
||||
protected void contributionChanged(final Contribution oldContrib,
|
||||
final Contribution newContrib) {
|
||||
final Contribution newContrib) {
|
||||
if (filter.matches(oldContrib)) {
|
||||
// if (true || filter.matches(oldContrib)) {
|
||||
// System.out.println(contributionTab.contribType + " tab: " +
|
||||
// "changed " + oldContrib + " -> " + newContrib);
|
||||
// new Exception().printStackTrace(System.out);
|
||||
StatusDetail detail = detailForContrib.get(oldContrib);
|
||||
// if (panel == null) {
|
||||
//// System.out.println("panel null for " + newContrib);
|
||||
// contributionAdded(newContrib);
|
||||
// } else {
|
||||
detailForContrib.remove(oldContrib);
|
||||
detail.setContrib(newContrib);
|
||||
detailForContrib.put(newContrib, detail);
|
||||
model.fireTableDataChanged();
|
||||
// }
|
||||
detailForContrib.remove(oldContrib);
|
||||
detail.setContrib(newContrib);
|
||||
detailForContrib.put(newContrib, detail);
|
||||
model.fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Thread: EDT
|
||||
protected void filterLibraries(String category, List<String> filters) {
|
||||
protected void updateFilter(String category, List<String> filters) {
|
||||
rowFilter.setCategoryFilter(category);
|
||||
rowFilter.setStringFilters(filters);
|
||||
model.fireTableDataChanged();
|
||||
|
||||
@@ -96,8 +96,12 @@ public class ManagerFrame {
|
||||
// ContributionListing.updateInstalled(base);
|
||||
// showTab.activate();
|
||||
// } else {
|
||||
ContributionListing.getInstance().updateInstalled(base.getInstalledContribs());
|
||||
}
|
||||
tabs.setPanel(showTab);
|
||||
// if (contributionType == null) {
|
||||
// showTab.listPanel.model.fireTableDataChanged();
|
||||
// System.out.println("rows: " + showTab.listPanel.model.getRowCount());
|
||||
// }
|
||||
frame.setVisible(true);
|
||||
// Avoid the search box taking focus and hiding the 'search' text
|
||||
|
||||
Reference in New Issue
Block a user