use of org.eclipse.core.runtime.preferences.IScopeContext in project che by eclipse.
the class StubUtility method getLineDelimiterPreference.
public static String getLineDelimiterPreference(IProject project) {
IScopeContext[] scopeContext;
if (project != null) {
// project preference
scopeContext = new IScopeContext[] { new ProjectScope(project) };
String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
if (lineDelimiter != null)
return lineDelimiter;
}
// workspace preference
scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
//$NON-NLS-1$ //$NON-NLS-2$
String platformDefault = System.getProperty("line.separator", "\n");
return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project sling by apache.
the class ProjectUtil method setPathPersistentProperty.
private static void setPathPersistentProperty(IProject project, IPath path, String propertyName) {
IScopeContext projectScope = new ProjectScope(project);
IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
if (projectNode != null) {
projectNode.put(propertyName, path.toPortableString());
try {
projectNode.flush();
} catch (BackingStoreException e) {
Activator.getDefault().getPluginLogger().error(e.getMessage(), e);
}
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project hale by halestudio.
the class ContentTypeCatalog method internalFindContentTypesFor.
/**
* This is the implementation for file name based content type matching.
*
* @return all matching content types in the preferred order
* @see IContentTypeManager#findContentTypesFor(String)
*/
private synchronized IContentType[][] internalFindContentTypesFor(ContentTypeMatcher matcher, final String fileName, Comparator sortingPolicy) {
IScopeContext context = matcher.getContext();
IContentType[][] result = { NO_CONTENT_TYPES, NO_CONTENT_TYPES };
final Set allByFileName;
if (context.equals(manager.getContext()))
allByFileName = getDirectlyAssociated(fileName, IContentTypeSettings.FILE_NAME_SPEC);
else {
allByFileName = new HashSet(getDirectlyAssociated(fileName, IContentTypeSettings.FILE_NAME_SPEC | IContentType.IGNORE_USER_DEFINED));
allByFileName.addAll(matcher.getDirectlyAssociated(this, fileName, IContentTypeSettings.FILE_NAME_SPEC));
}
Set selectedByName = selectMatchingByName(context, allByFileName, Collections.EMPTY_SET, fileName, IContentType.FILE_NAME_SPEC);
result[0] = (IContentType[]) selectedByName.toArray(new IContentType[selectedByName.size()]);
final String fileExtension = ContentTypeManager.getFileExtension(fileName);
if (fileExtension != null) {
final Set allByFileExtension;
if (context.equals(manager.getContext()))
allByFileExtension = getDirectlyAssociated(fileExtension, IContentTypeSettings.FILE_EXTENSION_SPEC);
else {
allByFileExtension = new HashSet(getDirectlyAssociated(fileExtension, IContentTypeSettings.FILE_EXTENSION_SPEC | IContentType.IGNORE_USER_DEFINED));
allByFileExtension.addAll(matcher.getDirectlyAssociated(this, fileExtension, IContentTypeSettings.FILE_EXTENSION_SPEC));
}
Set selectedByExtension = selectMatchingByName(context, allByFileExtension, selectedByName, fileExtension, IContentType.FILE_EXTENSION_SPEC);
if (!selectedByExtension.isEmpty())
result[1] = (IContentType[]) selectedByExtension.toArray(new IContentType[selectedByExtension.size()]);
}
if (result[0].length > 1)
Arrays.sort(result[0], sortingPolicy);
if (result[1].length > 1)
Arrays.sort(result[1], sortingPolicy);
return result;
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project xtext-xtend by eclipse.
the class JavaProjectPreferencesInitializer method addOwnFileExtensionsToJavaBuildResourceCopyFilter.
@SuppressWarnings("restriction")
@Inject
public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) {
@SuppressWarnings("deprecation") IScopeContext defaultScope = new DefaultScope();
// The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit
// of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN)
// causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366
defaultScope.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN);
IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID);
if (dnode == null)
return;
Set<String> filters = Sets.newLinkedHashSet();
for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) {
String trimmed = filter.trim();
if (!"".equals(trimmed))
filters.add(trimmed);
}
for (String ext : extensionProvider.getFileExtensions()) filters.add("*." + ext);
dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters));
try {
dnode.flush();
} catch (BackingStoreException e) {
log.error("Error saving preferences", e);
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project eclipse.platform.text by eclipse.
the class FileDocumentProvider method getLineDelimiterPreference.
/**
* Returns the default line delimiter preference for the given file.
*
* @param file the file
* @return the default line delimiter
* @since 3.1
*/
private String getLineDelimiterPreference(IFile file) {
IScopeContext[] scopeContext;
if (file != null && file.getProject() != null) {
// project preference
scopeContext = new IScopeContext[] { new ProjectScope(file.getProject()) };
String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
if (lineDelimiter != null)
return lineDelimiter;
}
// workspace preference
scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
}
Aggregations