Search in sources :

Example 46 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project xtext-eclipse by eclipse.

the class XtextProjectConfigurator method configureLanguages.

private void configureLanguages(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
    List<MojoExecution> executions = getMojoExecutions(request, monitor);
    SubMonitor progress = SubMonitor.convert(monitor, executions.size());
    for (MojoExecution execution : executions) {
        Languages languages = maven.getMojoParameterValue(request.getMavenProject(), execution, "languages", Languages.class, progress.split(1));
        if (languages != null) {
            ProjectScope projectPreferences = new ProjectScope(request.getProject());
            for (Language language : languages) {
                configureLanguage(projectPreferences, language, request);
            }
        }
    }
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) MojoExecution(org.apache.maven.plugin.MojoExecution) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Example 47 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project xtext-eclipse by eclipse.

the class PreferenceStoreWhitespaceInformationProvider method getLineSeparatorPreference.

protected String getLineSeparatorPreference(URI uri) {
    if (uri.isPlatformResource()) {
        IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(true)));
        String delimiter = senseLineDelimiter(file);
        if (delimiter != null)
            return delimiter;
    }
    IProject project = null;
    if (uri.isPlatformResource()) {
        project = workspace.getRoot().getProject(uri.segment(1));
    } else {
        for (Pair<IStorage, IProject> storage : storage2UriMapper.getStorages(uri)) {
            project = storage.getSecond();
            break;
        }
    }
    if (project != null) {
        String result = getLineSeparatorPreference(new ProjectScope(project));
        if (result != null)
            return result;
    }
    @SuppressWarnings("all") String result = getLineSeparatorPreference(new InstanceScope());
    if (result != null)
        return result;
    return System.getProperty("line.separator");
}
Also used : Path(org.eclipse.core.runtime.Path) ProjectScope(org.eclipse.core.resources.ProjectScope) IFile(org.eclipse.core.resources.IFile) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject)

Example 48 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project xtext-eclipse by eclipse.

the class PreferenceStoreAccessImpl method getWritablePreferenceStore.

@Override
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
    lazyInitialize();
    IProject project = getProject(context);
    if (project == null) {
        return getWritablePreferenceStore();
    }
    ProjectScope projectScope = new ProjectScope(project);
    FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
    result.setSearchContexts(new IScopeContext[] { projectScope, new InstanceScope(), new ConfigurationScope() });
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) IProject(org.eclipse.core.resources.IProject) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 49 with ProjectScope

use of org.eclipse.core.resources.ProjectScope in project xtext-eclipse by eclipse.

the class AbstractPreferencePage method handleUseProjectSettings.

/**
 * Switches the search scope of the preference store to use [Project, Instance, Configuration] if values are project
 * specific, and [Instance, Configuration] otherwise. This implementation requires that the given preference store
 * is based on the Project preference store when the page is used as a Properties page. (This is done in
 * {@link #doGetPreferenceStore()}).
 */
@SuppressWarnings("deprecation")
private void handleUseProjectSettings() {
    // Note: uses the pre Eclipse 3.6 way of specifying search scopes (deprecated since 3.6)
    boolean isUseProjectSettings = useProjectSettingsButton.getSelection();
    link.setEnabled(!isUseProjectSettings);
    if (!isUseProjectSettings) {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new InstanceScope(), new ConfigurationScope() });
    } else {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new ProjectScope(currentProject()), new InstanceScope(), new ConfigurationScope() });
        setProjectSpecificValues();
    }
    updateFieldEditors(isUseProjectSettings);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 50 with ProjectScope

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

the class PreferenceConstants method getPreference.

//	/**
//	 * Sets the completion proposal categories which are excluded from the
//	 * default proposal list and reloads the registry.
//	 *
//	 * @param categories the array with the IDs of the excluded categories
//	 * @see #CODEASSIST_EXCLUDED_CATEGORIES
//	 * @since 3.4
//	 */
//	public static void setExcludedCompletionProposalCategories(String[] categories) {
//		Assert.isLegal(categories != null);
//		StringBuffer buf = new StringBuffer(50 * categories.length);
//		for (int i = 0; i < categories.length; i++) {
//			buf.append(categories[i]);
//			buf.append('\0');
//		}
//		getPreferenceStore().setValue(CODEASSIST_EXCLUDED_CATEGORIES, buf.toString());
//		CompletionProposalComputerRegistry.getDefault().reload();
//	}
/**
	 * Returns the value for the given key in the given context.
	 * @param key The preference key
	 * @param project The current context or <code>null</code> if no context is available and the
	 * workspace setting should be taken. Note that passing <code>null</code> should
	 * be avoided.
	 * @return Returns the current value for the string.
	 * @since 3.1
	 */
public static String getPreference(String key, IJavaProject project) {
    String val;
    if (project != null) {
        val = new ProjectScope(project.getProject()).getNode(ID_PLUGIN).get(key, null);
        if (val != null && !val.isEmpty()) {
            return val;
        }
    }
    val = InstanceScope.INSTANCE.getNode(ID_PLUGIN).get(key, null);
    if (val != null) {
        return val;
    }
    return getPreferenceStore().getString(key);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope)

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