/** * @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; }
/** * 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/ui/FigEdgeModelElement.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Method name: Vector getPopUpActions(MouseEvent) Method name: Vector getPopUpActions(MouseEvent)
Number of AST nodes: 2 Number of AST nodes: 2
1
/**
1
/**
2
     * @param me the MouseEvent that triggered the popup menu request
2
     * This method returns a Vector of one of these 4 types:
3
     * @return a Vector containing a combination of these 4 types: Action,
3
     * AbstractAction, JMenu, JMenuItem, JSeparator.
4
     *         JMenu, JMenuItem, JSeparator.
4
     * {@inheritDoc}
5
     */
5
     */
6
    @Override
6
    @Override
7
    public Vector getPopUpActions(MouseEvent me) {
7
    public Vector getPopUpActions(MouseEvent me) {
8
        ActionList popUpActions =
8
        ActionList popUpActions =
9
            new ActionList(super.getPopUpActions(me), isReadOnly());
9
            new ActionList(super.getPopUpActions(me), isReadOnly());
10
        
10
11
        // Added this part to load the extra menu content
11
        final List<Action> modulesActions =
12
        final List<Action> modulesActions =
12
            ContextActionFactoryManager.getContextPopupActions();
13
            ContextActionFactoryManager.getContextPopupActions();
13
        
14
        
14
        for (Action a : modulesActions) {
15
        for (Action a : modulesActions) {
15
            if (a instanceof List) {
16
            if (a instanceof List) {
16
                JMenu m = new JMenu(a);
17
                JMenu m = new JMenu((Action) a);
17
                popUpActions.add(m);
18
                popUpActions.add(m);
18
                for (Action subAction : (List<Action>) a) {
19
                for (Action subAction : (List<Action>) a) {
19
                    m.add(subAction);
20
                    m.add(subAction);
20
                }
21
                }
21
            } else {
22
            } else {
22
                popUpActions.add(a);
23
                popUpActions.add(a);
23
            }
24
            }
24
        }
25
        }
25
        
26
        
26
        // Show ...
27
        // popupAddOffset should be equal to the number of items added here:
27
        ArgoJMenu show = buildShowPopUp();
28
        popUpActions.add(new JSeparator());
28
        if (show.getMenuComponentCount() > 0) {
29
        popupAddOffset = 1;
29
            popUpActions.add(show);
30
        if (removeFromDiagram) {
30
        }
31
            popUpActions.add(
31
        
32
                    ProjectActions.getInstance().getRemoveFromDiagramAction());
32
        // popupAddOffset should be equal to the number of items added here:
33
            popupAddOffset++;
33
        popUpActions.add(new JSeparator());
34
        }
34
        popupAddOffset = 1;
35
        popUpActions.add(new ActionDeleteModelElements());
35
        if (removeFromDiagram) {
36
        popupAddOffset++;
36
            popUpActions.add(
37
37
                    ProjectActions.getInstance().getRemoveFromDiagramAction());
38
        if (TargetManager.getInstance().getTargets().size() == 1) {
38
            popupAddOffset++;
39
            ToDoList list = Designer.theDesigner().getToDoList();
39
        }
40
            List<ToDoItem> items = list.elementListForOffender(getOwner());
40
        
41
            if (items != null && items.size() > 0) {
41
        if (!isReadOnly()) {
42
                // TODO: This creates a dependency on the Critics subsystem.
42
            popUpActions.add(new ActionDeleteModelElements());
43
                // We need a generic way for modules (including our internal
43
            popupAddOffset++;
44
                // subsystems) to request addition of actions to the popup
44
        }
45
                // menu. - tfm 20080430
45
46
                ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
46
        /* Check if multiple items are selected: */
47
                ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
47
        if (TargetManager.getInstance().getTargets().size() == 1) {
48
                if (itemUnderMouse != null) {
48
            
49
                    critiques.add(new ActionGoToCritique(itemUnderMouse));
49
            // TODO: Having Critics actions here introduces an unnecessary
50
                    critiques.addSeparator();
50
            // dependency on the Critics subsystem.  Have it register its
51
                }
51
            // desired actions using an extension mechanism - tfm
52
                for (ToDoItem item : items) {
52
            ToDoList tdList = Designer.theDesigner().getToDoList();
53
                    if (item == itemUnderMouse) {
53
            List<ToDoItem> items = tdList.elementListForOffender(getOwner());
54
                        continue;
54
            if (items != null && items.size() > 0) {
55
                    }
55
                // TODO: This creates a dependency on the Critics subsystem.
56
                    critiques.add(new ActionGoToCritique(item));
56
                // We need a generic way for modules (including our internal
57
                }
57
                // subsystems) to request addition of actions to the popup
58
                popUpActions.add(0, new JSeparator());
58
                // menu. - tfm 20080430
59
                popUpActions.add(0, critiques);
59
                ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
60
            }
60
                ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
61
        }
61
                if (itemUnderMouse != null) {
62
62
                    critiques.add(new ActionGoToCritique(itemUnderMouse));
63
        // Add stereotypes submenu
63
                    critiques.addSeparator();
64
        Action[] stereoActions = getApplyStereotypeActions();
64
                }
65
        if (stereoActions != null && stereoActions.length > 0) {
65
                for (ToDoItem item : items) {
66
            popUpActions.add(0, new JSeparator());
66
                    if (item != itemUnderMouse) {
67
            ArgoJMenu stereotypes = new ArgoJMenu(
67
                        critiques.add(new ActionGoToCritique(item));
68
                    "menu.popup.apply-stereotypes");
68
                    }
69
            for (int i = 0; i < stereoActions.length; ++i) {
69
                }
70
                stereotypes.addCheckItem(stereoActions[i]);
70
                popUpActions.add(0, new JSeparator());
71
            }
71
                popUpActions.add(0, critiques);
72
            popUpActions.add(0, stereotypes);
72
            }
73
        }
73
        }
74
74
75
        return popUpActions;
75
        // Add stereotypes submenu
76
    }
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 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.400
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    36
    for (int i = 0; i < stereoActions.length; ++i)
    51
    for (Action action : stereoActions)
    37
    stereotypes.addCheckItem(stereoActions[i]);
    37
    stereotypes.addCheckItem(stereoActions[i]);
    52
    stereotypes.addCheckItem(action);
    Differences
    Expression1Expression2Difference
    stereoActions[i]actionTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression stereoActions[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression action cannot be parameterized, because it has dependencies to/from statements that will be extracted
    52
    stereotypes.addCheckItem(action);
    Precondition Violations (2)
    Row Violation
    1Expression stereoActions[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression action cannot be parameterized, because it has dependencies to/from statements that will be extracted