if (e.isPopupTrigger()) {
// check if a single entry is selected
if ( list.getSelectedIndices().length <= 1 ) {
// select new item
int index = list.locationToIndex(p);
list.setSelectedIndex(index);
}
// show context menu
getPopupMenu().show(e.getComponent(), p.x, p.y);
}
if (e.isPopupTrigger()) {
// check if a single entry is selected
if (list.getSelectedIndices().length <= 1) {
// select new item
int index = list.locationToIndex(p);
list.setSelectedIndex(index);
}
// show context menu
getPopupMenu().show(e.getComponent(), p.x, p.y);
}
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/calendar/src/main/java/org/columba/calendar/ui/box/CalendarBox.java
|
|
File path: /columba-1.4-src/contact/src/main/java/org/columba/contact/gui/box/ContactBox.java
|
Method name: void handlePopupEvent(MouseEvent)
|
|
Method name: void handlePopupEvent(MouseEvent)
|
Number of AST nodes: 5
|
|
Number of AST nodes: 5
|
|
1 | if (e.isPopupTrigger()) {↵ | | 1 | if (e.isPopupTrigger()) {↵
|
2 | // check if a single entry is selected↵ | | 2 | // check if a single entry is selected↵
|
3 | if ( list.getSelectedIndices().length <= 1 ) {↵ | | 3 | if (list.getSelectedIndices().length <= 1) {↵
|
4 | // select new item↵ | | 4 | // select new item↵
|
5 | int index = list.locationToIndex(p);↵ | | 5 | int index = list.locationToIndex(p);↵
|
6 | list.setSelectedIndex(index);↵ | | 6 | list.setSelectedIndex(index);↵
|
7 | }↵ | | 7 | }↵
|
8 | // show context menu↵ | | 8 | // show context menu↵
|
9 | getPopupMenu().show(e.getComponent(), p.x, p.y);↵ | | 9 | getPopupMenu().show(e.getComponent(), p.x, p.y);↵
|
10 | } | | 10 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.5 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 13 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 5 |
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) | 2.5 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
2 | if (e.isPopupTrigger()) | | 2 | if (e.isPopupTrigger()) |
3 | if (list.getSelectedIndices().length <= 1) | | 3 | if (list.getSelectedIndices().length <= 1) |
4 | int index = list.locationToIndex(p); | | 4 | int index = list.locationToIndex(p); |
5 | list.setSelectedIndex(index); | | 5 | list.setSelectedIndex(index); |
6 | getPopupMenu().show(e.getComponent(), p.x, p.y); | | 6 | getPopupMenu().show(e.getComponent(), p.x, p.y); |
Precondition Violations (0)
Row |
Violation |