Sunday, January 3, 2010

Eclipse : Tips - Create a Structured Selection for a New Resource Creation Wizard

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);
}
}
}

No comments: