1 package net.sourceforge.phpdt.internal.ui.util;
3 import net.sourceforge.phpeclipse.PHPCore;
4 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
5 import org.eclipse.core.resources.IProject;
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.ui.model.WorkbenchLabelProvider;
8 import net.sourceforge.phpdt.internal.ui.dialog.ElementListSelectionDialog;
10 public class PHPProjectSelector extends ResourceSelector {
12 public PHPProjectSelector(Composite parent) {
15 browseDialogTitle = "Project Selection";
18 public IProject getSelection() {
19 String projectName = getSelectionText();
20 if (projectName != null && !projectName.equals(""))
21 return PHPeclipsePlugin.getWorkspace().getRoot().getProject(projectName);
26 protected void handleBrowseSelected() {
27 ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new WorkbenchLabelProvider());
28 dialog.setTitle(browseDialogTitle);
29 dialog.setMessage(browseDialogMessage);
30 dialog.setElements(PHPCore.getPHPProjects());
32 if (dialog.open() == dialog.OK) {
33 textField.setText(((IProject) dialog.getFirstResult()).getName());
37 protected String validateResourceSelection() {
38 IProject project = getSelection();
39 return project == null ? EMPTY_STRING : project.getName();