1 11 package org.eclipse.ui.internal.ide.dialogs; 12 13 import org.eclipse.jface.preference.IPreferenceStore; 14 import org.eclipse.jface.preference.RadioGroupFieldEditor; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.layout.GridData; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.ui.PlatformUI; 20 import org.eclipse.ui.internal.dialogs.PerspectivesPreferencePage; 21 import org.eclipse.ui.internal.ide.IDEInternalPreferences; 22 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 23 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 24 25 32 public class IDEPerspectivesPreferencePage extends PerspectivesPreferencePage { 33 private final String PROJECT_SWITCH_PERSP_MODE_TITLE = IDEWorkbenchMessages.ProjectSwitchPerspectiveMode_optionsTitle; 34 35 private final String PSPM_ALWAYS_TEXT = IDEWorkbenchMessages.ProjectSwitchPerspectiveMode_always; 36 37 private final String PSPM_NEVER_TEXT = IDEWorkbenchMessages.ProjectSwitchPerspectiveMode_never; 38 39 private final String PSPM_PROMPT_TEXT = IDEWorkbenchMessages.ProjectSwitchPerspectiveMode_prompt; 40 41 private RadioGroupFieldEditor projectSwitchField; 42 43 46 protected Control createContents(Composite parent) { 47 PlatformUI 50 .getWorkbench() 51 .getHelpSystem() 52 .setHelp( 53 parent, 54 org.eclipse.ui.internal.IWorkbenchHelpContextIds.PERSPECTIVES_PREFERENCE_PAGE); 55 56 Composite composite = createComposite(parent); 57 58 createOpenPerspButtonGroup(composite); 59 createOpenViewButtonGroup(composite); 60 createProjectPerspectiveGroup(composite); 61 createCustomizePerspective(composite); 62 63 return composite; 64 } 65 66 70 private void createProjectPerspectiveGroup(Composite composite) { 71 72 Composite projectComposite = new Composite(composite, SWT.NONE); 73 projectComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 74 projectComposite.setFont(composite.getFont()); 75 76 String [][] namesAndValues = { 77 { PSPM_ALWAYS_TEXT, IDEInternalPreferences.PSPM_ALWAYS }, 78 { PSPM_NEVER_TEXT, IDEInternalPreferences.PSPM_NEVER }, 79 { PSPM_PROMPT_TEXT, IDEInternalPreferences.PSPM_PROMPT } }; 80 projectSwitchField = new RadioGroupFieldEditor( 81 IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE, 82 PROJECT_SWITCH_PERSP_MODE_TITLE, namesAndValues.length, 83 namesAndValues, projectComposite, true); 84 projectSwitchField.setPreferenceStore(getIDEPreferenceStore()); 85 projectSwitchField.setPage(this); 86 projectSwitchField.load(); 87 } 88 89 92 protected IPreferenceStore getIDEPreferenceStore() { 93 return IDEWorkbenchPlugin.getDefault().getPreferenceStore(); 94 } 95 96 101 protected void performDefaults() { 102 projectSwitchField.loadDefault(); 103 super.performDefaults(); 104 } 105 106 111 public boolean performOk() { 112 projectSwitchField.store(); 113 IDEWorkbenchPlugin.getDefault().savePluginPreferences(); 114 return super.performOk(); 115 } 116 117 } 118 | Popular Tags |