Search in sources :

Example 61 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project linuxtools by eclipse.

the class CreaterepoPropertyPage method createContents.

@Override
protected Control createContents(Composite parent) {
    if (getElement() instanceof IResource) {
        project = ((IResource) getElement()).getProject();
    } else {
        Object adapter = getElement().getAdapter(IResource.class);
        if (adapter instanceof IResource) {
            project = ((IResource) adapter).getProject();
        }
    }
    setPreferenceStore(new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID));
    preferenceStore = getPreferenceStore();
    return addContents(parent);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IResource(org.eclipse.core.resources.IResource) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 62 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project eclipse-integration-commons by spring-projects.

the class SpringCorePreferences method getEclipsePreferences.

private IEclipsePreferences getEclipsePreferences(IProject project, String qualifier) {
    IScopeContext context = project != null ? new ProjectScope(project) : InstanceScope.INSTANCE;
    IEclipsePreferences node = context.getNode(qualifier);
    return node;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 63 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project webtools.sourceediting by eclipse.

the class FragmentValidationTools method shouldValidateFragment.

/**
 * @param resource
 * @return whether to perform validation on a fragment, returning the
 *         project-specific preference only of project-specific values are
 *         enabled
 */
static boolean shouldValidateFragment(IResource resource) {
    String qualifier = JSPCorePlugin.getDefault().getBundle().getSymbolicName();
    IProject project = null;
    if (resource.getType() == IResource.PROJECT) {
        project = (IProject) resource;
    } else {
        project = resource.getProject();
    }
    if (project != null) {
        IEclipsePreferences node = new ProjectScope(project).getNode(qualifier);
        // first, check whether project specific settings are to be used
        boolean useProjectSettings = node.getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false);
        if (useProjectSettings) {
            // only if so, return that value
            return node.getBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
        }
    // if not, return the workspace value
    }
    return new InstanceScope().getNode(qualifier).getBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IProject(org.eclipse.core.resources.IProject)

Example 64 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project webtools.sourceediting by eclipse.

the class JSPActionValidator method loadPreferences.

private void loadPreferences(IFile file) {
    fScopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
    fPreferencesService = Platform.getPreferencesService();
    if (file != null && file.isAccessible()) {
        ProjectScope projectScope = new ProjectScope(file.getProject());
        if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
            fScopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
        }
    }
    fSeverityMissingRequiredAttribute = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_MISSING_REQUIRED_ATTRIBUTE);
    fSeverityNonEmptyInlineTag = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_NON_EMPTY_INLINE_TAG);
    fSeverityUnknownAttribute = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNKNOWN_ATTRIBUTE);
    fSeverityUnexpectedRuntimeExpression = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNEXPECTED_RTEXPRVALUE);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 65 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project webtools.sourceediting by eclipse.

the class JSPELValidator method loadPreferences.

private void loadPreferences(IFile file) {
    fScopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
    fPreferencesService = Platform.getPreferencesService();
    if (file != null && file.isAccessible()) {
        ProjectScope projectScope = new ProjectScope(file.getProject());
        if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
            fScopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
        }
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Aggregations

ProjectScope (org.eclipse.core.resources.ProjectScope)92 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)42 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)31 IProject (org.eclipse.core.resources.IProject)28 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)24 Preferences (org.osgi.service.prefs.Preferences)18 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)17 BackingStoreException (org.osgi.service.prefs.BackingStoreException)17 ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)11 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 CoreException (org.eclipse.core.runtime.CoreException)8 IAdaptable (org.eclipse.core.runtime.IAdaptable)5 IPath (org.eclipse.core.runtime.IPath)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 Path (org.eclipse.core.runtime.Path)4 Test (org.junit.Test)4 File (java.io.File)3