X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/OpenActionUtil.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/OpenActionUtil.java index 272cf01..02c7b6b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/OpenActionUtil.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/OpenActionUtil.java @@ -25,75 +25,79 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.dialogs.ElementListSelectionDialog; public class OpenActionUtil { - + private OpenActionUtil() { // no instance. } - + /** * Opens the editor on the given element and subsequently selects it. */ - public static void open(Object element) throws JavaModelException, PartInitException { + public static void open(Object element) throws JavaModelException, + PartInitException { open(element, true); } - + /** * Opens the editor on the given element and subsequently selects it. */ - public static void open(Object element, boolean activate) throws JavaModelException, PartInitException { - IEditorPart part= EditorUtility.openInEditor(element, activate); + public static void open(Object element, boolean activate) + throws JavaModelException, PartInitException { + IEditorPart part = EditorUtility.openInEditor(element, activate); if (element instanceof IJavaElement) - EditorUtility.revealInEditor(part, (IJavaElement)element); + EditorUtility.revealInEditor(part, (IJavaElement) element); } - + /** - * Filters out source references from the given code resolve results. - * A utility method that can be called by subclassers. + * Filters out source references from the given code resolve results. A + * utility method that can be called by subclassers. */ public static List filterResolveResults(IJavaElement[] codeResolveResults) { - int nResults= codeResolveResults.length; - List refs= new ArrayList(nResults); - for (int i= 0; i < nResults; i++) { + int nResults = codeResolveResults.length; + List refs = new ArrayList(nResults); + for (int i = 0; i < nResults; i++) { if (codeResolveResults[i] instanceof ISourceReference) refs.add(codeResolveResults[i]); } return refs; } - + /** - * Shows a dialog for resolving an ambigous java element. - * Utility method that can be called by subclassers. + * Shows a dialog for resolving an ambigous java element. Utility method + * that can be called by subclassers. */ - public static IJavaElement selectJavaElement(IJavaElement[] elements, Shell shell, String title, String message) { - - int nResults= elements.length; - + public static IJavaElement selectJavaElement(IJavaElement[] elements, + Shell shell, String title, String message) { + + int nResults = elements.length; + if (nResults == 0) return null; - + if (nResults == 1) return elements[0]; - - int flags= JavaElementLabelProvider.SHOW_DEFAULT - | JavaElementLabelProvider.SHOW_QUALIFIED - | JavaElementLabelProvider.SHOW_ROOT; - - ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags)); + + int flags = JavaElementLabelProvider.SHOW_DEFAULT + | JavaElementLabelProvider.SHOW_QUALIFIED + | JavaElementLabelProvider.SHOW_ROOT; + + ElementListSelectionDialog dialog = new ElementListSelectionDialog( + shell, new JavaElementLabelProvider(flags)); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(elements); - + if (dialog.open() == ElementListSelectionDialog.OK) { - Object[] selection= dialog.getResult(); + Object[] selection = dialog.getResult(); if (selection != null && selection.length > 0) { - nResults= selection.length; - for (int i= 0; i < nResults; i++) { - Object current= selection[i]; + nResults = selection.length; + for (int i = 0; i < nResults; i++) { + Object current = selection[i]; if (current instanceof IJavaElement) return (IJavaElement) current; } } - } + } return null; - } + } }