1 11 12 package org.eclipse.debug.internal.ui.views.memory; 13 14 import org.eclipse.debug.internal.ui.DebugUIMessages; 15 import org.eclipse.debug.internal.ui.DebugUIPlugin; 16 import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; 17 import org.eclipse.debug.ui.IDebugUIConstants; 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.layout.GridData; 22 import org.eclipse.swt.layout.GridLayout; 23 import org.eclipse.swt.widgets.Combo; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Control; 26 import org.eclipse.swt.widgets.Label; 27 import org.eclipse.swt.widgets.Shell; 28 import org.eclipse.ui.help.WorkbenchHelp; 29 30 33 public class DefaultColumnSizeDialog extends Dialog { 34 35 private static final String PREFIX = "DefaultColumnSizeDialog."; private static final String DEFAULT_COLUMN_SIZE = PREFIX + "DefaultColumnSize"; private static final String COLUMN_SIZE = PREFIX + "ColumnSize"; 39 IPreferenceStore fPrefStore; 40 Combo fColumnSize; 41 42 private int[] fColumnSizes = new int[] {1, 2, 4, 8, 16}; 43 44 47 protected DefaultColumnSizeDialog(Shell parentShell) { 48 super(parentShell); 49 fPrefStore = DebugUIPlugin.getDefault().getPreferenceStore(); 50 } 51 52 55 protected Control createDialogArea(Composite parent) { 56 WorkbenchHelp.setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".DefaultColumnSizeDialog_context"); 58 getShell().setText(DebugUIMessages.getString(DEFAULT_COLUMN_SIZE)); 59 60 Composite content = new Composite(parent, SWT.NONE); 61 GridLayout layout = new GridLayout(); 62 layout.numColumns = 2; 63 content.setLayout(layout); 64 65 Label textLabel = new Label(content, SWT.NONE); 66 textLabel.setText(DebugUIMessages.getString(COLUMN_SIZE)); 67 68 GridData textLayout = new GridData(); 69 textLabel.setLayoutData(textLayout); 70 71 fColumnSize = new Combo(content, SWT.BORDER|SWT.READ_ONLY); 72 73 GridData columnLayout= new GridData(); 74 fColumnSize.setLayoutData(columnLayout); 75 76 for (int i=0; i<fColumnSizes.length; i++) 77 { 78 fColumnSize.add(String.valueOf(fColumnSizes[i])); 79 } 80 81 int colSize = fPrefStore.getInt(IDebugPreferenceConstants.PREF_COLUMN_SIZE); 82 int idx = 0; 83 84 for (int i=0; i<fColumnSizes.length; i++) 85 { 86 if (fColumnSizes[i] == colSize) 87 { 88 idx = i; 89 break; 90 } 91 } 92 93 fColumnSize.select(idx); 94 95 return content; 96 } 97 98 101 protected void okPressed() { 102 int idx = fColumnSize.getSelectionIndex(); 103 int colSize = fColumnSizes[idx]; 104 105 fPrefStore.setValue(IDebugPreferenceConstants.PREF_COLUMN_SIZE, colSize); 106 107 super.okPressed(); 108 } 109 } 110 | Popular Tags |