Fixed bug for stacktrace:
[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   StringFieldEditor xamppStartSFE;
25   StringFieldEditor xamppStopSFE;
26   StringFieldEditor apacheStartSFE;
27
28   StringFieldEditor apacheStopSFE;
29
30   StringFieldEditor apacheRestartSFE;
31
32   StringFieldEditor mySQLCommandSFE;
33
34   FileFieldEditor apacheRunFFE;
35
36   FileFieldEditor mysqlRunFFE;
37
38   FileFieldEditor phpRunFFE;
39
40   BooleanFieldEditor apacheStartBFE;
41
42   BooleanFieldEditor apacheStopBFE;
43
44   BooleanFieldEditor apacheRestartBFE;
45
46   BooleanFieldEditor mysqlStartBFE;
47
48   public PHPEclipseBasePreferencePage() {
49     super();
50     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
51     setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
52   }
53
54   public void init(IWorkbench workbench) {
55   }
56
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();
73   }
74
75   public boolean performOk() {
76     PHPFileUtil.setExtensions(null); 
77     phpParserExtensionsSFE.store();
78     xamppStartSFE.store();
79     xamppStopSFE.store();
80     apacheStartSFE.store();
81     apacheStopSFE.store();
82     apacheRestartSFE.store();
83     mySQLCommandSFE.store();
84     phpRunFFE.store();
85     apacheRunFFE.store();
86     mysqlRunFFE.store();
87
88     apacheStartBFE.store();
89     apacheStopBFE.store();
90     apacheRestartBFE.store();
91     mysqlStartBFE.store();
92     return super.performOk();
93   }
94
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());
101
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();
111     
112     //Create apache
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());
120
121     
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);
128     
129     xamppStopSFE = new StringFieldEditor(IPreferenceConstants.XAMPP_STOP_PREF, PHPPreferencesMessages
130         .getString("PHPBasePreferencePage.apacheGroup.xampp_stop"), apacheSettingsGroup);
131     xamppStopSFE.setPreferencePage(this);
132     xamppStopSFE.setPreferenceStore(getPreferenceStore());
133     xamppStopSFE.load();
134     new Label(apacheSettingsGroup, SWT.NONE);
135     
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();
141
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);
150
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);
164
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);
178
179     apacheRunFFE = new FileFieldEditor(IPreferenceConstants.APACHE_RUN_PREF, PHPPreferencesMessages
180         .getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
181     apacheRunFFE.setPreferencePage(this);
182     apacheRunFFE.setPreferenceStore(getPreferenceStore());
183     apacheRunFFE.load();
184
185     phpRunFFE = new FileFieldEditor(IPreferenceConstants.PHP_RUN_PREF, PHPPreferencesMessages
186         .getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
187     phpRunFFE.setPreferencePage(this);
188     phpRunFFE.setPreferenceStore(getPreferenceStore());
189     phpRunFFE.load();
190
191     //Create mySQL
192     Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
193     mySQLSettingsComposite.setLayout(new GridLayout());
194     mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
195
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());
200
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);
208
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);
215
216     mysqlRunFFE = new FileFieldEditor(IPreferenceConstants.MYSQL_RUN_PREF, PHPPreferencesMessages
217         .getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
218     mysqlRunFFE.setPreferencePage(this);
219     mysqlRunFFE.setPreferenceStore(getPreferenceStore());
220     mysqlRunFFE.load();
221
222     return composite;
223   }
224 }