Skip to content

Commit 384de70

Browse files
cmagliefacchinm
authored andcommitted
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 c9a351a commit 384de70

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;
@@ -220,11 +221,23 @@ protected void onUpdatePressed() {
220221
}
221222

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