Search in sources :

Example 1 with ArduinoLibraryIndex

use of io.sloeber.core.api.Json.ArduinoLibraryIndex in project arduino-eclipse-plugin by Sloeber.

the class LibraryManager method getLatestInstallableLibraries.

public static Map<String, ArduinoLibraryVersion> getLatestInstallableLibraries(Set<String> libnames) {
    Set<String> remainingLibNames = new TreeSet<>(libnames);
    Map<String, ArduinoLibraryVersion> ret = new HashMap<>();
    for (ArduinoLibraryIndex libraryIndex : libraryIndices) {
        ret.putAll(libraryIndex.getLatestInstallableLibraries(remainingLibNames));
        remainingLibNames.removeAll(ret.keySet());
    }
    return ret;
}
Also used : ArduinoLibraryVersion(io.sloeber.core.api.Json.ArduinoLibraryVersion) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArduinoLibraryIndex(io.sloeber.core.api.Json.ArduinoLibraryIndex)

Example 2 with ArduinoLibraryIndex

use of io.sloeber.core.api.Json.ArduinoLibraryIndex in project arduino-eclipse-plugin by Sloeber.

the class LibraryManager method InstallDefaultLibraries.

public static void InstallDefaultLibraries(IProgressMonitor monitor) {
    for (ArduinoLibraryIndex libindex : libraryIndices) {
        for (String libraryName : Defaults.DEFAULT_INSTALLED_LIBRARIES) {
            ArduinoLibrary toInstalLib = libindex.getLibrary(libraryName);
            if (toInstalLib != null) {
                ArduinoLibraryVersion toInstalLibVersion = toInstalLib.getNewestVersion();
                ArduinoLibraryVersion instaledLibVersion = toInstalLib.getInstalledVersion();
                if (toInstalLibVersion != null) {
                    if (toInstalLibVersion != instaledLibVersion) {
                        if (instaledLibVersion != null) {
                            unInstall(instaledLibVersion, monitor);
                        }
                        install(toInstalLibVersion, monitor);
                    }
                }
            }
        }
    }
}
Also used : ArduinoLibraryVersion(io.sloeber.core.api.Json.ArduinoLibraryVersion) ArduinoLibraryIndex(io.sloeber.core.api.Json.ArduinoLibraryIndex) ArduinoLibrary(io.sloeber.core.api.Json.ArduinoLibrary)

Example 3 with ArduinoLibraryIndex

use of io.sloeber.core.api.Json.ArduinoLibraryIndex in project arduino-eclipse-plugin by Sloeber.

the class LibraryManager method installAllLatestLibraries.

/**
 * Install the latest version of all the libraries belonging to this category If
 * a earlier version is installed this version will be removed before
 * installation of the newer version
 *
 * @param category
 */
public static void installAllLatestLibraries() {
    List<ArduinoLibraryIndex> libraryIndices1 = getLibraryIndices();
    for (ArduinoLibraryIndex libraryIndex : libraryIndices1) {
        for (ArduinoLibrary curLib : libraryIndex.getLibraries()) {
            String curLibName = curLib.getName();
            // $NON-NLS-1$ //$NON-NLS-2$
            String[] skipArray = { "Base64", "Add others if needed" };
            List<String> skipList = Arrays.asList(skipArray);
            if (!skipList.contains(curLibName)) {
                ArduinoLibraryVersion latestLibVersion = curLib.getNewestVersion();
                if (!latestLibVersion.isInstalled()) {
                    ArduinoLibraryVersion installedLibVersion = curLib.getInstalledVersion();
                    if (installedLibVersion != null) {
                        unInstall(installedLibVersion, null);
                    }
                    install(latestLibVersion, null);
                }
            }
        }
    }
}
Also used : ArduinoLibraryVersion(io.sloeber.core.api.Json.ArduinoLibraryVersion) ArduinoLibraryIndex(io.sloeber.core.api.Json.ArduinoLibraryIndex) ArduinoLibrary(io.sloeber.core.api.Json.ArduinoLibrary)

Example 4 with ArduinoLibraryIndex

use of io.sloeber.core.api.Json.ArduinoLibraryIndex in project arduino-eclipse-plugin by Sloeber.

the class LibraryManager method loadJson.

public static void loadJson(File jsonFile) {
    try (Reader reader = new FileReader(jsonFile)) {
        ArduinoLibraryIndex index = new Gson().fromJson(reader, ArduinoLibraryIndex.class);
        index.setJsonFile(jsonFile);
        libraryIndices.add(index);
    } catch (Exception e) {
        Common.log(new Status(IStatus.ERROR, Activator.getId(), Manager_Failed_to_parse.replace(FILE_TAG, jsonFile.getAbsolutePath()), e));
        // Delete the file so it stops damaging
        jsonFile.delete();
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Reader(java.io.Reader) FileReader(java.io.FileReader) Gson(com.google.gson.Gson) FileReader(java.io.FileReader) ArduinoLibraryIndex(io.sloeber.core.api.Json.ArduinoLibraryIndex) IOException(java.io.IOException)

Aggregations

ArduinoLibraryIndex (io.sloeber.core.api.Json.ArduinoLibraryIndex)4 ArduinoLibraryVersion (io.sloeber.core.api.Json.ArduinoLibraryVersion)3 ArduinoLibrary (io.sloeber.core.api.Json.ArduinoLibrary)2 Gson (com.google.gson.Gson)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1