Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2e4d76

Browse files
committed
Cumulative patch for MSFT Store hot-fix release
The following commits have been added here:-4286522: Library manager: update filters combo box only if there are changes-3263967: Removed unused include and clueless whitespaces-b66ed5e: LibraryManager: correctly apply "type" and "category" filters together-1361bce: Board manager: Update filters UI only if categories changes-a81772a: Boards Manager: update UI after an install/remove-851b5b1: Lib manager GUI is updated after installing/upgrading library-10bee20: Lib manager: added getContribModel() as in Boards manager
1 parent5adf408 commitd2e4d76

File tree

4 files changed

+69
-50
lines changed

4 files changed

+69
-50
lines changed

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
importjava.awt.Frame;
3636
importjava.awt.event.ActionEvent;
3737
importjava.awt.event.ActionListener;
38+
importjava.util.ArrayList;
3839
importjava.util.Collection;
3940
importjava.util.Collections;
4041
importjava.util.LinkedList;
4142
importjava.util.List;
4243
importjava.util.Optional;
43-
importjava.util.function.Predicate;
4444

4545
importjavax.swing.Box;
4646
importjavax.swing.JComboBox;
@@ -66,13 +66,16 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibraryRelease
6666

6767
privatefinalJComboBoxtypeChooser;
6868
privatefinalLibraryInstallerinstaller;
69-
privatePredicate<ContributedLibraryReleases>typeFilter;
7069

7170
@Override
7271
protectedFilteredAbstractTableModelcreateContribModel() {
7372
returnnewLibrariesIndexTableModel();
7473
}
7574

