Merged "Open PHP Declaration" and "Open Include File" into one action "Open Declarati...
[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   
25   StringFieldEditor apacheStartSFE;
26
27   StringFieldEditor apacheStopSFE;
28
29   StringFieldEditor apacheRestartSFE;
30
31   StringFieldEditor mySQLCommandSFE;
32
33   FileFieldEditor apacheRunFFE;
34
35   FileFieldEditor mysqlRunFFE;
36
37   FileFieldEditor phpRunFFE;
38
39   BooleanFieldEditor apacheStartBFE;
40
41   BooleanFieldEditor apacheStopBFE;
42
43   BooleanFieldEditor apacheRestartBFE;
44
45   BooleanFieldEditor mysqlStartBFE;
46
47   public PHPEclipseBasePreferencePage() {
48     super();
49     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
50     setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
51   }
52
53   public void init(IWorkbench workbench) {
54   }
55
56   protected void performDefaults() {
57     phpParserExtensionsSFE.loadDefault();
58     apacheStartSFE.loadDefault();
59     apacheStopSFE.loadDefault();
60     apacheRestartSFE.loadDefault();
61     mySQLCommandSFE.loadDefault();
62     phpRunFFE.loadDefault();
63     apacheRunFFE.loadDefault();
64     mysqlRunFFE.loadDefault();
65     apacheStartBFE.loadDefault();
66     apacheStopBFE.loadDefault();
67     apacheRestartBFE.loadDefault();
68     mysqlStartBFE.loadDefault();
69     super.performDefaults();
70   }
71
72   public boolean performOk() {
73     PHPFileUtil.setExtensins(null); 
74     phpParserExtensionsSFE.store();
75     apacheStartSFE.store();
76     apacheStopSFE.store();
77     apacheRestartSFE.store();
78     mySQLCommandSFE.store();
79     phpRunFFE.store();
80     apacheRunFFE.store();
81     mysqlRunFFE.store();
82
83     apacheStartBFE.store();
84     apacheStopBFE.store();
85     apacheRestartBFE.store();
86     mysqlStartBFE.store();
87     return super.performOk();
88   }
89
90   protected Control createContents(Composite parent) {
91     initializeDialogUnits(parent);
92     final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
93     Composite composite = new Composite(parent, SWT.LEFT);
94     composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
95     composite.setLayout(new GridLayout());
96
97     // allowed PHP file extensions for parsing
98     Composite phpParserExtensionsComposite = new Composite(composite, SWT.NULL);
99     phpParserExtensionsComposite.setLayout(new GridLayout());
100     phpParserExtensionsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
101     phpParserExtensionsSFE = new StringFieldEditor(IPreferenceConstants.PHP_EXTENSION_PREFS, PHPPreferencesMessages
102         .getString("PHPBasePreferencePage.phpExtensionPrefs"), phpParserExtensionsComposite);
103     phpParserExtensionsSFE.setPreferencePage(this);
104     phpParserExtensionsSFE.setPreferenceStore(getPreferenceStore());
105     phpParserExtensionsSFE.load();
106     
107     //Create apache
108     Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
109     apacheSettingsComposite.setLayout(new GridLayout());
110     apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
111     Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
112     apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
113     apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
114     apacheSettingsGroup.setLayout(new GridLayout());
115
116     apacheStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_START_BACKGROUND, PHPPreferencesMessages
117         .getString("PHPBasePreferencePage.apacheGroup.start_background"), apacheSettingsGroup);
118     apacheStartBFE.setPreferencePage(this);
119     apacheStartBFE.setPreferenceStore(getPreferenceStore());
120     apacheStartBFE.load();
121
122     new Label(apacheSettingsGroup, SWT.NONE);
123     new Label(apacheSettingsGroup, SWT.NONE);
124     apacheStartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_START_PREF, PHPPreferencesMessages
125         .getString("PHPBasePreferencePage.apacheGroup.start"), apacheSettingsGroup);
126     apacheStartSFE.setPreferencePage(this);
127     apacheStartSFE.setPreferenceStore(getPreferenceStore());
128     apacheStartSFE.load();
129     new Label(apacheSettingsGroup, SWT.NONE);
130
131     apacheStopBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_STOP_BACKGROUND, PHPPreferencesMessages
132         .getString("PHPBasePreferencePage.apacheGroup.stop_background"), apacheSettingsGroup);
133     apacheStopBFE.setPreferencePage(this);
134     apacheStopBFE.setPreferenceStore(getPreferenceStore());
135     apacheStopBFE.load();
136     new Label(apacheSettingsGroup, SWT.NONE);
137     new Label(apacheSettingsGroup, SWT.NONE);
138     apacheStopSFE = new StringFieldEditor(IPreferenceConstants.APACHE_STOP_PREF, PHPPreferencesMessages
139         .getString("PHPBasePreferencePage.apacheGroup.stop"), apacheSettingsGroup);
140     apacheStopSFE.setPreferencePage(this);
141     apacheStopSFE.setPreferenceStore(getPreferenceStore());
142     apacheStopSFE.load();
143     new Label(apacheSettingsGroup, SWT.NONE);
144
145     apacheRestartBFE = new BooleanFieldEditor(PHPeclipsePlugin.APACHE_RESTART_BACKGROUND, PHPPreferencesMessages
146         .getString("PHPBasePreferencePage.apacheGroup.restart_background"), apacheSettingsGroup);
147     apacheRestartBFE.setPreferencePage(this);
148     apacheRestartBFE.setPreferenceStore(getPreferenceStore());
149     apacheRestartBFE.load();
150     new Label(apacheSettingsGroup, SWT.NONE);
151     new Label(apacheSettingsGroup, SWT.NONE);
152     apacheRestartSFE = new StringFieldEditor(IPreferenceConstants.APACHE_RESTART_PREF, PHPPreferencesMessages
153         .getString("PHPBasePreferencePage.apacheGroup.restart"), apacheSettingsGroup);
154     apacheRestartSFE.setPreferencePage(this);
155     apacheRestartSFE.setPreferenceStore(getPreferenceStore());
156     apacheRestartSFE.load();
157     new Label(apacheSettingsGroup, SWT.NONE);
158
159     apacheRunFFE = new FileFieldEditor(IPreferenceConstants.APACHE_RUN_PREF, PHPPreferencesMessages
160         .getString("PHPBasePreferencePage.apacheGroup.run"), apacheSettingsGroup);
161     apacheRunFFE.setPreferencePage(this);
162     apacheRunFFE.setPreferenceStore(getPreferenceStore());
163     apacheRunFFE.load();
164
165     phpRunFFE = new FileFieldEditor(IPreferenceConstants.PHP_RUN_PREF, PHPPreferencesMessages
166         .getString("PHPBasePreferencePage.console.php"), apacheSettingsGroup);
167     phpRunFFE.setPreferencePage(this);
168     phpRunFFE.setPreferenceStore(getPreferenceStore());
169     phpRunFFE.load();
170
171     //Create mySQL
172     Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
173     mySQLSettingsComposite.setLayout(new GridLayout());
174     mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
175
176     Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
177     mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
178     mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
179     mySQLSettingsGroup.setLayout(new GridLayout());
180
181     mysqlStartBFE = new BooleanFieldEditor(PHPeclipsePlugin.MYSQL_START_BACKGROUND, PHPPreferencesMessages
182         .getString("PHPBasePreferencePage.mySQLGroup.start_background"), mySQLSettingsGroup);
183     mysqlStartBFE.setPreferencePage(this);
184     mysqlStartBFE.setPreferenceStore(getPreferenceStore());
185     mysqlStartBFE.load();
186     new Label(mySQLSettingsGroup, SWT.NONE);
187     new Label(mySQLSettingsGroup, SWT.NONE);
188
189     mySQLCommandSFE = new StringFieldEditor(IPreferenceConstants.MYSQL_PREF, PHPPreferencesMessages
190         .getString("PHPBasePreferencePage.mySQLGroup.command"), mySQLSettingsGroup);
191     mySQLCommandSFE.setPreferencePage(this);
192     mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
193     mySQLCommandSFE.load();
194     new Label(mySQLSettingsGroup, SWT.NONE);
195
196     mysqlRunFFE = new FileFieldEditor(IPreferenceConstants.MYSQL_RUN_PREF, PHPPreferencesMessages
197         .getString("PHPBasePreferencePage.mySQLGroup.run"), mySQLSettingsGroup);
198     mysqlRunFFE.setPreferencePage(this);
199     mysqlRunFFE.setPreferenceStore(getPreferenceStore());
200     mysqlRunFFE.load();
201
202     return composite;
203   }
204 }