protected ArgoJMenu buildShowPopUp() { ArgoJMenu showMenu = super.buildShowPopUp(); Iterator i = ActionCompartmentDisplay.getActions().iterator(); while (i.hasNext()) { showMenu.add((Action) i.next()); } return showMenu; }
/** * This method returns a Vector of one of these 4 types: * AbstractAction, JMenu, JMenuItem, JSeparator. * {@inheritDoc} */ @Override public Vector getPopUpActions(MouseEvent me) { ActionList popUpActions = new ActionList(super.getPopUpActions(me), isReadOnly()); final List<Action> modulesActions = ContextActionFactoryManager.getContextPopupActions(); for (Action a : modulesActions) { if (a instanceof List) { JMenu m = new JMenu(a); popUpActions.add(m); for (Action subAction : (List<Action>) a) { m.add(subAction); } } else { popUpActions.add(a); } } // Show ... ArgoJMenu show = buildShowPopUp(); if (show.getMenuComponentCount() > 0) { popUpActions.add(show); } // 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++; } if (!isReadOnly()) { popUpActions.add(new ActionDeleteModelElements()); popupAddOffset++; } /* Check if multiple items are selected: */ if (TargetManager.getInstance().getTargets().size() == 1) { // TODO: Having Critics actions here introduces an unnecessary // dependency on the Critics subsystem. Have it register its // desired actions using an extension mechanism - tfm ToDoList tdList = Designer.theDesigner().getToDoList(); List<ToDoItem> items = tdList.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) { critiques.add(new ActionGoToCritique(item)); } } popUpActions.add(0, new JSeparator()); popUpActions.add(0, critiques); } } // Add stereotypes submenu Collection<Object> elements = new ArrayList<Object>(); Object owner = getOwner(); if (owner != null) { elements.add(owner); } for (Object o : TargetManager.getInstance().getTargets()) { Object element = null; if (Model.getFacade().isAUMLElement(o)) { element = o; } else if (o instanceof Fig) { element = ((Fig) o).getOwner(); } if (element != null && element != owner) { elements.add(element); } } final Action[] stereoActions = StereotypeUtility.getApplyStereotypeActions(elements); if (stereoActions != null) { popUpActions.add(0, new JSeparator()); final ArgoJMenu stereotypes = new ArgoJMenu("menu.popup.apply-stereotypes"); for (Action action : stereoActions) { stereotypes.addCheckItem(action); } popUpActions.add(0, stereotypes); } if (TargetManager.getInstance().getTargets().size() == 1) { // add stereotype view submenu ArgoJMenu stereotypesView = new ArgoJMenu("menu.popup.stereotype-view"); // TODO: There are cyclic dependencies between ActionStereotypeView* // and FigNodeModelElement. Register these actions opaquely since // we don't what they are. - tfm stereotypesView.addRadioItem(new ActionStereotypeViewTextual(this)); stereotypesView.addRadioItem(new ActionStereotypeViewBigIcon(this)); stereotypesView.addRadioItem( new ActionStereotypeViewSmallIcon(this)); popUpActions.add(0, stereotypesView); } 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/FigNodeModelElement.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
     * This method returns a Vector of one of these 4 types:
3
3
     * AbstractAction, JMenu, JMenuItem, JSeparator.
4
        Iterator i = ActionCompartmentDisplay.getActions().iterator();
4
     * {@inheritDoc}
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
        final List<Action> modulesActions =
12
            ContextActionFactoryManager.getContextPopupActions();
13
        
14
        for (Action a : modulesActions) {
15
            if (a instanceof List) {
16
                JMenu m = new JMenu(a);
17
                popUpActions.add(m);
18
                for (Action subAction : (List<Action>) a) {
19
                    m.add(subAction);
20
                }
21
            } else {
22
                popUpActions.add(a);
23
            }
24
        }
25
        
26
        // Show ...
27
        ArgoJMenu show = buildShowPopUp();
28
        if (show.getMenuComponentCount() > 0) {
29
            popUpActions.add(show);
30
        }
31
        
32
        // popupAddOffset should be equal to the number of items added here:
33
        popUpActions.add(new JSeparator());
34
        popupAddOffset = 1;
35
        if (removeFromDiagram) {
36
            popUpActions.add(
37
                    ProjectActions.getInstance().getRemoveFromDiagramAction());
38
            popupAddOffset++;
39
        }
40
        
41
        if (!isReadOnly()) {
42
            popUpActions.add(new ActionDeleteModelElements());
43
            popupAddOffset++;
44
        }
45
46
        /* Check if multiple items are selected: */
47
        if (TargetManager.getInstance().getTargets().size() == 1) {
48
            
49
            // TODO: Having Critics actions here introduces an unnecessary
50
            // dependency on the Critics subsystem.  Have it register its
51
            // desired actions using an extension mechanism - tfm
52
            ToDoList tdList = Designer.theDesigner().getToDoList();
53
            List<ToDoItem> items = tdList.elementListForOffender(getOwner());
54
            if (items != null && items.size() > 0) {
55
                // TODO: This creates a dependency on the Critics subsystem.
56
                // We need a generic way for modules (including our internal
57
                // subsystems) to request addition of actions to the popup
58
                // menu. - tfm 20080430
59
                ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
60
                ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
61
                if (itemUnderMouse != null) {
62
                    critiques.add(new ActionGoToCritique(itemUnderMouse));
63
                    critiques.addSeparator();
64
                }
65
                for (ToDoItem item : items) {
66
                    if (item != itemUnderMouse) {
67
                        critiques.add(new ActionGoToCritique(item));
68
                    }
69
                }
70
                popUpActions.add(0, new JSeparator());
71
                popUpActions.add(0, critiques);
72
            }
73
        }
74
75
        // Add stereotypes submenu
76
        Collection<Object> elements = new ArrayList<Object>();
77
        Object owner = getOwner();
78
        if (owner != null) {
79
            elements.add(owner);
80
        }
81
        for (Object o : TargetManager.getInstance().getTargets()) {
82
            Object element = null;
83
            if (Model.getFacade().isAUMLElement(o)) {
84
                element = o;
85
            } else if (o instanceof Fig) {
86
                element = ((Fig) o).getOwner();
87
            }
88
            if (element != null && element != owner) {
89
                elements.add(element);
90
            }
91
        }
92
        final Action[] stereoActions =
93
            StereotypeUtility.getApplyStereotypeActions(elements);
94
        if (stereoActions != null) {
95
            popUpActions.add(0, new JSeparator());
96
            final ArgoJMenu stereotypes =
97
                new ArgoJMenu("menu.popup.apply-stereotypes");
98
            for (Action action : stereoActions) {
99
                stereotypes.addCheckItem(action);
100
            }
101
            popUpActions.add(0, stereotypes);
102
        }
103
            
104
        if (TargetManager.getInstance().getTargets().size() == 1) {
105
            // add stereotype view submenu
106
            ArgoJMenu stereotypesView =
107
                new ArgoJMenu("menu.popup.stereotype-view");
108
            
109
            // TODO: There are cyclic dependencies between ActionStereotypeView*
110
            // and FigNodeModelElement.  Register these actions opaquely since
111
            // we don't what they are. - tfm
112
            stereotypesView.addRadioItem(new ActionStereotypeViewTextual(this));
113
            stereotypesView.addRadioItem(new ActionStereotypeViewBigIcon(this));
114
            stereotypesView.addRadioItem(
115
                    new ActionStereotypeViewSmallIcon(this));
116
            
117
            popUpActions.add(0, stereotypesView);
118
        }
119
120
        return popUpActions;
121
    }
  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