From 07e1518b28c25ddba5a3a313109b313d68ef5c2f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 26 Jan 2017 18:51:07 +0100 Subject: [PATCH] Now libraries are installed with all the dependencies This is the base for the GUI that will be introduced in the next commits. --- .../libraries/ui/LibraryManagerUI.java | 14 +++++++++++++- .../libraries/LibraryInstaller.java | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java index 3847920b6..16f70f581 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java @@ -214,11 +214,23 @@ public class LibraryManagerUI extends InstallerJDialog deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib); + final boolean installDeps; + if (deps.size() > 1) { + System.out.println("The library requires dependencies!"); + installDeps = true; + } else { + installDeps = false; + } clearErrorMessage(); installerThread = new Thread(() -> { try { setProgressVisible(true, tr("Installing...")); - installer.install(lib, this::setProgress); + if (installDeps) { + installer.install(deps, this::setProgress); + } else { + installer.install(lib, this::setProgress); + } // TODO: Do a better job in refreshing only the needed element if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java index 8d040effc..de91c0490 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java @@ -88,11 +88,19 @@ public class LibraryInstaller { rescanLibraryIndex(progress, progressListener); } - public synchronized void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception { - final MultiStepProgress progress = new MultiStepProgress(4); + public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception { + ArrayList libs = new ArrayList<>(); + libs.add(lib); + install(libs, progressListener); + } - // Do install library (3 steps) - performInstall(lib, progressListener, progress); + public synchronized void install(List libs, ProgressListener progressListener) throws Exception { + MultiStepProgress progress = new MultiStepProgress(3 * libs.size() + 1); + + for (ContributedLibrary lib : libs) { + // Do install library (3 steps) + performInstall(lib, progressListener, progress); + } // Rescan index (1 step) rescanLibraryIndex(progress, progressListener);