mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Library and Boards Manager: preserving filter selections
This commit is contained in:
parent
7a97be43a5
commit
f79a6c5d8b
@ -17,4 +17,10 @@ public class DropdownBuiltInLibrariesItem implements DropdownItem<DownloadableCo
|
||||
public Predicate<DownloadableContribution> getFilterPredicate() {
|
||||
return new BuiltInPredicate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownBuiltInLibrariesItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,4 +24,10 @@ public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLib
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new InstalledLibraryPredicate(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownInstalledLibraryItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,4 +21,10 @@ public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLi
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new CategoryPredicate(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownLibraryOfCategoryItem && ((DropdownLibraryOfCategoryItem) obj).category.equals(category);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,4 +22,10 @@ public class DropdownLibraryOfTypeItem implements DropdownItem<ContributedLibrar
|
||||
public Predicate<ContributedLibrary> getFilterPredicate() {
|
||||
return new TypePredicate(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownLibraryOfTypeItem && ((DropdownLibraryOfTypeItem) obj).type.equals(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ package cc.arduino.contributions.libraries.ui;
|
||||
|
||||
import cc.arduino.contributions.libraries.ContributedLibrary;
|
||||
import cc.arduino.contributions.libraries.LibrariesIndexer;
|
||||
import cc.arduino.contributions.packages.DownloadableContribution;
|
||||
import cc.arduino.contributions.packages.ui.InstallerJDialogUncaughtExceptionHandler;
|
||||
import cc.arduino.contributions.ui.*;
|
||||
import cc.arduino.utils.Progress;
|
||||
@ -124,6 +125,10 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
|
||||
public void setIndexer(LibrariesIndexer indexer) {
|
||||
this.indexer = indexer;
|
||||
|
||||
DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
|
||||
DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem();
|
||||
|
||||
categoryChooser.removeActionListener(categoryChooserActionListener);
|
||||
typeChooser.removeActionListener(typeChooserActionListener);
|
||||
|
||||
@ -144,7 +149,11 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
categoryChooser.setEnabled(categoryChooser.getItemCount() > 1);
|
||||
|
||||
categoryChooser.addActionListener(categoryChooserActionListener);
|
||||
if (previouslySelectedCategory != null) {
|
||||
categoryChooser.setSelectedItem(previouslySelectedCategory);
|
||||
} else {
|
||||
categoryChooser.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
typeFilter = null;
|
||||
typeChooser.removeAllItems();
|
||||
@ -156,6 +165,11 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
||||
}
|
||||
typeChooser.setEnabled(typeChooser.getItemCount() > 1);
|
||||
typeChooser.addActionListener(typeChooserActionListener);
|
||||
if (previouslySelectedType != null) {
|
||||
typeChooser.setSelectedItem(previouslySelectedType);
|
||||
} else {
|
||||
typeChooser.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
filterField.setEnabled(contribModel.getRowCount() > 0);
|
||||
|
||||
|
@ -31,6 +31,8 @@ package cc.arduino.contributions.packages.ui;
|
||||
import cc.arduino.contributions.packages.ContributedPlatform;
|
||||
import cc.arduino.contributions.packages.ContributionInstaller;
|
||||
import cc.arduino.contributions.packages.ContributionsIndexer;
|
||||
import cc.arduino.contributions.packages.DownloadableContribution;
|
||||
import cc.arduino.contributions.ui.DropdownItem;
|
||||
import cc.arduino.contributions.ui.FilteredAbstractTableModel;
|
||||
import cc.arduino.contributions.ui.InstallerJDialog;
|
||||
import cc.arduino.contributions.ui.InstallerTableCell;
|
||||
@ -88,6 +90,8 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
}
|
||||
|
||||
public void setIndexer(ContributionsIndexer indexer) {
|
||||
DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem();
|
||||
|
||||
categoryChooser.removeActionListener(categoryChooserActionListener);
|
||||
|
||||
getContribModel().setIndex(indexer.getIndex());
|
||||
@ -105,6 +109,11 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
for (String s : categories) {
|
||||
categoryChooser.addItem(new DropdownCoreOfCategoryItem(s));
|
||||
}
|
||||
if (previouslySelectedCategory != null) {
|
||||
categoryChooser.setSelectedItem(previouslySelectedCategory);
|
||||
} else {
|
||||
categoryChooser.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
// Create ConstributionInstaller tied with the provided index
|
||||
installer = new ContributionInstaller(indexer) {
|
||||
|
@ -17,4 +17,9 @@ public class DropdownAllCoresItem implements DropdownItem<ContributedPlatform> {
|
||||
public Predicate<ContributedPlatform> getFilterPredicate() {
|
||||
return new NoopPredicate<ContributedPlatform>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownAllCoresItem;
|
||||
}
|
||||
}
|
||||
|
@ -21,4 +21,10 @@ public class DropdownCoreOfCategoryItem implements DropdownItem<ContributedPlatf
|
||||
public Predicate<ContributedPlatform> getFilterPredicate() {
|
||||
return new CategoryPredicate(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownCoreOfCategoryItem && ((DropdownCoreOfCategoryItem) obj).category.equals(category);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,4 +17,10 @@ public class DropdownAllItem implements DropdownItem<DownloadableContribution> {
|
||||
public Predicate<DownloadableContribution> getFilterPredicate() {
|
||||
return new NoopPredicate<DownloadableContribution>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof DropdownAllItem;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user