Refactory
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / preferences / MySQLPreferencePage.java
1 package net.sourceforge.phpdt.externaltools.preferences;
2
3 import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
4
5 import org.eclipse.jface.preference.BooleanFieldEditor;
6 import org.eclipse.jface.preference.FileFieldEditor;
7 import org.eclipse.jface.preference.PreferencePage;
8 import org.eclipse.jface.preference.StringFieldEditor;
9 import org.eclipse.swt.SWT;
10 import org.eclipse.swt.layout.GridData;
11 import org.eclipse.swt.layout.GridLayout;
12 import org.eclipse.swt.widgets.Composite;
13 import org.eclipse.swt.widgets.Control;
14 import org.eclipse.swt.widgets.Label;
15 import org.eclipse.ui.IWorkbench;
16 import org.eclipse.ui.IWorkbenchPreferencePage;
17
18 public class MySQLPreferencePage extends PreferencePage implements
19                 IWorkbenchPreferencePage {
20
21         StringFieldEditor mySQLCommandSFE;
22
23         FileFieldEditor mysqlRunFFE;
24
25         BooleanFieldEditor mysqlStartBFE;
26
27         public MySQLPreferencePage() {
28                 super();
29                 setPreferenceStore(ExternalToolsPlugin.getDefault()
30                                 .getPreferenceStore());
31         }
32
33         protected Control createContents(Composite parent) {
34                 initializeDialogUnits(parent);
35                 Composite composite = new Composite(parent, SWT.LEFT);
36                 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
37                 composite.setLayout(new GridLayout());
38
39                 mysqlStartBFE = new BooleanFieldEditor(
40                                 ExternalToolsPlugin.MYSQL_START_BACKGROUND,
41                                 PHPPreferencesMessages
42                                                 .getString("PHPBasePreferencePage.mySQLGroup.start_background"),
43                                 composite);
44                 mysqlStartBFE.setPage(this);
45                 mysqlStartBFE.setPreferenceStore(getPreferenceStore());
46                 mysqlStartBFE.load();
47                 new Label(composite, SWT.NONE);
48                 new Label(composite, SWT.NONE);
49
50                 mySQLCommandSFE = new StringFieldEditor(ExternalToolsPlugin.MYSQL_PREF,
51                                 PHPPreferencesMessages
52                                                 .getString("PHPBasePreferencePage.mySQLGroup.command"),
53                                 composite);
54                 mySQLCommandSFE.setPage(this);
55                 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
56                 mySQLCommandSFE.load();
57                 new Label(composite, SWT.NONE);
58
59                 mysqlRunFFE = new FileFieldEditor(ExternalToolsPlugin.MYSQL_RUN_PREF,
60                                 PHPPreferencesMessages
61                                                 .getString("PHPBasePreferencePage.mySQLGroup.run"),
62                                 composite);
63                 mysqlRunFFE.setPage(this);
64                 mysqlRunFFE.setPreferenceStore(getPreferenceStore());
65                 mysqlRunFFE.load();
66
67                 return composite;
68         }
69
70         public void init(IWorkbench workbench) {
71         }
72
73         protected void performDefaults() {
74                 mySQLCommandSFE.loadDefault();
75                 mysqlRunFFE.loadDefault();
76                 mysqlStartBFE.loadDefault();
77                 super.performDefaults();
78         }
79
80         public boolean performOk() {
81                 mySQLCommandSFE.store();
82                 mysqlRunFFE.store();
83                 mysqlStartBFE.store();
84                 return super.performOk();
85         }
86
87 }