1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-29 18:52:13 +01:00

Libraries under "contributed" in lib menu are those that have types "contributed"

This commit is contained in:
Federico Fissore 2015-03-26 17:11:43 +01:00
parent 6e498ee5b9
commit 3bcbf22a2a
2 changed files with 27 additions and 8 deletions

View File

@ -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<UserLibrary> CONTRIBUTED = new Predicate<UserLibrary>() {
@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<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), Predicates.not(CONTRIBUTED)));
return new LibraryList(libs);
}
public LibraryList getUserLibs() {
return BaseNoGui.getUserLibs();
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
List<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), CONTRIBUTED));
return new LibraryList(libs);
}
public void rebuildImportMenu(JMenu importMenu) {

View File

@ -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<UserLibrary> {
public class LibraryList extends LinkedList<UserLibrary> {
public LibraryList(LibraryList libs) {
super(libs);
@ -45,6 +46,10 @@ public class LibraryList extends ArrayList<UserLibrary> {
super();
}
public LibraryList(List<UserLibrary> 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<UserLibrary> {
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;
}
}