1) Fixed issue #844: Short form of ternary operator (since PHP 5.3).
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / preferences / ApachePrefencePage.java
1 package net.sourceforge.phpdt.externaltools.preferences;
2
3 import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
4
5 import org.eclipse.jface.preference.BooleanFieldEditor;
6 import org.eclipse.jface.preference.FileFieldEditor;
7 import org.eclipse.jface.preference.PreferencePage;
8 import org.eclipse.jface.preference.StringFieldEditor;
9 import org.eclipse.swt.SWT;
10 import org.eclipse.swt.layout.GridData;
11 import org.eclipse.swt.layout.GridLayout;
12 import org.eclipse.swt.widgets.Composite;
13 import org.eclipse.swt.widgets.Control;
14 import org.eclipse.swt.widgets.Label;
15 import org.eclipse.ui.IWorkbench;
16 import org.eclipse.ui.IWorkbenchPreferencePage;
17
18 public class ApachePrefencePage extends PreferencePage implements
19                 IWorkbenchPreferencePage {
20
21         StringFieldEditor apacheStartSFE;
22
23         StringFieldEditor apacheStopSFE;
24
25         StringFieldEditor apacheRestartSFE;
26
27         FileFieldEditor apacheRunFFE;
28
29         FileFieldEditor httpdConfFFE;
30
31         FileFieldEditor etcHostsFFE;
32
33         BooleanFieldEditor apacheStartBFE;
34
35         BooleanFieldEditor apacheStopBFE;
36
37         BooleanFieldEditor apacheRestartBFE;
38
39         public ApachePrefencePage() {
40                 super();
41                 
42                 if (ExternalToolsPlugin.getDefault () != null) {
43                   setPreferenceStore (ExternalToolsPlugin.getDefault().getPreferenceStore());
44                 }
45         }
46
47         protected Control createContents(Composite parent) {
48                 initializeDialogUnits(parent);
49                 Composite composite = new Composite(parent, SWT.LEFT);
50                 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
51                 composite.setLayout(new GridLayout());
52
53                 apacheStartSFE = new StringFieldEditor(
54                                 ExternalToolsPlugin.APACHE_START_PREF, PHPPreferencesMessages
55                                                 .getString("PHPBasePreferencePage.apacheGroup.start"),
56                                 composite);
57                 apacheStartSFE.setPage(this);
58                 apacheStartSFE.setPreferenceStore(getPreferenceStore());
59                 apacheStartSFE.load();
60                 new Label(composite, SWT.NONE);
61
62                 new Label(composite, SWT.NONE);
63                 apacheStartBFE = new BooleanFieldEditor(
64                                 ExternalToolsPlugin.APACHE_START_BACKGROUND,
65                                 PHPPreferencesMessages
66                                                 .getString("PHPBasePreferencePage.apacheGroup.start_background"),
67                                 composite);
68                 apacheStartBFE.setPage(this);
69                 apacheStartBFE.setPreferenceStore(getPreferenceStore());
70                 apacheStartBFE.load();
71                 new Label(composite, SWT.NONE);
72
73                 apacheStopSFE = new StringFieldEditor(
74                                 ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
75                                                 .getString("PHPBasePreferencePage.apacheGroup.stop"),
76                                 composite);
77                 apacheStopSFE.setPage(this);
78                 apacheStopSFE.setPreferenceStore(getPreferenceStore());
79                 apacheStopSFE.load();
80                 new Label(composite, SWT.NONE);
81
82                 new Label(composite, SWT.NONE);
83                 apacheStopBFE = new BooleanFieldEditor(
84                                 ExternalToolsPlugin.APACHE_STOP_BACKGROUND,
85                                 PHPPreferencesMessages
86                                                 .getString("PHPBasePreferencePage.apacheGroup.stop_background"),
87                                 composite);
88                 apacheStopBFE.setPage(this);
89                 apacheStopBFE.setPreferenceStore(getPreferenceStore());
90                 apacheStopBFE.load();
91                 new Label(composite, SWT.NONE);
92
93                 apacheRestartSFE = new StringFieldEditor(
94                                 ExternalToolsPlugin.APACHE_RESTART_PREF,
95                                 PHPPreferencesMessages
96                                                 .getString("PHPBasePreferencePage.apacheGroup.restart"),
97                                 composite);
98                 apacheRestartSFE.setPage(this);
99                 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
100                 apacheRestartSFE.load();
101                 new Label(composite, SWT.NONE);
102
103                 new Label(composite, SWT.NONE);
104                 apacheRestartBFE = new BooleanFieldEditor(
105                                 ExternalToolsPlugin.APACHE_RESTART_BACKGROUND,
106                                 PHPPreferencesMessages
107                                                 .getString("PHPBasePreferencePage.apacheGroup.restart_background"),
108                                 composite);
109                 apacheRestartBFE.setPage(this);
110                 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
111                 apacheRestartBFE.load();
112                 new Label(composite, SWT.NONE);
113
114                 apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF,
115                                 PHPPreferencesMessages
116                                                 .getString("PHPBasePreferencePage.apacheGroup.run"),
117                                 composite);
118                 apacheRunFFE.setPage(this);
119                 apacheRunFFE.setPreferenceStore(getPreferenceStore());
120                 apacheRunFFE.load();
121
122                 httpdConfFFE = new FileFieldEditor(
123                                 ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
124                                 "Path to httpd.conf:", composite);
125                 httpdConfFFE.setPage(this);
126                 httpdConfFFE.setPreferenceStore(getPreferenceStore());
127                 httpdConfFFE.load();
128
129                 etcHostsFFE = new FileFieldEditor(
130                                 ExternalToolsPlugin.ETC_HOSTS_PATH_PREF, "Path to etc/hosts:",
131                                 composite);
132                 etcHostsFFE.setPage(this);
133                 etcHostsFFE.setPreferenceStore(getPreferenceStore());
134                 etcHostsFFE.load();
135
136                 return composite;
137         }
138
139         public void init(IWorkbench workbench) {
140         }
141
142         protected void performDefaults() {
143                 apacheStartSFE.loadDefault();
144                 apacheStopSFE.loadDefault();
145                 apacheRestartSFE.loadDefault();
146                 apacheRunFFE.loadDefault();
147                 httpdConfFFE.loadDefault();
148                 etcHostsFFE.loadDefault();
149                 apacheStartBFE.loadDefault();
150                 apacheStopBFE.loadDefault();
151                 apacheRestartBFE.loadDefault();
152                 super.performDefaults();
153         }
154
155         public boolean performOk() {
156                 apacheStartSFE.store();
157                 apacheStopSFE.store();
158                 apacheRestartSFE.store();
159                 apacheRunFFE.store();
160                 httpdConfFFE.store();
161                 etcHostsFFE.store();
162                 apacheStartBFE.store();
163                 apacheStopBFE.store();
164                 apacheRestartBFE.store();
165                 return super.performOk();
166         }
167
168 }