From 1328f3a9e2ba5322b86e75cd10f4ab54d69030d9 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Tue, 17 Nov 2015 12:24:28 +0100 Subject: [PATCH] Library and Boards Managers were using old copies of library/boards indeces. thus making the UI show old data. Fixes #4139 #3904 #3795 --- .../contributions/libraries/ui/LibraryManagerUI.java | 8 ++++---- .../contributions/packages/ui/ContributionManagerUI.java | 6 +++--- app/src/processing/app/Base.java | 4 ++-- arduino-core/src/processing/app/BaseNoGui.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java index 79ef1139013..f6b6cd1c55d 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java @@ -36,6 +36,7 @@ import cc.arduino.contributions.libraries.LibraryTypeComparator; import cc.arduino.contributions.ui.*; import cc.arduino.utils.Progress; +import processing.app.BaseNoGui; import javax.swing.*; import java.awt.*; @@ -52,7 +53,6 @@ public class LibraryManagerUI extends InstallerJDialog { private final JComboBox typeChooser; - private final LibrariesIndexer indexer; private final LibraryInstaller installer; private Predicate typeFilter; @@ -89,9 +89,8 @@ protected void onRemove(ContributedLibrary library) { }; } - public LibraryManagerUI(Frame parent, LibrariesIndexer indexer, LibraryInstaller installer) { + public LibraryManagerUI(Frame parent, LibraryInstaller installer) { super(parent, tr("Library Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues.")); - this.indexer = indexer; this.installer = installer; filtersContainer.add(new JLabel(tr("Topic")), 1); @@ -139,6 +138,7 @@ public void updateUI() { // TODO: Remove setIndexer and make getContribModel // return a FilteredAbstractTableModel + LibrariesIndexer indexer = BaseNoGui.librariesIndexer; getContribModel().setIndexer(indexer); categoryFilter = null; @@ -236,7 +236,7 @@ public void onInstallPressed(final ContributedLibrary lib, final ContributedLibr } public void onRemovePressed(final ContributedLibrary lib) { - boolean managedByIndex = indexer.getIndex().getLibraries().contains(lib); + boolean managedByIndex = BaseNoGui.librariesIndexer.getIndex().getLibraries().contains(lib); if (!managedByIndex) { int chosenOption = JOptionPane.showConfirmDialog(this, tr("This library is not listed on Library Manager. You won't be able to reinstall it from here.\nAre you sure you want to delete it?"), tr("Please confirm library deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java index 49ef97618b5..e8a140492ba 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java @@ -35,6 +35,7 @@ import cc.arduino.contributions.packages.ContributionsIndexer; import cc.arduino.contributions.ui.*; import cc.arduino.utils.Progress; +import processing.app.BaseNoGui; import processing.app.I18n; import javax.swing.*; @@ -48,7 +49,6 @@ @SuppressWarnings("serial") public class ContributionManagerUI extends InstallerJDialog { - private final ContributionsIndexer indexer; private final ContributionInstaller installer; @Override @@ -84,9 +84,8 @@ protected void onRemove(ContributedPlatform installedPlatform) { }; } - public ContributionManagerUI(Frame parent, ContributionsIndexer indexer, ContributionInstaller installer) { + public ContributionManagerUI(Frame parent, ContributionInstaller installer) { super(parent, tr("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues.")); - this.indexer = indexer; this.installer = installer; } @@ -95,6 +94,7 @@ public void updateUI() { categoryChooser.removeActionListener(categoryChooserActionListener); + ContributionsIndexer indexer = BaseNoGui.indexer; getContribModel().setIndexer(indexer); categoryFilter = null; diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 23e549e8977..bc9c90ef82e 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1280,7 +1280,7 @@ public void openLibraryManager(String dropdownItem) { contributionsSelfCheck.cancel(); } @SuppressWarnings("serial") - LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, BaseNoGui.librariesIndexer, libraryInstaller) { + LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, libraryInstaller) { @Override protected void onIndexesUpdated() throws Exception { BaseNoGui.initPackages(); @@ -1309,7 +1309,7 @@ public void openBoardsManager(final String filterText, String dropdownItem) thro contributionsSelfCheck.cancel(); } @SuppressWarnings("serial") - ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, BaseNoGui.indexer, contributionInstaller) { + ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, contributionInstaller) { @Override protected void onIndexesUpdated() throws Exception { BaseNoGui.initPackages(); diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index badb7557ead..0edb40d6228 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -84,7 +84,7 @@ public class BaseNoGui { static final String portableSketchbookFolder = "sketchbook"; public static ContributionsIndexer indexer; - static LibrariesIndexer librariesIndexer; + public static LibrariesIndexer librariesIndexer; // Returns a File object for the given pathname. If the pathname // is not absolute, it is interpreted relative to the current