use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.
the class PortalCore method getPreference.
public static String getPreference(String key) {
IScopeContext[] scopes = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
IPreferencesService preferencesService = Platform.getPreferencesService();
return preferencesService.getString(PLUGIN_ID, key, null, scopes);
}
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<IContentType> sortingPolicy) {
IScopeContext context = matcher.getContext();
IContentType[][] result = { NO_CONTENT_TYPES, NO_CONTENT_TYPES, NO_CONTENT_TYPES };
Set<ContentType> existing = new HashSet<>();
final Set<ContentType> 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<ContentType> selectedByName = selectMatchingByName(context, allByFileName, Collections.emptySet(), fileName, IContentType.FILE_NAME_SPEC);
existing.addAll(selectedByName);
result[0] = selectedByName.toArray(new IContentType[selectedByName.size()]);
if (result[0].length > 1)
Arrays.sort(result[0], sortingPolicy);
final String fileExtension = ContentTypeManager.getFileExtension(fileName);
if (fileExtension != null) {
final Set<ContentType> 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<ContentType> selectedByExtension = selectMatchingByName(context, allByFileExtension, selectedByName, fileExtension, IContentType.FILE_EXTENSION_SPEC);
existing.addAll(selectedByExtension);
if (!selectedByExtension.isEmpty())
result[1] = selectedByExtension.toArray(new IContentType[selectedByExtension.size()]);
}
if (result[1].length > 1)
Arrays.sort(result[1], sortingPolicy);
final Set<ContentType> allByFilePattern;
if (context.equals(manager.getContext()))
allByFilePattern = getMatchingRegexpAssociated(fileName, IContentTypeSettings.FILE_PATTERN_SPEC);
else {
allByFilePattern = new HashSet<>(getMatchingRegexpAssociated(fileName, IContentTypeSettings.FILE_PATTERN_SPEC | IContentType.IGNORE_USER_DEFINED));
allByFilePattern.addAll(matcher.getMatchingRegexpAssociated(this, fileName, IContentTypeSettings.FILE_PATTERN_SPEC));
}
existing.addAll(allByFilePattern);
if (!allByFilePattern.isEmpty())
result[2] = allByFilePattern.toArray(new IContentType[allByFilePattern.size()]);
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 jop by jop-devel.
the class JOPUIUtils method getProjectSetting.
public static String getProjectSetting(ILaunchConfiguration configuration, String key, String def) {
String projectName = getProjectName(configuration);
if (projectName == null) {
return def;
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
IScopeContext scopeContext = new ProjectScope(project);
Preferences projectPrefs = scopeContext.getNode(IJOPUIConstants.PLUGIN_ID);
return projectPrefs.get(key, def);
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project statecharts by Yakindu.
the class DefaultResourceBlacklist method getPersistentValues.
protected String getPersistentValues(IProject project) {
IScopeContext projectScope = getPreferenceScope(project);
IEclipsePreferences node = projectScope.getNode(SCT_RESOURCE_NODE);
String string = node.get(SCT_BLACKLIST_KEY, SCT_BLACKLIST_DEFAULT);
return string;
}
Aggregations