File tree 2 files changed +7
-18
lines changed
app/src/cc/arduino/contributions/ui
2 files changed +7
-18
lines changed Original file line number Diff line number Diff line change 33
33
import javax .swing .event .DocumentEvent ;
34
34
import javax .swing .event .DocumentListener ;
35
35
import java .awt .*;
36
+ import java .awt .event .ActionEvent ;
37
+ import java .awt .event .ActionListener ;
36
38
import java .awt .event .FocusEvent ;
37
39
import java .awt .event .FocusListener ;
38
40
@@ -66,35 +68,21 @@ public void focusGained(FocusEvent focusEvent) {
66
68
}
67
69
});
68
70
69
- getDocument ().addDocumentListener (new DocumentListener () {
70
- public void removeUpdate (DocumentEvent e ) {
71
- applyFilter ();
72
- }
73
-
74
- public void insertUpdate (DocumentEvent e ) {
75
- applyFilter ();
76
- }
77
-
78
- public void changedUpdate (DocumentEvent e ) {
71
+ addActionListener (new ActionListener () {
72
+ @ Override
73
+ public void actionPerformed (ActionEvent e ) {
79
74
applyFilter ();
80
75
}
81
76
});
82
77
}
83
78
84
- private String lastFilter = "" ;
85
-
86
- private void applyFilter () {
79
+ public void applyFilter () {
87
80
String filter = showingHint ? "" : getText ();
88
81
filter = filter .toLowerCase ();
89
82
90
83
// Replace anything but 0-9, a-z, or : with a space
91
84
filter = filter .replaceAll ("[^\\ x30-\\ x39^\\ x61-\\ x7a^\\ x3a]" , " " );
92
85
93
- // Fire event only if the filter is changed
94
- if (filter .equals (lastFilter ))
95
- return ;
96
-
97
- lastFilter = filter ;
98
86
onFilter (filter .split (" " ));
99
87
}
100
88
Original file line number Diff line number Diff line change @@ -320,6 +320,7 @@ public void setFilterText(String filterText) {
320
320
listener .focusGained (new FocusEvent (filterField , FocusEvent .FOCUS_GAINED ));
321
321
}
322
322
filterField .setText (filterText );
323
+ filterField .applyFilter ();
323
324
}
324
325
325
326
public void selectDropdownItemByClassName (String dropdownItem ) {
You can’t perform that action at this time.
0 commit comments