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