1 11 12 package org.eclipse.jdt.apt.ui.internal.preferences; 13 14 import org.eclipse.core.resources.IProject; 15 import org.eclipse.core.runtime.IAdaptable; 16 import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.ui.PlatformUI; 20 21 24 public abstract class BasePreferencePage extends PropertyAndPreferencePage { 25 private BaseConfigurationBlock fConfigurationBlock; 26 27 protected Control createPreferenceContent(Composite composite) { 28 return getConfigurationBlock().createPreferenceContent(composite); 29 } 30 31 @Override 32 public void createControl(Composite parent) { 33 super.createControl(parent); 34 String contextId = getContextHelpId(); 35 if (contextId != null) { 36 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), contextId); 37 } 38 } 39 40 43 public void dispose() { 44 if (getConfigurationBlock() != null) { 45 getConfigurationBlock().dispose(); 46 } 47 super.dispose(); 48 } 49 52 protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { 53 if (getConfigurationBlock() != null) { 54 getConfigurationBlock().useProjectSpecificSettings(useProjectSpecificSettings); 55 } 56 super.enableProjectSpecificSettings(useProjectSpecificSettings); 57 } 58 59 protected BaseConfigurationBlock getConfigurationBlock() { 60 return fConfigurationBlock; 61 } 62 63 68 protected String getContextHelpId() { 69 return null; 70 } 71 72 protected boolean hasProjectSpecificOptions(IProject project) { 73 return getConfigurationBlock().hasProjectSpecificOptionsNoCache(project); 76 } 77 78 81 @Override 82 protected boolean offerLink() { 83 return false; 84 } 85 86 89 public void performApply() { 90 if (getConfigurationBlock() != null) { 91 getConfigurationBlock().performApply(); 92 } 93 } 94 95 98 protected void performDefaults() { 99 super.performDefaults(); 100 if (getConfigurationBlock() != null) { 101 getConfigurationBlock().performDefaults(); 102 } 103 } 104 105 108 public boolean performOk() { 109 if (getConfigurationBlock() != null && !getConfigurationBlock().performOk()) { 110 return false; 111 } 112 return super.performOk(); 113 } 114 115 protected void setConfigurationBlock(BaseConfigurationBlock configurationBlock) { 116 fConfigurationBlock = configurationBlock; 117 } 118 119 120 123 public void setElement(IAdaptable element) { 124 super.setElement(element); 125 setDescription(null); } 127 } 128 | Popular Tags |