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