1 11 package org.eclipse.jdt.internal.ui.preferences; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 15 import org.eclipse.core.resources.IProject; 16 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; 22 23 import org.eclipse.jdt.launching.JavaRuntime; 24 25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 26 import org.eclipse.jdt.internal.ui.JavaPlugin; 27 28 31 public class CompliancePreferencePage extends PropertyAndPreferencePage { 32 33 public static final String PREF_ID= "org.eclipse.jdt.ui.preferences.CompliancePreferencePage"; public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"; 36 private ComplianceConfigurationBlock fConfigurationBlock; 37 38 public CompliancePreferencePage() { 39 setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); 40 42 setTitle(PreferencesMessages.CompliancePreferencePage_title); 44 45 JavaRuntime.getDefaultVMInstall(); } 47 48 51 public void createControl(Composite parent) { 52 IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); 53 fConfigurationBlock= new ComplianceConfigurationBlock(getNewStatusChangedListener(), getProject(), container); 54 55 super.createControl(parent); 56 if (isProjectPreferencePage()) { 57 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE); 58 } else { 59 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE); 60 } 61 } 62 63 protected Control createPreferenceContent(Composite composite) { 64 return fConfigurationBlock.createContents(composite); 65 } 66 67 protected boolean hasProjectSpecificOptions(IProject project) { 68 return fConfigurationBlock.hasProjectSpecificOptions(project); 69 } 70 71 74 protected String getPreferencePageID() { 75 return PREF_ID; 76 } 77 78 81 protected String getPropertyPageID() { 82 return PROP_ID; 83 } 84 85 88 public void dispose() { 89 if (fConfigurationBlock != null) { 90 fConfigurationBlock.dispose(); 91 } 92 super.dispose(); 93 } 94 95 98 protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { 99 super.enableProjectSpecificSettings(useProjectSpecificSettings); 100 if (fConfigurationBlock != null) { 101 fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings); 102 } 103 } 104 105 108 protected void enablePreferenceContent(boolean enable) { 109 if (fConfigurationBlock != null) { 110 fConfigurationBlock.enablePreferenceContent(enable); 111 } 112 } 113 114 117 protected void performDefaults() { 118 super.performDefaults(); 119 if (fConfigurationBlock != null) { 120 fConfigurationBlock.performDefaults(); 121 } 122 } 123 124 127 public boolean performOk() { 128 if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) { 129 return false; 130 } 131 return super.performOk(); 132 } 133 134 137 public void performApply() { 138 if (fConfigurationBlock != null) { 139 fConfigurationBlock.performApply(); 140 } 141 } 142 143 146 public void setElement(IAdaptable element) { 147 super.setElement(element); 148 setDescription(null); } 150 151 } 152 | Popular Tags |