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)DataTypeClob.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 not.↵
|
11 | //↵ | | 11 | //↵
|
|
12 | if ( DataTypeBlob.this._isNullable) {↵ | | 12 | if ( DataTypeClob.this._isNullable) {↵
|
|
13 | // user enters something when field is null↵ | | 13 | // user enters something when field is null↵
|
14 | if (text.equals("<null>")) {↵ | | 14 | if (text.equals("<null>")) {↵
|
15 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | | 15 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵
|
16 | // delete when null => original value↵ | | 16 | // delete when null => original value↵
|
17 | DataTypeBlob.this._textComponent.restoreText();↵ | | 17 | DataTypeClob.this._textComponent.restoreText();↵
|
18 | e.consume();↵ | | 18 | e.consume();↵
|
19 | }↵ | | 19 | }↵
|
20 | else {↵ | | 20 | else {↵
|
21 | // non-delete when null => clear field and add text↵ | | 21 | // non-delete when null => clear field and add text↵
|
22 | DataTypeBlob.this._textComponent.updateText("");↵ | | 22 | DataTypeClob.this._textComponent.updateText("");↵
|
23 | // fall through to normal processing of this key stroke↵ | | 23 | // fall through to normal processing of this key stroke↵
|
24 | }↵ | | 24 | }↵
|
25 | }↵ | | 25 | }↵
|
26 | else {↵ | | 26 | else {↵
|
27 | // check for user deletes last thing in field↵ | | 27 | // check for user deletes last thing in field↵
|
28 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | | 28 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵
|
29 | if (text.length() <= 1 ) {↵ | | 29 | if (text.length() <= 1 ) {↵
|
30 | // about to delete last thing in field, so replace with null↵ | | 30 | // about to delete last thing in field, so replace with null↵
|
31 | DataTypeBlob.this._textComponent.updateText("<null>");↵ | | 31 | DataTypeClob.this._textComponent.updateText("<null>");↵
|
32 | e.consume();↵ | | 32 | e.consume();↵
|
33 | }↵ | | 33 | }↵
|
34 | }↵ | | 34 | }↵
|
35 | }↵ | | 35 | }↵
|
36 | }↵ | | 36 | }↵
|
37 | else {↵ | | 37 | else {↵
|
38 | // field is not nullable↵ | | 38 | // field is not nullable↵
|
39 | //↵ | | 39 | //↵
|
40 | handleNotNullableField(text, c, e, _textComponent) | | 40 | handleNotNullableField(text, c, e, _textComponent)
|