|
29 | 29 |
|
30 | 30 | package cc.arduino.contributions.packages.ui; |
31 | 31 |
|
32 | | -import cc.arduino.contributions.DownloadableContribution; |
33 | 32 | import cc.arduino.contributions.packages.ContributedPlatform; |
34 | 33 | import cc.arduino.contributions.packages.ContributionInstaller; |
35 | 34 | import cc.arduino.contributions.ui.*; |
|
41 | 40 | import javax.swing.table.TableCellRenderer; |
42 | 41 |
|
43 | 42 | import java.awt.*; |
| 43 | +import java.util.ArrayList; |
44 | 44 | import java.util.Collection; |
45 | 45 | import java.util.LinkedList; |
46 | 46 | import java.util.List; |
@@ -92,30 +92,28 @@ public ContributionManagerUI(Frame parent, ContributionInstaller installer) { |
92 | 92 | this.installer = installer; |
93 | 93 | } |
94 | 94 |
|
| 95 | + private Collection<String> oldCategories = new ArrayList<>(); |
| 96 | + |
95 | 97 | public void updateUI() { |
96 | | - DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser |
97 | | - .getSelectedItem(); |
| 98 | + // Check if categories have changed |
| 99 | + Collection<String> categories = BaseNoGui.indexer.getCategories(); |
| 100 | + if (categories.equals(oldCategories)) { |
| 101 | + return; |
| 102 | + } |
| 103 | + oldCategories = categories; |
98 | 104 |
|
99 | 105 | categoryChooser.removeActionListener(categoryChooserActionListener); |
100 | | - |
101 | | - filterField.setEnabled(getContribModel().getRowCount() > 0); |
102 | | - |
103 | | - categoryChooser.addActionListener(categoryChooserActionListener); |
104 | | - |
105 | 106 | // Enable categories combo only if there are two or more choices |
| 107 | + filterField.setEnabled(getContribModel().getRowCount() > 0); |
106 | 108 | categoryFilter = x -> true; |
107 | 109 | categoryChooser.removeAllItems(); |
108 | 110 | categoryChooser.addItem(new DropdownAllCoresItem()); |
109 | 111 | categoryChooser.addItem(new DropdownUpdatableCoresItem()); |
110 | | - Collection<String> categories = BaseNoGui.indexer.getCategories(); |
111 | 112 | for (String s : categories) { |
112 | 113 | categoryChooser.addItem(new DropdownCoreOfCategoryItem(s)); |
113 | 114 | } |
114 | | - if (previouslySelectedCategory != null) { |
115 | | - categoryChooser.setSelectedItem(previouslySelectedCategory); |
116 | | - } else { |
117 | | - categoryChooser.setSelectedIndex(0); |
118 | | - } |
| 115 | + categoryChooser.addActionListener(categoryChooserActionListener); |
| 116 | + categoryChooser.setSelectedIndex(0); |
119 | 117 | } |
120 | 118 |
|
121 | 119 | public void setProgress(Progress progress) { |
|
0 commit comments