1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 14 import org.eclipse.jdt.internal.debug.ui.DebugUIMessages; 15 import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants; 16 import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; 17 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 18 import org.eclipse.jface.dialogs.Dialog; 19 import org.eclipse.jface.preference.IPreferenceStore; 20 import org.eclipse.swt.SWT; 21 import org.eclipse.swt.widgets.Button; 22 import org.eclipse.swt.widgets.Composite; 23 import org.eclipse.swt.widgets.Control; 24 import org.eclipse.swt.widgets.Shell; 25 import org.eclipse.ui.PlatformUI; 26 27 30 public class PrimitiveOptionsDialog extends Dialog { 31 32 private Button fHexButton; 33 private Button fCharButton; 34 private Button fUnsignedButton; 35 private String fPrefix; 37 38 public PrimitiveOptionsDialog(Shell parentShell, String prefix) { 39 super(parentShell); 40 fPrefix = prefix; 41 } 42 43 46 protected Control createDialogArea(Composite parent) { 47 PlatformUI.getWorkbench().getHelpSystem().setHelp( 48 parent, 49 IJavaDebugHelpContextIds.PRIMITIVE_DISPLAY_OPTIONS_DIALOG); 50 51 getShell().setText(ActionMessages.PrimitiveOptionsDialog_Primitive_Type_Display_Options_1); Composite composite = (Composite)super.createDialogArea(parent); 53 54 fHexButton = new Button(composite, SWT.CHECK); 56 fHexButton.setText(DebugUIMessages.JavaDebugPreferencePage_Display__hexadecimal_values__byte__short__char__int__long__3); fHexButton.setSelection(getBooleanPreferenceValue(fPrefix, IJDIPreferencesConstants.PREF_SHOW_HEX)); 58 fCharButton = new Button(composite, SWT.CHECK); 59 fCharButton.setText(DebugUIMessages.JavaDebugPreferencePage_Display_ASCII__character_values__byte__short__int__long__4); fCharButton.setSelection(getBooleanPreferenceValue(fPrefix, IJDIPreferencesConstants.PREF_SHOW_CHAR)); 61 fUnsignedButton = new Button(composite, SWT.CHECK); 62 fUnsignedButton.setText(DebugUIMessages.JavaDebugPreferencePage_Display__unsigned_values__byte__5); fUnsignedButton.setSelection(getBooleanPreferenceValue(fPrefix, IJDIPreferencesConstants.PREF_SHOW_UNSIGNED)); 64 applyDialogFont(composite); 65 return composite; 66 } 67 68 71 protected void okPressed() { 72 IPreferenceStore store = JDIDebugUIPlugin.getDefault().getPreferenceStore(); 73 store.setValue(fPrefix + "." + IJDIPreferencesConstants.PREF_SHOW_HEX, fHexButton.getSelection()); store.setValue(fPrefix + "." + IJDIPreferencesConstants.PREF_SHOW_CHAR, fCharButton.getSelection()); store.setValue(fPrefix + "." + IJDIPreferencesConstants.PREF_SHOW_UNSIGNED, fUnsignedButton.getSelection()); super.okPressed(); 77 } 78 79 86 public static boolean getBooleanPreferenceValue(String id, String preference) { 87 String compositeKey = id + "." + preference; IPreferenceStore store = JDIDebugUIPlugin.getDefault().getPreferenceStore(); 89 boolean value = false; 90 if (store.contains(compositeKey)) { 91 value = store.getBoolean(compositeKey); 92 } else { 93 value = store.getBoolean(preference); 94 } 95 return value; 96 } 97 } 98 | Popular Tags |