Added filters properties for showing installed and upgradeable

This commit is contained in:
pesckal
2011-07-17 22:50:17 +00:00
parent d5626a8e01
commit 0a58c652b2
3 changed files with 25 additions and 9 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ public class Base {
/** True if heavy debugging error/log messages are enabled */
static public boolean DEBUG = false;
// static public boolean DEBUG = true;
static public boolean ENABLE_LIBRARY_MANAGER = false;
static public boolean ENABLE_LIBRARY_MANAGER = true;
static HashMap<Integer, String> platformNames =
new HashMap<Integer, String>();
@@ -220,23 +220,39 @@ public class ContributionListing {
return filteredList;
}
private boolean matches(ContributionInfo libInfo, String filter) {
private boolean matches(ContributionInfo info, String filter) {
// Maybe this can be fancy some other time
if (filter.equals("has:update") || filter.equals("has:updates")) {
return info.latestVersion != null;
}
if (filter.equals("is:installed")) {
return info.isInstalled();
}
if (filter.equals("not:installed")) {
return !info.isInstalled();
}
if (filter.contains(":")) {
// Return true and ignore everything else if the property is invalid.
return true;
}
// sdfikjfdslk Added filters properties for showing installed and upgrade
filter = ".*" + filter.toLowerCase() + ".*";
if (filter.isEmpty()) {
return true;
}
for (Author author : libInfo.authorList) {
for (Author author : info.authorList) {
if (author.name.toLowerCase().matches(filter)) {
return true;
}
}
return libInfo.sentence != null && libInfo.sentence.toLowerCase().matches(filter)
|| libInfo.paragraph != null && libInfo.paragraph.toLowerCase().matches(filter)
|| libInfo.category != null && libInfo.category.toLowerCase().matches(filter)
|| libInfo.name != null && libInfo.name.toLowerCase().matches(filter);
return info.sentence != null && info.sentence.toLowerCase().matches(filter)
|| info.paragraph != null && info.paragraph.toLowerCase().matches(filter)
|| info.category != null && info.category.toLowerCase().matches(filter)
|| info.name != null && info.name.toLowerCase().matches(filter);
}
@@ -755,8 +755,8 @@ public class ContributionManager {
String filter = filterField.getFilterText();
filter = filter.toLowerCase();
// Replace anything but 0-9 or a-z with a space
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a]", " ");
// 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);
}