From 1361bce6bc703602499c0bc7d4ac154063de4ade Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 22 Jul 2020 17:06:46 +0200 Subject: [PATCH 1/4] Board manager: Update filters UI only if categories changes --- .../packages/ui/ContributionManagerUI.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java index 6f9c903c3..48fbca5d8 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java @@ -29,7 +29,6 @@ package cc.arduino.contributions.packages.ui; -import cc.arduino.contributions.DownloadableContribution; import cc.arduino.contributions.packages.ContributedPlatform; import cc.arduino.contributions.packages.ContributionInstaller; import cc.arduino.contributions.ui.*; @@ -41,6 +40,7 @@ import javax.swing.*; import javax.swing.table.TableCellRenderer; import java.awt.*; +import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; @@ -92,30 +92,28 @@ public class ContributionManagerUI extends InstallerJDialog { this.installer = installer; } + private Collection oldCategories = new ArrayList<>(); + public void updateUI() { - DropdownItem previouslySelectedCategory = (DropdownItem) categoryChooser - .getSelectedItem(); + // Check if categories have changed + Collection categories = BaseNoGui.indexer.getCategories(); + if (categories.equals(oldCategories)) { + return; + } + oldCategories = categories; categoryChooser.removeActionListener(categoryChooserActionListener); - - filterField.setEnabled(getContribModel().getRowCount() > 0); - - categoryChooser.addActionListener(categoryChooserActionListener); - // Enable categories combo only if there are two or more choices + filterField.setEnabled(getContribModel().getRowCount() > 0); categoryFilter = x -> true; categoryChooser.removeAllItems(); categoryChooser.addItem(new DropdownAllCoresItem()); categoryChooser.addItem(new DropdownUpdatableCoresItem()); - Collection categories = BaseNoGui.indexer.getCategories(); for (String s : categories) { categoryChooser.addItem(new DropdownCoreOfCategoryItem(s)); } - if (previouslySelectedCategory != null) { - categoryChooser.setSelectedItem(previouslySelectedCategory); - } else { - categoryChooser.setSelectedIndex(0); - } + categoryChooser.addActionListener(categoryChooserActionListener); + categoryChooser.setSelectedIndex(0); } public void setProgress(Progress progress) { From a81772afc68fb1497b6374ad58d197ef84bcba4c Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 22 Jul 2020 17:07:59 +0200 Subject: [PATCH 2/4] Boards Manager: update UI after an install/remove --- .../packages/ui/ContributionIndexTableModel.java | 9 +++++++++ .../packages/ui/ContributionManagerUI.java | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java index f143e3317..7472c6247 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java @@ -47,9 +47,17 @@ public class ContributionIndexTableModel private final List contributions = new ArrayList<>(); private final String[] columnNames = { "Description" }; private final Class[] columnTypes = { ContributedPlatform.class }; + private Predicate filter; + private String[] filters; public void updateIndexFilter(String[] filters, Predicate filter) { + this.filter = filter; + this.filters = filters; + updateContributions(); + } + + private void updateContributions() { contributions.clear(); for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) { for (ContributedPlatform platform : pack.getPlatforms()) { @@ -146,6 +154,7 @@ public class ContributionIndexTableModel } public void update() { + updateContributions(); fireTableDataChanged(); } diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java index 48fbca5d8..0c949fe1c 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java @@ -144,6 +144,10 @@ public class ContributionManagerUI extends InstallerJDialog { .updateIndex(this::setProgress); installer.deleteUnknownFiles(downloadedPackageIndexFiles); onIndexesUpdated(); + if (contribTable.getCellEditor() != null) { + contribTable.getCellEditor().stopCellEditing(); + } + getContribModel().update(); } catch (Exception e) { throw new RuntimeException(e); } finally { @@ -169,6 +173,10 @@ public class ContributionManagerUI extends InstallerJDialog { } errors.addAll(installer.install(platformToInstall, this::setProgress)); onIndexesUpdated(); + if (contribTable.getCellEditor() != null) { + contribTable.getCellEditor().stopCellEditing(); + } + getContribModel().update(); } catch (Exception e) { throw new RuntimeException(e); } finally { @@ -207,6 +215,10 @@ public class ContributionManagerUI extends InstallerJDialog { setProgressVisible(true, tr("Removing...")); installer.remove(platform); onIndexesUpdated(); + if (contribTable.getCellEditor() != null) { + contribTable.getCellEditor().stopCellEditing(); + } + getContribModel().update(); } catch (Exception e) { throw new RuntimeException(e); } finally { From 851b5b14b1dc48572649e9a291d34415f018447f Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 15 Jul 2020 18:51:14 +0200 Subject: [PATCH 3/4] Lib manager GUI is updated after installing/upgrading library --- .../contributions/libraries/ui/LibraryManagerUI.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java index 67221f91c..5d2c1a134 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java @@ -197,8 +197,11 @@ public class LibraryManagerUI extends InstallerJDialog Date: Wed, 22 Jul 2020 17:13:25 +0200 Subject: [PATCH 4/4] Lib manager: added getContribModel() as in Boards manager --- .../contributions/libraries/ui/LibraryManagerUI.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java index 5d2c1a134..69ab10006 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java @@ -72,6 +72,10 @@ public class LibraryManagerUI extends InstallerJDialog