1 | private class KeyTextHandler extends BaseKeyTextHandler {↵ | | 1 | private class KeyTextHandler extends BaseKeyTextHandler {↵
|
2 | public void keyTyped(KeyEvent e) {↵ | | 2 | public void keyTyped(KeyEvent e) {↵
|
3 | char c = e.getKeyChar();↵ | | 3 | char c = e.getKeyChar();↵
|
|
4 | // as a coding convenience, create a reference to the text component↵ | | 4 | // as a coding convenience, create a reference to the text component↵
|
5 | // that is typecast to JTextComponent. this is not essential, as we↵ | | 5 | // that is typecast to JTextComponent. this is not essential, as we↵
|
6 | // could typecast every reference, but this makes the code cleaner↵ | | 6 | // could typecast every reference, but this makes the code cleaner↵
|
7 | JTextComponent _theComponent = (JTextComponent)DataTypeBlob.this._textComponent;↵ | | 7 | JTextComponent _theComponent = (JTextComponent) DerbyClobDataTypeComponent.this._textComponent;↵
|
8 | String text = _theComponent.getText();↵ | | 8 | String text = _theComponent.getText();↵
|
|
|
9 | // handle cases of null↵ | | 9 | // handle cases of null↵
|
10 | // The processing is different when nulls are allowed and when they are not.↵ | | 10 | // The processing is different when nulls are allowed and when they are↵
|
11 | //↵ | | |
|
|
12 | if ( DataTypeBlob↵ | | |
|
| | | 11 | // not.↵
|
| | | 12 | //↵
|
|
13 | .this._isNullable) {↵ | | 13 | if (DerbyClobDataTypeComponent.this._isNullable) {↵
|
|
14 | // user enters something when field is null↵ | | 14 | // user enters something when field is null↵
|
15 | if (text.equals("<null>")) {↵ | | 15 | if (text.equals("<null>")) {↵
|
16 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | | 16 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵
|
17 | // delete when null => original value↵ | | 17 | // delete when null => original value↵
|
18 | DataTypeBlob.this._textComponent.restoreText();↵ | | |
|
19 | e.consume();↵ | | |
|
20 | }↵ | | |
|
21 | else {↵ | | |
|
22 | ↵ | | 18 | DerbyClobDataTypeComponent.this._textComponent.restoreText();↵
|
| | | 19 | e.consume();↵
|
| | | 20 | } else {↵
|
23 | // non-delete when null => clear field and add text↵ | | 21 | // non-delete when null => clear field and add text↵
|
24 | DataTypeBlob.this._textComponent.updateText("");↵ | | 22 | DerbyClobDataTypeComponent.this._textComponent.updateText("");↵
|
25 | // fall through to normal processing of this key stroke↵ | | 23 | // fall through to normal processing of this key stroke↵
|
26 | }↵ | | |
|
27 | }↵ | | |
|
28 | else {↵ | | |
|
29 | ↵ | | 24 | }↵
|
| | | 25 | } else {↵
|
30 | // check for user deletes last thing in field↵ | | 26 | // check for user deletes last thing in field↵
|
31 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | | 27 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵
|
32 | if (text.length() <= 1 ) {↵ | | 28 | if (text.length() <= 1) {↵
|
33 | // about to delete last thing in field, so replace with null↵ | | 29 | // about to delete last thing in field, so replace with↵
|
34 | DataTypeBlob.this._textComponent.updateText("<null>");↵ | | |
|
35 | e.consume();↵ | | |
|
36 | }↵ | | |
|
37 | }↵ | | |
|
38 | }↵ | | |
|
39 | }↵ | | |
|
40 | else {↵ | | |
|
41 | ↵ | | |
|
| | | 30 | // null↵
|
| | | 31 | DerbyClobDataTypeComponent.this._textComponent.updateText("<null>");↵
|
| | | 32 | e.consume();↵
|
| | | 33 | }↵
|
| | | 34 | }↵
|
| | | 35 | }↵
|
| | | 36 | } else {↵
|
42 | // field is not nullable↵ | | 37 | // field is not nullable↵
|
43 | //↵ | | 38 | ↵
|
44 | ↵ | | 39 | //↵
|
45 | handleNotNullableField(text, c, e, _textComponent) | | 40 | handleNotNullableField(text, c, e, _textComponent)
|