/** * Returns the severity for the specific key from the given {@link IProject} * . If the project does not have project specific settings, the workspace * preference is returned. If <code>null</code> is passed in as the project * the workspace preferences are consulted. * * @param prefkey the given preference key * @param project the given project or <code>null</code> * @return the severity level for the given pref key */ public int getSeverityLevel(String prefkey, IProject project) { IPreferencesService service = Platform.getPreferencesService(); IScopeContext[] context = null; if (hasProjectSettings(project)) { context = new IScopeContext[] { new ProjectScope(project), InstanceScope.INSTANCE, DefaultScope.INSTANCE }; } else { context = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE }; } String value = service.get(prefkey, null, getPreferences(context)); if (VALUE_ERROR.equals(value)) { return SEVERITY_ERROR; } if (VALUE_WARNING.equals(value)) { return SEVERITY_WARNING; } return SEVERITY_IGNORE; }
/** * Returns the enable state for the specific key from the given * {@link IProject}. If the project does not have project specific settings, * the workspace preference is returned. If <code>null</code> is passed in * as the project the workspace preferences are consulted. * * @param prefkey the given preference key * @param project the given project or <code>null</code> * @return the enable state */ public boolean getEnableState(String prefkey, IProject project) { IPreferencesService service = Platform.getPreferencesService(); IScopeContext[] context = null; if (hasProjectSettings(project)) { context = new IScopeContext[] { new ProjectScope(project), InstanceScope.INSTANCE, DefaultScope.INSTANCE }; } else { context = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE }; } String value = service.get(prefkey, null, getPreferences(context)); return VALUE_ENABLED.equals(value); }