if (contentOutlinePage == null) { // The content outline is just a tree. // class MyContentOutlinePage extends ContentOutlinePage { @Override public void createControl(Composite parent) { super.createControl(parent); contentOutlineViewer = getTreeViewer(); contentOutlineViewer.addSelectionChangedListener(this); // Set up the tree viewer. // contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); contentOutlineViewer.setInput(editingDomain.getResourceSet()); // Make sure our popups work. // createContextMenuFor(contentOutlineViewer); if (!editingDomain.getResourceSet().getResources().isEmpty()) { // Select the root object in the view. // contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); } } @Override public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { super.makeContributions(menuManager, toolBarManager, statusLineManager); contentOutlineStatusLineManager = statusLineManager; } @Override public void setActionBars(IActionBars actionBars) { super.setActionBars(actionBars); getActionBarContributor().shareGlobalActions(this, actionBars); } } contentOutlinePage = new MyContentOutlinePage(); // Listen to selection so that we can handle it is a special way. // contentOutlinePage.addSelectionChangedListener (new ISelectionChangedListener() { // This ensures that we handle selections correctly. // public void selectionChanged(SelectionChangedEvent event) { handleContentOutlineSelection(event.getSelection()); } }); } return contentOutlinePage;
if (contentOutlinePage == null) { // The content outline is just a tree. // class MyContentOutlinePage extends ContentOutlinePage { @Override public void createControl(Composite parent) { super.createControl(parent); contentOutlineViewer = getTreeViewer(); contentOutlineViewer.addSelectionChangedListener(this); // Set up the tree viewer. // contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); contentOutlineViewer.setInput(editingDomain.getResourceSet()); // Make sure our popups work. // createContextMenuFor(contentOutlineViewer); if (!editingDomain.getResourceSet().getResources().isEmpty()) { // Select the root object in the view. // contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); } } @Override public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { super.makeContributions(menuManager, toolBarManager, statusLineManager); contentOutlineStatusLineManager = statusLineManager; } @Override public void setActionBars(IActionBars actionBars) { super.setActionBars(actionBars); getActionBarContributor().shareGlobalActions(this, actionBars); } } contentOutlinePage = new MyContentOutlinePage(); // Listen to selection so that we can handle it is a special way. // contentOutlinePage.addSelectionChangedListener (new ISelectionChangedListener() { // This ensures that we handle selections correctly. // public void selectionChanged(SelectionChangedEvent event) { handleContentOutlineSelection(event.getSelection()); } }); } return contentOutlinePage;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java File path: /emf-2.4.1/src/org/eclipse/emf/mapping/ecore2xml/presentation/Ecore2XMLEditor.java
Method name: IContentOutlinePage getContentOutlinePage() Method name: IContentOutlinePage getContentOutlinePage()
Number of AST nodes: 5 Number of AST nodes: 5
1
if (contentOutlinePage == null)
1
if (contentOutlinePage == null)
2
    {
2
    {
3
      // The content outline is just a tree.
3
      // The content outline is just a tree.
4
      //
4
      //
5
      class MyContentOutlinePage extends ContentOutlinePage
5
      class MyContentOutlinePage extends ContentOutlinePage
6
      {
6
      {
7
        @Override
7
        @Override
8
        public void createControl(Composite parent)
8
        public void createControl(Composite parent)
9
        {
9
        {
10
          super.createControl(parent);
10
          super.createControl(parent);
11
          contentOutlineViewer = getTreeViewer();
11
          contentOutlineViewer = getTreeViewer();
12
          contentOutlineViewer.addSelectionChangedListener(this);
12
          contentOutlineViewer.addSelectionChangedListener(this);
13
          // Set up the tree viewer.
13
          // Set up the tree viewer.
14
          //
14
          //
15
          contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
15
          contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
16
          contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
16
          contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
17
          contentOutlineViewer.setInput(editingDomain.getResourceSet());
17
          contentOutlineViewer.setInput(editingDomain.getResourceSet());
18
          // Make sure our popups work.
18
          // Make sure our popups work.
19
          //
19
          //
20
          createContextMenuFor(contentOutlineViewer);
20
          createContextMenuFor(contentOutlineViewer);
21
          if (!editingDomain.getResourceSet().getResources().isEmpty())
21
          if (!editingDomain.getResourceSet().getResources().isEmpty())
22
          {
22
          {
23
            // Select the root object in the view.
23
            // Select the root object in the view.
24
            //
24
            //
25
            contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
25
            contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
26
          }
26
          }
27
        }
27
        }
28
        @Override
28
        @Override
29
        public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager)
29
        public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager)
30
        {
30
        {
31
          super.makeContributions(menuManager, toolBarManager, statusLineManager);
31
          super.makeContributions(menuManager, toolBarManager, statusLineManager);
32
          contentOutlineStatusLineManager = statusLineManager;
32
          contentOutlineStatusLineManager = statusLineManager;
33
        }
33
        }
34
        @Override
34
        @Override
35
        public void setActionBars(IActionBars actionBars)
35
        public void setActionBars(IActionBars actionBars)
36
        {
36
        {
37
          super.setActionBars(actionBars);
37
          super.setActionBars(actionBars);
38
          getActionBarContributor().shareGlobalActions(this, actionBars);
38
          getActionBarContributor().shareGlobalActions(this, actionBars);
39
        }
39
        }
40
      }
40
      }
41
      contentOutlinePage = new MyContentOutlinePage();
41
      contentOutlinePage = new MyContentOutlinePage();
42
      // Listen to selection so that we can handle it is a special way.
42
      // Listen to selection so that we can handle it is a special way.
43
      //
43
      //
44
      contentOutlinePage.addSelectionChangedListener
44
      contentOutlinePage.addSelectionChangedListener
45
        (new ISelectionChangedListener()
45
        (new ISelectionChangedListener()
46
         {
46
         {
47
           // This ensures that we handle selections correctly.
47
           // This ensures that we handle selections correctly.
48
           //
48
           //
49
           public void selectionChanged(SelectionChangedEvent event)
49
           public void selectionChanged(SelectionChangedEvent event)
50
           {
50
           {
51
             handleContentOutlineSelection(event.getSelection());
51
             handleContentOutlineSelection(event.getSelection());
52
           }
52
           }
53
         });
53
         });
54
    }
54
    }
55
    return contentOutlinePage;
55
    return contentOutlinePage;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are in different classes having the same super class
Number of node comparisons10
  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)1.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (contentOutlinePage == null)
    1
    if (contentOutlinePage == null)
    2
    contentOutlinePage = new MyContentOutlinePage();
    2
    contentOutlinePage = new MyContentOutlinePage();
    2
    contentOutlinePage = new MyContentOutlinePage();
    Differences
    Expression1Expression2Difference
    SUBCLASS_TYPE_MISMATCH
    2
    contentOutlinePage = new MyContentOutlinePage();
    3
    contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {...});
    3
    contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {...});
    4
    return contentOutlinePage;
    4
    return contentOutlinePage;
    Precondition Violations (0)
    Row Violation