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: 11 | Number of AST nodes: 11 | |||
1 | if ((index != -1) && ((index + 1) < text.length())) {↵ | 1 | if ((index != -1) && ((index + 1) < text.length())) {↵ | |
2 | // mnemonic found↵ | 2 | // mnemonic found↵ | |
3 | // ...and not at the end of the string (which doesn't make sence)↵ | 3 | // ...and not at the end of the string (which doesn't make sence)↵ | |
4 | char mnemonic = text.charAt(index + 1);↵ | 4 | char mnemonic = text.charAt(index + 1);↵ | |
5 | StringBuffer buf = new StringBuffer();↵ | 5 | StringBuffer buf = new StringBuffer();↵ | |
6 | // if mnemonic is first character of this string↵ | 6 | // if mnemonic is first character of this string↵ | |
7 | if (index == 0) {↵ | 7 | if (index == 0) {↵ | |
8 | buf.append(text.substring(1));↵ | 8 | buf.append(text.substring(1));↵ | |
9 | } else {↵ | 9 | } else {↵ | |
10 | buf.append(text.substring(0, index));↵ | 10 | buf.append(text.substring(0, index));↵ | |
11 | buf.append(text.substring(index + 1));↵ | 11 | buf.append(text.substring(index + 1));↵ | |
12 | }↵ | 12 | }↵ | |
13 | // set display text↵ | 13 | // set display text↵ | |
14 | component.setText(buf.toString());↵ | 14 | label.setText(buf.toString());↵ | |
15 | // set mnemonic↵ | 15 | // set mnemonic↵ | |
16 | component.setMnemonic(mnemonic);↵ | 16 | label.setDisplayedMnemonic(mnemonic);↵ | |
17 | component.setDisplayedMnemonicIndex(index);↵ | 17 | label.setDisplayedMnemonicIndex(index);↵ | |
18 | } else {↵ | 18 | } else {↵ | |
19 | // no mnemonic found - just set the text on the menu item↵ | 19 | // no mnemonic found - just set the text on the menu item↵ | |
20 | component.setText(text);↵ | 20 | label.setText(text);↵ | |
21 | } | 21 |
| |
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.6 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 65 |
Number of mapped statements | 11 |
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.8 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 setMnemonic(char) , public void setDisplayedMnemonic(char) |
7 | 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 |
8 | 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) |