Skip to content

Commit 8f57144

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 18e90ea commit 8f57144

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,23 @@ protected void onUpdatePressed() {
214214
}
215215

216216
public void onInstallPressed(final ContributedLibrary lib) {
217+
List<ContributedLibrary> deps = BaseNoGui.librariesIndexer.getIndex().resolveDependeciesOf(lib);
218+
final boolean installDeps;
219+
if (deps.size() > 1) {
220+
System.out.println("The library requires dependencies!");
221+
installDeps = true;
222+
} else {
223+
installDeps = false;
224+
}
217225
clearErrorMessage();
218226
installerThread = new Thread(() -> {
219227
try {
220228
setProgressVisible(true, tr("Installing..."));
221-
installer.install(lib, this::setProgress);
229+
if (installDeps) {
230+
installer.install(deps, this::setProgress);
231+
} else {
232+
installer.install(lib, this::setProgress);
233+
}
222234
// TODO: Do a better job in refreshing only the needed element
223235
if (contribTable.getCellEditor() != null) {
224236
contribTable.getCellEditor().stopCellEditing();

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ public synchronized void updateIndex(ProgressListener progressListener) throws E
8888
rescanLibraryIndex(progress, progressListener);
8989
}
9090

91-
public synchronized void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
92-
final MultiStepProgress progress = new MultiStepProgress(4);
91+
public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
92+
ArrayList<ContributedLibrary> libs = new ArrayList<>();
93+
libs.add(lib);
94+
install(libs, progressListener);
95+
}
96+
97+
public synchronized void install(List<ContributedLibrary> libs, ProgressListener progressListener) throws Exception {
98+
MultiStepProgress progress = new MultiStepProgress(3 * libs.size() + 1);
9399

94-
// Do install library (3 steps)
95-
performInstall(lib, progressListener, progress);
100+
for (ContributedLibrary lib : libs) {
101+
// Do install library (3 steps)
102+
performInstall(lib, progressListener, progress);
103+
}
96104

97105
// Rescan index (1 step)
98106
rescanLibraryIndex(progress, progressListener);

0 commit comments

Comments
 (0)