Skip to content

Commit f508b68

Browse files
committed
Now libraries are installed with all the dependencies
This is the base for the GUI that will be introduced in the next commits.
1 parent d74083a commit f508b68

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.Collection;
3939
import java.util.Collections;
4040
import java.util.LinkedList;
41+
import java.util.List;
4142
import java.util.function.Predicate;
4243

4344
import javax.swing.Box;
@@ -221,11 +222,23 @@ protected void onUpdatePressed() {
221222
}
222223

223224
public void onInstallPressed(final ContributedLibrary lib) {
225+
List<ContributedLibrary> deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib);
226+
final boolean installDeps;
227+
if (deps.size() > 1) {
228+
System.out.println("The library requires dependencies!");
229+
installDeps = true;
230+
} else {
231+
installDeps = false;
232+
}
224233
clearErrorMessage();
225234
installerThread = new Thread(() -> {
226235
try {
227236
setProgressVisible(true, tr("Installing..."));
228-
installer.install(lib, this::setProgress);
237+
if (installDeps) {
238+
installer.install(deps, this::setProgress);
239+
} else {
240+
installer.install(lib, this::setProgress);
241+
}
229242
onIndexesUpdated(); // TODO: Do a better job in refreshing only the needed element
230243
//getContribModel().updateLibrary(lib);
231244
} catch (Exception e) {

arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
import java.io.File;
4444
import java.io.IOException;
4545
import java.net.URL;
46+
import java.util.ArrayList;
47+
import java.util.List;
4648

4749
import static processing.app.I18n.tr;
4850

@@ -82,11 +84,19 @@ public synchronized void updateIndex(ProgressListener progressListener) throws E
8284
rescanLibraryIndex(progress, progressListener);
8385
}
8486

85-
public synchronized void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
86-
final MultiStepProgress progress = new MultiStepProgress(4);
87+
public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
88+
ArrayList<ContributedLibrary> libs = new ArrayList<>();
89+
libs.add(lib);
90+
install(libs, progressListener);
91+
}
92+
93+
public synchronized void install(List<ContributedLibrary> libs, ProgressListener progressListener) throws Exception {
94+
MultiStepProgress progress = new MultiStepProgress(3 * libs.size() + 1);
8795

88-
// Do install library (3 steps)
89-
performInstall(lib, progressListener, progress);
96+
for (ContributedLibrary lib : libs) {
97+
// Do install library (3 steps)
98+
performInstall(lib, progressListener, progress);
99+
}
90100

91101
// Rescan index (1 step)
92102
rescanLibraryIndex(progress, progressListener);

0 commit comments

Comments
 (0)