import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
DescriptionBase<?> description = null;
ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
- if (selectedElement instanceof DescriptionBase<?>) {
- description = (DescriptionBase<?>) selectedElement;
- }
+ Object selectedElement = null;
+ if (selection instanceof ITreeSelection) {
+ TreePath[] paths = ((ITreeSelection) selection).getPaths();
+ selectedElement = paths[0].getFirstSegment();
+ }
+ else if (selection instanceof IStructuredSelection) {
+ selectedElement = ((IStructuredSelection) selection).getFirstElement();
+ }
+ if (selectedElement instanceof DescriptionBase<?>) {
+ description = (DescriptionBase<?>) selectedElement;
}
if (description != null) {