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.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
|
|
||||||
@ -66,35 +68,21 @@ public class FilterJTextField extends JTextField {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
getDocument().addDocumentListener(new DocumentListener() {
|
addActionListener(new ActionListener() {
|
||||||
public void removeUpdate(DocumentEvent e) {
|
@Override
|
||||||
applyFilter();
|
public void actionPerformed(ActionEvent e) {
|
||||||
}
|
|
||||||
|
|
||||||
public void insertUpdate(DocumentEvent e) {
|
|
||||||
applyFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changedUpdate(DocumentEvent e) {
|
|
||||||
applyFilter();
|
applyFilter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String lastFilter = "";
|
public void applyFilter() {
|
||||||
|
|
||||||
private void applyFilter() {
|
|
||||||
String filter = showingHint ? "" : getText();
|
String filter = showingHint ? "" : getText();
|
||||||
filter = filter.toLowerCase();
|
filter = filter.toLowerCase();
|
||||||
|
|
||||||
// Replace anything but 0-9, a-z, or : with a space
|
// Replace anything but 0-9, a-z, or : with a space
|
||||||
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " ");
|
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(" "));
|
onFilter(filter.split(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +320,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
|||||||
listener.focusGained(new FocusEvent(filterField, FocusEvent.FOCUS_GAINED));
|
listener.focusGained(new FocusEvent(filterField, FocusEvent.FOCUS_GAINED));
|
||||||
}
|
}
|
||||||
filterField.setText(filterText);
|
filterField.setText(filterText);
|
||||||
|
filterField.applyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectDropdownItemByClassName(String dropdownItem) {
|
public void selectDropdownItemByClassName(String dropdownItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user