File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDate.java | File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeBinary.java | |||
Method name: void keyTyped(KeyEvent)
|
Method name: void keyTyped(KeyEvent)
|
|||
Number of AST nodes: 23 | Number of AST nodes: 23 | |||
1 | char c = e.getKeyChar();↵ | 1 | char c = e.getKeyChar();↵ | |
2 | ↵ | |||
2 | // as a coding convenience, create a reference to the text component↵ | 3 | // as a coding convenience, create a reference to the text component↵ | |
3 | // that is typecast to JTextComponent. this is not essential, as we↵ | 4 | // that is typecast to JTextComponent. this is not essential, as we↵ | |
4 | // could typecast every reference, but this makes the code cleaner↵ | 5 | // could typecast every reference, but this makes the code cleaner↵ | |
5 | JTextComponent _theComponent = (JTextComponent)DataTypeDate.this._textComponent;↵ | 6 | JTextComponent _theComponent = (JTextComponent)DataTypeBinary.this._textComponent;↵ | |
6 | String text = _theComponent.getText();↵ | 7 | String text = _theComponent.getText();↵ | |
8 | ↵ | |||
7 | // tabs and newlines get put into the text before this check,↵ | 9 | // tabs and newlines get put into the text before this check,↵ | |
8 | // so remove them↵ | 10 | // so remove them↵ | |
9 | // This only applies to Popup editing since these chars are↵ | 11 | // This only applies to Popup editing since these chars are↵ | |
10 | // not passed to this level by the in-cell editor.↵ | 12 | // not passed to this level by the in-cell editor.↵ | |
11 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {↵ | 13 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) {↵ | |
12 | // remove all instances of the offending char↵ | 14 | // remove all instances of the offending char↵ | |
13 | int index = text.indexOf(c);↵ | 15 | int index = text.indexOf(c);↵ | |
14 | if (index != -1) {↵ | 16 | if (index != -1) {↵ | |
15 | if (index == text.length() -1) {↵ | 17 | if (index == text.length() -1) {↵ | |
16 | text = text.substring(0, text.length()-1); // truncate string↵ | 18 | text = text.substring(0, text.length()-1); // truncate string↵ | |
17 | }↵ | 19 | }↵ | |
18 | else {↵ | 20 | else {↵ | |
19 | text = text.substring(0, index) + text.substring(index+1);↵ | 21 | text = text.substring(0, index) + text.substring(index+1);↵ | |
20 | }↵ | 22 | }↵ | |
21 | ((IRestorableTextComponent)_theComponent).updateText( text);↵ | 23 | ((IRestorableTextComponent)_theComponent).updateText( text);↵ | |
22 | _beepHelper.beep(_theComponent);↵ | 24 | _beepHelper.beep(_theComponent);↵ | |
23 | }↵ | 25 | }↵ | |
24 | e.consume();↵ | 26 | e.consume();↵ | |
25 | }↵ | 27 | }↵ | |
26 | // handle cases of null↵ | 28 | // handle cases of null↵ | |
27 | // The processing is different when nulls are allowed and when they are not.↵ | 29 | // The processing is different when nulls are allowed and when they are not.↵ | |
28 | //↵ | 30 | //↵ | |
29 | if ( DataTypeDate.this._isNullable) {↵ | 31 | if ( DataTypeBinary.this._isNullable) {↵ | |
30 | // user enters something when field is null↵ | 32 | // user enters something when field is null↵ | |
31 | if (text.equals("<null>")) {↵ | 33 | if (text.equals("<null>")) {↵ | |
32 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | 34 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | |
33 | // delete when null => original value↵ | 35 | // delete when null => original value↵ | |
34 | DataTypeDate.this._textComponent.restoreText();↵ | 36 | DataTypeBinary.this._textComponent.restoreText();↵ | |
35 | e.consume();↵ | 37 | e.consume();↵ | |
36 | }↵ | 38 | }↵ | |
37 | else {↵ | 39 | else {↵ | |
38 | // non-delete when null => clear field and add text↵ | 40 | // non-delete when null => clear field and add text↵ | |
39 | DataTypeDate.this._textComponent.updateText("");↵ | 41 | DataTypeBinary.this._textComponent.updateText("");↵ | |
40 | // fall through to normal processing of this key stroke↵ | 42 | // fall through to normal processing of this key stroke↵ | |
41 | }↵ | 43 | }↵ | |
42 | }↵ | 44 | }↵ | |
43 | else {↵ | 45 | else {↵ | |
44 | // check for user deletes last thing in field↵ | 46 | // check for user deletes last thing in field↵ | |
45 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | 47 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | |
46 | if (text.length() <= 1 ) {↵ | 48 | if (text.length() <= 1 ) {↵ | |
47 | // about to delete last thing in field, so replace with null↵ | 49 | // about to delete last thing in field, so replace with null↵ | |
48 | DataTypeDate.this._textComponent.updateText("<null>");↵ | 50 | DataTypeBinary.this._textComponent.updateText("<null>");↵ | |
49 | e.consume();↵ | 51 | e.consume();↵ | |
50 | }↵ | 52 | }↵ | |
51 | }↵ | 53 | }↵ | |
52 | }↵ | 54 | }↵ | |
53 | }↵ | 55 | }↵ | |
54 | else {↵ | 56 | else {↵ | |
55 | // field is not nullable↵ | 57 | // field is not nullable↵ | |
56 | //↵ | |||
57 | ↵ | 58 | //↵ | |
58 | handleNotNullableField(text, c, e, _textComponent);↵ | 59 | handleNotNullableField(text, c, e, _textComponent);↵ | |
59 | } | 60 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 2.4 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 84 |
Number of mapped statements | 23 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 15.6 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | char c = e.getKeyChar(); | 1 | char c = e.getKeyChar(); | ||||||||||||
2 | JTextComponent _theComponent = (JTextComponent)DataTypeDate.this._textComponent; |
| 2 | JTextComponent _theComponent = (JTextComponent)DataTypeBinary.this._textComponent; | |||||||||||
3 | String text = _theComponent.getText(); | 3 | String text = _theComponent.getText(); | ||||||||||||
4 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) | 4 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) | ||||||||||||
5 | int index = text.indexOf(c); | 5 | int index = text.indexOf(c); | ||||||||||||
6 | if (index != -1) | 6 | if (index != -1) | ||||||||||||
7 | if (index == text.length() - 1) | 7 | if (index == text.length() - 1) | ||||||||||||
8 | text = text.substring(0, text.length() - 1); | 8 | text = text.substring(0, text.length() - 1); | ||||||||||||
else | else | ||||||||||||||
9 | text = text.substring(0, index) + text.substring(index + 1); | 9 | text = text.substring(0, index) + text.substring(index + 1); | ||||||||||||
10 | ((IRestorableTextComponent)_theComponent).updateText(text); | 10 | ((IRestorableTextComponent)_theComponent).updateText(text); | ||||||||||||
11 | _beepHelper.beep(_theComponent); | 11 | _beepHelper.beep(_theComponent); | ||||||||||||
12 | e.consume(); | 12 | e.consume(); | ||||||||||||
13 | if (DataTypeDate.this._isNullable) |
| 13 | if (DataTypeBinary.this._isNullable) | |||||||||||
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 | DataTypeDate.this._textComponent.restoreText(); |
| 16 | DataTypeBinary.this._textComponent.restoreText(); | |||||||||||
17 | e.consume(); | 17 | e.consume(); | ||||||||||||
else | else | ||||||||||||||
18 | DataTypeDate.this._textComponent.updateText(""); |
| 18 | DataTypeBinary.this._textComponent.updateText(""); | |||||||||||
else | else | ||||||||||||||
19 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) | 19 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) | ||||||||||||
20 | if (text.length() <= 1) | 20 | if (text.length() <= 1) | ||||||||||||
21 | DataTypeDate.this._textComponent.updateText("<null>"); |
| 21 | DataTypeBinary.this._textComponent.updateText("<null>"); | |||||||||||
22 | e.consume(); | 22 | e.consume(); | ||||||||||||
else | else | ||||||||||||||
23 | handleNotNullableField(text, c, e, _textComponent); | 23 | handleNotNullableField(text, c, e, _textComponent); |
Row | Violation |
---|---|
1 | Expression DataTypeDate cannot be unified with expression DataTypeBinary , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent |
2 | Expression DataTypeDate cannot be unified with expression DataTypeBinary , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private boolean _isNullable |
3 | Expression DataTypeDate cannot be unified with expression DataTypeBinary , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent |
4 | Expression DataTypeDate cannot be unified with expression DataTypeBinary , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent |
5 | Expression DataTypeDate cannot be unified with expression DataTypeBinary , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IRestorableTextComponent _textComponent |