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 6f9c903c3c0..48fbca5d889 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.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 ContributionManagerUI(Frame parent, ContributionInstaller installer) { 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 f143e33172a..7472c62479b 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 ContributedPlatform getSelectedRelease(int row) { } 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 48fbca5d889..0c949fe1cd3 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 void onUpdatePressed() { .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 void onInstallPressed(final ContributedPlatform platformToInstall, } 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 void onRemovePressed(final ContributedPlatform platform, 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 67221f91c3e..5d2c1a134f4 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 @@ protected void onUpdatePressed() { try { setProgressVisible(true, ""); installer.updateIndex(this::setProgress); - ((LibrariesIndexTableModel) contribModel).update(); onIndexesUpdated(); + if (contribTable.getCellEditor() != null) { + contribTable.getCellEditor().stopCellEditing(); + } + ((LibrariesIndexTableModel) contribModel).update(); } catch (Exception e) { throw new RuntimeException(e); } finally { @@ -234,12 +237,11 @@ public void onInstallPressed(final ContributedLibrary lib) { } else { installer.install(lib, this::setProgress); } - // TODO: Do a better job in refreshing only the needed element + onIndexesUpdated(); if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); } ((LibrariesIndexTableModel) contribModel).update(); - onIndexesUpdated(); } catch (Exception e) { throw new RuntimeException(e); } finally { @@ -266,12 +268,11 @@ public void onRemovePressed(final ContributedLibrary lib) { try { setProgressVisible(true, tr("Removing...")); installer.remove(lib, this::setProgress); - // TODO: Do a better job in refreshing only the needed element + onIndexesUpdated(); if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); } ((LibrariesIndexTableModel) contribModel).update(); - onIndexesUpdated(); } catch (Exception e) { throw new RuntimeException(e); } finally { From 10bee204e62a1339c803285d8ac9463bc2278f6a Mon Sep 17 00:00:00 2001 From: Cristian Maglie 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 5d2c1a134f4..69ab10006c9 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 @@ protected FilteredAbstractTableModel createContribModel() { return new LibrariesIndexTableModel(); } + private LibrariesIndexTableModel getContribModel() { + return (LibrariesIndexTableModel) contribModel; + } + @Override protected TableCellRenderer createCellRenderer() { return new ContributedLibraryTableCellRenderer(); @@ -201,7 +205,7 @@ protected void onUpdatePressed() { if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); } - ((LibrariesIndexTableModel) contribModel).update(); + getContribModel().update(); } catch (Exception e) { throw new RuntimeException(e); } finally { @@ -241,7 +245,7 @@ public void onInstallPressed(final ContributedLibrary lib) { if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); } - ((LibrariesIndexTableModel) contribModel).update(); + getContribModel().update(); } catch (Exception e) { throw new RuntimeException(e); } finally { @@ -272,7 +276,7 @@ public void onRemovePressed(final ContributedLibrary lib) { if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); } - ((LibrariesIndexTableModel) contribModel).update(); + getContribModel().update(); } catch (Exception e) { throw new RuntimeException(e); } finally { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy