+++ /dev/null
-package net.sourceforge.phpdt.internal.ui.util;
-
-import net.sourceforge.phpdt.internal.ui.dialogs.ElementListSelectionDialog;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-public class PHPFileSelector extends ResourceSelector {
- protected PHPProjectSelector phpProjectSelector;
-
- public PHPFileSelector(Composite parent, PHPProjectSelector aProjectSelector) {
- super(parent);
- Assert.isNotNull(aProjectSelector);
- phpProjectSelector = aProjectSelector;
-
- browseDialogTitle = "File Selection";
- }
-
- 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();
- }
-
- 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;
- }
-
- protected void handleBrowseSelected() {
- ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new WorkbenchLabelProvider());
- dialog.setTitle(browseDialogTitle);
- dialog.setMessage(browseDialogMessage);
- dialog.setElements(getPHPFiles());
-
- 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();
- }
-}