Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/arduino/Arduino.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java')
-rw-r--r--app/src/cc/arduino/contributions/packages/ui/ContributionManagerUI.java38
1 files changed, 24 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..0c949fe1c 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<String> oldCategories = new ArrayList<>();
+
public void updateUI() {
- DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser
- .getSelectedItem();
+ // Check if categories have changed
+ Collection<String> 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<String> 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) {
@@ -146,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 {
@@ -171,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 {
@@ -209,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 {