Created a separated 'externaltools' plugin: initial check-in
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / internal / program / launchConfigurations / ProgramMainTab.java
1 package net.sourceforge.phpdt.externaltools.internal.program.launchConfigurations;
2
3 import net.sourceforge.phpdt.externaltools.internal.ui.FileSelectionDialog;
4 import net.sourceforge.phpdt.externaltools.launchConfigurations.ExternalToolsMainTab;
5 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
6 import net.sourceforge.phpdt.externaltools.model.ToolUtil;
7
8 import org.eclipse.core.resources.IFile;
9 import org.eclipse.core.resources.ResourcesPlugin;
10
11 public class ProgramMainTab extends ExternalToolsMainTab {
12
13         /**
14          * Prompts the user for a program location within the workspace and sets the
15          * location as a String containing the workspace_loc variable or
16          * <code>null</code> if no location was obtained from the user.
17          */
18         protected void handleWorkspaceLocationButtonSelected() {
19                 FileSelectionDialog dialog;
20                 dialog = new FileSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), "&Select a program");
21                 dialog.open();
22                 IFile file = dialog.getResult();
23                 if (file == null) {
24                         return;
25                 }
26                 StringBuffer buf = new StringBuffer();
27                 ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, file.getFullPath().toString(), buf);
28                 String text= buf.toString();
29                 if (text != null) {
30                         locationField.setText(text);
31                 }
32         }
33
34 }