mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-06 01:08:25 +01:00
Libraries under "contributed" in lib menu are those that have types "contributed"
This commit is contained in:
parent
6e498ee5b9
commit
3bcbf22a2a
@ -26,6 +26,9 @@ import cc.arduino.contributions.libraries.ui.LibraryManagerUI;
|
|||||||
import cc.arduino.packages.DiscoveryManager;
|
import cc.arduino.packages.DiscoveryManager;
|
||||||
import cc.arduino.contributions.packages.ui.ContributionManagerUI;
|
import cc.arduino.contributions.packages.ui.ContributionManagerUI;
|
||||||
import cc.arduino.view.SplashScreenHelper;
|
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 org.apache.commons.lang3.StringUtils;
|
||||||
import processing.app.debug.TargetBoard;
|
import processing.app.debug.TargetBoard;
|
||||||
import processing.app.debug.TargetPackage;
|
import processing.app.debug.TargetPackage;
|
||||||
@ -59,6 +62,13 @@ import static processing.app.I18n._;
|
|||||||
*/
|
*/
|
||||||
public class Base {
|
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;
|
static private boolean commandLine;
|
||||||
public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
|
public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper(SplashScreen.getSplashScreen());
|
||||||
|
|
||||||
@ -1012,13 +1022,15 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LibraryList getIDELibs() {
|
public LibraryList getIDELibs() {
|
||||||
LibraryList res = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
|
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
|
||||||
res.removeAll(getUserLibs());
|
List<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), Predicates.not(CONTRIBUTED)));
|
||||||
return res;
|
return new LibraryList(libs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibraryList getUserLibs() {
|
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) {
|
public void rebuildImportMenu(JMenu importMenu) {
|
||||||
|
@ -29,13 +29,14 @@
|
|||||||
package processing.app.packages;
|
package processing.app.packages;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.FileUtils;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class LibraryList extends ArrayList<UserLibrary> {
|
public class LibraryList extends LinkedList<UserLibrary> {
|
||||||
|
|
||||||
public LibraryList(LibraryList libs) {
|
public LibraryList(LibraryList libs) {
|
||||||
super(libs);
|
super(libs);
|
||||||
@ -45,6 +46,10 @@ public class LibraryList extends ArrayList<UserLibrary> {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LibraryList(List<UserLibrary> ideLibs) {
|
||||||
|
super(ideLibs);
|
||||||
|
}
|
||||||
|
|
||||||
public UserLibrary getByName(String name) {
|
public UserLibrary getByName(String name) {
|
||||||
for (UserLibrary l : this)
|
for (UserLibrary l : this)
|
||||||
if (l.getName().equals(name))
|
if (l.getName().equals(name))
|
||||||
@ -69,9 +74,11 @@ public class LibraryList extends ArrayList<UserLibrary> {
|
|||||||
|
|
||||||
public LibraryList filterLibrariesInSubfolder(File subFolder) {
|
public LibraryList filterLibrariesInSubfolder(File subFolder) {
|
||||||
LibraryList res = new LibraryList();
|
LibraryList res = new LibraryList();
|
||||||
for (UserLibrary lib : this)
|
for (UserLibrary lib : this) {
|
||||||
if (FileUtils.isSubDirectory(subFolder, lib.getInstalledFolder()))
|
if (FileUtils.isSubDirectory(subFolder, lib.getInstalledFolder())) {
|
||||||
res.add(lib);
|
res.add(lib);
|
||||||
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user