diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 62508b995..c212dde77 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -26,6 +26,9 @@ import cc.arduino.contributions.libraries.ui.LibraryManagerUI; import cc.arduino.packages.DiscoveryManager; import cc.arduino.contributions.packages.ui.ContributionManagerUI; import cc.arduino.view.SplashScreenHelper; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Collections2; import org.apache.commons.lang3.StringUtils; import processing.app.debug.TargetBoard; import processing.app.debug.TargetPackage; @@ -59,6 +62,13 @@ import static processing.app.I18n._; */ public class Base { + public static final Predicate CONTRIBUTED = new Predicate() { + @Override + public boolean apply(UserLibrary library) { + return library.getTypes() == null || library.getTypes().isEmpty() || library.getTypes().contains("Contributed"); + } + }; + static private boolean commandLine; public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen()); @@ -1012,13 +1022,15 @@ public class Base { } public LibraryList getIDELibs() { - LibraryList res = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries()); - res.removeAll(getUserLibs()); - return res; + LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries()); + List libs = new LinkedList(Collections2.filter(new LinkedList(installedLibraries), Predicates.not(CONTRIBUTED))); + return new LibraryList(libs); } public LibraryList getUserLibs() { - return BaseNoGui.getUserLibs(); + LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries()); + List libs = new LinkedList(Collections2.filter(new LinkedList(installedLibraries), CONTRIBUTED)); + return new LibraryList(libs); } public void rebuildImportMenu(JMenu importMenu) { diff --git a/arduino-core/src/processing/app/packages/LibraryList.java b/arduino-core/src/processing/app/packages/LibraryList.java index 391c58b1a..9ae2c2b60 100644 --- a/arduino-core/src/processing/app/packages/LibraryList.java +++ b/arduino-core/src/processing/app/packages/LibraryList.java @@ -29,13 +29,14 @@ package processing.app.packages; import java.io.File; -import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedList; +import java.util.List; import processing.app.helpers.FileUtils; @SuppressWarnings("serial") -public class LibraryList extends ArrayList { +public class LibraryList extends LinkedList { public LibraryList(LibraryList libs) { super(libs); @@ -45,6 +46,10 @@ public class LibraryList extends ArrayList { super(); } + public LibraryList(List ideLibs) { + super(ideLibs); + } + public UserLibrary getByName(String name) { for (UserLibrary l : this) if (l.getName().equals(name)) @@ -69,9 +74,11 @@ public class LibraryList extends ArrayList { public LibraryList filterLibrariesInSubfolder(File subFolder) { LibraryList res = new LibraryList(); - for (UserLibrary lib : this) - if (FileUtils.isSubDirectory(subFolder, lib.getInstalledFolder())) + for (UserLibrary lib : this) { + if (FileUtils.isSubDirectory(subFolder, lib.getInstalledFolder())) { res.add(lib); + } + } return res; } }