1 | package de.uka.ipd.sdq.pcmbench.tabs.generic; |
2 | |
3 | import org.eclipse.emf.ecore.EObject; |
4 | import org.eclipse.jface.viewers.ISelectionChangedListener; |
5 | import org.eclipse.jface.viewers.IStructuredSelection; |
6 | import org.eclipse.jface.viewers.SelectionChangedEvent; |
7 | |
8 | /** |
9 | * The class delegates straight in the active View selected object on the |
10 | * subclass. |
11 | * |
12 | * @author Roman Andrej |
13 | */ |
14 | public class SelectionChangedListener implements ISelectionChangedListener { |
15 | |
16 | private EObject selectedElement = null; |
17 | |
18 | /* (non-Javadoc) |
19 | * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) |
20 | */ |
21 | public void selectionChanged(SelectionChangedEvent event) { |
22 | IStructuredSelection sel = (IStructuredSelection) event.getSelection(); |
23 | Object selection = (Object) sel.getFirstElement(); |
24 | this.selectedElement = (EObject) selection; |
25 | } |
26 | |
27 | public EObject getSelectedElement() { |
28 | return selectedElement; |
29 | } |
30 | } |