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);
71 apacheStopSFE = new StringFieldEditor(
72 ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
73 .getString("PHPBasePreferencePage.apacheGroup.stop"),
75 apacheStopSFE.setPage(this);
76 apacheStopSFE.setPreferenceStore(getPreferenceStore());
78 new Label(composite, SWT.NONE);
80 new Label(composite, SWT.NONE);
81 apacheStopBFE = new BooleanFieldEditor(
82 ExternalToolsPlugin.APACHE_STOP_BACKGROUND,
83 PHPPreferencesMessages
84 .getString("PHPBasePreferencePage.apacheGroup.stop_background"),
86 apacheStopBFE.setPage(this);
87 apacheStopBFE.setPreferenceStore(getPreferenceStore());
89 new Label(composite, SWT.NONE);
91 apacheRestartSFE = new StringFieldEditor(
92 ExternalToolsPlugin.APACHE_RESTART_PREF,
93 PHPPreferencesMessages
94 .getString("PHPBasePreferencePage.apacheGroup.restart"),
96 apacheRestartSFE.setPage(this);
97 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
98 apacheRestartSFE.load();
99 new Label(composite, SWT.NONE);
101 new Label(composite, SWT.NONE);
102 apacheRestartBFE = new BooleanFieldEditor(
103 ExternalToolsPlugin.APACHE_RESTART_BACKGROUND,
104 PHPPreferencesMessages
105 .getString("PHPBasePreferencePage.apacheGroup.restart_background"),
107 apacheRestartBFE.setPage(this);
108 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
109 apacheRestartBFE.load();
110 new Label(composite, SWT.NONE);
112 apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF,
113 PHPPreferencesMessages
114 .getString("PHPBasePreferencePage.apacheGroup.run"),
116 apacheRunFFE.setPage(this);
117 apacheRunFFE.setPreferenceStore(getPreferenceStore());
120 httpdConfFFE = new FileFieldEditor(
121 ExternalToolsPlugin.HTTPD_CONF_PATH_PREF,
122 "Path to httpd.conf:", composite);
123 httpdConfFFE.setPage(this);
124 httpdConfFFE.setPreferenceStore(getPreferenceStore());
127 etcHostsFFE = new FileFieldEditor(
128 ExternalToolsPlugin.ETC_HOSTS_PATH_PREF, "Path to etc/hosts:",
130 etcHostsFFE.setPage(this);
131 etcHostsFFE.setPreferenceStore(getPreferenceStore());
137 public void init(IWorkbench workbench) {
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();
153 public boolean performOk() {
154 apacheStartSFE.store();
155 apacheStopSFE.store();
156 apacheRestartSFE.store();
157 apacheRunFFE.store();
158 httpdConfFFE.store();
160 apacheStartBFE.store();
161 apacheStopBFE.store();
162 apacheRestartBFE.store();
163 return super.performOk();