1 package net.sourceforge.phpdt.externaltools.preferences;
3 import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
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;
18 public class ApachePrefencePage extends PreferencePage implements
19 IWorkbenchPreferencePage {
21 StringFieldEditor apacheStartSFE;
23 StringFieldEditor apacheStopSFE;
25 StringFieldEditor apacheRestartSFE;
27 FileFieldEditor apacheRunFFE;
29 FileFieldEditor httpdConfFFE;
31 FileFieldEditor etcHostsFFE;
33 BooleanFieldEditor apacheStartBFE;
35 BooleanFieldEditor apacheStopBFE;
37 BooleanFieldEditor apacheRestartBFE;
39 public ApachePrefencePage() {
41 setPreferenceStore(ExternalToolsPlugin.getDefault()
42 .getPreferenceStore());
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());
51 apacheStartSFE = new StringFieldEditor(
52 ExternalToolsPlugin.APACHE_START_PREF, PHPPreferencesMessages
53 .getString("PHPBasePreferencePage.apacheGroup.start"),
55 apacheStartSFE.setPage(this);
56 apacheStartSFE.setPreferenceStore(getPreferenceStore());
57 apacheStartSFE.load();
58 new Label(composite, SWT.NONE);
60 new Label(composite, SWT.NONE);
61 apacheStartBFE = new BooleanFieldEditor(
62 ExternalToolsPlugin.APACHE_START_BACKGROUND,
63 PHPPreferencesMessages
64 .getString("PHPBasePreferencePage.apacheGroup.start_background"),
66 apacheStartBFE.setPage(this);
67 apacheStartBFE.setPreferenceStore(getPreferenceStore());
68 apacheStartBFE.load();
69 new Label(composite, SWT.NONE);
72 apacheStopSFE = new StringFieldEditor(
73 ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
74 .getString("PHPBasePreferencePage.apacheGroup.stop"),
76 apacheStopSFE.setPage(this);
77 apacheStopSFE.setPreferenceStore(getPreferenceStore());
79 new Label(composite, SWT.NONE);
81 new Label(composite, SWT.NONE);
82 apacheStopBFE = new BooleanFieldEditor(
83 ExternalToolsPlugin.APACHE_STOP_BACKGROUND,
84 PHPPreferencesMessages
85 .getString("PHPBasePreferencePage.apacheGroup.stop_background"),
87 apacheStopBFE.setPage(this);
88 apacheStopBFE.setPreferenceStore(getPreferenceStore());
90 new Label(composite, SWT.NONE);
93 apacheRestartSFE = new StringFieldEditor(
94 ExternalToolsPlugin.APACHE_RESTART_PREF,
95 PHPPreferencesMessages
96 .getString("PHPBasePreferencePage.apacheGroup.restart"),
98 apacheRestartSFE.setPage(this);
99 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
100 apacheRestartSFE.load();
101 new Label(composite, SWT.NONE);
103 new Label(composite, SWT.NONE);
104 apacheRestartBFE = new BooleanFieldEditor(
105 ExternalToolsPlugin.APACHE_RESTART_BACKGROUND,
106 PHPPreferencesMessages
107 .getString("PHPBasePreferencePage.apacheGroup.restart_background"),
109 apacheRestartBFE.setPage(this);
110 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
111 apacheRestartBFE.load();
112 new Label(composite, SWT.NONE);
115 apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF,
116 PHPPreferencesMessages
117 .getString("PHPBasePreferencePage.apacheGroup.run"),
119 apacheRunFFE.setPage(this);
120 apacheRunFFE.setPreferenceStore(getPreferenceStore());
123 httpdConfFFE = new FileFieldEditor(
124 ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
125 "Path to httpd.conf:", composite);
126 httpdConfFFE.setPage(this);
127 httpdConfFFE.setPreferenceStore(getPreferenceStore());
130 etcHostsFFE = new FileFieldEditor(
131 ExternalToolsPlugin.ETC_HOSTS_PATH_PREF, "Path to etc/hosts:",
133 etcHostsFFE.setPage(this);
134 etcHostsFFE.setPreferenceStore(getPreferenceStore());
140 public void init(IWorkbench workbench) {
143 protected void performDefaults() {
144 apacheStartSFE.loadDefault();
145 apacheStopSFE.loadDefault();
146 apacheRestartSFE.loadDefault();
147 apacheRunFFE.loadDefault();
148 httpdConfFFE.loadDefault();
149 etcHostsFFE.loadDefault();
150 apacheStartBFE.loadDefault();
151 apacheStopBFE.loadDefault();
152 apacheRestartBFE.loadDefault();
153 super.performDefaults();
156 public boolean performOk() {
157 apacheStartSFE.store();
158 apacheStopSFE.store();
159 apacheRestartSFE.store();
160 apacheRunFFE.store();
161 httpdConfFFE.store();
163 apacheStartBFE.store();
164 apacheStopBFE.store();
165 apacheRestartBFE.store();
166 return super.performOk();