File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeDouble.java | File path: /sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DataTypeTime.java | |||
Method name: void keyTyped(KeyEvent)
|
Method name: void keyTyped(KeyEvent)
|
|||
Number of AST nodes: 26 | Number of AST nodes: 22 | |||
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)DataTypeDouble.this._textComponent;↵ | 5 | JTextComponent _theComponent = (JTextComponent)DataTypeTime.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) {↵ | |||
15 | if (index == text.length() -1) {↵ | 14 | if (index == text.length() -1) {↵ | |
16 | text = text.substring(0, text.length()-1); // truncate string↵ | 15 | text = text.substring(0, text.length()-1); // truncate string↵ | |
17 | }↵ | 16 | }↵ | |
18 | else {↵ | 17 | else {↵ | |
19 | text = text.substring(0, index) + text.substring(index+1);↵ | 18 | text = text.substring(0, index) + text.substring(index+1);↵ | |
20 | }↵ | 19 | }↵ | |
21 | ((IRestorableTextComponent)_theComponent).updateText( text);↵ | 20 | ((IRestorableTextComponent)_theComponent).updateText( text);↵ | |
22 | _beepHelper.beep(_theComponent);↵ | 21 | _beepHelper.beep(_theComponent);↵ | |
23 | }↵ | 22 | ↵ | |
24 | e.consume();↵ | 23 | e.consume();↵ | |
25 | }↵ | 24 | }↵ | |
26 | if ( ! ( Character.isDigit(c) ||↵ | |||
27 | (c == '-') || (c == '+') ||↵ | |||
28 | (c == 'e') || (c == 'E') ||↵ | |||
29 | (c == 'f') || (c == 'F') ||↵ | |||
30 | (c == 'd') || (c == 'D') ||↵ | |||
31 | (c == '.') || (c == ',') || // several number formats use '.' as decimal separator, others use ','↵ | |||
32 | (c == KeyEvent.VK_BACK_SPACE) ||↵ | |||
33 | (c == KeyEvent.VK_DELETE) ) ) {↵ | |||
34 | _beepHelper.beep(_theComponent);↵ | |||
35 | e.consume();↵ | |||
36 | }↵ | |||
37 | // handle cases of null↵ | 25 | // handle cases of null↵ | |
38 | // The processing is different when nulls are allowed and when they are not.↵ | 26 | // The processing is different when nulls are allowed and when they are not.↵ | |
39 | //↵ | 27 | //↵ | |
40 | if ( DataTypeDouble.this._isNullable) {↵ | 28 | if ( DataTypeTime.this._isNullable) {↵ | |
41 | // user enters something when field is null↵ | 29 | // user enters something when field is null↵ | |
42 | if (text.equals("<null>")) {↵ | 30 | if (text.equals("<null>")) {↵ | |
43 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | 31 | if ((c==KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | |
44 | // delete when null => original value↵ | 32 | // delete when null => original value↵ | |
45 | DataTypeDouble.this._textComponent.restoreText();↵ | 33 | DataTypeTime.this._textComponent.restoreText();↵ | |
46 | e.consume();↵ | 34 | e.consume();↵ | |
47 | }↵ | 35 | }↵ | |
48 | else {↵ | 36 | else {↵ | |
49 | // non-delete when null => clear field and add text↵ | 37 | // non-delete when null => clear field and add text↵ | |
50 | DataTypeDouble.this._textComponent.updateText("");↵ | 38 | DataTypeTime.this._textComponent.updateText("");↵ | |
51 | // fall through to normal processing of this key stroke↵ | 39 | // fall through to normal processing of this key stroke↵ | |
52 | }↵ | 40 | }↵ | |
53 | }↵ | 41 | }↵ | |
54 | else {↵ | 42 | else {↵ | |
55 | // check for user deletes last thing in field↵ | 43 | // check for user deletes last thing in field↵ | |
56 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | 44 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) {↵ | |
57 | if (text.length() <= 1 ) {↵ | 45 | if (text.length() <= 1 ) {↵ | |
58 | // about to delete last thing in field, so replace with null↵ | 46 | // about to delete last thing in field, so replace with null↵ | |
59 | DataTypeDouble.this._textComponent.updateText("<null>");↵ | 47 | DataTypeTime.this._textComponent.updateText("<null>");↵ | |
60 | e.consume();↵ | 48 | e.consume();↵ | |
61 | }↵ | 49 | }↵ | |
62 | }↵ | 50 | }↵ | |
63 | }↵ | 51 | }↵ | |
64 | }↵ | 52 | }↵ | |
65 | else {↵ | 53 | else {↵ | |
66 | // field is not nullable↵ | 54 | // field is not nullable↵ | |
67 | //↵ | 55 | //↵ | |
68 | handleNotNullableField(text, c, e, _textComponent);↵ | 56 | handleNotNullableField(text, c, e, _textComponent);↵ | |
69 | } | 57 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 2 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 2 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 3.5 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 78 |
Number of mapped statements | 6 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 5.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | char c = e.getKeyChar(); | ||||||||||||||||||||
| 2 | JTextComponent _theComponent = (JTextComponent)DataTypeTime.this._textComponent; | ||||||||||||||||||||
| 3 | String text = _theComponent.getText(); | ||||||||||||||||||||
5 | int index = text.indexOf(c); | | ||||||||||||||||||||
6 | if (index != -1) |
| 4 | if (c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER) | ||||||||||||||||||
|
| 5 | int index = text.indexOf(c); | |||||||||||||||||||
7 | if (index == text.length() - 1) | 6 | if (index == text.length() - 1) | |||||||||||||||||||
8 | text = text.substring(0, text.length() - 1); | 7 | text = text.substring(0, text.length() - 1); | |||||||||||||||||||
else | else | |||||||||||||||||||||
9 | text = text.substring(0, index) + text.substring(index + 1); | 8 | text = text.substring(0, index) + text.substring(index + 1); | |||||||||||||||||||
10 | ((IRestorableTextComponent)_theComponent).updateText(text); | 9 | ((IRestorableTextComponent)_theComponent).updateText(text); | |||||||||||||||||||
11 | _beepHelper.beep(_theComponent); | 10 | _beepHelper.beep(_theComponent); | |||||||||||||||||||
| 11 | e.consume(); |
Row | Violation |
---|---|
1 | Expression index != -1 cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression c == KeyEvent.VK_TAB || c == KeyEvent.VK_ENTER cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement int index=text.indexOf(c); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
Number of mapped statements | 14 |
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) | 10.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | char c = e.getKeyChar(); | 1 | char c = e.getKeyChar(); | ||||||||||||
2 | JTextComponent _theComponent = (JTextComponent)DataTypeDouble.this._textComponent; |
| 2 | JTextComponent _theComponent = (JTextComponent)DataTypeTime.this._textComponent; | |||||||||||
3 | String text = _theComponent.getText(); | 3 | String text = _theComponent.getText(); | ||||||||||||
16 | if (DataTypeDouble.this._isNullable) |
| 12 | if (DataTypeTime.this._isNullable) | |||||||||||
17 | if (text.equals("<null>")) | 13 | if (text.equals("<null>")) | ||||||||||||
18 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) | 14 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) | ||||||||||||
19 | DataTypeDouble.this._textComponent.restoreText(); |
| 15 | DataTypeTime.this._textComponent.restoreText(); | |||||||||||
20 | e.consume(); | 16 | e.consume(); | ||||||||||||
else | else | ||||||||||||||
21 | DataTypeDouble.this._textComponent.updateText(""); |
| 17 | DataTypeTime.this._textComponent.updateText(""); | |||||||||||
else | else | ||||||||||||||
22 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) | 18 | if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)) | ||||||||||||
23 | if (text.length() <= 1) | 19 | if (text.length() <= 1) | ||||||||||||
24 | DataTypeDouble.this._textComponent.updateText("<null>"); |
| 20 | DataTypeTime.this._textComponent.updateText("<null>"); | |||||||||||
25 | e.consume(); | 21 | e.consume(); | ||||||||||||
else | else | ||||||||||||||
26 | handleNotNullableField(text, c, e, _textComponent); | 22 | handleNotNullableField(text, c, e, _textComponent); |
Row | Violation |
---|---|
1 | Expression DataTypeDouble cannot be unified with expression DataTypeTime , 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 DataTypeDouble cannot be unified with expression DataTypeTime , because common superclass net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.BaseDataTypeComponent does not declare member(s) private boolean _isNullable |
3 | Expression DataTypeDouble cannot be unified with expression DataTypeTime , 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 DataTypeDouble cannot be unified with expression DataTypeTime , 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 DataTypeDouble cannot be unified with expression DataTypeTime , 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 |
6 | Clone fragment #1 returns variables c, text, _theComponent , while Clone fragment #2 returns variables c, text, _theComponent |