@Override protected void updateListeners(Object oldOwner, Object newOwner) { Set<Object[]> l = new HashSet<Object[]>(); if (newOwner != null) { // add the listeners to the newOwner l.add(new Object[] {newOwner, null}); Collection c = Model.getFacade().getStereotypes(newOwner); Iterator i = c.iterator(); while (i.hasNext()) { Object st = i.next(); l.add(new Object[] {st, "name"}); } } updateElementListeners(l); }
@Override protected void updateListeners(Object oldOwner, Object newOwner) { if (isCompartmentVisible(Model.getMetaTypes().getAttribute())) { Set<Object[]> listeners = new HashSet<Object[]>(); // Collect the set of model elements that we want to listen to if (newOwner != null) { // TODO: Because we get called on each and every change event, when // the model is in a state of flux, we'll often get an // InvalidElementException before we finish this collection. The // only saving grace is that we're called SO many times that on the // last time, things should be stable again and we'll get a good set // of elements for the final update. We need a better mechanism. // add the listeners to the newOwner listeners.add(new Object[] {newOwner, null}); // and its stereotypes // TODO: Aren't stereotypes handled elsewhere? for (Object stereotype : Model.getFacade().getStereotypes(newOwner)) { listeners.add(new Object[] {stereotype, null}); } // and its features for (Object feat : Model.getFacade().getFeatures(newOwner)) { listeners.add(new Object[] {feat, null}); // and the stereotypes of its features for (Object stereotype : Model.getFacade().getStereotypes(feat)) { listeners.add(new Object[] {stereotype, null}); } // and the parameter of its operations if (Model.getFacade().isAOperation(feat)) { for (Object param : Model.getFacade().getParameters(feat)) { listeners.add(new Object[] {param, null}); } } } } // Update the listeners to match the desired set using the minimal // update facility updateElementListeners(listeners); } else { super.updateListeners(oldOwner, newOwner); } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/ui/AbstractFigNode.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigClassifierBox.java
Method name: void updateListeners(Object, Object) Method name: void updateListeners(Object, Object)
Number of AST nodes: 3 Number of AST nodes: 2
1
@Override
1
@Override
2
    protected void updateListeners(Object oldOwner, Object newOwner) {
2
    protected void updateListeners(Object oldOwner, Object newOwner) {
3
        Set<Object[]> l = new HashSet<Object[]>();
3
       
4
        if (newOwner != null) {
4
        if (isCompartmentVisible(Model.getMetaTypes().getAttribute())) {
5
            // add the listeners to the newOwner
5
            Set<Object[]> listeners = new HashSet<Object[]>();
6
            l.add(new Object[] {newOwner, null});
6
7
            
7
            // Collect the set of model elements that we want to listen to
8
            Collection c = Model.getFacade().getStereotypes(newOwner);
8
            if (newOwner != null) {
9
            Iterator i = c.iterator();
9
                // TODO: Because we get called on each and every change event, when
10
            while (i.hasNext()) {
10
                // the model is in a state of flux, we'll often get an
11
                Object st = i.next();
11
                // InvalidElementException before we finish this collection. The
12
                l.add(new Object[] {st, "name"});
12
                // only saving grace is that we're called SO many times that on the
13
            }
13
                // last time, things should be stable again and we'll get a good set
14
        }
14
                // of elements for the final update.  We need a better mechanism.
15
        updateElementListeners(l);
15
                
16
    }
16
                // add the listeners to the newOwner
17
                listeners.add(new Object[] {newOwner, null});
18
                
19
                // and its stereotypes
20
                // TODO: Aren't stereotypes handled elsewhere?
21
                for (Object stereotype 
22
                        : Model.getFacade().getStereotypes(newOwner)) {
23
                    listeners.add(new Object[] {stereotype, null});
24
                }
25
26
                // and its features
27
                for (Object feat : Model.getFacade().getFeatures(newOwner)) {
28
                    listeners.add(new Object[] {feat, null});
29
                    // and the stereotypes of its features
30
                    for (Object stereotype 
31
                            : Model.getFacade().getStereotypes(feat)) {
32
                        listeners.add(new Object[] {stereotype, null});
33
                    }
34
                    // and the parameter of its operations
35
                    if (Model.getFacade().isAOperation(feat)) {
36
                        for (Object param : Model.getFacade().getParameters(feat)) {
37
                            listeners.add(new Object[] {param, null});
38
                        }
39
                    }
40
                }
41
            }
42
            
43
            // Update the listeners to match the desired set using the minimal
44
            // update facility
45
            updateElementListeners(listeners);
46
        } else {
47
            super.updateListeners(oldOwner, newOwner);
48
        }
49
    }
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements4
    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.600
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    while (i.hasNext())
    6
    while (i.hasNext())
    12
    for (Object param : Model.getFacade().getParameters(feat))
    Differences
    Expression1Expression2Difference
    stparamVARIABLE_NAME_MISMATCH
    cModel.getFacade().getParameters(feat)TYPE_COMPATIBLE_REPLACEMENT
    12
    for (Object param : Model.getFacade().getParameters(feat))
    7
    Object st = i.next();
    7
    Object st = i.next();
    Differences
    Expression1Expression2Difference
    stparamVARIABLE_NAME_MISMATCH
                                                
    8
    l.add(new Object[] {st, "name"});
    8
    l.add(new Object[] {st, "name"});
    13
    listeners.add(new Object[] {param, null});
    Differences
    Expression1Expression2Difference
    stparamVARIABLE_NAME_MISMATCH
    "name"nullTYPE_COMPATIBLE_REPLACEMENT
    llistenersVARIABLE_NAME_MISMATCH
    13
    listeners.add(new Object[] {param, null});
    Precondition Violations (0)
    Row Violation