improved code formatter
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPEclipseParserPreferencePage.java
1 package net.sourceforge.phpeclipse;
2
3 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
4
5 import org.eclipse.jface.preference.IPreferenceStore;
6 import org.eclipse.jface.preference.PreferencePage;
7 import org.eclipse.jface.preference.RadioGroupFieldEditor;
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.Group;
15 import org.eclipse.ui.IWorkbench;
16 import org.eclipse.ui.IWorkbenchPreferencePage;
17
18 public class PHPEclipseParserPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
19
20 //  private SelectionListener SelectionListener;
21 //  private ModifyListener ModifyListener;
22 //  private ModifyListener TextModifyListener;
23 //
24 //  private ArrayList CheckBoxes = new ArrayList();
25 //  private ArrayList ComboBoxes = new ArrayList();
26 //  private ArrayList TextBoxes = new ArrayList();
27 //  private ArrayList RadioButtons = new ArrayList();
28
29
30   RadioGroupFieldEditor chooseParser;
31   StringFieldEditor externalParserSFE;
32  // BooleanFieldEditor parseOnSave;
33
34   public PHPEclipseParserPreferencePage() {
35     super();
36     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
37     setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
38   }
39   public void init(IWorkbench workbench) {
40   }
41   protected void performDefaults() {
42     chooseParser.loadDefault();
43     externalParserSFE.loadDefault();
44 //    parseOnSave.loadDefault();
45     super.performDefaults();
46   }
47
48   public boolean performOk() {
49     chooseParser.store();
50     externalParserSFE.store();
51 //    parseOnSave.store();
52     return super.performOk();
53   }
54
55   protected Control createContents(Composite parent) {
56     initializeDialogUnits(parent);
57     final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
58     Composite composite = new Composite(parent, SWT.LEFT);
59     composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
60     composite.setLayout(new GridLayout());
61     //Create Websettings
62     //    Composite webSettingsComposite = new Composite(composite, SWT.NONE);
63     //    webSettingsComposite.setLayout(new GridLayout());
64     //    webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
65
66     //Create parser settings composite
67     Composite parserSettingsComposite = new Composite(composite, SWT.NONE);
68     parserSettingsComposite.setLayout(new GridLayout());
69     parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
70     Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
71     parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers"));
72     parserSettingsGroup.setLayout(new GridLayout());
73     parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
74
75     chooseParser =
76       new RadioGroupFieldEditor(
77         IPreferenceConstants.PHP_PARSER_DEFAULT,
78         PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"),
79         1,
80         new String[][] {
81           { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER },
82           {
83         PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER }
84     }, parserSettingsGroup);
85     chooseParser.setPreferencePage(this);
86     chooseParser.setPreferenceStore(getPreferenceStore());
87     chooseParser.load();
88     //create a copmposte just for the StringEditor - makes layout simpler
89     Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE);
90     externalParserSFE =
91       new StringFieldEditor(
92         IPreferenceConstants.EXTERNAL_PARSER_PREF,
93         PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
94         externalParserCompo
95     /*parserSettingsGroup*/
96     );
97     externalParserSFE.setPreferencePage(this);
98     externalParserSFE.setPreferenceStore(getPreferenceStore());
99     externalParserSFE.load();
100
101 //    parseOnSave =
102 //      new BooleanFieldEditor(
103 //        PHPeclipsePlugin.PHP_PARSE_ON_SAVE,
104 //        PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"),
105 //        parserSettingsGroup);
106 //    parseOnSave.setPreferencePage(this);
107 //    parseOnSave.setPreferenceStore(getPreferenceStore());
108 //    parseOnSave.load();
109
110     return composite;
111   }
112 }