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