mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-19 08:52:15 +01:00
parent
2b11e94afe
commit
f3d521d820
@ -33,6 +33,8 @@ import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
|
||||
@ -66,35 +68,21 @@ public class FilterJTextField extends JTextField {
|
||||
}
|
||||
});
|
||||
|
||||
getDocument().addDocumentListener(new DocumentListener() {
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
applyFilter();
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
applyFilter();
|
||||
}
|
||||
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
applyFilter();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String lastFilter = "";
|
||||
|
||||
private void applyFilter() {
|
||||
public void applyFilter() {
|
||||
String filter = showingHint ? "" : getText();
|
||||
filter = filter.toLowerCase();
|
||||
|
||||
// Replace anything but 0-9, a-z, or : with a space
|
||||
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
|
||||
|
||||
// Fire event only if the filter is changed
|
||||
if (filter.equals(lastFilter))
|
||||
return;
|
||||
|
||||
lastFilter = filter;
|
||||
onFilter(filter.split(" "));
|
||||
}
|
||||
|
||||
|
@ -320,6 +320,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
||||
listener.focusGained(new FocusEvent(filterField, FocusEvent.FOCUS_GAINED));
|
||||
}
|
||||
filterField.setText(filterText);
|
||||
filterField.applyFilter();
|
||||
}
|
||||
|
||||
public void selectDropdownItemByClassName(String dropdownItem) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user