1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / actions / SelectionConverter.java
index dbcb732..b5e1428 100644 (file)
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.ui.actions;
 
-import java.util.Iterator;
+//import java.util.Iterator;
 
 import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.IJavaElement;
-import net.sourceforge.phpdt.core.IType;
+//import net.sourceforge.phpdt.core.IType;
 import net.sourceforge.phpdt.core.JavaModelException;
-import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+//import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
@@ -67,20 +67,20 @@ public class SelectionConverter {
         * An empty array is returned if one of the elements stored in the
         * structured selection is not of tupe <code>IJavaElement</code>
         */
-       public static IJavaElement[] getElements(IStructuredSelection selection) {
-               if (!selection.isEmpty()) {
-                       IJavaElement[] result = new IJavaElement[selection.size()];
-                       int i = 0;
-                       for (Iterator iter = selection.iterator(); iter.hasNext(); i++) {
-                               Object element = (Object) iter.next();
-                               if (!(element instanceof IJavaElement))
-                                       return EMPTY_RESULT;
-                               result[i] = (IJavaElement) element;
-                       }
-                       return result;
-               }
-               return EMPTY_RESULT;
-       }
+//     public static IJavaElement[] getElements(IStructuredSelection selection) {
+//             if (!selection.isEmpty()) {
+//                     IJavaElement[] result = new IJavaElement[selection.size()];
+//                     int i = 0;
+//                     for (Iterator iter = selection.iterator(); iter.hasNext(); i++) {
+//                             Object element = (Object) iter.next();
+//                             if (!(element instanceof IJavaElement))
+//                                     return EMPTY_RESULT;
+//                             result[i] = (IJavaElement) element;
+//                     }
+//                     return result;
+//             }
+//             return EMPTY_RESULT;
+//     }
 
        public static boolean canOperateOn(PHPEditor editor) {
                if (editor == null)
@@ -107,16 +107,16 @@ public class SelectionConverter {
                return result;
        }
 
-       public static IJavaElement[] codeResolveOrInputHandled(PHPEditor editor,
-                       Shell shell, String title) {
-               try {
-                       return codeResolveOrInput(editor);
-               } catch (JavaModelException e) {
-                       ExceptionHandler.handle(e, shell, title, ActionMessages
-                                       .getString("SelectionConverter.codeResolve_failed")); //$NON-NLS-1$
-               }
-               return null;
-       }
+//     public static IJavaElement[] codeResolveOrInputHandled(PHPEditor editor,
+//                     Shell shell, String title) {
+//             try {
+//                     return codeResolveOrInput(editor);
+//             } catch (JavaModelException e) {
+//                     ExceptionHandler.handle(e, shell, title, ActionMessages
+//                                     .getString("SelectionConverter.codeResolve_failed")); //$NON-NLS-1$
+//             }
+//             return null;
+//     }
 
        /**
         * Converts the text selection provided by the given editor a Java element
@@ -138,16 +138,16 @@ public class SelectionConverter {
                return candidate;
        }
 
-       public static IJavaElement codeResolveOrInputHandled(PHPEditor editor,
-                       Shell shell, String title, String message) {
-               try {
-                       return codeResolveOrInput(editor, shell, title, message);
-               } catch (JavaModelException e) {
-                       ExceptionHandler.handle(e, shell, title, ActionMessages
-                                       .getString("SelectionConverter.codeResolveOrInput_failed")); //$NON-NLS-1$
-               }
-               return null;
-       }
+//     public static IJavaElement codeResolveOrInputHandled(PHPEditor editor,
+//                     Shell shell, String title, String message) {
+//             try {
+//                     return codeResolveOrInput(editor, shell, title, message);
+//             } catch (JavaModelException e) {
+//                     ExceptionHandler.handle(e, shell, title, ActionMessages
+//                                     .getString("SelectionConverter.codeResolveOrInput_failed")); //$NON-NLS-1$
+//             }
+//             return null;
+//     }
 
        public static IJavaElement[] codeResolve(PHPEditor editor)
                        throws JavaModelException {
@@ -160,29 +160,29 @@ public class SelectionConverter {
         * by asking the user if code reolve returned more than one result. If the
         * selection doesn't cover a Java element <code>null</code> is returned.
         */
-       public static IJavaElement codeResolve(PHPEditor editor, Shell shell,
-                       String title, String message) throws JavaModelException {
-               IJavaElement[] elements = codeResolve(editor);
-               if (elements == null || elements.length == 0)
-                       return null;
-               IJavaElement candidate = elements[0];
-               if (elements.length > 1) {
-                       candidate = OpenActionUtil.selectJavaElement(elements, shell,
-                                       title, message);
-               }
-               return candidate;
-       }
+//     public static IJavaElement codeResolve(PHPEditor editor, Shell shell,
+//                     String title, String message) throws JavaModelException {
+//             IJavaElement[] elements = codeResolve(editor);
+//             if (elements == null || elements.length == 0)
+//                     return null;
+//             IJavaElement candidate = elements[0];
+//             if (elements.length > 1) {
+//                     candidate = OpenActionUtil.selectJavaElement(elements, shell,
+//                                     title, message);
+//             }
+//             return candidate;
+//     }
 
-       public static IJavaElement[] codeResolveHandled(PHPEditor editor,
-                       Shell shell, String title) {
-               try {
-                       return codeResolve(editor);
-               } catch (JavaModelException e) {
-                       ExceptionHandler.handle(e, shell, title, ActionMessages
-                                       .getString("SelectionConverter.codeResolve_failed")); //$NON-NLS-1$
-               }
-               return null;
-       }
+//     public static IJavaElement[] codeResolveHandled(PHPEditor editor,
+//                     Shell shell, String title) {
+//             try {
+//                     return codeResolve(editor);
+//             } catch (JavaModelException e) {
+//                     ExceptionHandler.handle(e, shell, title, ActionMessages
+//                                     .getString("SelectionConverter.codeResolve_failed")); //$NON-NLS-1$
+//             }
+//             return null;
+//     }
 
        public static IJavaElement getElementAtOffset(PHPEditor editor)
                        throws JavaModelException {
@@ -190,18 +190,18 @@ public class SelectionConverter {
                                .getSelectionProvider().getSelection());
        }
 
-       public static IType getTypeAtOffset(PHPEditor editor)
-                       throws JavaModelException {
-               IJavaElement element = SelectionConverter.getElementAtOffset(editor);
-               IType type = (IType) element.getAncestor(IJavaElement.TYPE);
-               if (type == null) {
-                       ICompilationUnit unit = SelectionConverter
-                                       .getInputAsCompilationUnit(editor);
-                       if (unit != null)
-                               type = unit.findPrimaryType();
-               }
-               return type;
-       }
+//     public static IType getTypeAtOffset(PHPEditor editor)
+//                     throws JavaModelException {
+//             IJavaElement element = SelectionConverter.getElementAtOffset(editor);
+//             IType type = (IType) element.getAncestor(IJavaElement.TYPE);
+//             if (type == null) {
+//                     ICompilationUnit unit = SelectionConverter
+//                                     .getInputAsCompilationUnit(editor);
+//                     if (unit != null)
+//                             type = unit.findPrimaryType();
+//             }
+//             return type;
+//     }
 
        public static IJavaElement getInput(PHPEditor editor) {
                if (editor == null)
@@ -214,13 +214,13 @@ public class SelectionConverter {
                return manager.getWorkingCopy(input);
        }
 
-       public static ICompilationUnit getInputAsCompilationUnit(PHPEditor editor) {
-               Object editorInput = SelectionConverter.getInput(editor);
-               if (editorInput instanceof ICompilationUnit)
-                       return (ICompilationUnit) editorInput;
-               else
-                       return null;
-       }
+//     public static ICompilationUnit getInputAsCompilationUnit(PHPEditor editor) {
+//             Object editorInput = SelectionConverter.getInput(editor);
+//             if (editorInput instanceof ICompilationUnit)
+//                     return (ICompilationUnit) editorInput;
+//             else
+//                     return null;
+//     }
 
        private static IJavaElement[] codeResolve(IJavaElement input,
                        ITextSelection selection) throws JavaModelException {