1 package net.sourceforge.phpeclipse;
3 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
4 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
6 import org.eclipse.jface.preference.BooleanFieldEditor;
7 import org.eclipse.jface.preference.FileFieldEditor;
8 import org.eclipse.jface.preference.IPreferenceStore;
9 import org.eclipse.jface.preference.PreferencePage;
10 import org.eclipse.jface.preference.StringFieldEditor;
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.layout.GridData;
13 import org.eclipse.swt.layout.GridLayout;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Group;
17 import org.eclipse.swt.widgets.Label;
18 import org.eclipse.ui.IWorkbench;
19 import org.eclipse.ui.IWorkbenchPreferencePage;
21 public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
23 StringFieldEditor phpParserExtensionsSFE;
24 StringFieldEditor xamppStartSFE;
25 StringFieldEditor xamppStopSFE;
26 StringFieldEditor apacheStartSFE;
28 StringFieldEditor apacheStopSFE;
30 StringFieldEditor apacheRestartSFE;
32 StringFieldEditor mySQLCommandSFE;
34 FileFieldEditor apacheRunFFE;
36 FileFieldEditor mysqlRunFFE;
38 FileFieldEditor phpRunFFE;
40 BooleanFieldEditor apacheStartBFE;
42 BooleanFieldEditor apacheStopBFE;
44 BooleanFieldEditor apacheRestartBFE;
46 BooleanFieldEditor mysqlStartBFE;
48 public PHPEclipseBasePreferencePage() {
50 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
51 setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
54 public void init(IWorkbench workbench) {
57 protected void performDefaults() {
58 phpParserExtensionsSFE.loadDefault();
59 xamppStartSFE.loadDefault();
60 xamppStopSFE.loadDefault();
61 apacheStartSFE.loadDefault();
62 apacheStopSFE.loadDefault();
63 apacheRestartSFE.loadDefault();
64 mySQLCommandSFE.loadDefault();
65 phpRunFFE.loadDefault();
66 apacheRunFFE.loadDefault();
67 mysqlRunFFE.loadDefault();
68 apacheStartBFE.loadDefault();
69 apacheStopBFE.loadDefault();
70 apacheRestartBFE.loadDefault();
71 mysqlStartBFE.loadDefault();
72 super.performDefaults();
75 public boolean performOk() {
76 PHPFileUtil.setExtensins(null);
77 phpParserExtensionsSFE.store();
78 xamppStartSFE.store();
80 apacheStartSFE.store();
81 apacheStopSFE.store();
82 apacheRestartSFE.store();
83 mySQLCommandSFE.store();
88 apacheStartBFE.store();
89 apacheStopBFE.store();
90 apacheRestartBFE.store();
91 mysqlStartBFE.store();
92 return super.performOk();
95 protected Control createContents(Composite parent) {
96 initializeDialogUnits(parent);
97 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
98 Composite composite = new Composite(parent, SWT.LEFT);
99 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
100 composite.setLayout(new GridLayout());
102 // allowed PHP file extensions for parsing
103 Composite phpParserExtensionsComposite = new Composite(composite, SWT.NULL);
104 phpParserExtensionsComposite.setLayout(new GridLayout());
105 phpParserExtensionsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
106 phpParserExtensionsSFE = new StringFieldEditor(IPreferenceConstants.PHP_EXTENSION_PREFS, PHPPreferencesMessages
107 .getString("PHPBasePreferencePage.phpExtensionPrefs"), phpParserExtensionsComposite);
108 phpParserExtensionsSFE.setPreferencePage(this);
109 phpParserExtensionsSFE.setPreferenceStore(getPreferenceStore());
110 phpParserExtensionsSFE.load();
113 Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
114 apacheSettingsComposite.setLayout(new GridLayout());
115 apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
116 Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
117 apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
118 apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
119 apacheSettingsGroup.setLayout(new GridLayout());
122 xamppStartSFE = new StringFieldEditor(IPreferenceConstants.XAMPP_START_PREF, PHPPreferencesMessages
123 .getString("PHPBasePreferencePage.apacheGroup.xampp_start"), apacheSettingsGroup);
124 xamppStartSFE.setPreferencePage(this);
125 xamppStartSFE.setPreferenceStore(getPreferenceStore());
126 xamppStartSFE.load();
127 new Label(apacheSettingsGroup, SWT.NONE);
129 xamppStopSFE = new StringFieldEditor(IPreferenceConstants.XAMPP_STOP_PREF, PHPPreferencesMessages
130 .getString("PHPBasePreferencePage.apacheGroup.xampp_stop"), apacheSettingsGroup);
131 xamppStopSFE.setPreferencePage(this);
132 xamppStopSFE.setPreferenceStore(getPreferenceStore());
134 new Label(apacheSettingsGroup, SWT.NONE);
136 apacheStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_START_BACKGROUND, PHPPreferencesMessages
137 .getString("PHPBasePreferencePage.apacheGroup.start_background"), apacheSettingsGroup);
138 apacheStartBFE.setPreferencePage(this);
139 apacheStartBFE.setPreferenceStore(getPreferenceStore());
140 apacheStartBFE.load();
142 new Label(apacheSettingsGroup, SWT.NONE);
143 new Label(apacheSettingsGroup, SWT.NONE);
144 apacheStartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_START_PREF, PHPPreferencesMessages
145 .getString("PHPBasePreferencePage.apacheGroup.start"), apacheSettingsGroup);
146 apacheStartSFE.setPreferencePage(this);
147 apacheStartSFE.setPreferenceStore(getPreferenceStore());
148 apacheStartSFE.load();
149 new Label(apacheSettingsGroup, SWT.NONE);
151 apacheStopBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_STOP_BACKGROUND, PHPPreferencesMessages
152 .getString("PHPBasePreferencePage.apacheGroup.stop_background"), apacheSettingsGroup);
153 apacheStopBFE.setPreferencePage(this);
154 apacheStopBFE.setPreferenceStore(getPreferenceStore());
155 apacheStopBFE.load();
156 new Label(apacheSettingsGroup, SWT.NONE);
157 new Label(apacheSettingsGroup, SWT.NONE);
158 apacheStopSFE = new StringFieldEditor(IPreferenceConstants.APACHE_STOP_PREF, PHPPreferencesMessages
159 .getString("PHPBasePreferencePage.apacheGroup.stop"), apacheSettingsGroup);
160 apacheStopSFE.setPreferencePage(this);
161 apacheStopSFE.setPreferenceStore(getPreferenceStore());
162 apacheStopSFE.load();
163 new Label(apacheSettingsGroup, SWT.NONE);
165 apacheRestartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_RESTART_BACKGROUND, PHPPreferencesMessages
166 .getString("PHPBasePreferencePage.apacheGroup.restart_background"), apacheSettingsGroup);
167 apacheRestartBFE.setPreferencePage(this);
168 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
169 apacheRestartBFE.load();
170 new Label(apacheSettingsGroup, SWT.NONE);
171 new Label(apacheSettingsGroup, SWT.NONE);
172 apacheRestartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_RESTART_PREF, PHPPreferencesMessages
173 .getString("PHPBasePreferencePage.apacheGroup.restart"), apacheSettingsGroup);
174 apacheRestartSFE.setPreferencePage(this);
175 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
176 apacheRestartSFE.load();
177 new Label(apacheSettingsGroup, SWT.NONE);
179 apacheRunFFE = new FileFieldEditor(IPreferenceConstants.APACHE_RUN_PREF, PHPPreferencesMessages
180 .getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
181 apacheRunFFE.setPreferencePage(this);
182 apacheRunFFE.setPreferenceStore(getPreferenceStore());
185 phpRunFFE = new FileFieldEditor(IPreferenceConstants.PHP_RUN_PREF, PHPPreferencesMessages
186 .getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
187 phpRunFFE.setPreferencePage(this);
188 phpRunFFE.setPreferenceStore(getPreferenceStore());
192 Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
193 mySQLSettingsComposite.setLayout(new GridLayout());
194 mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
196 Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
197 mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
198 mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
199 mySQLSettingsGroup.setLayout(new GridLayout());
201 mysqlStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.MYSQL_START_BACKGROUND, PHPPreferencesMessages
202 .getString("PHPBasePreferencePage.mySQLGroup.start_background"), mySQLSettingsGroup);
203 mysqlStartBFE.setPreferencePage(this);
204 mysqlStartBFE.setPreferenceStore(getPreferenceStore());
205 mysqlStartBFE.load();
206 new Label(mySQLSettingsGroup, SWT.NONE);
207 new Label(mySQLSettingsGroup, SWT.NONE);
209 mySQLCommandSFE = new StringFieldEditor(IPreferenceConstants.MYSQL_PREF, PHPPreferencesMessages
210 .getString("PHPBasePreferencePage.mySQLGroup.command"), mySQLSettingsGroup);
211 mySQLCommandSFE.setPreferencePage(this);
212 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
213 mySQLCommandSFE.load();
214 new Label(mySQLSettingsGroup, SWT.NONE);
216 mysqlRunFFE = new FileFieldEditor(IPreferenceConstants.MYSQL_RUN_PREF, PHPPreferencesMessages
217 .getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
218 mysqlRunFFE.setPreferencePage(this);
219 mysqlRunFFE.setPreferenceStore(getPreferenceStore());