protected Command createMappingCommand; public DelegateCommand(EditingDomain editingDomain, CommandParameter commandParameter) { super (MappingUIPlugin.getPlugin().getString("_UI_NameMatchMappingAction_label"), MappingUIPlugin.getPlugin().getString("_UI_NameMatchMappingAction_description")); collection = commandParameter.getCollection(); mappingDomain = (MappingDomain)editingDomain; } @Override protected boolean prepare() { boolean result = false; if (collection != null) { Collection<Object> mappedObjects = new HashSet<Object>(); Collection<Object> mappingObjects = new HashSet<Object>(); MappingRoot mappingRoot = mappingDomain.getMappingRoot(); for (Object object : collection) { if (object instanceof Mapping) { appendIfCanExecute(NameMatchMappingCommand.create(mappingDomain, (Mapping)object)); mappingObjects.add(object); } else if (mappingRoot.isInputObject(object) || mappingRoot.isOutputObject(object)) { mappedObjects.add(object); } } if (!mappedObjects.isEmpty()) { Collection<? extends Mapping> mappings = mappingRoot.getAllMappings(mappedObjects); switch (mappings.size()) { case 0: { createMappingCommand = CreateMappingCommand.create(mappingDomain, mappedObjects); result = appendIfCanExecute(createMappingCommand); break; } case 1: { result = appendIfCanExecute(NameMatchMappingCommand.create(mappingDomain, mappings.iterator().next())); break; } default: { break; } } } } result = result || !isEmpty(); return result; } @Override public void execute() { super.execute(); if (createMappingCommand != null) { appendAndExecute(NameMatchMappingCommand.create(mappingDomain, (Mapping)createMappingCommand.getResult().iterator().next())); } } /** * This returns the icon, if any, of the action. */ public Object getImage() { return "Placeholder"; } public String getText() { return getLabel(); } /** * This returns the tool tip text, if any, of the action. */ public String getToolTipText() { return getDescription();
protected Command createMappingCommand; public DelegateCommand(EditingDomain editingDomain, CommandParameter commandParameter) { super (MappingUIPlugin.getPlugin().getString("_UI_TypeMatchMappingAction_label"), MappingUIPlugin.getPlugin().getString("_UI_TypeMatchMappingAction_description")); collection = commandParameter.getCollection(); mappingDomain = (MappingDomain)editingDomain; } @Override protected boolean prepare() { boolean result = false; if (collection != null) { Collection<Object> mappedObjects = new HashSet<Object>(); Collection<Object> mappingObjects = new HashSet<Object>(); MappingRoot mappingRoot = mappingDomain.getMappingRoot(); for (Object object : collection) { if (object instanceof Mapping) { appendIfCanExecute(TypeMatchMappingCommand.create(mappingDomain, (Mapping)object)); mappingObjects.add(object); } else if (mappingRoot.isInputObject(object) || mappingRoot.isOutputObject(object)) { mappedObjects.add(object); } } if (!mappedObjects.isEmpty()) { Collection<? extends Mapping> mappings = mappingRoot.getAllMappings(mappedObjects); switch (mappings.size()) { case 0: { createMappingCommand = CreateMappingCommand.create(mappingDomain, mappedObjects); result = appendIfCanExecute(createMappingCommand); break; } case 1: { result = appendIfCanExecute(TypeMatchMappingCommand.create(mappingDomain, mappings.iterator().next())); break; } default: { break; } } } } result = result || !isEmpty(); return result; } @Override public void execute() { super.execute(); if (createMappingCommand != null) { appendAndExecute(TypeMatchMappingCommand.create(mappingDomain, (Mapping)createMappingCommand.getResult().iterator().next())); } } /** * This returns the icon, if any, of the action. */ public Object getImage() { return "Placeholder"; } public String getText() { return getLabel(); } /** * This returns the tool tip text, if any, of the action. */ public String getToolTipText() { return getDescription();
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/mapping/action/NameMatchMappingAction.java File path: /emf-2.4.1/src/org/eclipse/emf/mapping/action/TypeMatchMappingAction.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
protected Command createMappingCommand;
1
protected Command createMappingCommand;
2
    public DelegateCommand(EditingDomain editingDomain, CommandParameter commandParameter)
2
    public DelegateCommand(EditingDomain editingDomain, CommandParameter commandParameter)
3
    {
3
    {
4
      super
4
      super
5
        (MappingUIPlugin.getPlugin().getString("_UI_NameMatchMappingAction_label"),
5
        (MappingUIPlugin.getPlugin().getString("_UI_TypeMatchMappingAction_label"),
6
         MappingUIPlugin.getPlugin().getString("_UI_NameMatchMappingAction_description"));
6
         MappingUIPlugin.getPlugin().getString("_UI_TypeMatchMappingAction_description"));
7
      collection = commandParameter.getCollection();
7
      collection = commandParameter.getCollection();
8
      mappingDomain = (MappingDomain)editingDomain;
8
      mappingDomain = (MappingDomain)editingDomain;
9
    }
9
    }
10
    @Override
10
    @Override
11
    protected boolean prepare()
11
    protected boolean prepare()
12
    {
12
    {
13
      boolean result = false;
13
      boolean result = false;
14
      if (collection != null)
14
      if (collection != null)
15
      {
15
      {
16
        Collection<Object> mappedObjects = new HashSet<Object>();
16
        Collection<Object> mappedObjects = new HashSet<Object>();
17
        Collection<Object> mappingObjects = new HashSet<Object>();
17
        Collection<Object> mappingObjects = new HashSet<Object>();
18
        MappingRoot mappingRoot = mappingDomain.getMappingRoot();
18
        MappingRoot mappingRoot = mappingDomain.getMappingRoot();
19
    
19
    
20
        for (Object object : collection)
20
        for (Object object : collection)
21
        {
21
        {
22
          if (object instanceof Mapping)
22
          if (object instanceof Mapping)
23
          {
23
          {
24
            appendIfCanExecute(NameMatchMappingCommand.create(mappingDomain, (Mapping)object));
24
            appendIfCanExecute(TypeMatchMappingCommand.create(mappingDomain, (Mapping)object));
25
            mappingObjects.add(object);
25
            mappingObjects.add(object);
26
          }
26
          }
27
          else if (mappingRoot.isInputObject(object) || mappingRoot.isOutputObject(object))
27
          else if (mappingRoot.isInputObject(object) || mappingRoot.isOutputObject(object))
28
          {
28
          {
29
            mappedObjects.add(object);
29
            mappedObjects.add(object);
30
          }
30
          }
31
        }
31
        }
32
        if (!mappedObjects.isEmpty())
32
        if (!mappedObjects.isEmpty())
33
        {
33
        {
34
          Collection<? extends Mapping> mappings = mappingRoot.getAllMappings(mappedObjects);
34
          Collection<? extends Mapping> mappings = mappingRoot.getAllMappings(mappedObjects);
35
          switch (mappings.size())
35
          switch (mappings.size())
36
          {
36
          {
37
            case 0:
37
            case 0:
38
            {
38
            {
39
              createMappingCommand = CreateMappingCommand.create(mappingDomain, mappedObjects);
39
              createMappingCommand = CreateMappingCommand.create(mappingDomain, mappedObjects);
40
              result = appendIfCanExecute(createMappingCommand);
40
              result = appendIfCanExecute(createMappingCommand);
41
              break;
41
              break;
42
            }
42
            }
43
            case 1:
43
            case 1:
44
            {
44
            {
45
              result = appendIfCanExecute(NameMatchMappingCommand.create(mappingDomain, mappings.iterator().next()));
45
              result = appendIfCanExecute(TypeMatchMappingCommand.create(mappingDomain, mappings.iterator().next()));
46
              break;
46
              break;
47
            }
47
            }
48
            default:
48
            default:
49
            {
49
            {
50
              break;
50
              break;
51
            }
51
            }
52
          }
52
          }
53
        }
53
        }
54
      }
54
      }
55
      result = result || !isEmpty();
55
      result = result || !isEmpty();
56
      return result;
56
      return result;
57
    }
57
    }
58
    @Override
58
    @Override
59
    public void execute()
59
    public void execute()
60
    {
60
    {
61
      super.execute();
61
      super.execute();
62
      if (createMappingCommand != null)
62
      if (createMappingCommand != null)
63
      {
63
      {
64
        appendAndExecute(NameMatchMappingCommand.create(mappingDomain, (Mapping)createMappingCommand.getResult().iterator().next()));
64
        appendAndExecute(TypeMatchMappingCommand.create(mappingDomain, (Mapping)createMappingCommand.getResult().iterator().next()));
65
      }
65
      }
66
    }
66
    }
67
    /**
67
    /**
68
     * This returns the icon, if any, of the action.
68
     * This returns the icon, if any, of the action.
69
     */
69
     */
70
    public Object getImage()
70
    public Object getImage()
71
    {
71
    {
72
      return "Placeholder";
72
      return "Placeholder";
73
    }
73
    }
74
    public String getText()
74
    public String getText()
75
    {
75
    {
76
      return getLabel();
76
      return getLabel();
77
    }
77
    }
78
    /**
78
    /**
79
     * This returns the tool tip text, if any, of the action.
79
     * This returns the tool tip text, if any, of the action.
80
     */
80
     */
81
    public String getToolTipText()
81
    public String getToolTipText()
82
    {
82
    {
83
      return getDescription();
83
      return getDescription();
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0