1 11 package org.eclipse.jdt.internal.ui.preferences; 12 13 import java.util.Map ; 14 15 import org.eclipse.core.runtime.IAdaptable; 16 17 import org.eclipse.core.resources.IProject; 18 19 import org.eclipse.swt.widgets.Composite; 20 import org.eclipse.swt.widgets.Control; 21 22 import org.eclipse.ui.PlatformUI; 23 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; 24 25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 26 import org.eclipse.jdt.internal.ui.JavaPlugin; 27 28 31 public class ProblemSeveritiesPreferencePage extends PropertyAndPreferencePage { 32 33 public static final String PREF_ID= "org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage"; public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.ProblemSeveritiesPreferencePage"; 36 public static final String DATA_SELECT_OPTION_KEY= "select_option_key"; public static final String DATA_SELECT_OPTION_QUALIFIER= "select_option_qualifier"; 39 private ProblemSeveritiesConfigurationBlock fConfigurationBlock; 40 41 public ProblemSeveritiesPreferencePage() { 42 setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); 43 45 setTitle(PreferencesMessages.ProblemSeveritiesPreferencePage_title); 47 } 48 49 52 public void createControl(Composite parent) { 53 IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); 54 fConfigurationBlock= new ProblemSeveritiesConfigurationBlock(getNewStatusChangedListener(), getProject(), container); 55 56 super.createControl(parent); 57 if (isProjectPreferencePage()) { 58 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROBLEM_SEVERITIES_PROPERTY_PAGE); 59 } else { 60 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.PROBLEM_SEVERITIES_PREFERENCE_PAGE); 61 } 62 } 63 64 protected Control createPreferenceContent(Composite composite) { 65 return fConfigurationBlock.createContents(composite); 66 } 67 68 protected boolean hasProjectSpecificOptions(IProject project) { 69 return fConfigurationBlock.hasProjectSpecificOptions(project); 70 } 71 72 75 protected String getPreferencePageID() { 76 return PREF_ID; 77 } 78 79 82 protected String getPropertyPageID() { 83 return PROP_ID; 84 } 85 86 89 public void dispose() { 90 if (fConfigurationBlock != null) { 91 fConfigurationBlock.dispose(); 92 } 93 super.dispose(); 94 } 95 96 99 protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { 100 super.enableProjectSpecificSettings(useProjectSpecificSettings); 101 if (fConfigurationBlock != null) { 102 fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings); 103 } 104 } 105 106 109 protected void performDefaults() { 110 super.performDefaults(); 111 if (fConfigurationBlock != null) { 112 fConfigurationBlock.performDefaults(); 113 } 114 } 115 116 119 public boolean performOk() { 120 if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) { 121 return false; 122 } 123 return super.performOk(); 124 } 125 126 129 public void performApply() { 130 if (fConfigurationBlock != null) { 131 fConfigurationBlock.performApply(); 132 } 133 } 134 135 138 public void applyData(Object data) { 139 super.applyData(data); 140 if (data instanceof Map && fConfigurationBlock != null) { 141 Map map= (Map ) data; 142 Object key= map.get(DATA_SELECT_OPTION_KEY); 143 Object qualifier= map.get(DATA_SELECT_OPTION_QUALIFIER); 144 if (key instanceof String && qualifier instanceof String ) { 145 fConfigurationBlock.selectOption((String ) key, (String ) qualifier); 146 } 147 } 148 } 149 150 153 public void setElement(IAdaptable element) { 154 super.setElement(element); 155 setDescription(null); } 157 158 } 159 | Popular Tags |