1 11 package org.eclipse.pde.internal.ui.preferences; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.jface.preference.IPreferenceStore; 15 import org.eclipse.jface.preference.PreferencePage; 16 import org.eclipse.pde.internal.ui.IHelpContextIds; 17 import org.eclipse.pde.internal.ui.IPreferenceConstants; 18 import org.eclipse.pde.internal.ui.PDEPlugin; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 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.Button; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Control; 26 import org.eclipse.swt.widgets.Group; 27 import org.eclipse.ui.IWorkbench; 28 import org.eclipse.ui.IWorkbenchPreferencePage; 29 import org.eclipse.ui.PlatformUI; 30 31 public class MainPreferencePage extends PreferencePage 32 implements IWorkbenchPreferencePage { 33 private Button fUseID; 34 private Button fUseName; 35 private Button fAutoManage; 36 37 38 public MainPreferencePage() { 39 setPreferenceStore(PDEPlugin.getDefault().getPreferenceStore()); 40 setDescription(PDEUIMessages.Preferences_MainPage_Description); 41 } 42 43 protected Control createContents(Composite parent) { 44 IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); 45 46 Composite composite = new Composite(parent, SWT.NONE); 47 GridLayout layout = new GridLayout(); 48 layout.verticalSpacing = 15; 49 composite.setLayout(layout); 50 51 Group group = new Group(composite, SWT.NONE); 52 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 53 group.setText(PDEUIMessages.Preferences_MainPage_showObjects); 54 group.setLayout(new GridLayout()); 55 56 fUseID = new Button(group, SWT.RADIO); 57 fUseID.setText(PDEUIMessages.Preferences_MainPage_useIds); 58 59 fUseName = new Button(group, SWT.RADIO); 60 fUseName.setText(PDEUIMessages.Preferences_MainPage_useFullNames); 61 62 if (store.getString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_IDS)) { 63 fUseID.setSelection(true); 64 } else { 65 fUseName.setSelection(true); 66 } 67 68 group = new Group(composite, SWT.NONE); 69 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 70 group.setLayout(new GridLayout()); 71 group.setText(PDEUIMessages.MainPreferencePage_group2); 72 73 fAutoManage = new Button(group, SWT.CHECK); 74 fAutoManage.setText(PDEUIMessages.MainPreferencePage_updateStale); 75 fAutoManage.setSelection(store.getBoolean(IPreferenceConstants.PROP_AUTO_MANAGE)); 76 return composite; 77 } 78 79 public void createControl(Composite parent) { 80 super.createControl(parent); 81 Dialog.applyDialogFont(getControl()); 82 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.MAIN_PREFERENCE_PAGE); 83 } 84 85 public boolean performOk() { 86 IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); 87 if (fUseID.getSelection()) { 88 store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_IDS); 89 } else { 90 store.setValue(IPreferenceConstants.PROP_SHOW_OBJECTS, IPreferenceConstants.VALUE_USE_NAMES); 91 } 92 store.setValue(IPreferenceConstants.PROP_AUTO_MANAGE, fAutoManage.getSelection()); 93 PDEPlugin.getDefault().savePluginPreferences(); 94 return super.performOk(); 95 } 96 97 protected void performDefaults() { 98 IPreferenceStore store = PDEPlugin.getDefault().getPreferenceStore(); 99 if (store.getDefaultString(IPreferenceConstants.PROP_SHOW_OBJECTS).equals(IPreferenceConstants.VALUE_USE_IDS)) { 100 fUseID.setSelection(true); 101 fUseName.setSelection(false); 102 } else { 103 fUseID.setSelection(false); 104 fUseName.setSelection(true); 105 } 106 fAutoManage.setSelection(false); 107 } 108 109 113 public void init(IWorkbench workbench) { 114 } 115 } 116 | Popular Tags |