KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > JavaPrimitivesPreferencePage


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

11 package org.eclipse.jdt.internal.debug.ui;
12
13  
14 import java.util.ArrayList JavaDoc;
15 import java.util.Iterator JavaDoc;
16 import java.util.List JavaDoc;
17
18 import org.eclipse.jface.preference.BooleanFieldEditor;
19 import org.eclipse.jface.preference.IPreferenceStore;
20 import org.eclipse.jface.preference.PreferencePage;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.layout.GridData;
23 import org.eclipse.swt.layout.GridLayout;
24 import org.eclipse.swt.widgets.Composite;
25 import org.eclipse.swt.widgets.Control;
26 import org.eclipse.ui.IWorkbench;
27 import org.eclipse.ui.IWorkbenchPreferencePage;
28 import org.eclipse.ui.PlatformUI;
29
30 /**
31  * Preference page for debug preferences that apply specifically to
32  * Java Debugging.
33  */

34 public class JavaPrimitivesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
35     
36     private List JavaDoc fEdtiors = new ArrayList JavaDoc();
37
38     public JavaPrimitivesPreferencePage() {
39         super(DebugUIMessages.JavaPrimitivesPreferencePage_0);
40         setPreferenceStore(JDIDebugUIPlugin.getDefault().getPreferenceStore());
41         setDescription(DebugUIMessages.JavaPrimitivesPreferencePage_1);
42     }
43
44     /**
45      * @see PreferencePage#createContents(Composite)
46      */

47     protected Control createContents(Composite parent) {
48         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.JAVA_PRIMITIVES_PREFERENCE_PAGE);
49         
50         //The main composite
51
Composite composite = new Composite(parent, SWT.NULL);
52         GridLayout layout = new GridLayout();
53         layout.numColumns = 1;
54         layout.marginHeight=0;
55         layout.marginWidth=0;
56         composite.setLayout(layout);
57         GridData data = new GridData();
58         data.verticalAlignment = GridData.FILL;
59         data.horizontalAlignment = GridData.FILL;
60         composite.setLayoutData(data);
61         
62         IPreferenceStore preferenceStore = JDIDebugUIPlugin.getDefault().getPreferenceStore();
63         
64         BooleanFieldEditor editor = new BooleanFieldEditor(IJDIPreferencesConstants.PREF_SHOW_HEX,
65                 DebugUIMessages.JavaDebugPreferencePage_Display__hexadecimal_values__byte__short__char__int__long__3,
66                 composite);
67         editor.setPreferenceStore(preferenceStore);
68         fEdtiors.add(editor);
69         editor = new BooleanFieldEditor(IJDIPreferencesConstants.PREF_SHOW_CHAR,
70                 DebugUIMessages.JavaDebugPreferencePage_Display_ASCII__character_values__byte__short__int__long__4,
71                 composite);
72         editor.setPreferenceStore(preferenceStore);
73         fEdtiors.add(editor);
74         editor = new BooleanFieldEditor(IJDIPreferencesConstants.PREF_SHOW_UNSIGNED,
75                 DebugUIMessages.JavaDebugPreferencePage_Display__unsigned_values__byte__5,
76                 composite);
77         editor.setPreferenceStore(preferenceStore);
78         fEdtiors.add(editor);
79         
80         loadValues();
81         applyDialogFont(composite);
82         return composite;
83     }
84         
85     /**
86      * @see IWorkbenchPreferencePage#init(IWorkbench)
87      */

88     public void init(IWorkbench workbench) {
89     }
90     
91     /**
92      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
93      * Also, notifies interested listeners
94      */

95     public boolean performOk() {
96         storeValues();
97         return true;
98     }
99     
100     /**
101      * Sets the default preferences.
102      * @see PreferencePage#performDefaults()
103      */

104     protected void performDefaults() {
105         Iterator JavaDoc iterator = fEdtiors.iterator();
106         while (iterator.hasNext()) {
107             BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next();
108             editor.loadDefault();
109         }
110         super.performDefaults();
111     }
112             
113     /**
114      * Set the values of the component widgets based on the
115      * values in the preference store
116      */

117     private void loadValues() {
118         Iterator JavaDoc iterator = fEdtiors.iterator();
119         while (iterator.hasNext()) {
120             BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next();
121             editor.load();
122         }
123     }
124     
125     /**
126      * Store the preference values based on the state of the
127      * component widgets
128      */

129     private void storeValues() {
130         Iterator JavaDoc iterator = fEdtiors.iterator();
131         while (iterator.hasNext()) {
132             BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next();
133             editor.store();
134         }
135     }
136
137 }
138
Popular Tags