1 11 package org.eclipse.jdt.internal.debug.ui; 12 13 14 import java.util.ArrayList ; 15 import java.util.Iterator ; 16 import java.util.List ; 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 34 public class JavaPrimitivesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 35 36 private List fEdtiors = new ArrayList (); 37 38 public JavaPrimitivesPreferencePage() { 39 super(DebugUIMessages.JavaPrimitivesPreferencePage_0); 40 setPreferenceStore(JDIDebugUIPlugin.getDefault().getPreferenceStore()); 41 setDescription(DebugUIMessages.JavaPrimitivesPreferencePage_1); 42 } 43 44 47 protected Control createContents(Composite parent) { 48 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.JAVA_PRIMITIVES_PREFERENCE_PAGE); 49 50 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 88 public void init(IWorkbench workbench) { 89 } 90 91 95 public boolean performOk() { 96 storeValues(); 97 return true; 98 } 99 100 104 protected void performDefaults() { 105 Iterator iterator = fEdtiors.iterator(); 106 while (iterator.hasNext()) { 107 BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next(); 108 editor.loadDefault(); 109 } 110 super.performDefaults(); 111 } 112 113 117 private void loadValues() { 118 Iterator iterator = fEdtiors.iterator(); 119 while (iterator.hasNext()) { 120 BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next(); 121 editor.load(); 122 } 123 } 124 125 129 private void storeValues() { 130 Iterator iterator = fEdtiors.iterator(); 131 while (iterator.hasNext()) { 132 BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next(); 133 editor.store(); 134 } 135 } 136 137 } 138 | Popular Tags |