1 package net.sourceforge.phpeclipse;
3 import java.util.ArrayList;
5 import org.eclipse.jface.preference.BooleanFieldEditor;
6 import org.eclipse.jface.preference.DirectoryFieldEditor;
7 import org.eclipse.jface.preference.IPreferenceStore;
8 import org.eclipse.jface.preference.PreferencePage;
9 import org.eclipse.jface.preference.RadioGroupFieldEditor;
10 import org.eclipse.jface.preference.StringFieldEditor;
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.events.ModifyListener;
13 import org.eclipse.swt.events.SelectionListener;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.layout.GridLayout;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.swt.widgets.Group;
19 import org.eclipse.ui.IWorkbench;
20 import org.eclipse.ui.IWorkbenchPreferencePage;
22 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
24 public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
26 private SelectionListener SelectionListener;
27 private ModifyListener ModifyListener;
28 private ModifyListener TextModifyListener;
30 private ArrayList CheckBoxes = new ArrayList();
31 private ArrayList ComboBoxes = new ArrayList();
32 private ArrayList TextBoxes = new ArrayList();
33 private ArrayList RadioButtons = new ArrayList();
35 StringFieldEditor localHostSFE;
36 DirectoryFieldEditor documentRootDFE;
37 BooleanFieldEditor externalBrowserBFE;
38 StringFieldEditor externalBrowserSFE;
39 StringFieldEditor apacheStartSFE;
40 StringFieldEditor apacheStopSFE;
41 StringFieldEditor apacheRestartSFE;
42 StringFieldEditor mySQLCommandSFE;
43 RadioGroupFieldEditor chooseParser;
44 BooleanFieldEditor parseOnSave;
46 public PHPEclipseBasePreferencePage() {
48 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
49 setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
51 public void init(IWorkbench workbench) {
53 protected void performDefaults() {
54 localHostSFE.loadDefault();
55 documentRootDFE.loadDefault();
56 externalBrowserBFE.loadDefault();
57 externalBrowserSFE.loadDefault();
58 apacheStartSFE.loadDefault();
59 apacheStopSFE.loadDefault();
60 apacheRestartSFE.loadDefault();
61 mySQLCommandSFE.loadDefault();
62 chooseParser.loadDefault();
63 parseOnSave.loadDefault();
64 super.performDefaults();
67 public boolean performOk() {
69 documentRootDFE.store();
70 externalBrowserBFE.store();
71 externalBrowserSFE.store();
72 apacheStartSFE.store();
73 apacheStopSFE.store();
74 apacheRestartSFE.store();
75 mySQLCommandSFE.store();
78 return super.performOk();
81 protected Control createContents(Composite parent) {
82 initializeDialogUnits(parent);
83 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
84 Composite composite = new Composite(parent, SWT.LEFT);
85 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
86 composite.setLayout(new GridLayout());
88 Composite webSettingsComposite = new Composite(composite, SWT.NONE);
89 webSettingsComposite.setLayout(new GridLayout());
90 webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
91 Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE);
92 webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup"));
93 webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
94 webSettingsGroup.setLayout(new GridLayout());
96 new StringFieldEditor(
97 IPreferenceConstants.LOCALHOST_PREF,
98 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"),
100 localHostSFE.setPreferencePage(this);
101 localHostSFE.setPreferenceStore(getPreferenceStore());
104 new DirectoryFieldEditor(
105 IPreferenceConstants.DOCUMENTROOT_PREF,
106 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"),
108 documentRootDFE.setPreferencePage(this);
109 documentRootDFE.setPreferenceStore(getPreferenceStore());
110 documentRootDFE.load();
112 new BooleanFieldEditor(
113 IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF,
114 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.useexternal"),
116 externalBrowserBFE.setPreferencePage(this);
117 externalBrowserBFE.setPreferenceStore(getPreferenceStore());
118 externalBrowserBFE.load();
120 new StringFieldEditor(
121 IPreferenceConstants.EXTERNAL_BROWSER_PREF,
122 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.browser"),
124 externalBrowserSFE.setPreferencePage(this);
125 externalBrowserSFE.setPreferenceStore(getPreferenceStore());
126 externalBrowserSFE.load();
129 Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
130 apacheSettingsComposite.setLayout(new GridLayout());
131 apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
132 Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
133 apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
134 apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
135 apacheSettingsGroup.setLayout(new GridLayout());
137 new StringFieldEditor(
138 IPreferenceConstants.APACHE_START_PREF,
139 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start"),
140 apacheSettingsGroup);
141 apacheStartSFE.setPreferencePage(this);
142 apacheStartSFE.setPreferenceStore(getPreferenceStore());
143 apacheStartSFE.load();
145 new StringFieldEditor(
146 IPreferenceConstants.APACHE_STOP_PREF,
147 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop"),
148 apacheSettingsGroup);
149 apacheStopSFE.setPreferencePage(this);
150 apacheStopSFE.setPreferenceStore(getPreferenceStore());
151 apacheStopSFE.load();
153 new StringFieldEditor(
154 IPreferenceConstants.APACHE_RESTART_PREF,
155 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart"),
156 apacheSettingsGroup);
157 apacheRestartSFE.setPreferencePage(this);
158 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
159 apacheRestartSFE.load();
162 Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
163 mySQLSettingsComposite.setLayout(new GridLayout());
164 mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
166 Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
167 mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
168 mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
169 mySQLSettingsGroup.setLayout(new GridLayout());
171 new StringFieldEditor(
172 IPreferenceConstants.MYSQL_PREF,
173 PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.command"),
175 mySQLCommandSFE.setPreferencePage(this);
176 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
177 mySQLCommandSFE.load();
179 //Create parser settings composite
180 Composite parserSettingsComposite = new Composite(composite, SWT.NONE);
181 parserSettingsComposite.setLayout(new GridLayout());
182 parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
183 Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
184 parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers"));
185 parserSettingsGroup.setLayout(new GridLayout());
186 parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
189 new RadioGroupFieldEditor(
190 IPreferenceConstants.PHP_PARSER_DEFAULT,
191 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"),
194 { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER },
196 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER }
197 }, parserSettingsGroup);
198 chooseParser.setPreferencePage(this);
199 chooseParser.setPreferenceStore(getPreferenceStore());
201 parseOnSave = new BooleanFieldEditor(PHPeclipsePlugin.PHP_PARSE_ON_SAVE, "&Parse automatically on save", parserSettingsGroup);
202 parseOnSave.setPreferencePage(this);
203 parseOnSave.setPreferenceStore(getPreferenceStore());