IStructuredSelection selectionToPass = StructuredSelection.EMPTY;
Class resourceClass = LegacyResourceSupport.getResourceClass();
if (resourceClass != null) {
IWorkbenchPart part = workbench.getActiveWorkbenchWindow().getPartService() .getActivePart();
if (part instanceof IEditorPart) {
IEditorInput input = ((IEditorPart) part).getEditorInput();
Object resource = org.eclipse.ui.internal.util.Util.getAdapter(input, resourceClass);
if (resource != null) {
selectionToPass = new StructuredSelection(resource);
}
}
}

Advertisements