Skip to content

Commit 1328f3a

Browse files
author
Federico Fissore
committed
Library and Boards Managers were using old copies of library/boards indeces. thus making the UI show old data. Fixes #4139 #3904 #3795
1 parent 0fb04b3 commit 1328f3a

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import cc.arduino.contributions.libraries.LibraryTypeComparator;
3737
import cc.arduino.contributions.ui.*;
3838
import cc.arduino.utils.Progress;
39+
import processing.app.BaseNoGui;
3940

4041
import javax.swing.*;
4142
import java.awt.*;
@@ -52,7 +53,6 @@
5253
public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
5354

5455
private final JComboBox typeChooser;
55-
private final LibrariesIndexer indexer;
5656
private final LibraryInstaller installer;
5757
private Predicate<ContributedLibrary> typeFilter;
5858

@@ -89,9 +89,8 @@ protected void onRemove(ContributedLibrary library) {
8989
};
9090
}
9191

92-
public LibraryManagerUI(Frame parent, LibrariesIndexer indexer, LibraryInstaller installer) {
92+
public LibraryManagerUI(Frame parent, LibraryInstaller installer) {
9393
super(parent, tr("Library Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
94-
this.indexer = indexer;
9594
this.installer = installer;
9695

9796
filtersContainer.add(new JLabel(tr("Topic")), 1);
@@ -139,6 +138,7 @@ public void updateUI() {
139138

140139
// TODO: Remove setIndexer and make getContribModel
141140
// return a FilteredAbstractTableModel
141+
LibrariesIndexer indexer = BaseNoGui.librariesIndexer;
142142
getContribModel().setIndexer(indexer);
143143

144144
categoryFilter = null;
@@ -236,7 +236,7 @@ public void onInstallPressed(final ContributedLibrary lib, final ContributedLibr
236236
}
237237

238238
public void onRemovePressed(final ContributedLibrary lib) {
239-
boolean managedByIndex = indexer.getIndex().getLibraries().contains(lib);
239+
boolean managedByIndex = BaseNoGui.librariesIndexer.getIndex().getLibraries().contains(lib);
240240

241241
if (!managedByIndex) {
242242
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);

app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import cc.arduino.contributions.packages.ContributionsIndexer;
3636
import cc.arduino.contributions.ui.*;
3737
import cc.arduino.utils.Progress;
38+
import processing.app.BaseNoGui;
3839
import processing.app.I18n;
3940

4041
import javax.swing.*;
@@ -48,7 +49,6 @@
4849
@SuppressWarnings("serial")
4950
public class ContributionManagerUI extends InstallerJDialog {
5051

51-
private final ContributionsIndexer indexer;
5252
private final ContributionInstaller installer;
5353

5454
@Override
@@ -84,9 +84,8 @@ protected void onRemove(ContributedPlatform installedPlatform) {
8484
};
8585
}
8686

87-
public ContributionManagerUI(Frame parent, ContributionsIndexer indexer, ContributionInstaller installer) {
87+
public ContributionManagerUI(Frame parent, ContributionInstaller installer) {
8888
super(parent, tr("Boards Manager"), Dialog.ModalityType.APPLICATION_MODAL, tr("Unable to reach Arduino.cc due to possible network issues."));
89-
this.indexer = indexer;
9089
this.installer = installer;
9190
}
9291

@@ -95,6 +94,7 @@ public void updateUI() {
9594

9695
categoryChooser.removeActionListener(categoryChooserActionListener);
9796

97+
ContributionsIndexer indexer = BaseNoGui.indexer;
9898
getContribModel().setIndexer(indexer);
9999

100100
categoryFilter = null;

app/src/processing/app/Base.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ public void openLibraryManager(String dropdownItem) {
12801280
contributionsSelfCheck.cancel();
12811281
}
12821282
@SuppressWarnings("serial")
1283-
LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, BaseNoGui.librariesIndexer, libraryInstaller) {
1283+
LibraryManagerUI managerUI = new LibraryManagerUI(activeEditor, libraryInstaller) {
12841284
@Override
12851285
protected void onIndexesUpdated() throws Exception {
12861286
BaseNoGui.initPackages();
@@ -1309,7 +1309,7 @@ public void openBoardsManager(final String filterText, String dropdownItem) thro
13091309
contributionsSelfCheck.cancel();
13101310
}
13111311
@SuppressWarnings("serial")
1312-
ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, BaseNoGui.indexer, contributionInstaller) {
1312+
ContributionManagerUI managerUI = new ContributionManagerUI(activeEditor, contributionInstaller) {
13131313
@Override
13141314
protected void onIndexesUpdated() throws Exception {
13151315
BaseNoGui.initPackages();

arduino-core/src/processing/app/BaseNoGui.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class BaseNoGui {
8484
static final String portableSketchbookFolder = "sketchbook";
8585

8686
public static ContributionsIndexer indexer;
87-
static LibrariesIndexer librariesIndexer;
87+
public static LibrariesIndexer librariesIndexer;
8888

8989
// Returns a File object for the given pathname. If the pathname
9090
// is not absolute, it is interpreted relative to the current

0 commit comments

Comments
 (0)