63179efa77d9671733d9e8fd29ac1ff6bf3b0257
[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     //Create apache
107     Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
108     apacheSettingsComposite.setLayout(new GridLayout());
109     apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
110     Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
111     apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
112     apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
113     apacheSettingsGroup.setLayout(new GridLayout());
114
115     
116     xamppStartSFE = new StringFieldEditor(ExternalToolsPlugin.XAMPP_START_PREF, PHPPreferencesMessages
117         .getString("PHPBasePreferencePage.apacheGroup.xampp_start"), apacheSettingsGroup);
118     xamppStartSFE.setPreferencePage(this);
119     xamppStartSFE.setPreferenceStore(getPreferenceStore());
120     xamppStartSFE.load();
121     new Label(apacheSettingsGroup, SWT.NONE);
122     
123     xamppStopSFE = new StringFieldEditor(ExternalToolsPlugin.XAMPP_STOP_PREF, PHPPreferencesMessages
124         .getString("PHPBasePreferencePage.apacheGroup.xampp_stop"), apacheSettingsGroup);
125     xamppStopSFE.setPreferencePage(this);
126     xamppStopSFE.setPreferenceStore(getPreferenceStore());
127     xamppStopSFE.load();
128     new Label(apacheSettingsGroup, SWT.NONE);
129     
130     apacheStartBFE = new BooleanFieldEditor(ExternalToolsPlugin.APACHE_START_BACKGROUND, PHPPreferencesMessages
131         .getString("PHPBasePreferencePage.apacheGroup.start_background"), apacheSettingsGroup);
132     apacheStartBFE.setPreferencePage(this);
133     apacheStartBFE.setPreferenceStore(getPreferenceStore());
134     apacheStartBFE.load();
135
136     new Label(apacheSettingsGroup, SWT.NONE);
137     new Label(apacheSettingsGroup, SWT.NONE);
138     apacheStartSFE = new StringFieldEditor(ExternalToolsPlugin.APACHE_START_PREF, PHPPreferencesMessages
139         .getString("PHPBasePreferencePage.apacheGroup.start"), apacheSettingsGroup);
140     apacheStartSFE.setPreferencePage(this);
141     apacheStartSFE.setPreferenceStore(getPreferenceStore());
142     apacheStartSFE.load();
143     new Label(apacheSettingsGroup, SWT.NONE);
144
145     apacheStopBFE = new BooleanFieldEditor(ExternalToolsPlugin.APACHE_STOP_BACKGROUND, PHPPreferencesMessages
146         .getString("PHPBasePreferencePage.apacheGroup.stop_background"), apacheSettingsGroup);
147     apacheStopBFE.setPreferencePage(this);
148     apacheStopBFE.setPreferenceStore(getPreferenceStore());
149     apacheStopBFE.load();
150     new Label(apacheSettingsGroup, SWT.NONE);
151     new Label(apacheSettingsGroup, SWT.NONE);
152     apacheStopSFE = new StringFieldEditor(ExternalToolsPlugin.APACHE_STOP_PREF, PHPPreferencesMessages
153         .getString("PHPBasePreferencePage.apacheGroup.stop"), apacheSettingsGroup);
154     apacheStopSFE.setPreferencePage(this);
155     apacheStopSFE.setPreferenceStore(getPreferenceStore());
156     apacheStopSFE.load();
157     new Label(apacheSettingsGroup, SWT.NONE);
158
159     apacheRestartBFE = new BooleanFieldEditor(ExternalToolsPlugin.APACHE_RESTART_BACKGROUND, PHPPreferencesMessages
160         .getString("PHPBasePreferencePage.apacheGroup.restart_background"), apacheSettingsGroup);
161     apacheRestartBFE.setPreferencePage(this);
162     apacheRestartBFE.setPreferenceStore(getPreferenceStore());
163     apacheRestartBFE.load();
164     new Label(apacheSettingsGroup, SWT.NONE);
165     new Label(apacheSettingsGroup, SWT.NONE);
166     apacheRestartSFE = new StringFieldEditor(ExternalToolsPlugin.APACHE_RESTART_PREF, PHPPreferencesMessages
167         .getString("PHPBasePreferencePage.apacheGroup.restart"), apacheSettingsGroup);
168     apacheRestartSFE.setPreferencePage(this);
169     apacheRestartSFE.setPreferenceStore(getPreferenceStore());
170     apacheRestartSFE.load();
171     new Label(apacheSettingsGroup, SWT.NONE);
172
173     apacheRunFFE = new FileFieldEditor(ExternalToolsPlugin.APACHE_RUN_PREF, PHPPreferencesMessages
174         .getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
175     apacheRunFFE.setPreferencePage(this);
176     apacheRunFFE.setPreferenceStore(getPreferenceStore());
177     apacheRunFFE.load();
178
179     phpRunFFE = new FileFieldEditor(ExternalToolsPlugin.PHP_RUN_PREF, PHPPreferencesMessages
180         .getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
181     phpRunFFE.setPreferencePage(this);
182     phpRunFFE.setPreferenceStore(getPreferenceStore());
183     phpRunFFE.load();
184
185     //Create mySQL
186     Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
187     mySQLSettingsComposite.setLayout(new GridLayout());
188     mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
189
190     Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
191     mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
192     mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
193     mySQLSettingsGroup.setLayout(new GridLayout());
194
195     mysqlStartBFE = new BooleanFieldEditor(ExternalToolsPlugin.MYSQL_START_BACKGROUND, PHPPreferencesMessages
196         .getString("PHPBasePreferencePage.mySQLGroup.start_background"), mySQLSettingsGroup);
197     mysqlStartBFE.setPreferencePage(this);
198     mysqlStartBFE.setPreferenceStore(getPreferenceStore());
199     mysqlStartBFE.load();
200     new Label(mySQLSettingsGroup, SWT.NONE);
201     new Label(mySQLSettingsGroup, SWT.NONE);
202
203     mySQLCommandSFE = new StringFieldEditor(ExternalToolsPlugin.MYSQL_PREF, PHPPreferencesMessages
204         .getString("PHPBasePreferencePage.mySQLGroup.command"), mySQLSettingsGroup);
205     mySQLCommandSFE.setPreferencePage(this);
206     mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
207     mySQLCommandSFE.load();
208     new Label(mySQLSettingsGroup, SWT.NONE);
209
210     mysqlRunFFE = new FileFieldEditor(ExternalToolsPlugin.MYSQL_RUN_PREF, PHPPreferencesMessages
211         .getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
212     mysqlRunFFE.setPreferencePage(this);
213     mysqlRunFFE.setPreferenceStore(getPreferenceStore());
214     mysqlRunFFE.load();
215     
216     Composite parserSettingsComposite = new Composite(composite, SWT.NULL);
217     parserSettingsComposite.setLayout(new GridLayout());
218     parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
219     
220     Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
221     parserSettingsGroup.setText("External parser command");
222     parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
223     parserSettingsGroup.setLayout(new GridLayout());
224     
225     externalParserSFE =
226       new StringFieldEditor(
227         ExternalToolsPlugin.EXTERNAL_PARSER_PREF,
228         PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
229         parserSettingsGroup
230     );
231     externalParserSFE.setPreferencePage(this);
232     externalParserSFE.setPreferenceStore(getPreferenceStore());
233     externalParserSFE.load();
234     
235     return composite;
236   }
237 }