1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.pcmbench.tabs.operations; |
5 | |
6 | import org.eclipse.emf.transaction.RecordingCommand; |
7 | import org.eclipse.emf.transaction.TransactionalEditingDomain; |
8 | import org.eclipse.emf.transaction.util.TransactionUtil; |
9 | import org.eclipse.jface.viewers.TableViewer; |
10 | import org.eclipse.swt.events.SelectionEvent; |
11 | import org.eclipse.swt.events.SelectionListener; |
12 | |
13 | import de.uka.ipd.sdq.pcm.repository.EventType; |
14 | import de.uka.ipd.sdq.pcmbench.tabs.generic.SelectionChangedListener; |
15 | |
16 | /** |
17 | * Cell value delete listener for event types. |
18 | * |
19 | * @author Benjamin Klatt |
20 | */ |
21 | public class EventTypeDeleteCellValueListener extends SelectionChangedListener implements SelectionListener { |
22 | |
23 | |
24 | private TableViewer viewer; |
25 | |
26 | /** Constructor */ |
27 | public EventTypeDeleteCellValueListener(TableViewer viewer) { |
28 | this.viewer = viewer; |
29 | } |
30 | |
31 | /* (non-Javadoc) |
32 | * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
33 | */ |
34 | public void widgetSelected(SelectionEvent e) { |
35 | |
36 | final EventType eventType = (EventType) getSelectedElement(); |
37 | |
38 | TransactionalEditingDomain editingDomain = TransactionUtil |
39 | .getEditingDomain(eventType); |
40 | |
41 | RecordingCommand recCommand = new RecordingCommand(editingDomain) { |
42 | @Override |
43 | protected void doExecute() { |
44 | eventType.getParameter__EventType().setDataType__Parameter(null); |
45 | } |
46 | }; |
47 | |
48 | recCommand.setDescription("Set event type parameter type to null"); |
49 | editingDomain.getCommandStack().execute(recCommand); |
50 | |
51 | viewer.refresh(); |
52 | } |
53 | |
54 | /* (non-Javadoc) |
55 | * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) |
56 | */ |
57 | public void widgetDefaultSelected(SelectionEvent e) { |
58 | // The implementation is not necessary. |
59 | } |
60 | } |