protected ArgoJMenu buildShowPopUp() { ArgoJMenu showMenu = super.buildShowPopUp(); Iterator i = ActionCompartmentDisplay.getActions().iterator(); while (i.hasNext()) { showMenu.add((Action) i.next()); } return showMenu; }
/** * @param me the MouseEvent that triggered the popup menu request * @return a Vector containing a combination of these 4 types: Action, * JMenu, JMenuItem, JSeparator. */ @Override public Vector getPopUpActions(MouseEvent me) { ActionList popUpActions = new ActionList(super.getPopUpActions(me), isReadOnly()); // Added this part to load the extra menu content final List<Action> modulesActions = ContextActionFactoryManager.getContextPopupActions(); for (Action a : modulesActions) { if (a instanceof List) { JMenu m = new JMenu((Action) a); popUpActions.add(m); for (Action subAction : (List<Action>) a) { m.add(subAction); } } else { popUpActions.add(a); } } // popupAddOffset should be equal to the number of items added here: popUpActions.add(new JSeparator()); popupAddOffset = 1; if (removeFromDiagram) { popUpActions.add( ProjectActions.getInstance().getRemoveFromDiagramAction()); popupAddOffset++; } popUpActions.add(new ActionDeleteModelElements()); popupAddOffset++; if (TargetManager.getInstance().getTargets().size() == 1) { ToDoList list = Designer.theDesigner().getToDoList(); List<ToDoItem> items = list.elementListForOffender(getOwner()); if (items != null && items.size() > 0) { // TODO: This creates a dependency on the Critics subsystem. // We need a generic way for modules (including our internal // subsystems) to request addition of actions to the popup // menu. - tfm 20080430 ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques"); ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY()); if (itemUnderMouse != null) { critiques.add(new ActionGoToCritique(itemUnderMouse)); critiques.addSeparator(); } for (ToDoItem item : items) { if (item == itemUnderMouse) { continue; } critiques.add(new ActionGoToCritique(item)); } popUpActions.add(0, new JSeparator()); popUpActions.add(0, critiques); } } // Add stereotypes submenu Action[] stereoActions = getApplyStereotypeActions(); if (stereoActions != null && stereoActions.length > 0) { popUpActions.add(0, new JSeparator()); ArgoJMenu stereotypes = new ArgoJMenu( "menu.popup.apply-stereotypes"); for (int i = 0; i < stereoActions.length; ++i) { stereotypes.addCheckItem(stereoActions[i]); } popUpActions.add(0, stereotypes); } return popUpActions; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
Method name: ArgoJMenu buildShowPopUp() Method name: Vector getPopUpActions(MouseEvent)
Number of AST nodes: 2 Number of AST nodes: 2
1
protected ArgoJMenu buildShowPopUp() {
1
/**
2
        ArgoJMenu showMenu = super.buildShowPopUp();
2
     * @param me the MouseEvent that triggered the popup menu request
3
3
     * @return a Vector containing a combination of these 4 types: Action,
4
        Iterator i = ActionCompartmentDisplay.getActions().iterator();
4
     *         JMenu, JMenuItem, JSeparator.
5
        while (i.hasNext()) {
5
     */
6
            showMenu.add((Action) i.next());
6
    @Override
7
        }
7
    public Vector getPopUpActions(MouseEvent me) {
8
        return showMenu;
8
        ActionList popUpActions =
9
    }
9
            new ActionList(super.getPopUpActions(me), isReadOnly());
10
        
11
        // Added this part to load the extra menu content
12
        final List<Action> modulesActions =
13
            ContextActionFactoryManager.getContextPopupActions();
14
        
15
        for (Action a : modulesActions) {
16
            if (a instanceof List) {
17
                JMenu m = new JMenu((Action) a);
18
                popUpActions.add(m);
19
                for (Action subAction : (List<Action>) a) {
20
                    m.add(subAction);
21
                }
22
            } else {
23
                popUpActions.add(a);
24
            }
25
        }
26
        
27
        // popupAddOffset should be equal to the number of items added here:
28
        popUpActions.add(new JSeparator());
29
        popupAddOffset = 1;
30
        if (removeFromDiagram) {
31
            popUpActions.add(
32
                    ProjectActions.getInstance().getRemoveFromDiagramAction());
33
            popupAddOffset++;
34
        }
35
        popUpActions.add(new ActionDeleteModelElements());
36
        popupAddOffset++;
37
38
        if (TargetManager.getInstance().getTargets().size() == 1) {
39
            ToDoList list = Designer.theDesigner().getToDoList();
40
            List<ToDoItem> items = list.elementListForOffender(getOwner());
41
            if (items != null && items.size() > 0) {
42
                // TODO: This creates a dependency on the Critics subsystem.
43
                // We need a generic way for modules (including our internal
44
                // subsystems) to request addition of actions to the popup
45
                // menu. - tfm 20080430
46
                ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
47
                ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
48
                if (itemUnderMouse != null) {
49
                    critiques.add(new ActionGoToCritique(itemUnderMouse));
50
                    critiques.addSeparator();
51
                }
52
                for (ToDoItem item : items) {
53
                    if (item == itemUnderMouse) {
54
                        continue;
55
                    }
56
                    critiques.add(new ActionGoToCritique(item));
57
                }
58
                popUpActions.add(0, new JSeparator());
59
                popUpActions.add(0, critiques);
60
            }
61
        }
62
63
        // Add stereotypes submenu
64
        Action[] stereoActions = getApplyStereotypeActions();
65
        if (stereoActions != null && stereoActions.length > 0) {
66
            popUpActions.add(0, new JSeparator());
67
            ArgoJMenu stereotypes = new ArgoJMenu(
68
                    "menu.popup.apply-stereotypes");
69
            for (int i = 0; i < stereoActions.length; ++i) {
70
                stereotypes.addCheckItem(stereoActions[i]);
71
            }
72
            popUpActions.add(0, stereotypes);
73
        }
74
75
        return popUpActions;
76
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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.500
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    while (i.hasNext())
    3
    while (i.hasNext())
    7
    for (Action subAction : (List<Action>)a)
    Differences
    Expression1Expression2Difference
    java.util.Collectionjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<javax.swing.Action> of variable ActionCompartmentDisplay.getActions() does not match with type java.util.List<javax.swing.Action> of variable (List<Action>)a
    • Make classes java.util.Collection and java.util.List extend a common superclass
    7
    for (Action subAction : (List<Action>)a)
    4
    showMenu.add((Action)i.next());
    4
    showMenu.add((Action)i.next());
    8
    m.add(subAction);
    Differences
    Expression1Expression2Difference
    (Action)i.next()subActionTYPE_COMPATIBLE_REPLACEMENT
    showMenumVARIABLE_NAME_MISMATCH
    org.argouml.ui.ArgoJMenujavax.swing.JMenuSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression subAction cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    m.add(subAction);
    Precondition Violations (2)
    Row Violation
    1Type java.util.Collection<javax.swing.Action> of variable ActionCompartmentDisplay.getActions() does not match with type java.util.List<javax.swing.Action> of variable (List<Action>)a
    2Expression subAction cannot be parameterized, because it has dependencies to/from statements that will be extracted