KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > preferences > BuildOptionsPreferencePage


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.preferences;
12
13 import org.eclipse.ui.IWorkbench;
14 import org.eclipse.pde.internal.ui.IPreferenceConstants;
15 import org.eclipse.pde.internal.ui.PDEPlugin;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.GridData;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.Button;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.jface.dialogs.Dialog;
23 import org.eclipse.jface.preference.IPreferenceStore;
24 import org.eclipse.jface.preference.PreferencePage;
25 import org.eclipse.ui.IWorkbenchPreferencePage;
26
27 /**
28  * @see PreferencePage
29  */

30 public class BuildOptionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IPreferenceConstants {
31     private IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore();
32     private Button fFailOnError;
33     private Button fVerbose;
34     private Button fDebugInfo;
35
36     /**
37      *
38      */

39     public BuildOptionsPreferencePage() {
40         setDescription(PDEPlugin.getResourceString("BuildPropertiesPreferencePage.desc")); //$NON-NLS-1$
41
}
42
43     /**
44      * @see PreferencePage#init
45      */

46     public void init(IWorkbench workbench) {
47     }
48
49     /**
50      * @see PreferencePage#createContents
51      */

52     protected Control createContents(Composite parent) {
53         Composite composite = new Composite(parent, SWT.NONE);
54         GridLayout layout = new GridLayout();
55         layout.numColumns = 2;
56         layout.marginWidth = 15;
57         composite.setLayout(layout);
58         
59         fFailOnError = new Button(composite, SWT.CHECK);
60         fFailOnError.setText(PDEPlugin.getResourceString("BuildPropertiesPreferencePage.failOnError")); //$NON-NLS-1$
61
fFailOnError.setSelection(store.getBoolean(PROP_JAVAC_FAIL_ON_ERROR));
62         GridData gd = new GridData();
63         gd.horizontalSpan = 2;
64         fFailOnError.setLayoutData(gd);
65         
66         fVerbose = new Button(composite, SWT.CHECK);
67         fVerbose.setText(PDEPlugin.getResourceString("BuildPropertiesPreferencePage.compilerVerbose")); //$NON-NLS-1$
68
fVerbose.setSelection(store.getBoolean(PROP_JAVAC_VERBOSE));
69         gd = new GridData();
70         gd.horizontalSpan = 2;
71         fVerbose.setLayoutData(gd);
72         
73         fDebugInfo = new Button(composite, SWT.CHECK);
74         fDebugInfo.setText(PDEPlugin.getResourceString("BuildPropertiesPreferencePage.compilerDebug")); //$NON-NLS-1$
75
fDebugInfo.setSelection(store.getBoolean(PROP_JAVAC_DEBUG_INFO));
76         gd = new GridData();
77         gd.horizontalSpan = 2;
78         fDebugInfo.setLayoutData(gd);
79         
80         
81         Dialog.applyDialogFont(composite);
82         
83         return composite;
84     }
85     
86     /* (non-Javadoc)
87      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
88      */

89     public boolean performOk() {
90         store.setValue(PROP_JAVAC_FAIL_ON_ERROR, fFailOnError.getSelection());
91         store.setValue(PROP_JAVAC_VERBOSE, fVerbose.getSelection());
92         store.setValue(PROP_JAVAC_DEBUG_INFO, fDebugInfo.getSelection());
93         PDEPlugin.getDefault().savePluginPreferences();
94         return super.performOk();
95     }
96     
97     /* (non-Javadoc)
98      * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
99      */

100     protected void performDefaults() {
101         fFailOnError.setSelection(store.getDefaultBoolean(PROP_JAVAC_FAIL_ON_ERROR));
102         fVerbose.setSelection(store.getDefaultBoolean(PROP_JAVAC_VERBOSE));
103         fDebugInfo.setSelection(store.getDefaultBoolean(PROP_JAVAC_DEBUG_INFO));
104     }
105 }
106
Popular Tags