1 | package de.uka.ipd.sdq.pcm.dialogs.parameters; |
2 | |
3 | import org.eclipse.emf.common.util.EList; |
4 | import org.eclipse.emf.transaction.RecordingCommand; |
5 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
6 | import org.eclipse.emf.transaction.util.TransactionUtil; |
7 | import org.eclipse.swt.events.SelectionEvent; |
8 | import org.eclipse.swt.events.SelectionListener; |
9 | |
10 | import de.uka.ipd.sdq.pcm.repository.Parameter; |
11 | import de.uka.ipd.sdq.pcm.repository.Signature; |
12 | |
13 | /** |
14 | * The class define an action, which a parameter for the signature delete. |
15 | * |
16 | * @author Roman Andrej |
17 | */ |
18 | public class DeleteParameterAction extends EditorContentsSelectionAction |
19 | implements SelectionListener { |
20 | |
21 | private Signature parentSignature; |
22 | |
23 | /** |
24 | * The transactional editing domain which is used to get the commands and |
25 | * alter the model |
26 | */ |
27 | private TransactionalEditingDomain editingDomain = null; |
28 | |
29 | public DeleteParameterAction(Signature signature) { |
30 | this.parentSignature = signature; |
31 | this.editingDomain = TransactionUtil.getEditingDomain(signature); |
32 | } |
33 | |
34 | /* (non-Javadoc) |
35 | * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
36 | */ |
37 | public void widgetSelected(SelectionEvent e) { |
38 | final Parameter selectedParameter = (Parameter) getSelectedDeclaration(); |
39 | final EList<Parameter> parameters = ParametersUtil.getParametersOfSignature(parentSignature); |
40 | |
41 | RecordingCommand recCommand = new RecordingCommand(editingDomain) { |
42 | @Override |
43 | protected void doExecute() { |
44 | parameters.remove(selectedParameter); |
45 | } |
46 | }; |
47 | |
48 | recCommand.setDescription("Delete ..."); |
49 | editingDomain.getCommandStack().execute(recCommand); |
50 | } |
51 | |
52 | public void widgetDefaultSelected(SelectionEvent e) { |
53 | // TODO Auto-generated method stub |
54 | |
55 | } |
56 | } |