Search in sources :

Example 6 with ArduinoLibraryVersion

use of io.sloeber.core.api.Json.ArduinoLibraryVersion 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 7 with ArduinoLibraryVersion

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

the class LibrarySelectionPage method performOk.

@Override
public boolean performOk() {
    if (this.isJobRunning == true) {
        // $NON-NLS-1$
        MessageDialog.openInformation(// $NON-NLS-1$
        getShell(), // $NON-NLS-1$
        "Library Manager", // $NON-NLS-1$
        "Library Manager is busy. Please wait some time...");
        return false;
    }
    this.isJobRunning = true;
    Job job = new Job(Messages.ui_Adopting_arduino_libraries) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            MultiStatus status = new MultiStatus(PLUGIN_ID, 0, Messages.ui_installing_arduino_libraries, null);
            Set<ArduinoLibraryVersion> toRemoveLibs = new HashSet<>();
            Set<ArduinoLibraryVersion> toInstallLibs = new HashSet<>();
            for (Category category : libs.categories.values()) {
                for (Library library : category.libraries.values()) {
                    ArduinoLibraryVersion installedVersion = library.getInstalledVersion();
                    ArduinoLibraryVersion toInstalVersion = library.getVersion();
                    if ((installedVersion != null) && (installedVersion.compareTo(toInstalVersion) != 0)) {
                        toRemoveLibs.add(installedVersion);
                    }
                    if ((toInstalVersion != null) && (toInstalVersion.compareTo(installedVersion) != 0)) {
                        toInstallLibs.add(toInstalVersion);
                    }
                }
            }
            return LibraryManager.updateLibraries(toRemoveLibs, toInstallLibs, monitor, status);
        }
    };
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            LibrarySelectionPage.this.isJobRunning = false;
        }
    });
    job.setUser(true);
    job.schedule();
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArduinoLibraryVersion(io.sloeber.core.api.Json.ArduinoLibraryVersion) Category(io.sloeber.ui.preferences.LibrarySelectionPage.LibraryTree.Category) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) MultiStatus(org.eclipse.core.runtime.MultiStatus) ArduinoLibrary(io.sloeber.core.api.Json.ArduinoLibrary) Library(io.sloeber.ui.preferences.LibrarySelectionPage.LibraryTree.Library) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) HashSet(java.util.HashSet)

Aggregations

ArduinoLibraryVersion (io.sloeber.core.api.Json.ArduinoLibraryVersion)7 ArduinoLibrary (io.sloeber.core.api.Json.ArduinoLibrary)4 ArduinoLibraryIndex (io.sloeber.core.api.Json.ArduinoLibraryIndex)3 TreeSet (java.util.TreeSet)3 Category (io.sloeber.ui.preferences.LibrarySelectionPage.LibraryTree.Category)2 Library (io.sloeber.ui.preferences.LibrarySelectionPage.LibraryTree.Library)2 HashMap (java.util.HashMap)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IInstallLibraryHandler (io.sloeber.core.api.IInstallLibraryHandler)1 VersionNumber (io.sloeber.core.api.VersionNumber)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)1 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)1 ICProjectDescriptionManager (org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1