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);
}
}
}
}
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");
}
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;
}
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);
}
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);
}
Aggregations