File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/base/MnemonicSetter.java | File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/base/MnemonicSetter.java | |||
Method name: void setTextWithMnemonic(AbstractButton, String)
|
Method name: void setTextWithMnemonic(JLabel, String)
|
|||
Number of AST nodes: 12 | Number of AST nodes: 12 | |||
1 | int index = text.indexOf("&");↵ | 1 | int index = text.indexOf("&");↵ | |
2 | if ((index != -1) && ((index + 1) < text.length())) {↵ | 2 | if ((index != -1) && ((index + 1) < text.length())) {↵ | |
3 | // mnemonic found↵ | 3 | // mnemonic found↵ | |
4 | // ...and not at the end of the string (which doesn't make sence)↵ | 4 | // ...and not at the end of the string (which doesn't make sence)↵ | |
5 | char mnemonic = text.charAt(index + 1);↵ | 5 | char mnemonic = text.charAt(index + 1);↵ | |
6 | StringBuffer buf = new StringBuffer();↵ | 6 | StringBuffer buf = new StringBuffer();↵ | |
7 | // if mnemonic is first character of this string↵ | 7 | // if mnemonic is first character of this string↵ | |
8 | if (index == 0) {↵ | 8 | if (index == 0) {↵ | |
9 | buf.append(text.substring(1));↵ | 9 | buf.append(text.substring(1));↵ | |
10 | } else {↵ | 10 | } else {↵ | |
11 | buf.append(text.substring(0, index));↵ | 11 | buf.append(text.substring(0, index));↵ | |
12 | buf.append(text.substring(index + 1));↵ | 12 | buf.append(text.substring(index + 1));↵ | |
13 | }↵ | 13 | }↵ | |
14 | // set display text↵ | 14 | // set display text↵ | |
15 | component.setText(buf.toString());↵ | 15 | label.setText(buf.toString());↵ | |
16 | // set mnemonic↵ | 16 | // set mnemonic↵ | |
17 | component.setMnemonic(mnemonic);↵ | 17 | label.setDisplayedMnemonic(mnemonic);↵ | |
18 | component.setDisplayedMnemonicIndex(index);↵ | 18 | label.setDisplayedMnemonicIndex(index);↵ | |
19 | } else {↵ | 19 | } else {↵ | |
20 | // no mnemonic found - just set the text on the menu item↵ | 20 | // no mnemonic found - just set the text on the menu item↵ | |
21 | component.setText(text);↵ | 21 | label.setText(text);↵ | |
22 | } | 22 |
| |
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) | 0.4 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 66 |
Number of mapped statements | 12 |
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) | 16.4 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | int index = text.indexOf("&"); | 1 | int index = text.indexOf("&"); | |||||||||||||||||||||
2 | if ((index != -1) && ((index + 1) < text.length())) | 2 | if ((index != -1) && ((index + 1) < text.length())) | |||||||||||||||||||||
3 | char mnemonic = text.charAt(index + 1); | 3 | char mnemonic = text.charAt(index + 1); | |||||||||||||||||||||
4 | StringBuffer buf = new StringBuffer(); | 4 | StringBuffer buf = new StringBuffer(); | |||||||||||||||||||||
5 | if (index == 0) | 5 | if (index == 0) | |||||||||||||||||||||
6 | buf.append(text.substring(1)); | 6 | buf.append(text.substring(1)); | |||||||||||||||||||||
else | else | |||||||||||||||||||||||
7 | buf.append(text.substring(0, index)); | 7 | buf.append(text.substring(0, index)); | |||||||||||||||||||||
8 | buf.append(text.substring(index + 1)); | 8 | buf.append(text.substring(index + 1)); | |||||||||||||||||||||
9 | component.setText(buf.toString()); |
| 9 | label.setText(buf.toString()); | ||||||||||||||||||||
10 | component.setMnemonic(mnemonic); |
| 10 | label.setDisplayedMnemonic(mnemonic); | ||||||||||||||||||||
11 | component.setDisplayedMnemonicIndex(index); |
| 11 | label.setDisplayedMnemonicIndex(index); | ||||||||||||||||||||
else | else | |||||||||||||||||||||||
12 | component.setText(text); |
| 12 | label.setText(text); |
Row | Violation |
---|---|
1 | Expression component cannot be unified with expression label , because common superclass javax.swing.JComponent does not declare member(s) public void setText(java.lang.String) |
2 | Expression component.setMnemonic(mnemonic) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression label.setDisplayedMnemonic(mnemonic) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression component.setMnemonic(mnemonic) is a void method call, and thus it cannot be parameterized |
5 | Expression label.setDisplayedMnemonic(mnemonic) is a void method call, and thus it cannot be parameterized |
6 | Expression component cannot be unified with expression label , because common superclass javax.swing.JComponent does not declare member(s) public void setDisplayedMnemonicIndex(int) throws java.lang.IllegalArgumentException |
7 | Expression component cannot be unified with expression label , because common superclass javax.swing.JComponent does not declare member(s) public void setText(java.lang.String) |