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.jface.preference.IPreferencePageContainer; 21 22 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; 23 import org.eclipse.ui.preferences.IWorkingCopyManager; 24 import org.eclipse.ui.preferences.WorkingCopyManager; 25 26 import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileConfigurationBlock; 27 28 public abstract class ProfilePreferencePage extends PropertyAndPreferencePage { 29 30 private ProfileConfigurationBlock fConfigurationBlock; 31 32 public ProfilePreferencePage() { 33 super(); 34 } 35 36 protected abstract ProfileConfigurationBlock createConfigurationBlock(PreferencesAccess access); 37 38 public void createControl(Composite parent) { 39 IPreferencePageContainer container= getContainer(); 40 IWorkingCopyManager workingCopyManager; 41 if (container instanceof IWorkbenchPreferenceContainer) { 42 workingCopyManager= ((IWorkbenchPreferenceContainer) container).getWorkingCopyManager(); 43 } else { 44 workingCopyManager= new WorkingCopyManager(); } 46 PreferencesAccess access= PreferencesAccess.getWorkingCopyPreferences(workingCopyManager); 47 fConfigurationBlock= createConfigurationBlock(access); 48 49 super.createControl(parent); 50 } 51 52 protected Control createPreferenceContent(Composite composite) { 53 return fConfigurationBlock.createContents(composite); 54 } 55 56 protected boolean hasProjectSpecificOptions(IProject project) { 57 return fConfigurationBlock.hasProjectSpecificOptions(project); 58 } 59 60 protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { 61 super.enableProjectSpecificSettings(useProjectSpecificSettings); 62 if (fConfigurationBlock != null) { 63 fConfigurationBlock.enableProjectSpecificSettings(useProjectSpecificSettings); 64 } 65 } 66 67 public void dispose() { 68 if (fConfigurationBlock != null) { 69 fConfigurationBlock.dispose(); 70 } 71 super.dispose(); 72 } 73 74 protected void performDefaults() { 75 if (fConfigurationBlock != null) { 76 fConfigurationBlock.performDefaults(); 77 } 78 super.performDefaults(); 79 } 80 81 public boolean performOk() { 82 if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) { 83 return false; 84 } 85 return super.performOk(); 86 } 87 88 public void performApply() { 89 if (fConfigurationBlock != null) { 90 fConfigurationBlock.performApply(); 91 } 92 super.performApply(); 93 } 94 95 public void setElement(IAdaptable element) { 96 super.setElement(element); 97 setDescription(null); } 99 100 } 101 | Popular Tags |