1 11 12 package org.eclipse.jdt.internal.ui.preferences; 13 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.swt.widgets.Control; 16 17 import org.eclipse.jface.dialogs.Dialog; 18 import org.eclipse.jface.preference.PreferencePage; 19 20 import org.eclipse.ui.IWorkbench; 21 import org.eclipse.ui.IWorkbenchPreferencePage; 22 import org.eclipse.ui.PlatformUI; 23 24 import org.eclipse.jdt.internal.ui.JavaPlugin; 25 26 32 public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 33 34 35 private IPreferenceConfigurationBlock fConfigurationBlock; 36 private OverlayPreferenceStore fOverlayStore; 37 38 39 42 public AbstractConfigurationBlockPreferencePage() { 43 setDescription(); 44 setPreferenceStore(); 45 fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {}); 46 fConfigurationBlock= createConfigurationBlock(fOverlayStore); 47 } 48 49 protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore); 50 protected abstract String getHelpId(); 51 protected abstract void setDescription(); 52 protected abstract void setPreferenceStore(); 53 54 57 public void init(IWorkbench workbench) { 58 } 59 60 63 public void createControl(Composite parent) { 64 super.createControl(parent); 65 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId()); 66 } 67 68 71 protected Control createContents(Composite parent) { 72 73 fOverlayStore.load(); 74 fOverlayStore.start(); 75 76 Control content= fConfigurationBlock.createControl(parent); 77 78 initialize(); 79 80 Dialog.applyDialogFont(content); 81 return content; 82 } 83 84 private void initialize() { 85 fConfigurationBlock.initialize(); 86 } 87 88 91 public boolean performOk() { 92 93 fConfigurationBlock.performOk(); 94 95 fOverlayStore.propagate(); 96 97 JavaPlugin.getDefault().savePluginPreferences(); 98 99 return true; 100 } 101 102 105 public void performDefaults() { 106 107 fOverlayStore.loadDefaults(); 108 fConfigurationBlock.performDefaults(); 109 110 super.performDefaults(); 111 } 112 113 116 public void dispose() { 117 118 fConfigurationBlock.dispose(); 119 120 if (fOverlayStore != null) { 121 fOverlayStore.stop(); 122 fOverlayStore= null; 123 } 124 125 super.dispose(); 126 } 127 } 128 | Popular Tags |