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();
|