private void doAdd() { Designer designer = Designer.theDesigner(); String headline = headLineTextField.getText(); int priority = ToDoItem.HIGH_PRIORITY; switch (priorityComboBox.getSelectedIndex()) { case 0: priority = ToDoItem.HIGH_PRIORITY; break; case 1: priority = ToDoItem.MED_PRIORITY; break; case 2: priority = ToDoItem.LOW_PRIORITY; break; } String desc = descriptionTextArea.getText(); String moreInfoURL = moreinfoTextField.getText(); ListSet newOffenders = new ListSet(); for (int i = 0; i < offenderList.getModel().getSize(); i++) { newOffenders.add(offenderList.getModel().getElementAt(i)); } ToDoItem item = new UMLToDoItem(designer, headline, priority, desc, moreInfoURL, newOffenders); designer.getToDoList().addElement(item); //? inform() Designer.firePropertyChange(Designer.MODEL_TODOITEM_ADDED, null, item); }
/** * Returns the selected elements in the selected list * * @return List */ private List getSelectedChoices() { List result = new ArrayList(); for (int index : selectedList.getSelectedIndices()) { result.add(selectedList.getModel().getElementAt(index)); } return result; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/cognitive/ui/AddToDoItemDialog.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/ui/UMLAddDialog.java
Method name: void doAdd() Method name: List getSelectedChoices()
Number of AST nodes: 2 Number of AST nodes: 2
1
private void doAdd() {
1
/**
2
        Designer designer = Designer.theDesigner();
2
     * Returns the selected elements in the selected list
3
        String headline = headLineTextField.getText();
3
     *
4
        int priority = ToDoItem.HIGH_PRIORITY;
4
     * @return List
5
        switch (priorityComboBox.getSelectedIndex()) {
5
     */
6
	case 0:
6
    private List getSelectedChoices() {
7
	    priority = ToDoItem.HIGH_PRIORITY;
7
        List result = new ArrayList();
8
	    break;
8
        for (int index : selectedList.getSelectedIndices()) {
9
	case 1:
9
            result.add(selectedList.getModel().getElementAt(index));
10
	    priority = ToDoItem.MED_PRIORITY;
10
        }
11
	    break;
11
        return result;
12
	case 2:
12
    }
13
	    priority = ToDoItem.LOW_PRIORITY;
14
	    break;
15
        }
16
        String desc = descriptionTextArea.getText();
17
        String moreInfoURL = moreinfoTextField.getText();
18
        ListSet newOffenders = new ListSet();
19
        for (int i = 0; i < offenderList.getModel().getSize(); i++) {
20
            newOffenders.add(offenderList.getModel().getElementAt(i));
21
        }
22
        ToDoItem item =
23
            new UMLToDoItem(designer, headline, priority, 
24
                    desc, moreInfoURL, newOffenders);
25
        designer.getToDoList().addElement(item); //? inform()
26
        Designer.firePropertyChange(Designer.MODEL_TODOITEM_ADDED, null, item);
27
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.714
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    17
    for (int i = 0; i < offenderList.getModel().getSize(); i++)
    17
    for (int i = 0; i < offenderList.getModel().getSize(); i++)
    2
    for (int index : selectedList.getSelectedIndices())
    Differences
    Expression1Expression2Difference
    javax.swing.ListModelint[]VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type javax.swing.ListModel of variable offenderList.getModel() does not match with type int[] of variable selectedList.getSelectedIndices()
    • Make classes javax.swing.ListModel and int[] extend a common superclass
    2
    for (int index : selectedList.getSelectedIndices())
    18
    newOffenders.add(offenderList.getModel().getElementAt(i));
    18
    newOffenders.add(offenderList.getModel().getElementAt(i));
    3
    result.add(selectedList.getModel().getElementAt(index));
    Differences
    Expression1Expression2Difference
    iindexVARIABLE_NAME_MISMATCH
    offenderListselectedListVARIABLE_NAME_MISMATCH
    newOffendersresultVARIABLE_NAME_MISMATCH
    org.argouml.cognitive.ListSetjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression i cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.argouml.cognitive.ListSet of variable newOffenders does not match with type java.util.List of variable result
    • Make classes org.argouml.cognitive.ListSet and java.util.List extend a common superclass
    3
    result.add(selectedList.getModel().getElementAt(index));
    Precondition Violations (4)
    Row Violation
    1Type javax.swing.ListModel of variable offenderList.getModel() does not match with type int[] of variable selectedList.getSelectedIndices()
    2Expression i cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression index cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type org.argouml.cognitive.ListSet of variable newOffenders does not match with type java.util.List of variable result