75+
privateLibrariesIndexTableModelgetContribModel() {
76+
return (LibrariesIndexTableModel)contribModel;
77+
}
78+
7679
@Override
7780
protectedTableCellRenderercreateCellRenderer() {
7881
returnnewContributedLibraryTableCellRenderer();
@@ -115,63 +118,60 @@ public LibraryManagerUI(Frame parent, LibraryInstaller installer) {
115118
}
116119

117120
protectedfinalActionListenertypeChooserActionListener =newActionListener() {
118-
119121
@Override
120122
publicvoidactionPerformed(ActionEventevent) {
121123
DropdownItem<ContributedLibraryReleases>selected = (DropdownItem<ContributedLibraryReleases>)typeChooser.getSelectedItem();
122124
previousRowAtPoint = -1;
123-
if (selected !=null &&typeFilter !=selected.getFilterPredicate()) {
124-
typeFilter =selected.getFilterPredicate();
125+
if (selected !=null &&extraFilter !=selected.getFilterPredicate()) {
126+
extraFilter =selected.getFilterPredicate();
125127
if (contribTable.getCellEditor() !=null) {
126128
contribTable.getCellEditor().stopCellEditing();
127129
}
128-
updateIndexFilter(filters,categoryFilter.and(typeFilter));
130+
updateIndexFilter(filters,categoryFilter.and(extraFilter));
129131
}
130132
}
131133
};
132134

135+
privateCollection<String>oldCategories =newArrayList<>();
136+
privateCollection<String>oldTypes =newArrayList<>();
137+
133138
publicvoidupdateUI() {
134-
DropdownItem<ContributedLibraryReleases>previouslySelectedCategory = (DropdownItem<ContributedLibraryReleases>)categoryChooser.getSelectedItem();
135-
DropdownItem<ContributedLibraryReleases>previouslySelectedType = (DropdownItem<ContributedLibraryReleases>)typeChooser.getSelectedItem();
139+
// Check if categories or types have changed
140+
Collection<String>categories =BaseNoGui.librariesIndexer.getIndex().getCategories();
141+
List<String>types =newLinkedList<>(BaseNoGui.librariesIndexer.getIndex().getTypes());
142+
Collections.sort(types,newLibraryTypeComparator());
136143

137-
categoryChooser.removeActionListener(categoryChooserActionListener);
138-
typeChooser.removeActionListener(typeChooserActionListener);
144+
if (categories.equals(oldCategories) &&types.equals(oldTypes)) {
145+
return;
146+
}
147+
oldCategories =categories;
148+
oldTypes =types;
139149

140150
// Load categories
141151
categoryFilter =x ->true;
152+
categoryChooser.removeActionListener(categoryChooserActionListener);
142153
categoryChooser.removeAllItems();
143154
categoryChooser.addItem(newDropdownAllLibraries());
144-
Collection<String>categories =BaseNoGui.librariesIndexer.getIndex().getCategories();
145155
for (Stringcategory :categories) {
146156
categoryChooser.addItem(newDropdownLibraryOfCategoryItem(category));
147157
}
148-
149158
categoryChooser.setEnabled(categoryChooser.getItemCount() >1);
150-
151159
categoryChooser.addActionListener(categoryChooserActionListener);
152-
if (previouslySelectedCategory !=null) {
153-
categoryChooser.setSelectedItem(previouslySelectedCategory);
154-
}else {
155-
categoryChooser.setSelectedIndex(0);
156-
}
160+
categoryChooser.setSelectedIndex(0);
157161

158-
typeFilter =x ->true;
162+
// Load types
163+
extraFilter =x ->true;
164+
typeChooser.removeActionListener(typeChooserActionListener);
159165
typeChooser.removeAllItems();
160166
typeChooser.addItem(newDropdownAllLibraries());
161167
typeChooser.addItem(newDropdownUpdatableLibrariesItem());
162168
typeChooser.addItem(newDropdownInstalledLibraryItem());
163-
List<String>types =newLinkedList<>(BaseNoGui.librariesIndexer.getIndex().getTypes());
164-
Collections.sort(types,newLibraryTypeComparator());
165169
for (Stringtype :types) {
166170
typeChooser.addItem(newDropdownLibraryOfTypeItem(type));
167171
}
168172
typeChooser.setEnabled(typeChooser.getItemCount() >1);
169173
typeChooser.addActionListener(typeChooserActionListener);
170-
if (previouslySelectedType !=null) {
171-
typeChooser.setSelectedItem(previouslySelectedType);
172-
}else {
173-
typeChooser.setSelectedIndex(0);
174-
}
174+
typeChooser.setSelectedIndex(0);
175175

176176
filterField.setEnabled(contribModel.getRowCount() >0);
177177
}
@@ -201,8 +201,11 @@ protected void onUpdatePressed() {
201201
try {
202202
setProgressVisible(true,"");
203203
installer.updateIndex(this::setProgress);
204-
((LibrariesIndexTableModel)contribModel).update();
205204
onIndexesUpdated();
205+
if (contribTable.getCellEditor() !=null) {
206+
contribTable.getCellEditor().stopCellEditing();
207+
}
208+
getContribModel().update();
206209
}catch (Exceptione) {
207210
thrownewRuntimeException(e);
208211
}finally {
@@ -238,12 +241,11 @@ public void onInstallPressed(final ContributedLibrary lib) {
238241
}else {
239242
installer.install(lib,this::setProgress);
240243
}
241-
// TODO: Do a better job in refreshing only the needed element
244+
onIndexesUpdated();
242245
if (contribTable.getCellEditor() !=null) {
243246
contribTable.getCellEditor().stopCellEditing();
244247
}
245-
((LibrariesIndexTableModel)contribModel).update();
246-
onIndexesUpdated();
248+
getContribModel().update();
247249
}catch (Exceptione) {
248250
thrownewRuntimeException(e);
249251
}finally {
@@ -270,12 +272,11 @@ public void onRemovePressed(final ContributedLibrary lib) {
270272
try {
271273
setProgressVisible(true,tr("Removing..."));
272274
installer.remove(lib,this::setProgress);
273-
// TODO: Do a better job in refreshing only the needed element
275+
onIndexesUpdated();
274276
if (contribTable.getCellEditor() !=null) {
275277
contribTable.getCellEditor().stopCellEditing();
276278
}
277-
((LibrariesIndexTableModel)contribModel).update();
278-
onIndexesUpdated();
279+
getContribModel().update();
279280
}catch (Exceptione) {
280281
thrownewRuntimeException(e);
281282
}finally {

‎app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,17 @@ public class ContributionIndexTableModel
4747
privatefinalList<ContributedPlatformReleases>contributions =newArrayList<>();
4848
privatefinalString[]columnNames = {"Description" };
4949
privatefinalClass<?>[]columnTypes = {ContributedPlatform.class };
50+
privatePredicate<ContributedPlatform>filter;
51+
privateString[]filters;
5052

5153
publicvoidupdateIndexFilter(String[]filters,
5254
Predicate<ContributedPlatform>filter) {
55+
this.filter =filter;
56+
this.filters =filters;
57+
updateContributions();
58+
}
59+
60+
privatevoidupdateContributions() {
5361
contributions.clear();
5462
for (ContributedPackagepack :BaseNoGui.indexer.getPackages()) {
5563
for (ContributedPlatformplatform :pack.getPlatforms()) {
@@ -146,6 +154,7 @@ public ContributedPlatform getSelectedRelease(int row) {
146154
}
147155

148156
publicvoidupdate() {
157+
updateContributions();
149158
fireTableDataChanged();
150159
}
151160

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
packagecc.arduino.contributions.packages.ui;
3131

32-
importcc.arduino.contributions.DownloadableContribution;
3332
importcc.arduino.contributions.packages.ContributedPlatform;
3433
importcc.arduino.contributions.packages.ContributionInstaller;
3534
importcc.arduino.contributions.ui.*;
@@ -41,6 +40,7 @@
4140
importjavax.swing.table.TableCellRenderer;
4241

4342
importjava.awt.*;
43+
importjava.util.ArrayList;
4444
importjava.util.Collection;
4545
importjava.util.LinkedList;
4646
importjava.util.List;
@@ -92,30 +92,28 @@ public ContributionManagerUI(Frame parent, ContributionInstaller installer) {
9292
this.installer =installer;
9393
}
9494

95+
privateCollection<String>oldCategories =newArrayList<>();
96+
9597
publicvoidupdateUI() {
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;
98104

99105
categoryChooser.removeActionListener(categoryChooserActionListener);
100-
101-
filterField.setEnabled(getContribModel().getRowCount() >0);
102-
103-
categoryChooser.addActionListener(categoryChooserActionListener);
104-
105106
// Enable categories combo only if there are two or more choices
107+
filterField.setEnabled(getContribModel().getRowCount() >0);
106108
categoryFilter =x ->true;
107109
categoryChooser.removeAllItems();
108110
categoryChooser.addItem(newDropdownAllCoresItem());
109111
categoryChooser.addItem(newDropdownUpdatableCoresItem());
110-
Collection<String>categories =BaseNoGui.indexer.getCategories();
111112
for (Strings :categories) {
112113
categoryChooser.addItem(newDropdownCoreOfCategoryItem(s));
113114
}
114-
if (previouslySelectedCategory !=null) {
115-
categoryChooser.setSelectedItem(previouslySelectedCategory);
116-
}else {
117-
categoryChooser.setSelectedIndex(0);
118-
}
115+
categoryChooser.addActionListener(categoryChooserActionListener);
116+
categoryChooser.setSelectedIndex(0);
119117
}
120118

121119
publicvoidsetProgress(Progressprogress) {
@@ -146,6 +144,10 @@ public void onUpdatePressed() {
146144
.updateIndex(this::setProgress);
147145
installer.deleteUnknownFiles(downloadedPackageIndexFiles);
148146
onIndexesUpdated();
147+
if (contribTable.getCellEditor() !=null) {
148+
contribTable.getCellEditor().stopCellEditing();
149+
}
150+
getContribModel().update();
149151
}catch (Exceptione) {
150152
thrownewRuntimeException(e);
151153
}finally {
@@ -171,6 +173,10 @@ public void onInstallPressed(final ContributedPlatform platformToInstall,
171173
}
172174
errors.addAll(installer.install(platformToInstall,this::setProgress));
173175
onIndexesUpdated();
176+
if (contribTable.getCellEditor() !=null) {
177+
contribTable.getCellEditor().stopCellEditing();
178+
}
179+
getContribModel().update();
174180
}catch (Exceptione) {
175181
thrownewRuntimeException(e);
176182
}finally {
@@ -209,6 +215,10 @@ public void onRemovePressed(final ContributedPlatform platform,
209215
setProgressVisible(true,tr("Removing..."));
210216
installer.remove(platform);
211217
onIndexesUpdated();
218+
if (contribTable.getCellEditor() !=null) {
219+
contribTable.getCellEditor().stopCellEditing();
220+
}
221+
getContribModel().update();
212222
}catch (Exceptione) {
213223
thrownewRuntimeException(e);
214224
}finally {

‎app/src/cc/arduino/contributions/ui/InstallerJDialog.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171

7272
importcc.arduino.contributions.ui.listeners.AbstractKeyListener;
7373
importprocessing.app.Base;
74-
importprocessing.app.Theme;
7574

7675
publicabstractclassInstallerJDialog<T>extendsJDialog {
7776

@@ -82,6 +81,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
8281
protectedfinalFilterJTextFieldfilterField;
8382
protectedfinalJPanelfiltersContainer;
8483
// Currently selected category and filters
84+
protectedPredicate<T>extraFilter =x ->true;
8585
protectedPredicate<T>categoryFilter;
8686
protectedString[]filters;
8787
protectedfinalStringnoConnectionErrorMessage;
@@ -329,7 +329,6 @@ private void setErrorMessageVisible(boolean visible) {
329329
}
330330

331331
protectedfinalActionListenercategoryChooserActionListener =newActionListener() {
332-
333332
@Override
334333
publicvoidactionPerformed(ActionEventevent) {
335334
DropdownItem<T>selected = (DropdownItem<T>)categoryChooser.getSelectedItem();
@@ -339,7 +338,7 @@ public void actionPerformed(ActionEvent event) {
339338
if (contribTable.getCellEditor() !=null) {
340339
contribTable.getCellEditor().stopCellEditing();
341340
}
342-
updateIndexFilter(filters,categoryFilter);
341+
updateIndexFilter(filters,categoryFilter.and(extraFilter));
343342
}
344343
}
345344
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp