File tree 2 files changed +28
-5
lines changed
app/src/cc/arduino/contributions/libraries/ui
arduino-core/src/cc/arduino/contributions/libraries
2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 38
38
import java .util .Collection ;
39
39
import java .util .Collections ;
40
40
import java .util .LinkedList ;
41
+ import java .util .List ;
41
42
import java .util .function .Predicate ;
42
43
43
44
import javax .swing .Box ;
@@ -220,11 +221,23 @@ protected void onUpdatePressed() {
220
221
}
221
222
222
223
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
+ }
223
232
clearErrorMessage ();
224
233
installerThread = new Thread (() -> {
225
234
try {
226
235
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
+ }
228
241
onIndexesUpdated (); // TODO: Do a better job in refreshing only the needed element
229
242
//getContribModel().updateLibrary(lib);
230
243
} catch (Exception e ) {
Original file line number Diff line number Diff line change 43
43
import java .io .File ;
44
44
import java .io .IOException ;
45
45
import java .net .URL ;
46
+ import java .util .ArrayList ;
47
+ import java .util .List ;
46
48
47
49
import static processing .app .I18n .tr ;
48
50
@@ -82,11 +84,19 @@ public synchronized void updateIndex(ProgressListener progressListener) throws E
82
84
rescanLibraryIndex (progress , progressListener );
83
85
}
84
86
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 );
87
95
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
+ }
90
100
91
101
// Rescan index (1 step)
92
102
rescanLibraryIndex (progress , progressListener );
You can’t perform that action at this time.
0 commit comments