Created a separated 'externaltools' plugin
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPEclipseBasePreferencePage.java
1 package net.sourceforge.phpeclipse;
2
3 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
4 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
5
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;
20
21 public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
22
23   StringFieldEditor phpParserExtensionsSFE;
24   FileFieldEditor xamppStartSFE;
25   FileFieldEditor xamppStopSFE;
26   StringFieldEditor apacheStartSFE;
27
28   StringFieldEditor apacheStopSFE;
29
30   StringFieldEditor apacheRestartSFE;
31
32   StringFieldEditor mySQLCommandSFE;
33
34   FileFieldEditor apacheRunFFE;
35
36   FileFieldEditor httpdConfFFE;
37
38   FileFieldEditor etcHostsFFE;
39
40   FileFieldEditor mysqlRunFFE;
41
42   FileFieldEditor phpRunFFE;
43
44   BooleanFieldEditor apacheStartBFE;
45
46   BooleanFieldEditor apacheStopBFE;
47
48   BooleanFieldEditor apacheRestartBFE;
49
50   BooleanFieldEditor mysqlStartBFE;
51
52   public PHPEclipseBasePreferencePage() {
53     super();
54     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
55     setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
56   }
57
58   public void init(IWorkbench workbench) {
59   }
60
61   protected void performDefaults() {
62     phpParserExtensionsSFE.loadDefault();
63     xamppStartSFE.loadDefault();
64     xamppStopSFE.loadDefault();
65     apacheStartSFE.loadDefault();
66     apacheStopSFE.loadDefault();
67     apacheRestartSFE.loadDefault();
68     mySQLCommandSFE.loadDefault();
69     phpRunFFE.loadDefault();
70     apacheRunFFE.loadDefault();
71     httpdConfFFE.loadDefault();
72     etcHostsFFE.loadDefault();
73     mysqlRunFFE.loadDefault();
74     apacheStartBFE.loadDefault();
75     apacheStopBFE.loadDefault();
76     apacheRestartBFE.loadDefault();
77     mysqlStartBFE.loadDefault();
78     super.performDefaults();
79   }
80
81   public boolean performOk() {
82     PHPFileUtil.setExtensions(null); 
83     phpParserExtensionsSFE.store();
84     xamppStartSFE.store();
85     xamppStopSFE.store();
86     apacheStartSFE.store();
87     apacheStopSFE.store();
88     apacheRestartSFE.store();
89     mySQLCommandSFE.store();
90     phpRunFFE.store();
91     apacheRunFFE.store();
92     httpdConfFFE.store();
93     etcHostsFFE.store();
94     mysqlRunFFE.store();
95
96     apacheStartBFE.store();
97     apacheStopBFE.store();
98     apacheRestartBFE.store();
99     mysqlStartBFE.store();
100     return super.performOk();
101   }
102
103   protected Control createContents(Composite parent) {
104     initializeDialogUnits(parent);
105     final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
106     Composite composite = new Composite(parent, SWT.LEFT);
107     composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
108     composite.setLayout(new GridLayout());
109
110     // allowed PHP file extensions for parsing
111     Composite phpParserExtensionsComposite = new Composite(composite, SWT.NULL);
112     phpParserExtensionsComposite.setLayout(new GridLayout());
113     phpParserExtensionsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
114     phpParserExtensionsSFE = new StringFieldEditor(IPreferenceConstants.PHP_EXTENSION_PREFS, PHPPreferencesMessages
115         .getString("PHPBasePreferencePage.phpExtensionPrefs"), phpParserExtensionsComposite);
116     phpParserExtensionsSFE.setPreferencePage(this);
117     phpParserExtensionsSFE.setPreferenceStore(getPreferenceStore());
118     phpParserExtensionsSFE.load();
119     
120     //Create apache
121     Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
122     apacheSettingsComposite.setLayout(new GridLayout());
123     apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
124     Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
125     apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
126     apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
127     apacheSettingsGroup.setLayout(new GridLayout());
128
129     xamppStartSFE = new FileFieldEditor(IPreferenceConstants.XAMPP_START_PREF, PHPPreferencesMessages
130         .getString("PHPBasePreferencePage.apacheGroup.xampp_start"), apacheSettingsGroup);
131     xamppStartSFE.setPreferencePage(this);
132     xamppStartSFE.setPreferenceStore(getPreferenceStore());
133     xamppStartSFE.load();
134     
135     xamppStopSFE = new FileFieldEditor(IPreferenceConstants.XAMPP_STOP_PREF, PHPPreferencesMessages
136         .getString("PHPBasePreferencePage.apacheGroup.xampp_stop"), apacheSettingsGroup);
137     xamppStopSFE.setPreferencePage(this);
138     xamppStopSFE.setPreferenceStore(getPreferenceStore());
139     xamppStopSFE.load();
140     
141     apacheStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_START_BACKGROUND, PHPPreferencesMessages
142         .getString("PHPBasePreferencePage.apacheGroup.start_background"), apacheSettingsGroup);
143     apacheStartBFE.setPreferencePage(this);
144     apacheStartBFE.setPreferenceStore(getPreferenceStore());
145     apacheStartBFE.load();
146
147     new Label(apacheSettingsGroup, SWT.NONE);
148     new Label(apacheSettingsGroup, SWT.NONE);
149     apacheStartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_START_PREF, PHPPreferencesMessages
150         .getString("PHPBasePreferencePage.apacheGroup.start"), apacheSettingsGroup);
151     apacheStartSFE.setPreferencePage(this);
152     apacheStartSFE.setPreferenceStore(getPreferenceStore());
153     apacheStartSFE.load();
154     new Label(apacheSettingsGroup, SWT.NONE);
155
156     apacheStopBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_STOP_BACKGROUND, PHPPreferencesMessages
157         .getString("PHPBasePreferencePage.apacheGroup.stop_background"), apacheSettingsGroup);
158     apacheStopBFE.setPreferencePage(this);
159     apacheStopBFE.setPreferenceStore(getPreferenceStore());
160     apacheStopBFE.load();
161     new Label(apacheSettingsGroup, SWT.NONE);
162     new Label(apacheSettingsGroup, SWT.NONE);
163     apacheStopSFE = new StringFieldEditor(IPreferenceConstants.APACHE_STOP_PREF, PHPPreferencesMessages
164         .getString("PHPBasePreferencePage.apacheGroup.stop"), apacheSettingsGroup);
165     apacheStopSFE.setPreferencePage(this);
166     apacheStopSFE.setPreferenceStore(getPreferenceStore());
167     apacheStopSFE.load();
168     new Label(apacheSettingsGroup, SWT.NONE);
169
170     apacheRestartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_RESTART_BACKGROUND, PHPPreferencesMessages
171         .getString("PHPBasePreferencePage.apacheGroup.restart_background"), apacheSettingsGroup);
172     apacheRestartBFE.setPreferencePage(this);
173     apacheRestartBFE.setPreferenceStore(getPreferenceStore());
174     apacheRestartBFE.load();
175     new Label(apacheSettingsGroup, SWT.NONE);
176     new Label(apacheSettingsGroup, SWT.NONE);
177     apacheRestartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_RESTART_PREF, PHPPreferencesMessages
178         .getString("PHPBasePreferencePage.apacheGroup.restart"), apacheSettingsGroup);
179     apacheRestartSFE.setPreferencePage(this);
180     apacheRestartSFE.setPreferenceStore(getPreferenceStore());
181     apacheRestartSFE.load();
182     new Label(apacheSettingsGroup, SWT.NONE);
183
184     apacheRunFFE = new FileFieldEditor(IPreferenceConstants.APACHE_RUN_PREF, PHPPreferencesMessages
185         .getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
186     apacheRunFFE.setPreferencePage(this);
187     apacheRunFFE.setPreferenceStore(getPreferenceStore());
188     apacheRunFFE.load();
189
190     httpdConfFFE = new FileFieldEditor(IPreferenceConstants.HTTPD_CONF_PATH_PREF, PHPPreferencesMessages
191             .getString("PHPBasePreferencePage.apacheGroup.httpdconf"), apacheSettingsGroup);
192     httpdConfFFE.setPreferencePage(this);
193     httpdConfFFE.setPreferenceStore(getPreferenceStore());
194     httpdConfFFE.load();
195
196     etcHostsFFE = new FileFieldEditor(IPreferenceConstants.ETC_HOSTS_PATH_PREF, PHPPreferencesMessages
197             .getString("PHPBasePreferencePage.apacheGroup.etchosts"), apacheSettingsGroup);
198     etcHostsFFE.setPreferencePage(this);
199     etcHostsFFE.setPreferenceStore(getPreferenceStore());
200     etcHostsFFE.load();
201
202     phpRunFFE = new FileFieldEditor(IPreferenceConstants.PHP_RUN_PREF, PHPPreferencesMessages
203         .getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
204     phpRunFFE.setPreferencePage(this);
205     phpRunFFE.setPreferenceStore(getPreferenceStore());
206     phpRunFFE.load();
207
208     //Create mySQL
209     Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
210     mySQLSettingsComposite.setLayout(new GridLayout());
211     mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
212
213     Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
214     mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
215     mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
216     mySQLSettingsGroup.setLayout(new GridLayout());
217
218     mysqlStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.MYSQL_START_BACKGROUND, PHPPreferencesMessages
219         .getString("PHPBasePreferencePage.mySQLGroup.start_background"), mySQLSettingsGroup);
220     mysqlStartBFE.setPreferencePage(this);
221     mysqlStartBFE.setPreferenceStore(getPreferenceStore());
222     mysqlStartBFE.load();
223     new Label(mySQLSettingsGroup, SWT.NONE);
224     new Label(mySQLSettingsGroup, SWT.NONE);
225
226     mySQLCommandSFE = new StringFieldEditor(IPreferenceConstants.MYSQL_PREF, PHPPreferencesMessages
227         .getString("PHPBasePreferencePage.mySQLGroup.command"), mySQLSettingsGroup);
228     mySQLCommandSFE.setPreferencePage(this);
229     mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
230     mySQLCommandSFE.load();
231     new Label(mySQLSettingsGroup, SWT.NONE);
232
233     mysqlRunFFE = new FileFieldEditor(IPreferenceConstants.MYSQL_RUN_PREF, PHPPreferencesMessages
234         .getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
235     mysqlRunFFE.setPreferencePage(this);
236     mysqlRunFFE.setPreferenceStore(getPreferenceStore());
237     mysqlRunFFE.load();
238
239     return composite;
240   }
241 }