Added word wrap option (problem: conflicts with folding)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / externaltools / launchConfigurations / ExternalToolsMainTab.java
1 package net.sourceforge.phpdt.externaltools.launchConfigurations;
2
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 **********************************************************************/
9
10 import java.io.File;
11
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;
20 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
21
22 import org.eclipse.core.resources.IResource;
23 import org.eclipse.core.resources.ResourcesPlugin;
24 import org.eclipse.core.runtime.CoreException;
25 import org.eclipse.core.runtime.IPath;
26 import org.eclipse.core.runtime.IStatus;
27 import org.eclipse.core.runtime.MultiStatus;
28 import org.eclipse.debug.core.ILaunchConfiguration;
29 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30 import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
31 import org.eclipse.jface.dialogs.IDialogConstants;
32 import org.eclipse.jface.dialogs.IMessageProvider;
33 import org.eclipse.jface.preference.IPreferenceStore;
34 import org.eclipse.swt.SWT;
35 import org.eclipse.swt.events.ModifyEvent;
36 import org.eclipse.swt.events.ModifyListener;
37 import org.eclipse.swt.events.SelectionAdapter;
38 import org.eclipse.swt.events.SelectionEvent;
39 import org.eclipse.swt.events.SelectionListener;
40 import org.eclipse.swt.graphics.Font;
41 import org.eclipse.swt.graphics.Image;
42 import org.eclipse.swt.layout.GridData;
43 import org.eclipse.swt.layout.GridLayout;
44 import org.eclipse.swt.widgets.Button;
45 import org.eclipse.swt.widgets.Combo;
46 import org.eclipse.swt.widgets.Composite;
47 import org.eclipse.swt.widgets.Control;
48 import org.eclipse.swt.widgets.DirectoryDialog;
49 import org.eclipse.swt.widgets.FileDialog;
50 import org.eclipse.swt.widgets.Label;
51 import org.eclipse.swt.widgets.Shell;
52 import org.eclipse.swt.widgets.Text;
53 import org.eclipse.ui.dialogs.ContainerSelectionDialog;
54 import org.eclipse.ui.dialogs.ResourceSelectionDialog;
55 import org.eclipse.ui.dialogs.SelectionDialog;
56
57 public class ExternalToolsMainTab extends AbstractLaunchConfigurationTab {
58
59   protected Combo locationField;
60   protected Text workDirectoryField;
61   protected Button fileLocationButton;
62   protected Button workspaceLocationButton;
63   protected Button fileWorkingDirectoryButton;
64   protected Button workspaceWorkingDirectoryButton;
65
66   protected Button runBackgroundButton;
67   protected Text argumentField;
68   protected Button variableButton;
69
70   protected SelectionAdapter selectionAdapter;
71
72   protected ModifyListener modifyListener = new ModifyListener() {
73     public void modifyText(ModifyEvent e) {
74       updateLaunchConfigurationDialog();
75     }
76   };
77
78   /**
79    * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
80    */
81   public void createControl(Composite parent) {
82     Composite mainComposite = new Composite(parent, SWT.NONE);
83     setControl(mainComposite);
84     GridLayout layout = new GridLayout();
85     layout.numColumns = 2;
86     GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
87     mainComposite.setLayout(layout);
88     mainComposite.setLayoutData(gridData);
89     mainComposite.setFont(parent.getFont());
90     createLocationComponent(mainComposite);
91     createWorkDirectoryComponent(mainComposite);
92     createArgumentComponent(mainComposite);
93     createVerticalSpacer(mainComposite, 2);
94     createRunBackgroundComponent(mainComposite);
95   }
96
97   /**
98    * Creates the controls needed to edit the location
99    * attribute of an external tool
100    * 
101    * @param parent the composite to create the controls in
102    */
103   protected void createLocationComponent(Composite parent) {
104     Font font = parent.getFont();
105
106     Composite composite = new Composite(parent, SWT.NONE);
107     GridLayout layout = new GridLayout();
108     layout.marginWidth = 0;
109     layout.marginHeight = 0;
110     layout.numColumns = 1;
111     GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
112     composite.setLayout(layout);
113     composite.setLayoutData(gridData);
114
115     Label label = new Label(composite, SWT.NONE);
116     label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Location___2")); //$NON-NLS-1$
117     label.setFont(font);
118
119     final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
120     locationField = new Combo(composite, SWT.DROP_DOWN | SWT.BORDER);
121     GridData data = new GridData(GridData.FILL_HORIZONTAL);
122     data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
123     locationField.setLayoutData(data);
124     locationField.setFont(font);
125     locationField.add( store.getString(PHPeclipsePlugin.PHP_RUN_PREF), 0);
126                 locationField.add( store.getString(PHPeclipsePlugin.APACHE_RUN_PREF), 1);
127                 locationField.add( store.getString(PHPeclipsePlugin.MYSQL_RUN_PREF), 2);
128
129     Composite buttonComposite = new Composite(parent, SWT.NONE);
130     layout = new GridLayout();
131     layout.marginWidth = 0;
132     layout.marginHeight = 0;
133     layout.numColumns = 1;
134     gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
135     buttonComposite.setLayout(layout);
136     buttonComposite.setLayoutData(gridData);
137     buttonComposite.setFont(font);
138
139     createVerticalSpacer(buttonComposite, 1);
140
141     workspaceLocationButton = createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Browse_Workspace..._3"), null); //$NON-NLS-1$
142     workspaceLocationButton.addSelectionListener(new SelectionAdapter() {
143       public void widgetSelected(SelectionEvent evt) {
144         handleWorkspaceLocationButtonSelected();
145       }
146     });
147     fileLocationButton = createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Brows&e_File_System..._4"), null); //$NON-NLS-1$
148     fileLocationButton.addSelectionListener(new SelectionAdapter() {
149       public void widgetSelected(SelectionEvent evt) {
150         handleLocationButtonSelected();
151       }
152     });
153   }
154
155   /**
156    * Creates the controls needed to edit the working directory
157    * attribute of an external tool
158    * 
159    * @param parent the composite to create the controls in
160    */
161   protected void createWorkDirectoryComponent(Composite parent) {
162     Font font = parent.getFont();
163
164     Composite composite = new Composite(parent, SWT.NONE);
165     GridLayout layout = new GridLayout();
166     layout.marginWidth = 0;
167     layout.marginHeight = 0;
168     layout.numColumns = 1;
169     GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
170     composite.setLayout(layout);
171     composite.setLayoutData(gridData);
172
173     Label label = new Label(composite, SWT.NONE);
174     label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Working_&Directory__5")); //$NON-NLS-1$
175     label.setFont(font);
176
177     workDirectoryField = new Text(composite, SWT.BORDER);
178     GridData data = new GridData(GridData.FILL_HORIZONTAL);
179     data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
180     workDirectoryField.setLayoutData(data);
181     workDirectoryField.setFont(font);
182
183     Composite buttonComposite = new Composite(parent, SWT.NONE);
184     layout = new GridLayout();
185     layout.marginWidth = 0;
186     layout.marginHeight = 0;
187     layout.numColumns = 1;
188     gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
189     buttonComposite.setLayout(layout);
190     buttonComposite.setLayoutData(gridData);
191     buttonComposite.setFont(font);
192
193     createVerticalSpacer(buttonComposite, 1);
194     workspaceWorkingDirectoryButton = createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Browse_Wor&kspace..._6"), null); //$NON-NLS-1$
195     workspaceWorkingDirectoryButton.addSelectionListener(new SelectionAdapter() {
196       public void widgetSelected(SelectionEvent evt) {
197         handleWorkspaceWorkingDirectoryButtonSelected();
198       }
199     });
200     fileWorkingDirectoryButton = createPushButton(buttonComposite, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Browse_F&ile_System..._7"), null); //$NON-NLS-1$
201     fileWorkingDirectoryButton.addSelectionListener(new SelectionAdapter() {
202       public void widgetSelected(SelectionEvent evt) {
203         handleFileWorkingDirectoryButtonSelected();
204       }
205     });
206   }
207
208   /**
209    * Creates the controls needed to edit the argument and
210    * prompt for argument attributes of an external tool
211    *
212    * @param parent the composite to create the controls in
213    */
214   protected void createArgumentComponent(Composite parent) {
215     Font font = parent.getFont();
216
217     Label label = new Label(parent, SWT.NONE);
218     label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.&Arguments___1")); //$NON-NLS-1$
219     GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
220     data.horizontalSpan = 2;
221     label.setLayoutData(data);
222     label.setFont(font);
223
224     argumentField = new Text(parent, SWT.BORDER);
225     data = new GridData(GridData.FILL_HORIZONTAL);
226     data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
227     argumentField.setLayoutData(data);
228     argumentField.setFont(font);
229     argumentField.addModifyListener(new ModifyListener() {
230       public void modifyText(ModifyEvent e) {
231         updateLaunchConfigurationDialog();
232       }
233     });
234
235     variableButton = createPushButton(parent, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Varia&bles..._2"), null); //$NON-NLS-1$
236     variableButton.addSelectionListener(new SelectionAdapter() {
237       public void widgetSelected(SelectionEvent e) {
238         VariableSelectionDialog dialog = new VariableSelectionDialog(getShell());
239         if (dialog.open() == SelectionDialog.OK) {
240           argumentField.insert(dialog.getForm().getSelectedVariable());
241         }
242       }
243     });
244
245     Label instruction = new Label(parent, SWT.NONE);
246     instruction.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Note__Enclose_an_argument_containing_spaces_using_double-quotes_(__)._Not_applicable_for_variables._3")); //$NON-NLS-1$
247     data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
248     data.horizontalSpan = 2;
249     instruction.setLayoutData(data);
250     instruction.setFont(font);
251   }
252
253   /**
254    * Creates the controls needed to edit the run in background
255    * attribute of an external tool
256    *
257    * @param parent the composite to create the controls in
258    */
259   protected void createRunBackgroundComponent(Composite parent) {
260     runBackgroundButton = new Button(parent, SWT.CHECK);
261     runBackgroundButton.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Run_tool_in_bac&kground_4")); //$NON-NLS-1$
262     GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
263     runBackgroundButton.setLayoutData(data);
264     runBackgroundButton.setFont(parent.getFont());
265     runBackgroundButton.addSelectionListener(getSelectionAdapter());
266   }
267
268   /**
269    * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
270    */
271   public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
272     configuration.setAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, false);
273   }
274
275   /**
276    * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
277    */
278   public void initializeFrom(ILaunchConfiguration configuration) {
279     updateLocation(configuration);
280     updateWorkingDirectory(configuration);
281     updateArgument(configuration);
282     updateRunBackground(configuration);
283   }
284
285   protected void updateWorkingDirectory(ILaunchConfiguration configuration) {
286     String workingDir = ""; //$NON-NLS-1$
287     try {
288       workingDir = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, ""); //$NON-NLS-1$
289     } catch (CoreException ce) {
290       ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Error_reading_configuration_10"), ce); //$NON-NLS-1$
291     }
292     workDirectoryField.setText(workingDir);
293     workDirectoryField.addModifyListener(modifyListener);
294
295   }
296
297   protected void updateLocation(ILaunchConfiguration configuration) {
298     String location = ""; //$NON-NLS-1$
299     try {
300       location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, ""); //$NON-NLS-1$
301     } catch (CoreException ce) {
302       ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Error_reading_configuration_10"), ce); //$NON-NLS-1$
303     }
304     locationField.setText(location);
305     locationField.addModifyListener(modifyListener);
306   }
307
308   protected void updateArgument(ILaunchConfiguration configuration) {
309     String arguments = ""; //$NON-NLS-1$
310     try {
311       arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
312     } catch (CoreException ce) {
313       ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Error_reading_configuration_7"), ce); //$NON-NLS-1$
314     }
315     argumentField.setText(arguments);
316   }
317
318   protected void updateRunBackground(ILaunchConfiguration configuration) {
319     boolean runInBackgroud = true;
320     try {
321       runInBackgroud = configuration.getAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, false);
322     } catch (CoreException ce) {
323       ExternalToolsPlugin.getDefault().log(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Error_reading_configuration_7"), ce); //$NON-NLS-1$
324     }
325     runBackgroundButton.setSelection(runInBackgroud);
326   }
327
328   /**
329    * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
330    */
331   public void performApply(ILaunchConfigurationWorkingCopy configuration) {
332     String location = locationField.getText().trim();
333     if (location.length() == 0) {
334       configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
335     } else {
336       configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, location);
337     }
338
339     String workingDirectory = workDirectoryField.getText().trim();
340     if (workingDirectory.length() == 0) {
341       configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
342     } else {
343       configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, workingDirectory);
344     }
345
346     setAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, configuration, runBackgroundButton.getSelection(), false);
347
348     String arguments = argumentField.getText().trim();
349     if (arguments.length() == 0) {
350       configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
351     } else {
352       configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
353     }
354   }
355
356   /**
357    * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
358    */
359   public String getName() {
360     return ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Main_17"); //$NON-NLS-1$
361   }
362
363   /**
364    * @see ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
365    */
366   public boolean isValid(ILaunchConfiguration launchConfig) {
367     setErrorMessage(null);
368     setMessage(null);
369     return validateLocation() && validateWorkDirectory();
370   }
371
372   /**
373    * Validates the content of the location field.
374    */
375   protected boolean validateLocation() {
376     String value = locationField.getText().trim();
377     if (value.length() < 1) {
378       setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_cannot_be_empty_18")); //$NON-NLS-1$
379       setMessage(null);
380       return false;
381     }
382
383     // Translate field contents to the actual file location so we
384     // can check to ensure the file actually exists.
385     MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
386     value = ToolUtil.expandFileLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
387     if (!multiStatus.isOK()) {
388       IStatus[] children = multiStatus.getChildren();
389       if (children.length > 0) {
390         setErrorMessage(children[0].getMessage());
391         setMessage(null);
392       }
393       return false;
394     }
395
396     File file = new File(value);
397     if (!file.exists()) { // The file does not exist.
398       setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_does_not_exist_19")); //$NON-NLS-1$
399       return false;
400     }
401     if (!file.isFile()) {
402       setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_specified_is_not_a_file_20")); //$NON-NLS-1$
403       return false;
404     }
405     return true;
406   }
407
408   /**
409    * Validates the content of the working directory field.
410    */
411   protected boolean validateWorkDirectory() {
412
413     String value = workDirectoryField.getText().trim();
414     if (value.length() > 0) {
415       // Translate field contents to the actual directory location so we
416       // can check to ensure the directory actually exists.
417       MultiStatus multiStatus = new MultiStatus(IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
418       value = ToolUtil.expandDirectoryLocation(value, ExpandVariableContext.EMPTY_CONTEXT, multiStatus);
419       if (!multiStatus.isOK()) {
420         IStatus[] children = multiStatus.getChildren();
421         if (children.length > 0) {
422           setErrorMessage(children[0].getMessage());
423         }
424         return false;
425       }
426
427       File file = new File(value);
428       if (!file.exists()) { // The directory does not exist.
429         setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_working_directory_does_not_exist_or_is_invalid_21")); //$NON-NLS-1$
430         return false;
431       }
432     }
433     return true;
434   }
435
436   protected void handleLocationButtonSelected() {
437     FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
438     fileDialog.setFileName(locationField.getText());
439     String text = fileDialog.open();
440     if (text != null) {
441       locationField.setText(text);
442     }
443   }
444
445   /**
446    * Prompts the user for a workspace location within the workspace and sets
447    * the location as a String containing the workspace_loc variable or
448    * <code>null</code> if no location was obtained from the user.
449    */
450   protected void handleWorkspaceLocationButtonSelected() {
451     ResourceSelectionDialog dialog;
452     dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Select_a_resource_22")); //$NON-NLS-1$
453     dialog.open();
454     Object[] results = dialog.getResult();
455     if (results == null || results.length < 1) {
456       return;
457     }
458     IResource resource = (IResource) results[0];
459     StringBuffer buf = new StringBuffer();
460     ToolUtil.buildVariableTag(IExternalToolConstants.VAR_WORKSPACE_LOC, resource.getFullPath().toString(), buf);
461     String text = buf.toString();
462     if (text != null) {
463       locationField.setText(text);
464     }
465   }
466
467   /**
468    * Prompts the user for a working directory location within the workspace
469    * and sets the working directory as a String containing the workspace_loc
470    * variable or <code>null</code> if no location was obtained from the user.
471    */
472   protected void handleWorkspaceWorkingDirectoryButtonSelected() {
473     ContainerSelectionDialog containerDialog;
474     containerDialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Select_a_directory__23")); //$NON-NLS-1$
475     containerDialog.open();
476     Object[] resource = containerDialog.getResult();
477     String text = null;
478     if (resource != null && resource.length > 0) {
479       text = ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, ((IPath) resource[0]).toString());
480     }
481     if (text != null) {
482       workDirectoryField.setText(text);
483     }
484   }
485
486   protected void handleFileWorkingDirectoryButtonSelected() {
487     DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
488     dialog.setMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Select_a_directory__23")); //$NON-NLS-1$
489     dialog.setFilterPath(workDirectoryField.getText());
490     String text = dialog.open();
491     if (text != null) {
492       workDirectoryField.setText(text);
493     }
494   }
495
496   /**
497    * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
498    */
499   public Image getImage() {
500     return ExternalToolsImages.getImage(IExternalToolConstants.IMG_TAB_MAIN);
501   }
502
503   /**
504    * Method getSelectionAdapter.
505    * @return SelectionListener
506    */
507   protected SelectionListener getSelectionAdapter() {
508     if (selectionAdapter == null) {
509       selectionAdapter = new SelectionAdapter() {
510         public void widgetSelected(SelectionEvent e) {
511           updateLaunchConfigurationDialog();
512         }
513       };
514     }
515     return selectionAdapter;
516   }
517
518   private class VariableSelectionDialog extends SelectionDialog {
519     private ExternalToolVariableForm form;
520     private VariableSelectionDialog(Shell parent) {
521       super(parent);
522       setTitle(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Select_variable_10")); //$NON-NLS-1$
523     }
524     protected Control createDialogArea(Composite parent) {
525       // Create the dialog area
526       Composite composite = (Composite) super.createDialogArea(parent);
527       ExternalToolVariable[] variables = ExternalToolsPlugin.getDefault().getArgumentVariableRegistry().getArgumentVariables();
528       form = new ExternalToolVariableForm(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.&Choose_a_variable__11"), variables); //$NON-NLS-1$
529       form.createContents(composite, new IGroupDialogPage() {
530         public GridData setButtonGridData(Button button) {
531           GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
532           data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
533           int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
534           data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
535           button.setLayoutData(data);
536           return data;
537         }
538
539         public void setMessage(String newMessage, int newType) {
540           VariableSelectionDialog.this.setMessage(newMessage);
541         }
542
543         public void updateValidState() {
544         }
545
546         public int convertHeightHint(int chars) {
547           return convertHeightInCharsToPixels(chars);
548         }
549
550         public String getMessage() {
551           if (!form.isValid()) {
552             return ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Invalid_selection_12"); //$NON-NLS-1$
553           }
554           return null;
555         }
556
557         public int getMessageType() {
558           if (!form.isValid()) {
559             return IMessageProvider.ERROR;
560           }
561           return 0;
562         }
563       });
564       return composite;
565     }
566
567     private ExternalToolVariableForm getForm() {
568       return form;
569     }
570   }
571
572 }