19
19
package mediathek .tool .swing ;
20
20
21
21
import com .jidesoft .swing .AutoCompletion ;
22
- import com .jidesoft .swing .ComboBoxSearchable ;
23
22
24
23
import javax .swing .*;
25
24
31
30
*/
32
31
public class AutoCompletionComboBox2 extends JComboBox <String > {
33
32
protected AutoCompletion _autoCompletion ;
34
- protected boolean _noActionOnKeyNavigation ;
35
- private boolean _preventActionEvent ;
36
33
37
34
public AutoCompletionComboBox2 () {
38
35
initComponents ();
39
36
}
40
37
41
38
protected void initComponents () {
42
39
setEditable (true );
43
- setNoActionOnKeyNavigation (true );
44
40
45
41
_autoCompletion = createAutoCompletion ();
46
42
_autoCompletion .setStrict (true );
47
43
_autoCompletion .setStrictCompletion (true );
44
+ setNoActionOnKeyNavigation (true );
48
45
}
49
46
50
- public void setNoActionOnKeyNavigation (boolean _noActionOnKeyNavigation ) {
51
- this . _noActionOnKeyNavigation = _noActionOnKeyNavigation ;
47
+ public void setNoActionOnKeyNavigation (boolean value ) {
48
+ (( NoFireOnKeyComboBoxSearchable ) _autoCompletion . getSearchable ()). setNoActionOnKeyNavigation ( value ) ;
52
49
}
53
50
54
51
/**
@@ -69,31 +66,10 @@ protected void resetCaretPosition() {
69
66
70
67
@ Override
71
68
protected void fireActionEvent () {
72
- if (!_preventActionEvent ) {
69
+ if (!(( NoFireOnKeyComboBoxSearchable ) _autoCompletion . getSearchable ()). isPreventActionEvent () ) {
73
70
resetCaretPosition ();
74
71
super .fireActionEvent ();
75
72
}
76
73
}
77
74
78
- private class NoFireOnKeyComboBoxSearchable extends ComboBoxSearchable {
79
- public NoFireOnKeyComboBoxSearchable (JComboBox <?> comboBox ) {
80
- super (comboBox );
81
- }
82
-
83
- @ Override
84
- protected void setSelectedIndex (int index , boolean incremental ) {
85
- Object propTableCellEditor = _component .getClientProperty ("JComboBox.isTableCellEditor" );
86
- Object propNoActionOnKeyNavigation = UIManager .get ("ComboBox.noActionOnKeyNavigation" );
87
- if ((propTableCellEditor instanceof Boolean && (Boolean ) propTableCellEditor ) ||
88
- (propNoActionOnKeyNavigation instanceof Boolean && (Boolean ) propNoActionOnKeyNavigation ) ||
89
- _noActionOnKeyNavigation ) {
90
- _preventActionEvent = true ;
91
- }
92
- try {
93
- super .setSelectedIndex (index , incremental );
94
- } finally {
95
- _preventActionEvent = false ;
96
- }
97
- }
98
- }
99
75
}
0 commit comments