A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / util / PHPFileSelector.java
index 41fce7c..bb920a7 100644 (file)
@@ -16,91 +16,97 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.model.IWorkbenchAdapter;
 
 public class PHPFileSelector extends ResourceSelector {
-  static class FileLabelProvider extends LabelProvider {
-    /**
-     * Returns the implementation of IWorkbenchAdapter for the given object.
-     * 
-     * @param o
-     *          the object to look up.
-     * @return IWorkbenchAdapter or <code>null</code> if the adapter is not defined or the object is not adaptable.
-     */
-    protected final IWorkbenchAdapter getAdapter(Object o) {
-      if (!(o instanceof IAdaptable)) {
-        return null;
-      }
-      return (IWorkbenchAdapter) ((IAdaptable) o).getAdapter(IWorkbenchAdapter.class);
-    }
+       static class FileLabelProvider extends LabelProvider {
+               /**
+                * Returns the implementation of IWorkbenchAdapter for the given object.
+                * 
+                * @param o
+                *            the object to look up.
+                * @return IWorkbenchAdapter or <code>null</code> if the adapter is
+                *         not defined or the object is not adaptable.
+                */
+               protected final IWorkbenchAdapter getAdapter(Object o) {
+                       if (!(o instanceof IAdaptable)) {
+                               return null;
+                       }
+                       return (IWorkbenchAdapter) ((IAdaptable) o)
+                                       .getAdapter(IWorkbenchAdapter.class);
+               }
 
-    /*
-     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
-     */
-    public String getText(Object element) {
-      if (element instanceof IFile) {
-        //                     query the element for its label
-        IWorkbenchAdapter adapter = getAdapter(element);
-        if (adapter == null) {
-          return ""; //$NON-NLS-1$
-        }
-        String filename = adapter.getLabel(element);
-        IPath path = ((IFile) element).getFullPath();
-        String filePathname = path != null ? path.toString() : ""; //$NON-NLS-1$
-        return filename + " (" + filePathname + ")";
-      }
-      return super.getText(element);
-    }
-  }
+               /*
+                * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+                */
+               public String getText(Object element) {
+                       if (element instanceof IFile) {
+                               // query the element for its label
+                               IWorkbenchAdapter adapter = getAdapter(element);
+                               if (adapter == null) {
+                                       return ""; //$NON-NLS-1$
+                               }
+                               String filename = adapter.getLabel(element);
+                               IPath path = ((IFile) element).getFullPath();
+                               String filePathname = path != null ? path.toString() : ""; //$NON-NLS-1$
+                               return filename + " (" + filePathname + ")";
+                       }
+                       return super.getText(element);
+               }
+       }
 
-  protected PHPProjectSelector phpProjectSelector;
+       protected PHPProjectSelector phpProjectSelector;
 
-  public PHPFileSelector(Composite parent, PHPProjectSelector aProjectSelector) {
-    super(parent);
-    Assert.isNotNull(aProjectSelector);
-    phpProjectSelector = aProjectSelector;
+       public PHPFileSelector(Composite parent, PHPProjectSelector aProjectSelector) {
+               super(parent);
+               Assert.isNotNull(aProjectSelector);
+               phpProjectSelector = aProjectSelector;
 
-    browseDialogTitle = "File Selection";
-  }
+               browseDialogTitle = "File Selection";
+       }
 
-  protected Object[] getPHPFiles() {
-    IProject phpProject = phpProjectSelector.getSelection();
-    if (phpProject == null)
-      return new Object[0];
+       protected Object[] getPHPFiles() {
+               IProject phpProject = phpProjectSelector.getSelection();
+               if (phpProject == null)
+                       return new Object[0];
 
-    PHPElementVisitor visitor = new PHPElementVisitor();
-    try {
-      phpProject.accept(visitor);
-    } catch (CoreException e) {
-      PHPeclipsePlugin.log(e);
-    }
-    return visitor.getCollectedPHPFiles();
-  }
+               PHPElementVisitor visitor = new PHPElementVisitor();
+               try {
+                       phpProject.accept(visitor);
+               } catch (CoreException e) {
+                       PHPeclipsePlugin.log(e);
+               }
+               return visitor.getCollectedPHPFiles();
+       }
 
-  public IFile getSelection() {
-    String fileName = getSelectionText();
-    if (fileName != null && !fileName.equals("")) {
-      IPath filePath = new Path(fileName);
-      IProject project = phpProjectSelector.getSelection();
-      if (project != null && project.exists(filePath))
-        return project.getFile(filePath);
-    }
+       public IFile getSelection() {
+               String fileName = getSelectionText();
+               if (fileName != null && !fileName.equals("")) {
+                       IPath filePath = new Path(fileName);
+                       IProject project = phpProjectSelector.getSelection();
+                       if (project != null && project.exists(filePath))
+                               return project.getFile(filePath);
+               }
 
-    return null;
-  }
+               return null;
+       }
 
-  protected void handleBrowseSelected() {
-//    ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new WorkbenchLabelProvider());
-    ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new FileLabelProvider());
+       protected void handleBrowseSelected() {
+               // ElementListSelectionDialog dialog = new
+               // ElementListSelectionDialog(getShell(), new WorkbenchLabelProvider());
+               ElementListSelectionDialog dialog = new ElementListSelectionDialog(
+                               getShell(), new FileLabelProvider());
 
-    dialog.setTitle(browseDialogTitle);
-    dialog.setMessage(browseDialogMessage);
-    dialog.setElements(getPHPFiles());
+               dialog.setTitle(browseDialogTitle);
+               dialog.setMessage(browseDialogMessage);
+               dialog.setElements(getPHPFiles());
 
-    if (dialog.open() == ElementListSelectionDialog.OK) {
-      textField.setText(((IResource) dialog.getFirstResult()).getProjectRelativePath().toString());
-    }
-  }
+               if (dialog.open() == ElementListSelectionDialog.OK) {
+                       textField.setText(((IResource) dialog.getFirstResult())
+                                       .getProjectRelativePath().toString());
+               }
+       }
 
-  protected String validateResourceSelection() {
-    IFile selection = getSelection();
-    return selection == null ? EMPTY_STRING : selection.getProjectRelativePath().toString();
-  }
+       protected String validateResourceSelection() {
+               IFile selection = getSelection();
+               return selection == null ? EMPTY_STRING : selection
+                               .getProjectRelativePath().toString();
+       }
 }
\ No newline at end of file