7d2ae921bef3173dffe595c646073e7e9a6327ed
[phpeclipse.git] /
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
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;
54
55 public class ExternalToolsMainTab extends AbstractLaunchConfigurationTab {
56
57         protected Combo locationField;
58         protected Text workDirectoryField;
59         protected Button fileLocationButton;
60         protected Button workspaceLocationButton;
61         protected Button fileWorkingDirectoryButton;
62         protected Button workspaceWorkingDirectoryButton;
63
64         protected Button runBackgroundButton;
65         protected Text argumentField;
66         protected Button variableButton;
67
68         protected SelectionAdapter selectionAdapter;
69         
70         protected ModifyListener modifyListener = new ModifyListener() {
71                 public void modifyText(ModifyEvent e) {
72                         updateLaunchConfigurationDialog();
73                 }
74         };
75
76         /**
77          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
78          */
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);
93         }
94         
95         /**
96          * Creates the controls needed to edit the location
97          * attribute of an external tool
98          * 
99          * @param parent the composite to create the controls in
100          */
101         protected void createLocationComponent(Composite parent) {
102                 Font font = parent.getFont();
103                 
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);
112                 
113                 Label label = new Label(composite, SWT.NONE);
114                 label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Location___2")); //$NON-NLS-1$
115                 label.setFont(font);
116                 
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);
123                 
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);
133                 
134                 createVerticalSpacer(buttonComposite, 1);
135                 
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();
140                         }
141                 });
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();
146                         }
147                 });
148         }
149         
150         /**
151          * Creates the controls needed to edit the working directory
152          * attribute of an external tool
153          * 
154          * @param parent the composite to create the controls in
155          */
156         protected void createWorkDirectoryComponent(Composite parent) {
157                 Font font = parent.getFont();
158                 
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);
167                 
168                 Label label = new Label(composite, SWT.NONE);
169                 label.setText(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.Working_&Directory__5")); //$NON-NLS-1$
170                 label.setFont(font);
171                 
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);
177                 
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);
187                 
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();
193                         }
194                 });
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();
199                         }
200                 });
201         }
202         
203         /**
204          * Creates the controls needed to edit the argument and
205          * prompt for argument attributes of an external tool
206          *
207          * @param parent the composite to create the controls in
208          */
209         protected void createArgumentComponent(Composite parent) {
210                 Font font = parent.getFont();
211
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);
217                 label.setFont(font);
218
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();
227                         }
228                 });
229
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());
236                                 }
237                         }
238                 });
239
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);
246         }
247
248         /**
249          * Creates the controls needed to edit the run in background
250          * attribute of an external tool
251          *
252          * @param parent the composite to create the controls in
253          */
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());
261         }
262         
263         /**
264          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
265          */
266         public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
267                 configuration.setAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, false);
268         }
269
270         /**
271          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
272          */
273         public void initializeFrom(ILaunchConfiguration configuration) {
274                 updateLocation(configuration);
275                 updateWorkingDirectory(configuration);
276                 updateArgument(configuration);
277                 updateRunBackground(configuration);
278         }
279         
280         protected void updateWorkingDirectory(ILaunchConfiguration configuration) {
281                 String workingDir= ""; //$NON-NLS-1$
282                 try {
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$
286                 }
287                 workDirectoryField.setText(workingDir);
288                 workDirectoryField.addModifyListener(modifyListener);
289                 
290         }
291         
292         protected void updateLocation(ILaunchConfiguration configuration) {
293                 String location= ""; //$NON-NLS-1$
294                 try {
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$
298                 }
299                 locationField.setText(location);
300                 locationField.addModifyListener(modifyListener);
301         }
302
303         protected void updateArgument(ILaunchConfiguration configuration) {
304                 String arguments= ""; //$NON-NLS-1$
305                 try {
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$
309                 }
310                 argumentField.setText(arguments);
311         }
312
313         protected void updateRunBackground(ILaunchConfiguration configuration) {
314                 boolean  runInBackgroud= true;
315                 try {
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$
319                 }
320                 runBackgroundButton.setSelection(runInBackgroud);
321         }
322
323         /**
324          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
325          */
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);
330                 } else {
331                         configuration.setAttribute(IExternalToolConstants.ATTR_LOCATION, location);
332                 }
333                 
334                 String workingDirectory= workDirectoryField.getText().trim();
335                 if (workingDirectory.length() == 0) {
336                         configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String)null);
337                 } else {
338                         configuration.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, workingDirectory);
339                 }
340                 
341                 setAttribute(IExternalToolConstants.ATTR_RUN_IN_BACKGROUND, configuration, runBackgroundButton.getSelection(), false);
342
343                 String arguments= argumentField.getText().trim();
344                 if (arguments.length() == 0) {
345                         configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String)null);
346                 } else {
347                         configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
348                 }
349         }
350
351         /**
352          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
353          */
354         public String getName() {
355                 return ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Main_17"); //$NON-NLS-1$
356         }
357         
358         /**
359          * @see ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
360          */
361         public boolean isValid(ILaunchConfiguration launchConfig) {
362                 setErrorMessage(null);
363                 setMessage(null);
364                 return validateLocation() && validateWorkDirectory();
365         }
366         
367         /**
368          * Validates the content of the location field.
369          */
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$
374                         setMessage(null);
375                         return false;
376                 }
377
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());
386                                 setMessage(null);
387                         }
388                         return false;
389                 }
390                 
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$
394                         return false;
395                 }
396                 if (!file.isFile()) {
397                         setErrorMessage(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.External_tool_location_specified_is_not_a_file_20")); //$NON-NLS-1$
398                         return false;
399                 }
400                 return true;
401         }
402
403         /**
404          * Validates the content of the working directory field.
405          */
406         protected boolean validateWorkDirectory() {
407                 
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());
418                                 }
419                                 return false;
420                         }
421                                 
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$
425                                 return false;
426                         }
427                 }
428                 return true;
429         }
430         
431         protected void handleLocationButtonSelected() {
432                 FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
433                 fileDialog.setFileName(locationField.getText());
434                 String text= fileDialog.open();
435                 if (text != null) {
436                         locationField.setText(text);
437                 }
438         }
439         
440         /**
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.
444          */
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$
448                 dialog.open();
449                 Object[] results = dialog.getResult();
450                 if (results == null || results.length < 1) {
451                         return;
452                 }
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();
457                 if (text != null) {
458                         locationField.setText(text);
459                 }
460         }
461         
462         /**
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.
466          */
467         protected void handleWorkspaceWorkingDirectoryButtonSelected() {
468                 ContainerSelectionDialog containerDialog;
469                 containerDialog = new ContainerSelectionDialog(
470                         getShell(), 
471                         ResourcesPlugin.getWorkspace().getRoot(),
472                         false,
473                         ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsMainTab.&Select_a_directory__23")); //$NON-NLS-1$
474                 containerDialog.open();
475                 Object[] resource = containerDialog.getResult();
476                 String text= null;
477                 if (resource != null && resource.length > 0) {
478                         text= ToolUtil.buildVariableTag(IExternalToolConstants.VAR_RESOURCE_LOC, ((IPath)resource[0]).toString());
479                 }
480                 if (text != null) {
481                         workDirectoryField.setText(text);
482                 }
483         }
484         
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();
490                 if (text != null) {
491                         workDirectoryField.setText(text);
492                 }
493         }
494
495         /**
496          * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
497          */
498         public Image getImage() {
499                 return ExternalToolsImages.getImage(IExternalToolConstants.IMG_TAB_MAIN);
500         }
501         
502         /**
503          * Method getSelectionAdapter.
504          * @return SelectionListener
505          */
506         protected SelectionListener getSelectionAdapter() {
507                 if (selectionAdapter == null) {
508                         selectionAdapter= new SelectionAdapter() {
509                                 public void widgetSelected(SelectionEvent e) {
510                                         updateLaunchConfigurationDialog();
511                                 }
512                         };
513                 }
514                 return selectionAdapter;
515         }
516         
517         private class VariableSelectionDialog extends SelectionDialog {
518                 private ExternalToolVariableForm form;
519                 private VariableSelectionDialog(Shell parent) {
520                         super(parent);
521                         setTitle(ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Select_variable_10")); //$NON-NLS-1$
522                 }
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);
535                                         return data;
536                                 }
537
538                                 public void setMessage(String newMessage, int newType) {
539                                         VariableSelectionDialog.this.setMessage(newMessage);
540                                 }
541
542                                 public void updateValidState() {
543                                 }
544
545                                 public int convertHeightHint(int chars) {
546                                         return convertHeightInCharsToPixels(chars);
547                                 }
548
549                                 public String getMessage() {
550                                         if (!form.isValid()) {
551                                                 return ExternalToolsLaunchConfigurationMessages.getString("ExternalToolsOptionTab.Invalid_selection_12"); //$NON-NLS-1$
552                                         }
553                                         return null;
554                                 }
555
556                                 public int getMessageType() {
557                                         if (!form.isValid()) {
558                                                 return IMessageProvider.ERROR;
559                                         }
560                                         return 0;
561                                 }
562                         });
563                         return composite;
564                 }
565
566                 private ExternalToolVariableForm getForm() {
567                         return form;
568                 }
569         }
570
571 }