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() {
42 if (ExternalToolsPlugin.getDefault () != null) {
43 setPreferenceStore (ExternalToolsPlugin.getDefault().getPreferenceStore());
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());
53 apacheStartSFE = new StringFieldEditor(
54 ExternalToolsPlugin.APACHE_START_PREF, PHPPreferencesMessages
55 .getString("PHPBasePreferencePage.apacheGroup.start"),
57 apacheStartSFE.setPage(this);
58 apacheStartSFE.setPreferenceStore(getPreferenceStore());
59 apacheStartSFE.load();
60 new Label(composite, SWT.NONE);
62 new Label(composite, SWT.NONE);
63 apacheStartBFE = new BooleanFieldEditor(
64 ExternalToolsPlugin.APACHE_START_BACKGROUND,
65 PHPPreferencesMessages
66 .getString("PHPBasePreferencePage.apacheGroup.start_background"),
68 apacheStartBFE.setPage(this);
69 apacheStartBFE.setPreferenceStore(getPreferenceStore());
70 apacheStartBFE.load();
71 new Label(composite, SWT.NONE);
73 apacheStopSFE = new StringFieldEditor(
74 ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
75 .getString("PHPBasePreferencePage.apacheGroup.stop"),
77 apacheStopSFE.setPage(this);
78 apacheStopSFE.setPreferenceStore(getPreferenceStore());
80 new Label(composite, SWT.NONE);
82 new Label(composite, SWT.NONE);
83 apacheStopBFE = new BooleanFieldEditor(
84 ExternalToolsPlugin.APACHE_STOP_BACKGROUND,
85 PHPPreferencesMessages
86 .getString("PHPBasePreferencePage.apacheGroup.stop_background"),
88 apacheStopBFE.setPage(this);
89 apacheStopBFE.setPreferenceStore(getPreferenceStore());
91 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);
114 apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF,
115 PHPPreferencesMessages
116 .getString("PHPBasePreferencePage.apacheGroup.run"),
118 apacheRunFFE.setPage(this);
119 apacheRunFFE.setPreferenceStore(getPreferenceStore());
122 httpdConfFFE = new FileFieldEditor(
123 ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
124 "Path to httpd.conf:", composite);
125 httpdConfFFE.setPage(this);
126 httpdConfFFE.setPreferenceStore(getPreferenceStore());
129 etcHostsFFE = new FileFieldEditor(
130 ExternalToolsPlugin.ETC_HOSTS_PATH_PREF, "Path to etc/hosts:",
132 etcHostsFFE.setPage(this);
133 etcHostsFFE.setPreferenceStore(getPreferenceStore());
139 public void init(IWorkbench workbench) {
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();
155 public boolean performOk() {
156 apacheStartSFE.store();
157 apacheStopSFE.store();
158 apacheRestartSFE.store();
159 apacheRunFFE.store();
160 httpdConfFFE.store();
162 apacheStartBFE.store();
163 apacheStopBFE.store();
164 apacheRestartBFE.store();
165 return super.performOk();