1 package net.sourceforge.phpdt.externaltools.launchConfigurations;
 
   3 /**********************************************************************
 
   4 Copyright (c) 2000, 2002 IBM Corp.  All rights reserved.
 
   5 This file is made available under the terms of the Common Public License v1.0
 
   6 which accompanies this distribution, and is available at
 
   7 http://www.eclipse.org/legal/cpl-v10.html
 
   8 **********************************************************************/
 
  12 import net.sourceforge.phpdt.externaltools.group.IGroupDialogPage;
 
  13 import net.sourceforge.phpdt.externaltools.internal.dialog.ExternalToolVariableForm;
 
  14 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsImages;
 
  15 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin;
 
  16 import net.sourceforge.phpdt.externaltools.internal.registry.ExternalToolVariable;
 
  17 import net.sourceforge.phpdt.externaltools.model.IExternalToolConstants;
 
  18 import net.sourceforge.phpdt.externaltools.model.ToolUtil;
 
  19 import net.sourceforge.phpdt.externaltools.variable.ExpandVariableContext;
 
  21 import org.eclipse.core.resources.IResource;
 
  22 import org.eclipse.core.resources.ResourcesPlugin;
 
  23 import org.eclipse.core.runtime.CoreException;
 
  24 import org.eclipse.core.runtime.IPath;
 
  25 import org.eclipse.core.runtime.IStatus;
 
  26 import org.eclipse.core.runtime.MultiStatus;
 
  27 import org.eclipse.debug.core.ILaunchConfiguration;
 
  28 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 
  29 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
 
  30 import org.eclipse.jface.dialogs.IDialogConstants;
 
  31 import org.eclipse.jface.dialogs.IMessageProvider;
 
  32 import org.eclipse.swt.SWT;
 
  33 import org.eclipse.swt.events.ModifyEvent;
 
  34 import org.eclipse.swt.events.ModifyListener;
 
  35 import org.eclipse.swt.events.SelectionAdapter;
 
  36 import org.eclipse.swt.events.SelectionEvent;
 
  37 import org.eclipse.swt.events.SelectionListener;
 
  38 import org.eclipse.swt.graphics.Font;
 
  39 import org.eclipse.swt.graphics.Image;
 
  40 import org.eclipse.swt.layout.GridData;
 
  41 import org.eclipse.swt.layout.GridLayout;
 
  42 import org.eclipse.swt.widgets.Button;
 
  43 import org.eclipse.swt.widgets.Combo;
 
  44 import org.eclipse.swt.widgets.Composite;
 
  45 import org.eclipse.swt.widgets.Control;
 
  46 import org.eclipse.swt.widgets.DirectoryDialog;
 
  47 import org.eclipse.swt.widgets.FileDialog;
 
  48 import org.eclipse.swt.widgets.Label;
 
  49 import org.eclipse.swt.widgets.Shell;
 
  50 import org.eclipse.swt.widgets.Text;
 
  51 import org.eclipse.ui.dialogs.ContainerSelectionDialog;
 
  52 import org.eclipse.ui.dialogs.ResourceSelectionDialog;
 
  53 import org.eclipse.ui.dialogs.SelectionDialog;
 
  55 public class ExternalToolsMainTab extends AbstractLaunchConfigurationTab {
 
  57         protected Combo locationField;
 
  58         protected Text workDirectoryField;
 
  59         protected Button fileLocationButton;
 
  60         protected Button workspaceLocationButton;
 
  61         protected Button fileWorkingDirectoryButton;
 
  62         protected Button workspaceWorkingDirectoryButton;
 
  64         protected Button runBackgroundButton;
 
  65         protected Text argumentField;
 
  66         protected Button variableButton;
 
  68         protected SelectionAdapter selectionAdapter;
 
  70         protected ModifyListener modifyListener = new ModifyListener() {
 
  71                 public void modifyText(ModifyEvent e) {
 
  72                         updateLaunchConfigurationDialog();
 
  77          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
 
  79         public void createControl(Composite parent) {
 
  80                 Composite mainComposite = new Composite(parent, SWT.NONE);
 
  81                 setControl(mainComposite);
 
  82                 GridLayout layout = new GridLayout();
 
  83                 layout.numColumns = 2;
 
  84                 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
 
  85                 mainComposite.setLayout(layout);
 
  86                 mainComposite.setLayoutData(gridData);
 
  87                 mainComposite.setFont(parent.getFont());
 
  88                 createLocationComponent(mainComposite);
 
  89                 createWorkDirectoryComponent(mainComposite);
 
  90                 createArgumentComponent(mainComposite);
 
  91                 createVerticalSpacer(mainComposite, 2);
 
  92                 createRunBackgroundComponent(mainComposite);
 
  96          * Creates the controls needed to edit the location
 
  97          * attribute of an external tool
 
  99          * @param parent the composite to create the controls in
 
 101         protected void createLocationComponent(Composite parent) {
 
 102                 Font font = parent.getFont();
 
 104                 Composite composite = new Composite(parent, SWT.NONE);
 
 105                 GridLayout layout = new GridLayout();
 
 106                 layout.marginWidth = 0;
 
 107                 layout.marginHeight = 0;
 
 108                 layout.numColumns = 1;
 
 109                 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
 
 110                 composite.setLayout(layout);
 
 111                 composite.setLayoutData(gridData);
 
 113                 Label label = new Label(composite, SWT.NONE);
 
 114                 label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Location___2")); //$NON-NLS-1$
 
 117                 locationField = new Combo(composite, SWT.DROP_DOWN | SWT.BORDER);
 
 118                 GridData data = new GridData(GridData.FILL_HORIZONTAL);
 
 119                 data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
 
 120                 locationField.setLayoutData(data);
 
 121                 locationField.setFont(font);
 
 122                 locationField.add("C:\\apache\\php\\php.exe", 0);
 
 124                 Composite buttonComposite = new Composite(parent, SWT.NONE);
 
 125                 layout = new GridLayout();
 
 126                 layout.marginWidth = 0;
 
 127                 layout.marginHeight = 0;
 
 128                 layout.numColumns = 1;
 
 129                 gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
 
 130                 buttonComposite.setLayout(layout);
 
 131                 buttonComposite.setLayoutData(gridData);
 
 132                 buttonComposite.setFont(font);
 
 134                 createVerticalSpacer(buttonComposite, 1);
 
 136                 workspaceLocationButton= createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Browse_Workspace..._3"), null); //$NON-NLS-1$
 
 137                 workspaceLocationButton.addSelectionListener(new SelectionAdapter() {
 
 138                         public void widgetSelected(SelectionEvent evt) {
 
 139                                 handleWorkspaceLocationButtonSelected();
 
 142                 fileLocationButton= createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Brows&e_File_System..._4"), null); //$NON-NLS-1$
 
 143                 fileLocationButton.addSelectionListener(new SelectionAdapter() {
 
 144                         public void widgetSelected(SelectionEvent evt) {
 
 145                                 handleLocationButtonSelected();
 
 151          * Creates the controls needed to edit the working directory
 
 152          * attribute of an external tool
 
 154          * @param parent the composite to create the controls in
 
 156         protected void createWorkDirectoryComponent(Composite parent) {
 
 157                 Font font = parent.getFont();
 
 159                 Composite composite = new Composite(parent, SWT.NONE);
 
 160                 GridLayout layout = new GridLayout();
 
 161                 layout.marginWidth = 0;
 
 162                 layout.marginHeight = 0;
 
 163                 layout.numColumns = 1;
 
 164                 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
 
 165                 composite.setLayout(layout);
 
 166                 composite.setLayoutData(gridData);
 
 168                 Label label = new Label(composite, SWT.NONE);
 
 169                 label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Working_&Directory__5")); //$NON-NLS-1$
 
 172                 workDirectoryField = new Text(composite, SWT.BORDER);
 
 173                 GridData data = new GridData(GridData.FILL_HORIZONTAL);
 
 174                 data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
 
 175                 workDirectoryField.setLayoutData(data);
 
 176                 workDirectoryField.setFont(font);
 
 178                 Composite buttonComposite = new Composite(parent, SWT.NONE);
 
 179                 layout = new GridLayout();
 
 180                 layout.marginWidth = 0;
 
 181                 layout.marginHeight = 0;
 
 182                 layout.numColumns = 1;
 
 183                 gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
 
 184                 buttonComposite.setLayout(layout);
 
 185                 buttonComposite.setLayoutData(gridData);
 
 186                 buttonComposite.setFont(font);
 
 188                 createVerticalSpacer(buttonComposite, 1);
 
 189                 workspaceWorkingDirectoryButton= createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Browse_Wor&kspace..._6"), null); //$NON-NLS-1$
 
 190                 workspaceWorkingDirectoryButton.addSelectionListener(new SelectionAdapter() {
 
 191                         public void widgetSelected(SelectionEvent evt) {
 
 192                                 handleWorkspaceWorkingDirectoryButtonSelected();
 
 195                 fileWorkingDirectoryButton= createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Browse_F&ile_System..._7"), null); //$NON-NLS-1$
 
 196                 fileWorkingDirectoryButton.addSelectionListener(new SelectionAdapter() {
 
 197                         public void widgetSelected(SelectionEvent evt) {
 
 198                                 handleFileWorkingDirectoryButtonSelected();
 
 204          * Creates the controls needed to edit the argument and
 
 205          * prompt for argument attributes of an external tool
 
 207          * @param parent the composite to create the controls in
 
 209         protected void createArgumentComponent(Composite parent) {
 
 210                 Font font = parent.getFont();
 
 212                 Label label = new Label(parent, SWT.NONE);
 
 213                 label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.&Arguments___1")); //$NON-NLS-1$
 
 214                 GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 
 215                 data.horizontalSpan = 2;
 
 216                 label.setLayoutData(data);
 
 219                 argumentField = new Text(parent, SWT.BORDER);
 
 220                 data = new GridData(GridData.FILL_HORIZONTAL);
 
 221                 data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
 
 222                 argumentField.setLayoutData(data);
 
 223                 argumentField.setFont(font);
 
 224                 argumentField.addModifyListener(new ModifyListener() {
 
 225                         public void modifyText(ModifyEvent e) {
 
 226                                 updateLaunchConfigurationDialog();
 
 230                 variableButton= createPushButton(parent, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Varia&bles..._2"), null); //$NON-NLS-1$
 
 231                 variableButton.addSelectionListener(new SelectionAdapter() {
 
 232                         public void widgetSelected(SelectionEvent e) {
 
 233                                 VariableSelectionDialog dialog= new VariableSelectionDialog(getShell());
 
 234                                 if (dialog.open() == SelectionDialog.OK) {
 
 235                                         argumentField.insert(dialog.getForm().getSelectedVariable());
 
 240                 Label instruction = new Label(parent, SWT.NONE);
 
 241                 instruction.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Note__Enclose_an_argument_containing_spaces_using_double-quotes_(__)._Not_applicable_for_variables._3")); //$NON-NLS-1$
 
 242                 data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 
 243                 data.horizontalSpan = 2;
 
 244                 instruction.setLayoutData(data);
 
 245                 instruction.setFont(font);
 
 249          * Creates the controls needed to edit the run in background
 
 250          * attribute of an external tool
 
 252          * @param parent the composite to create the controls in
 
 254         protected void createRunBackgroundComponent(Composite parent) {
 
 255                 runBackgroundButton = new Button(parent, SWT.CHECK);
 
 256                 runBackgroundButton.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Run_tool_in_bac&kground_4")); //$NON-NLS-1$
 
 257                 GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 
 258                 runBackgroundButton.setLayoutData(data);
 
 259                 runBackgroundButton.setFont(parent.getFont());
 
 260                 runBackgroundButton.addSelectionListener(getSelectionAdapter());
 
 264          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
 
 266         public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
 
 267                 configuration.setAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, false);
 
 271          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
 
 273         public void initializeFrom(ILaunchConfiguration configuration) {
 
 274                 updateLocation(configuration);
 
 275                 updateWorkingDirectory(configuration);
 
 276                 updateArgument(configuration);
 
 277                 updateRunBackground(configuration);
 
 280         protected void updateWorkingDirectory(ILaunchConfiguration configuration) {
 
 281                 String workingDir= ""; //$NON-NLS-1$
 
 283                         workingDir= configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, ""); //$NON-NLS-1$
 
 284                 } catch (CoreException ce) {
 
 285                         ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Error_reading_configuration_10"), ce); //$NON-NLS-1$
 
 287                 workDirectoryField.setText(workingDir);
 
 288                 workDirectoryField.addModifyListener(modifyListener);
 
 292         protected void updateLocation(ILaunchConfiguration configuration) {
 
 293                 String location= ""; //$NON-NLS-1$
 
 295                         location= configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, ""); //$NON-NLS-1$
 
 296                 } catch (CoreException ce) {
 
 297                         ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Error_reading_configuration_10"), ce); //$NON-NLS-1$
 
 299                 locationField.setText(location);
 
 300                 locationField.addModifyListener(modifyListener);
 
 303         protected void updateArgument(ILaunchConfiguration configuration) {
 
 304                 String arguments= ""; //$NON-NLS-1$
 
 306                         arguments= configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
 
 307                 } catch (CoreException ce) {
 
 308                         ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Error_reading_configuration_7"), ce); //$NON-NLS-1$
 
 310                 argumentField.setText(arguments);
 
 313         protected void updateRunBackground(ILaunchConfiguration configuration) {
 
 314                 boolean  runInBackgroud= true;
 
 316                         runInBackgroud= configuration.getAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, false);
 
 317                 } catch (CoreException ce) {
 
 318                         ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Error_reading_configuration_7"), ce); //$NON-NLS-1$
 
 320                 runBackgroundButton.setSelection(runInBackgroud);
 
 324          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
 
 326         public void performApply(ILaunchConfigurationWorkingCopy configuration) {
 
 327                 String location= locationField.getText().trim();
 
 328                 if (location.length() == 0) {
 
 329                         configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null);
 
 331                         configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, location);
 
 334                 String workingDirectory= workDirectoryField.getText().trim();
 
 335                 if (workingDirectory.length() == 0) {
 
 336                         configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String)null);
 
 338                         configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, workingDirectory);
 
 341                 setAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, configuration, runBackgroundButton.getSelection(), false);
 
 343                 String arguments= argumentField.getText().trim();
 
 344                 if (arguments.length() == 0) {
 
 345                         configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String)null);
 
 347                         configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
 
 352          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
 
 354         public String getName() {
 
 355                 return ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Main_17"); //$NON-NLS-1$
 
 359          * @see ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
 
 361         public boolean isValid(ILaunchConfiguration launchConfig) {
 
 362                 setErrorMessage(null);
 
 364                 return validateLocation() && validateWorkDirectory();
 
 368          * Validates the content of the location field.
 
 370         protected boolean validateLocation() {
 
 371                 String value = locationField.getText().trim();
 
 372                 if (value.length() < 1) {
 
 373                         setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_cannot_be_empty_18")); //$NON-NLS-1$
 
 378                 // Translate field contents to the actual file location so we
 
 379                 // can check to ensure the file actually exists.
 
 380                 MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
 
 381                 value = ToolUtil.expandFileLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
 
 382                 if (!multiStatus.isOK()) {
 
 383                         IStatus[] children = multiStatus.getChildren();
 
 384                         if (children.length > 0) {
 
 385                                 setErrorMessage(children[0].getMessage());
 
 391                 File file = new File(value);
 
 392                 if (!file.exists()) { // The file does not exist.
 
 393                         setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_does_not_exist_19")); //$NON-NLS-1$
 
 396                 if (!file.isFile()) {
 
 397                         setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_specified_is_not_a_file_20")); //$NON-NLS-1$
 
 404          * Validates the content of the working directory field.
 
 406         protected boolean validateWorkDirectory() {
 
 408                 String value = workDirectoryField.getText().trim();
 
 409                 if (value.length() > 0) {
 
 410                         // Translate field contents to the actual directory location so we
 
 411                         // can check to ensure the directory actually exists.
 
 412                         MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
 
 413                         value = ToolUtil.expandDirectoryLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
 
 414                         if (!multiStatus.isOK()) {
 
 415                                 IStatus[] children = multiStatus.getChildren();
 
 416                                 if (children.length > 0) {
 
 417                                         setErrorMessage(children[0].getMessage());
 
 422                         File file = new File(value);
 
 423                         if (!file.exists()) { // The directory does not exist.
 
 424                                 setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_working_directory_does_not_exist_or_is_invalid_21")); //$NON-NLS-1$
 
 431         protected void handleLocationButtonSelected() {
 
 432                 FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
 
 433                 fileDialog.setFileName(locationField.getText());
 
 434                 String text= fileDialog.open();
 
 436                         locationField.setText(text);
 
 441          * Prompts the user for a workspace location within the workspace and sets
 
 442          * the location as a String containing the workspace_loc variable or
 
 443          * <code>null</code> if no location was obtained from the user.
 
 445         protected void handleWorkspaceLocationButtonSelected() {
 
 446                 ResourceSelectionDialog dialog;
 
 447                 dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Select_a_resource_22")); //$NON-NLS-1$
 
 449                 Object[] results = dialog.getResult();
 
 450                 if (results == null || results.length < 1) {
 
 453                 IResource resource = (IResource)results[0];
 
 454                 StringBuffer buf = new StringBuffer();
 
 455                 ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, resource.getFullPath().toString(), buf);
 
 456                 String text= buf.toString();
 
 458                         locationField.setText(text);
 
 463          * Prompts the user for a working directory location within the workspace
 
 464          * and sets the working directory as a String containing the workspace_loc
 
 465          * variable or <code>null</code> if no location was obtained from the user.
 
 467         protected void handleWorkspaceWorkingDirectoryButtonSelected() {
 
 468                 ContainerSelectionDialog containerDialog;
 
 469                 containerDialog = new ContainerSelectionDialog(
 
 471                         ResourcesPlugin.getWorkspace().getRoot(),
 
 473                         ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Select_a_directory__23")); //$NON-NLS-1$
 
 474                 containerDialog.open();
 
 475                 Object[] resource = containerDialog.getResult();
 
 477                 if (resource != null && resource.length > 0) {
 
 478                         text= ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, ((IPath)resource[0]).toString());
 
 481                         workDirectoryField.setText(text);
 
 485         protected void handleFileWorkingDirectoryButtonSelected() {
 
 486                 DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
 
 487                 dialog.setMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Select_a_directory__23")); //$NON-NLS-1$
 
 488                 dialog.setFilterPath(workDirectoryField.getText());
 
 489                 String text= dialog.open();
 
 491                         workDirectoryField.setText(text);
 
 496          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
 
 498         public Image getImage() {
 
 499                 return ExternalToolsImages.getImage(IExternalToolConstants.IMG_TAB_MAIN);
 
 503          * Method getSelectionAdapter.
 
 504          * @return SelectionListener
 
 506         protected SelectionListener getSelectionAdapter() {
 
 507                 if (selectionAdapter == null) {
 
 508                         selectionAdapter= new SelectionAdapter() {
 
 509                                 public void widgetSelected(SelectionEvent e) {
 
 510                                         updateLaunchConfigurationDialog();
 
 514                 return selectionAdapter;
 
 517         private class VariableSelectionDialog extends SelectionDialog {
 
 518                 private ExternalToolVariableForm form;
 
 519                 private VariableSelectionDialog(Shell parent) {
 
 521                         setTitle(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Select_variable_10")); //$NON-NLS-1$
 
 523                 protected Control createDialogArea(Composite parent) {
 
 524                         // Create the dialog area
 
 525                         Composite composite= (Composite)super.createDialogArea(parent);
 
 526                         ExternalToolVariable[] variables= ExternalToolsPlugin.getDefault().getArgumentVariableRegistry().getArgumentVariables();
 
 527                         form= new ExternalToolVariableForm(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.&Choose_a_variable__11"), variables); //$NON-NLS-1$
 
 528                         form.createContents(composite, new IGroupDialogPage() {
 
 529                                 public GridData setButtonGridData(Button button) {
 
 530                                         GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
 
 531                                         data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
 
 532                                         int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
 
 533                                         data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
 
 534                                         button.setLayoutData(data);
 
 538                                 public void setMessage(String newMessage, int newType) {
 
 539                                         VariableSelectionDialog.this.setMessage(newMessage);
 
 542                                 public void updateValidState() {
 
 545                                 public int convertHeightHint(int chars) {
 
 546                                         return convertHeightInCharsToPixels(chars);
 
 549                                 public String getMessage() {
 
 550                                         if (!form.isValid()) {
 
 551                                                 return ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Invalid_selection_12"); //$NON-NLS-1$
 
 556                                 public int getMessageType() {
 
 557                                         if (!form.isValid()) {
 
 558                                                 return IMessageProvider.ERROR;
 
 566                 private ExternalToolVariableForm getForm() {