Organized imports
[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 IWorkbenchPropertyPage {
17         protected Text interpreterArgumentsText, programArgumentsText;
18         
19         public PHPExecutionArgumentsPage() {
20         }
21
22         protected Control createContents(Composite parent)  {
23                 noDefaultAndApplyButton();
24
25                 Composite composite = new Composite(parent, SWT.NONE);
26                 
27                 GridLayout layout = new GridLayout();
28                 layout.numColumns = 2;
29                 composite.setLayout(layout);
30                 new Label(composite, SWT.NONE).setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPArguments.interpreter_args_box_title"));
31                 new Label(composite, SWT.NONE).setText("                      ");
32                 interpreterArgumentsText = new Text(composite, SWT.BORDER);
33                 GridData interpreterArgumentsData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
34                 interpreterArgumentsData.horizontalSpan = 2;
35                 interpreterArgumentsText.setLayoutData(interpreterArgumentsData);
36                 interpreterArgumentsText.setText(getArgument("interpreter"));
37                 
38                 new Label(composite, SWT.NONE).setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPArguments.program_args_box_title"));
39                 programArgumentsText = new Text(composite, SWT.BORDER);
40                 GridData programArgumentsData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
41                 programArgumentsData.horizontalSpan = 2;
42                 programArgumentsText.setLayoutData(programArgumentsData);
43                 programArgumentsText.setText(getArgument("program"));
44                 
45                 return composite;
46         }
47         
48         protected String getArgument(String name) {
49                 String argumentValue = null;
50                 try {
51                         argumentValue = ((IFile)getElement()).getPersistentProperty(new QualifiedName("executionArguments", name));
52                 } catch(CoreException e) {}
53                 
54                 return argumentValue != null ? argumentValue : "";
55         }
56         
57         public boolean performOk() {
58                 IFile phpFile = (IFile)getElement();
59                 try {
60                         phpFile.setPersistentProperty(new QualifiedName("executionArguments", "interpreter"), interpreterArgumentsText.getText());
61                         phpFile.setPersistentProperty(new QualifiedName("executionArguments", "program"), programArgumentsText.getText());
62                 } catch(CoreException e) {
63                         PHPDebugUiPlugin.log(e);
64                         return false;
65                 }
66                 return true;
67         }
68
69 }