@@ -92,6 +92,8 @@ public boolean test(UserLibrary library) {
9292
9393 public static SplashScreenHelper splashScreenHelper = new SplashScreenHelper (SplashScreen .getSplashScreen ());
9494 public static Map <String , Object > FIND_DIALOG_STATE = new HashMap <String , Object >();
95+ private final ContributionInstaller contributionInstaller ;
96+ private final LibraryInstaller libraryInstaller ;
9597 private Timer selfCheckTimer ;
9698
9799 // set to true after the first time the menu is built.
@@ -302,6 +304,9 @@ public Base(String[] args) throws Exception {
302304 this .pdeKeywords = new PdeKeywords ();
303305 this .pdeKeywords .reload ();
304306
307+ contributionInstaller = new ContributionInstaller (BaseNoGui .indexer , BaseNoGui .getPlatform (), new GPGDetachedSignatureVerifier ());
308+ libraryInstaller = new LibraryInstaller (BaseNoGui .librariesIndexer , BaseNoGui .getPlatform ());
309+
305310 parser .parseArgumentsPhase2 ();
306311
307312 for (String path : parser .getFilenames ()) {
@@ -341,10 +346,9 @@ public Base(String[] args) throws Exception {
341346 if (parser .isInstallBoard ()) {
342347 ContributionsIndexer indexer = new ContributionsIndexer (BaseNoGui .getSettingsFolder (), BaseNoGui .getPlatform (), new GPGDetachedSignatureVerifier ());
343348 ProgressListener progressListener = new ConsoleProgressListener ();
344- ContributionInstaller installer = new ContributionInstaller (indexer , BaseNoGui .getPlatform (), new GPGDetachedSignatureVerifier ());
345349
346- List <String > downloadedPackageIndexFiles = installer .updateIndex (progressListener );
347- installer .deleteUnknownFiles (downloadedPackageIndexFiles );
350+ List <String > downloadedPackageIndexFiles = contributionInstaller .updateIndex (progressListener );
351+ contributionInstaller .deleteUnknownFiles (downloadedPackageIndexFiles );
348352 indexer .parseIndex ();
349353 indexer .syncWithFilesystem (BaseNoGui .getHardwareFolder ());
350354
@@ -368,24 +372,23 @@ public Base(String[] args) throws Exception {
368372 ContributedPlatform installed = indexer .getInstalled (boardToInstallParts [0 ], boardToInstallParts [1 ]);
369373
370374 if (!selected .isReadOnly ()) {
371- installer .install (selected , progressListener );
375+ contributionInstaller .install (selected , progressListener );
372376 }
373377
374378 if (installed != null && !installed .isReadOnly ()) {
375- installer .remove (installed );
379+ contributionInstaller .remove (installed );
376380 }
377381
378382 System .exit (0 );
379383
380384 } else if (parser .isInstallLibrary ()) {
381385 LibrariesIndexer indexer = new LibrariesIndexer (BaseNoGui .getSettingsFolder (), new ContributionsIndexer (BaseNoGui .getSettingsFolder (), BaseNoGui .getPlatform (), new GPGDetachedSignatureVerifier ()));
382386 ProgressListener progressListener = new ConsoleProgressListener ();
383- LibraryInstaller installer = new LibraryInstaller (indexer , BaseNoGui .getPlatform ());
384387 indexer .parseIndex ();
385388 BaseNoGui .onBoardOrPortChange ();
386389 indexer .setSketchbookLibrariesFolder (BaseNoGui .getSketchbookLibrariesFolder ());
387390 indexer .setLibrariesFolders (BaseNoGui .getLibrariesPath ());
388- installer .updateIndex (progressListener );
391+ libraryInstaller .updateIndex (progressListener );
389392
390393 for (String library : parser .getLibraryToInstall ().split ("," )) {
391394 String [] libraryToInstallParts = library .split (":" );
@@ -407,9 +410,9 @@ public Base(String[] args) throws Exception {
407410
408411 ContributedLibrary installed = indexer .getIndex ().getInstalled (libraryToInstallParts [0 ]);
409412 if (selected .isReadOnly ()) {
410- installer .remove (installed , progressListener );
413+ libraryInstaller .remove (installed , progressListener );
411414 } else {
412- installer .install (selected , installed , progressListener );
415+ libraryInstaller .install (selected , installed , progressListener );
413416 }
414417 }
415418
@@ -464,8 +467,6 @@ public Base(String[] args) throws Exception {
464467 new Thread (new BuiltInCoreIsNewerCheck (this )).start ();
465468
466469 selfCheckTimer = new Timer (false );
467- ContributionInstaller contributionInstaller = new ContributionInstaller (BaseNoGui .indexer , BaseNoGui .getPlatform (), new GPGDetachedSignatureVerifier ());
468- LibraryInstaller libraryInstaller = new LibraryInstaller (BaseNoGui .librariesIndexer , BaseNoGui .getPlatform ());
469470 selfCheckTimer .schedule (new ContributionsSelfCheck (this , new UpdatableBoardsLibsFakeURLsHandler (this ), BaseNoGui .indexer , contributionInstaller , BaseNoGui .librariesIndexer , libraryInstaller ), Constants .BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD );
470471
471472 } else if (parser .isNoOpMode ()) {
@@ -682,13 +683,6 @@ protected int[] nextEditorLocation() {
682683 "jul" , "aug" , "sep" , "oct" , "nov" , "dec"
683684 };
684685
685- /**
686- * Handle creating a sketch folder, return its base .pde file
687- * or null if the operation was canceled.
688- *
689- * @param shift whether shift is pressed, which will invert prompt setting
690- * @param noPrompt disable prompt, no matter the setting
691- */
692686 protected File createNewUntitled () throws IOException {
693687 File newbieDir = null ;
694688 String newbieName = null ;
@@ -791,20 +785,13 @@ protected void handleNewReplaceImpl() {
791785 activeEditor .handleOpenInternal (file );
792786 activeEditor .untitled = true ;
793787 }
794- // return true;
795788
796789 } catch (IOException e ) {
797790 activeEditor .statusError (e );
798- // return false;
799791 }
800792 }
801793
802794
803- /**
804- * Open a sketch, replacing the sketch in the current window.
805- *
806- * @param path Location of the primary pde file for the sketch.
807- */
808795 public void handleOpenReplace (File file ) {
809796 if (!activeEditor .checkModified ()) {
810797 return ; // sketch was modified, and user canceled
@@ -1245,21 +1232,21 @@ public void openLibraryManager(String dropdownItem) {
12451232 selfCheckTimer .cancel ();
12461233 }
12471234 @ SuppressWarnings ("serial" )
1248- LibraryManagerUI managerUI = new LibraryManagerUI (activeEditor , BaseNoGui .getPlatform () ) {
1235+ LibraryManagerUI managerUI = new LibraryManagerUI (activeEditor , BaseNoGui .librariesIndexer , libraryInstaller ) {
12491236 @ Override
12501237 protected void onIndexesUpdated () throws Exception {
12511238 BaseNoGui .initPackages ();
12521239 rebuildBoardsMenu ();
12531240 rebuildProgrammerMenu ();
12541241 onBoardOrPortChange ();
1255- setIndexer ( BaseNoGui . librariesIndexer );
1242+ updateUI ( );
12561243 if (StringUtils .isNotEmpty (dropdownItem )) {
12571244 selectDropdownItemByClassName (dropdownItem );
12581245 }
12591246 }
12601247 };
12611248 managerUI .setLocationRelativeTo (activeEditor );
1262- managerUI .setIndexer ( BaseNoGui . librariesIndexer );
1249+ managerUI .updateUI ( );
12631250 managerUI .setVisible (true );
12641251 // Manager dialog is modal, waits here until closed
12651252
@@ -1274,13 +1261,13 @@ public void openBoardsManager(final String filterText, String dropdownItem) thro
12741261 selfCheckTimer .cancel ();
12751262 }
12761263 @ SuppressWarnings ("serial" )
1277- ContributionManagerUI managerUI = new ContributionManagerUI (activeEditor , BaseNoGui .getPlatform () ) {
1264+ ContributionManagerUI managerUI = new ContributionManagerUI (activeEditor , BaseNoGui .indexer , contributionInstaller ) {
12781265 @ Override
12791266 protected void onIndexesUpdated () throws Exception {
12801267 BaseNoGui .initPackages ();
12811268 rebuildBoardsMenu ();
12821269 rebuildProgrammerMenu ();
1283- setIndexer ( BaseNoGui . indexer );
1270+ updateUI ( );
12841271 if (StringUtils .isNotEmpty (dropdownItem )) {
12851272 selectDropdownItemByClassName (dropdownItem );
12861273 }
@@ -1290,7 +1277,7 @@ protected void onIndexesUpdated() throws Exception {
12901277 }
12911278 };
12921279 managerUI .setLocationRelativeTo (activeEditor );
1293- managerUI .setIndexer ( BaseNoGui . indexer );
1280+ managerUI .updateUI ( );
12941281 managerUI .setVisible (true );
12951282 // Installer dialog is modal, waits here until closed
12961283
0 commit comments