public void run(ITextSelection selection) {
if (!isProcessable())
return;
try {
IJavaElement[] elements= SelectionConverter.codeResolveForked(fEditor, false);
if (elements == null || elements.length == 0) {
IEditorStatusLine statusLine= (IEditorStatusLine) fEditor.getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine.setMessage(true, ActionMessages.OpenAction_error_messageBadSelection, null);
getShell().getDisplay().beep();
return;
}
IJavaElement element= elements[0];
if (elements.length > 1) {
element= SelectionConverter.selectJavaElement(elements, getShell(), getDialogTitle(), ActionMessages.OpenAction_select_element);
if (element == null)
return;
}
int type= element.getElementType();
if (type == IJavaElement.JAVA_PROJECT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT || type == IJavaElement.PACKAGE_FRAGMENT)
element= EditorUtility.getEditorInputJavaElement(fEditor, false);
run(new Object[] {element} );
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.OpenAction_error_message);
} catch (InterruptedException e) {
}
}