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;
25 StringFieldEditor apacheStartSFE;
27 StringFieldEditor apacheStopSFE;
29 StringFieldEditor apacheRestartSFE;
31 StringFieldEditor mySQLCommandSFE;
33 FileFieldEditor apacheRunFFE;
35 FileFieldEditor mysqlRunFFE;
37 FileFieldEditor phpRunFFE;
39 BooleanFieldEditor apacheStartBFE;
41 BooleanFieldEditor apacheStopBFE;
43 BooleanFieldEditor apacheRestartBFE;
45 BooleanFieldEditor mysqlStartBFE;
47 public PHPEclipseBasePreferencePage() {
49 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
50 setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
53 public void init(IWorkbench workbench) {
56 protected void performDefaults() {
57 phpParserExtensionsSFE.loadDefault();
58 apacheStartSFE.loadDefault();
59 apacheStopSFE.loadDefault();
60 apacheRestartSFE.loadDefault();
61 mySQLCommandSFE.loadDefault();
62 phpRunFFE.loadDefault();
63 apacheRunFFE.loadDefault();
64 mysqlRunFFE.loadDefault();
65 apacheStartBFE.loadDefault();
66 apacheStopBFE.loadDefault();
67 apacheRestartBFE.loadDefault();
68 mysqlStartBFE.loadDefault();
69 super.performDefaults();
72 public boolean performOk() {
73 PHPFileUtil.setExtensins(null);
74 phpParserExtensionsSFE.store();
75 apacheStartSFE.store();
76 apacheStopSFE.store();
77 apacheRestartSFE.store();
78 mySQLCommandSFE.store();
83 apacheStartBFE.store();
84 apacheStopBFE.store();
85 apacheRestartBFE.store();
86 mysqlStartBFE.store();
87 return super.performOk();
90 protected Control createContents(Composite parent) {
91 initializeDialogUnits(parent);
92 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
93 Composite composite = new Composite(parent, SWT.LEFT);
94 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
95 composite.setLayout(new GridLayout());
97 // allowed PHP file extensions for parsing
98 Composite phpParserExtensionsComposite = new Composite(composite, SWT.NULL);
99 phpParserExtensionsComposite.setLayout(new GridLayout());
100 phpParserExtensionsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
101 phpParserExtensionsSFE = new StringFieldEditor(IPreferenceConstants.PHP_EXTENSION_PREFS, PHPPreferencesMessages
102 .getString("PHPBasePreferencePage.phpExtensionPrefs"), phpParserExtensionsComposite);
103 phpParserExtensionsSFE.setPreferencePage(this);
104 phpParserExtensionsSFE.setPreferenceStore(getPreferenceStore());
105 phpParserExtensionsSFE.load();
108 Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
109 apacheSettingsComposite.setLayout(new GridLayout());
110 apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
111 Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
112 apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
113 apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
114 apacheSettingsGroup.setLayout(new GridLayout());
116 apacheStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_START_BACKGROUND, PHPPreferencesMessages
117 .getString("PHPBasePreferencePage.apacheGroup.start_background"), apacheSettingsGroup);
118 apacheStartBFE.setPreferencePage(this);
119 apacheStartBFE.setPreferenceStore(getPreferenceStore());
120 apacheStartBFE.load();
122 new Label(apacheSettingsGroup, SWT.NONE);
123 new Label(apacheSettingsGroup, SWT.NONE);
124 apacheStartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_START_PREF, PHPPreferencesMessages
125 .getString("PHPBasePreferencePage.apacheGroup.start"), apacheSettingsGroup);
126 apacheStartSFE.setPreferencePage(this);
127 apacheStartSFE.setPreferenceStore(getPreferenceStore());
128 apacheStartSFE.load();
129 new Label(apacheSettingsGroup, SWT.NONE);
131 apacheStopBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_STOP_BACKGROUND, PHPPreferencesMessages
132 .getString("PHPBasePreferencePage.apacheGroup.stop_background"), apacheSettingsGroup);
133 apacheStopBFE.setPreferencePage(this);
134 apacheStopBFE.setPreferenceStore(getPreferenceStore());
135 apacheStopBFE.load();
136 new Label(apacheSettingsGroup, SWT.NONE);
137 new Label(apacheSettingsGroup, SWT.NONE);
138 apacheStopSFE = new StringFieldEditor(IPreferenceConstants.APACHE_STOP_PREF, PHPPreferencesMessages
139 .getString("PHPBasePreferencePage.apacheGroup.stop"), apacheSettingsGroup);
140 apacheStopSFE.setPreferencePage(this);
141 apacheStopSFE.setPreferenceStore(getPreferenceStore());
142 apacheStopSFE.load();
143 new Label(apacheSettingsGroup, SWT.NONE);
145 apacheRestartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_RESTART_BACKGROUND, PHPPreferencesMessages
146 .getString("PHPBasePreferencePage.apacheGroup.restart_background"), apacheSettingsGroup);
147 apacheRestartBFE.setPreferencePage(this);
148 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
149 apacheRestartBFE.load();
150 new Label(apacheSettingsGroup, SWT.NONE);
151 new Label(apacheSettingsGroup, SWT.NONE);
152 apacheRestartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_RESTART_PREF, PHPPreferencesMessages
153 .getString("PHPBasePreferencePage.apacheGroup.restart"), apacheSettingsGroup);
154 apacheRestartSFE.setPreferencePage(this);
155 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
156 apacheRestartSFE.load();
157 new Label(apacheSettingsGroup, SWT.NONE);
159 apacheRunFFE = new FileFieldEditor(IPreferenceConstants.APACHE_RUN_PREF, PHPPreferencesMessages
160 .getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
161 apacheRunFFE.setPreferencePage(this);
162 apacheRunFFE.setPreferenceStore(getPreferenceStore());
165 phpRunFFE = new FileFieldEditor(IPreferenceConstants.PHP_RUN_PREF, PHPPreferencesMessages
166 .getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
167 phpRunFFE.setPreferencePage(this);
168 phpRunFFE.setPreferenceStore(getPreferenceStore());
172 Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
173 mySQLSettingsComposite.setLayout(new GridLayout());
174 mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
176 Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
177 mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
178 mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
179 mySQLSettingsGroup.setLayout(new GridLayout());
181 mysqlStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.MYSQL_START_BACKGROUND, PHPPreferencesMessages
182 .getString("PHPBasePreferencePage.mySQLGroup.start_background"), mySQLSettingsGroup);
183 mysqlStartBFE.setPreferencePage(this);
184 mysqlStartBFE.setPreferenceStore(getPreferenceStore());
185 mysqlStartBFE.load();
186 new Label(mySQLSettingsGroup, SWT.NONE);
187 new Label(mySQLSettingsGroup, SWT.NONE);
189 mySQLCommandSFE = new StringFieldEditor(IPreferenceConstants.MYSQL_PREF, PHPPreferencesMessages
190 .getString("PHPBasePreferencePage.mySQLGroup.command"), mySQLSettingsGroup);
191 mySQLCommandSFE.setPreferencePage(this);
192 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
193 mySQLCommandSFE.load();
194 new Label(mySQLSettingsGroup, SWT.NONE);
196 mysqlRunFFE = new FileFieldEditor(IPreferenceConstants.MYSQL_RUN_PREF, PHPPreferencesMessages
197 .getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
198 mysqlRunFFE.setPreferencePage(this);
199 mysqlRunFFE.setPreferenceStore(getPreferenceStore());