Fix java 1.4 VM compatibility.
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / PHPExecutionArgumentsPage.java
1 package net.sourceforge.phpdt.internal.debug.ui;
2
3 import org.eclipse.core.resources.IFile;
4 import org.eclipse.core.runtime.CoreException;
5 import org.eclipse.core.runtime.QualifiedName;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.layout.GridData;
8 import org.eclipse.swt.layout.GridLayout;
9 import org.eclipse.swt.widgets.Composite;
10 import org.eclipse.swt.widgets.Control;
11 import org.eclipse.swt.widgets.Label;
12 import org.eclipse.swt.widgets.Text;
13 import org.eclipse.ui.IWorkbenchPropertyPage;
14 import org.eclipse.ui.dialogs.PropertyPage;
15
16 public class PHPExecutionArgumentsPage extends PropertyPage implements
17                 IWorkbenchPropertyPage {
18         protected Text interpreterArgumentsText, programArgumentsText;
19
20         public PHPExecutionArgumentsPage() {
21         }
22
23         protected Control createContents(Composite parent) {
24                 noDefaultAndApplyButton();
25
26                 Composite composite = new Composite(parent, SWT.NONE);
27
28                 GridLayout layout = new GridLayout();
29                 layout.numColumns = 2;
30                 composite.setLayout(layout);
31                 new Label(composite, SWT.NONE)
32                                 .setText(PHPDebugUiMessages
33                                                 .getString("LaunchConfigurationTab.PHPArguments.interpreter_args_box_title"));
34                 new Label(composite, SWT.NONE).setText("                      ");
35                 interpreterArgumentsText = new Text(composite, SWT.BORDER);
36                 GridData interpreterArgumentsData = new GridData(
37                                 GridData.HORIZONTAL_ALIGN_FILL);
38                 interpreterArgumentsData.horizontalSpan = 2;
39                 interpreterArgumentsText.setLayoutData(interpreterArgumentsData);
40                 interpreterArgumentsText.setText(getArgument("interpreter"));
41
42                 new Label(composite, SWT.NONE)
43                                 .setText(PHPDebugUiMessages
44                                                 .getString("LaunchConfigurationTab.PHPArguments.program_args_box_title"));
45                 programArgumentsText = new Text(composite, SWT.BORDER);
46                 GridData programArgumentsData = new GridData(
47                                 GridData.HORIZONTAL_ALIGN_FILL);
48                 programArgumentsData.horizontalSpan = 2;
49                 programArgumentsText.setLayoutData(programArgumentsData);
50                 programArgumentsText.setText(getArgument("program"));
51
52                 return composite;
53         }
54
55         protected String getArgument(String name) {
56                 String argumentValue = null;
57                 try {
58                         argumentValue = ((IFile) getElement())
59                                         .getPersistentProperty(new QualifiedName(
60                                                         "executionArguments", name));
61                 } catch (CoreException e) {
62                 }
63
64                 return argumentValue != null ? argumentValue : "";
65         }
66
67         public boolean performOk() {
68                 IFile phpFile = (IFile) getElement();
69                 try {
70                         phpFile.setPersistentProperty(new QualifiedName(
71                                         "executionArguments", "interpreter"),
72                                         interpreterArgumentsText.getText());
73                         phpFile.setPersistentProperty(new QualifiedName(
74                                         "executionArguments", "program"), programArgumentsText
75                                         .getText());
76                 } catch (CoreException e) {
77                         PHPDebugUiPlugin.log(e);
78                         return false;
79                 }
80                 return true;
81         }
82
83 }