mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Finished work on Showing only compatible contribs
This commit is contained in:
@@ -137,9 +137,8 @@ abstract public class Contribution {
|
||||
if (compatibleVersions == null)
|
||||
return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("");
|
||||
for (Map.Entry<Integer, Integer> range : compatibleVersions.entrySet()) {
|
||||
if (range.getKey() == range.getValue()) {
|
||||
if (range.getKey().equals(range.getValue())) {
|
||||
sb.append(range.getKey());
|
||||
sb.append(",");
|
||||
}
|
||||
@@ -147,6 +146,7 @@ abstract public class Contribution {
|
||||
sb.append(range.getKey());
|
||||
sb.append("-");
|
||||
sb.append(range.getValue());
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length()-1); // delete last comma
|
||||
@@ -161,9 +161,9 @@ abstract public class Contribution {
|
||||
|
||||
public boolean isCompatible(int versionNum) {
|
||||
if (compatibleVersions != null) {
|
||||
if (compatibleVersions.ceilingEntry(versionNum) != null
|
||||
&& versionNum <= compatibleVersions.ceilingEntry(versionNum).getValue())
|
||||
return true;
|
||||
if (compatibleVersions.floorEntry(versionNum) != null
|
||||
&& versionNum <= compatibleVersions.floorEntry(versionNum).getValue()) {
|
||||
return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -308,6 +308,24 @@ public class ContributionListing {
|
||||
}
|
||||
|
||||
|
||||
protected List<Contribution> getCompatibleContributionList(List<Contribution> filteredLibraries, boolean filter) {
|
||||
ArrayList<Contribution> filteredList =
|
||||
new ArrayList<Contribution>(filteredLibraries);
|
||||
|
||||
if (!filter)
|
||||
return filteredList;
|
||||
|
||||
Iterator<Contribution> it = filteredList.iterator();
|
||||
while (it.hasNext()) {
|
||||
Contribution libInfo = it.next();
|
||||
if (!libInfo.isCompatible(Base.getRevision())) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return filteredList;
|
||||
}
|
||||
|
||||
|
||||
private void notifyRemove(Contribution contribution) {
|
||||
for (ContributionChangeListener listener : listeners) {
|
||||
listener.contributionRemoved(contribution);
|
||||
|
||||
@@ -57,6 +57,7 @@ public class ContributionManagerDialog {
|
||||
// the calling editor, so updates can be applied
|
||||
Editor editor;
|
||||
String category;
|
||||
boolean isCompatibilityFilter;
|
||||
ContributionListing contribListing;
|
||||
|
||||
|
||||
@@ -217,7 +218,7 @@ public class ContributionManagerDialog {
|
||||
if (ContributionManagerDialog.ANY_CATEGORY.equals(category)) {
|
||||
category = null;
|
||||
}
|
||||
filterLibraries(category, filterField.filters);
|
||||
filterLibraries(category, filterField.filters, isCompatibilityFilter);
|
||||
contributionListPanel.updateColors();
|
||||
}
|
||||
});
|
||||
@@ -233,12 +234,14 @@ public class ContributionManagerDialog {
|
||||
.equalsIgnoreCase("Library") ? "Libraries" : (title.substring(0, title
|
||||
.indexOf(" ")) + "s");
|
||||
|
||||
JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType);
|
||||
final JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType);
|
||||
compatibleContrib.addItemListener(new ItemListener() {
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent arg0) {
|
||||
System.out.println(Base.getRevision());
|
||||
isCompatibilityFilter = compatibleContrib.isSelected();
|
||||
filterLibraries(category, filterField.filters, isCompatibilityFilter);
|
||||
contributionListPanel.updateColors();
|
||||
}
|
||||
});
|
||||
filterPanel.add(compatibleContrib);
|
||||
@@ -403,6 +406,14 @@ public class ContributionManagerDialog {
|
||||
contributionListPanel.filterLibraries(filteredLibraries);
|
||||
}
|
||||
|
||||
|
||||
protected void filterLibraries(String category, List<String> filters, boolean isCompatibilityFilter) {
|
||||
List<Contribution> filteredLibraries =
|
||||
contribListing.getFilteredLibraryList(category, filters);
|
||||
filteredLibraries = contribListing.getCompatibleContributionList(filteredLibraries, isCompatibilityFilter);
|
||||
contributionListPanel.filterLibraries(filteredLibraries);
|
||||
}
|
||||
|
||||
|
||||
protected void updateContributionListing() {
|
||||
if (editor != null) {
|
||||
@@ -539,7 +550,7 @@ public class ContributionManagerDialog {
|
||||
// Replace anything but 0-9, a-z, or : with a space
|
||||
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
|
||||
filters = Arrays.asList(filter.split(" "));
|
||||
filterLibraries(category, filters);
|
||||
filterLibraries(category, filters, isCompatibilityFilter);
|
||||
|
||||
contributionListPanel.updateColors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user