Adds a private listener class to the Arguments tab and an appropriate listener to...
[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                 setPreferenceStore(ExternalToolsPlugin.getDefault()
42                                 .getPreferenceStore());
43         }
44
45         protected Control createContents(Composite parent) {
46                 initializeDialogUnits(parent);
47                 Composite composite = new Composite(parent, SWT.LEFT);
48                 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
49                 composite.setLayout(new GridLayout());
50
51                 apacheStartSFE = new StringFieldEditor(
52                                 ExternalToolsPlugin.APACHE_START_PREF, PHPPreferencesMessages
53                                                 .getString("PHPBasePreferencePage.apacheGroup.start"),
54                                 composite);
55                 apacheStartSFE.setPage(this);
56                 apacheStartSFE.setPreferenceStore(getPreferenceStore());
57                 apacheStartSFE.load();
58                 new Label(composite, SWT.NONE);
59
60                 new Label(composite, SWT.NONE);
61                 apacheStartBFE = new BooleanFieldEditor(
62                                 ExternalToolsPlugin.APACHE_START_BACKGROUND,
63                                 PHPPreferencesMessages
64                                                 .getString("PHPBasePreferencePage.apacheGroup.start_background"),
65                                 composite);
66                 apacheStartBFE.setPage(this);
67                 apacheStartBFE.setPreferenceStore(getPreferenceStore());
68                 apacheStartBFE.load();
69                 new Label(composite, SWT.NONE);
70
71                 apacheStopSFE = new StringFieldEditor(
72                                 ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
73                                                 .getString("PHPBasePreferencePage.apacheGroup.stop"),
74                                 composite);
75                 apacheStopSFE.setPage(this);
76                 apacheStopSFE.setPreferenceStore(getPreferenceStore());
77                 apacheStopSFE.load();
78                 new Label(composite, SWT.NONE);
79
80                 new Label(composite, SWT.NONE);
81                 apacheStopBFE = new BooleanFieldEditor(
82                                 ExternalToolsPlugin.APACHE_STOP_BACKGROUND,
83                                 PHPPreferencesMessages
84                                                 .getString("PHPBasePreferencePage.apacheGroup.stop_background"),
85                                 composite);
86                 apacheStopBFE.setPage(this);
87                 apacheStopBFE.setPreferenceStore(getPreferenceStore());
88                 apacheStopBFE.load();
89                 new Label(composite, SWT.NONE);
90
91                 apacheRestartSFE = new StringFieldEditor(
92                                 ExternalToolsPlugin.APACHE_RESTART_PREF,
93                                 PHPPreferencesMessages
94                                                 .getString("PHPBasePreferencePage.apacheGroup.restart"),
95                                 composite);
96                 apacheRestartSFE.setPage(this);
97                 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
98                 apacheRestartSFE.load();
99                 new Label(composite, SWT.NONE);
100
101                 new Label(composite, SWT.NONE);
102                 apacheRestartBFE = new BooleanFieldEditor(
103                                 ExternalToolsPlugin.APACHE_RESTART_BACKGROUND,
104                                 PHPPreferencesMessages
105                                                 .getString("PHPBasePreferencePage.apacheGroup.restart_background"),
106                                 composite);
107                 apacheRestartBFE.setPage(this);
108                 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
109                 apacheRestartBFE.load();
110                 new Label(composite, SWT.NONE);
111
112                 apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF,
113                                 PHPPreferencesMessages
114                                                 .getString("PHPBasePreferencePage.apacheGroup.run"),
115                                 composite);
116                 apacheRunFFE.setPage(this);
117                 apacheRunFFE.setPreferenceStore(getPreferenceStore());
118                 apacheRunFFE.load();
119
120                 httpdConfFFE = new FileFieldEditor(
121                                 ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
122                                 "Path to httpd.conf:", composite);
123                 httpdConfFFE.setPage(this);
124                 httpdConfFFE.setPreferenceStore(getPreferenceStore());
125                 httpdConfFFE.load();
126
127                 etcHostsFFE = new FileFieldEditor(
128                                 ExternalToolsPlugin.ETC_HOSTS_PATH_PREF, "Path to etc/hosts:",
129                                 composite);
130                 etcHostsFFE.setPage(this);
131                 etcHostsFFE.setPreferenceStore(getPreferenceStore());
132                 etcHostsFFE.load();
133
134                 return composite;
135         }
136
137         public void init(IWorkbench workbench) {
138         }
139
140         protected void performDefaults() {
141                 apacheStartSFE.loadDefault();
142                 apacheStopSFE.loadDefault();
143                 apacheRestartSFE.loadDefault();
144                 apacheRunFFE.loadDefault();
145                 httpdConfFFE.loadDefault();
146                 etcHostsFFE.loadDefault();
147                 apacheStartBFE.loadDefault();
148                 apacheStopBFE.loadDefault();
149                 apacheRestartBFE.loadDefault();
150                 super.performDefaults();
151         }
152
153         public boolean performOk() {
154                 apacheStartSFE.store();
155                 apacheStopSFE.store();
156                 apacheRestartSFE.store();
157                 apacheRunFFE.store();
158                 httpdConfFFE.store();
159                 etcHostsFFE.store();
160                 apacheStartBFE.store();
161                 apacheStopBFE.store();
162                 apacheRestartBFE.store();
163                 return super.performOk();
164         }
165
166 }