1 11 12 package org.eclipse.ui.internal.editors.text; 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 30 abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { 31 32 33 private IPreferenceConfigurationBlock fConfigurationBlock; 34 private OverlayPreferenceStore fOverlayStore; 35 36 37 40 public AbstractConfigurationBlockPreferencePage() { 41 setDescription(); 42 setPreferenceStore(); 43 fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {}); 44 fConfigurationBlock= createConfigurationBlock(fOverlayStore); 45 } 46 47 protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore); 48 protected abstract String getHelpId(); 49 protected abstract void setDescription(); 50 protected abstract void setPreferenceStore(); 51 52 55 public void init(IWorkbench workbench) { 56 } 57 58 61 public void createControl(Composite parent) { 62 super.createControl(parent); 63 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId()); 64 } 65 66 69 protected Control createContents(Composite parent) { 70 71 fOverlayStore.load(); 72 fOverlayStore.start(); 73 74 Control content= fConfigurationBlock.createControl(parent); 75 76 initialize(); 77 78 Dialog.applyDialogFont(content); 79 return content; 80 } 81 82 private void initialize() { 83 fConfigurationBlock.initialize(); 84 } 85 86 89 public boolean performOk() { 90 91 if (!fConfigurationBlock.canPerformOk()) 92 return false; 93 94 fConfigurationBlock.performOk(); 95 96 fOverlayStore.propagate(); 97 98 EditorsPlugin.getDefault().savePluginPreferences(); 99 100 return true; 101 } 102 103 106 public void performDefaults() { 107 108 fOverlayStore.loadDefaults(); 109 fConfigurationBlock.performDefaults(); 110 111 super.performDefaults(); 112 } 113 114 117 public void dispose() { 118 119 fConfigurationBlock.dispose(); 120 121 if (fOverlayStore != null) { 122 fOverlayStore.stop(); 123 fOverlayStore= null; 124 } 125 126 super.dispose(); 127 } 128 } 129 | Popular Tags |