1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.papyrus.sysml14.diagram.common.command;
15
16 import org.eclipse.core.commands.ExecutionException;
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.gmf.runtime.common.core.command.CommandResult;
20 import org.eclipse.gmf.runtime.common.core.command.ICommand;
21 import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
22 import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
23 import org.eclipse.papyrus.infra.services.edit.utils.GMFCommandUtils;
24 import org.eclipse.uml2.uml.Property;
25 import org.eclipse.uml2.uml.Type;
26
27
28
29
30 public class ConfigurePartCommand extends ConfigureElementCommand {
31
32
33 private Type partType;
34 private ICommand typeCreationCommand;
35
36
37
38
39
40
41
42
43
44 public ConfigurePartCommand(ConfigureRequest request, Type partType, ICommand typeCreationCommand) {
45 super(request);
46 this.partType= partType;
47 this.typeCreationCommand = typeCreationCommand;
48 }
49
50 @Override
51 protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
52
53 Property part = (Property) getElementToEdit();
54 if (partType != null) {
55 part.setType(partType);
56 } else {
57 Type newType = (Type) GMFCommandUtils.getCommandEObjectResult(typeCreationCommand);
58 part.setType(newType);
59 }
60 return CommandResult.newOKCommandResult(part);
61 }
62 }