1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Now libraries are installed with all the dependencies

This is the base for the GUI that will be introduced in the
next commits.
This commit is contained in:
Cristian Maglie 2017-01-26 18:51:07 +01:00 committed by Martino Facchin
parent 67e38bc80a
commit 07e1518b28
2 changed files with 25 additions and 5 deletions

View File

@ -214,11 +214,23 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
} }
public void onInstallPressed(final ContributedLibrary lib) { public void onInstallPressed(final ContributedLibrary lib) {
List<ContributedLibrary> 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(); clearErrorMessage();
installerThread = new Thread(() -> { installerThread = new Thread(() -> {
try { try {
setProgressVisible(true, tr("Installing...")); 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 // TODO: Do a better job in refreshing only the needed element
if (contribTable.getCellEditor() != null) { if (contribTable.getCellEditor() != null) {
contribTable.getCellEditor().stopCellEditing(); contribTable.getCellEditor().stopCellEditing();

View File

@ -88,11 +88,19 @@ public class LibraryInstaller {
rescanLibraryIndex(progress, progressListener); rescanLibraryIndex(progress, progressListener);
} }
public synchronized void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception { public void install(ContributedLibrary lib, ProgressListener progressListener) throws Exception {
final MultiStepProgress progress = new MultiStepProgress(4); ArrayList<ContributedLibrary> libs = new ArrayList<>();
libs.add(lib);
install(libs, progressListener);
}
// Do install library (3 steps) public synchronized void install(List<ContributedLibrary> libs, ProgressListener progressListener) throws Exception {
performInstall(lib, progressListener, progress); 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) // Rescan index (1 step)
rescanLibraryIndex(progress, progressListener); rescanLibraryIndex(progress, progressListener);