use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class SimpleTestProjectWithMapping method setDefaultConsoleConfiguration.
public void setDefaultConsoleConfiguration(String ccName) throws BackingStoreException, CoreException {
IScopeContext scope = new ProjectScope(getIProject());
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
node.putBoolean(HibernatePropertiesConstants.HIBERNATE3_ENABLED, true);
// $NON-NLS-1$
node.put(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, ccName);
node.flush();
addHibernateNature();
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-hibernate by jbosstools.
the class HibernateNature method getDefaultConsoleConfigurationName.
public String getDefaultConsoleConfigurationName() {
IJavaProject prj = JavaCore.create(project);
IScopeContext scope = new ProjectScope(prj.getProject());
Preferences node = scope.getNode(HibernatePropertiesConstants.HIBERNATE_CONSOLE_NODE);
if (node != null) {
String cfg = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, prj.getProject().getName());
return cfg;
} else {
return null;
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project eclipse-cs by checkstyle.
the class FormatterConfigWriter method writeCleanupSettings.
private void writeCleanupSettings(final Map<String, String> settings) {
PreferencesAccess access = PreferencesAccess.getOriginalPreferences();
IScopeContext instanceScope = access.getInstanceScope();
IScopeContext scope = access.getProjectScope(mProject);
IProfileVersioner versioner = new CleanUpProfileVersioner();
ProfileStore profilesStore = new ProfileStore(CleanUpConstants.CLEANUP_PROFILES, versioner);
try {
List<Profile> profiles = profilesStore.readProfiles(instanceScope);
if (profiles == null) {
profiles = new ArrayList<Profile>();
}
profiles.addAll(CleanUpPreferenceUtil.getBuiltInProfiles());
ProfileManager manager = new CleanUpProfileManager(profiles, scope, access, versioner);
CustomProfile myProfile = (CustomProfile) manager.getProfile(ProfileManager.ID_PREFIX + mNewProfileName);
if (myProfile == null) {
// take current settings and create new profile
Profile current = manager.getSelected();
myProfile = new CustomProfile(mNewProfileName, current.getSettings(), versioner.getCurrentVersion(), versioner.getProfileKind());
manager.addProfile(myProfile);
}
Map<String, String> joinedSettings = myProfile.getSettings();
joinedSettings.putAll(settings);
myProfile.setSettings(joinedSettings);
manager.setSelected(myProfile);
// writes profiles to the workspace profile store
profilesStore.writeProfiles(manager.getSortedProfiles(), instanceScope);
// commits changes to the project profile settings
manager.commitChanges(scope);
scope.getNode(JDT_UI_PLUGINID).flush();
scope.getNode(JavaCore.PLUGIN_ID).flush();
if (scope != instanceScope) {
instanceScope.getNode(JDT_UI_PLUGINID).flush();
instanceScope.getNode(JavaCore.PLUGIN_ID).flush();
}
} catch (CoreException e) {
CheckstyleLog.log(e, "Error storing cleanup profile");
} catch (BackingStoreException e) {
CheckstyleLog.log(e, "Error storing cleanup profile");
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project eclipse-cs by checkstyle.
the class FormatterConfigWriter method writeFormatterSettings.
/**
* Method for writing all formatter-settings to disc.
*
* @param settings
* All the settings.
*/
private void writeFormatterSettings(final Map<String, String> settings) {
PreferencesAccess access = PreferencesAccess.getOriginalPreferences();
IScopeContext instanceScope = access.getInstanceScope();
IScopeContext scope = access.getProjectScope(mProject);
IProfileVersioner versioner = new ProfileVersioner();
ProfileStore profilesStore = new FormatterProfileStore(versioner);
try {
List<Profile> profiles = profilesStore.readProfiles(instanceScope);
if (profiles == null) {
profiles = new ArrayList<Profile>();
}
ProfileManager manager = new FormatterProfileManager(profiles, scope, access, versioner);
CustomProfile myProfile = (CustomProfile) manager.getProfile(ProfileManager.ID_PREFIX + mNewProfileName);
if (myProfile == null) {
// take current settings and create new profile
Profile current = manager.getSelected();
myProfile = new CustomProfile(mNewProfileName, current.getSettings(), versioner.getCurrentVersion(), versioner.getProfileKind());
manager.addProfile(myProfile);
}
Map<String, String> joinedSettings = myProfile.getSettings();
joinedSettings.putAll(settings);
myProfile.setSettings(joinedSettings);
manager.setSelected(myProfile);
// writes profiles to the workspace profile store
profilesStore.writeProfiles(manager.getSortedProfiles(), instanceScope);
// commits changes to the project profile settings
manager.commitChanges(scope);
scope.getNode(JDT_UI_PLUGINID).flush();
scope.getNode(JavaCore.PLUGIN_ID).flush();
if (scope != instanceScope) {
instanceScope.getNode(JDT_UI_PLUGINID).flush();
instanceScope.getNode(JavaCore.PLUGIN_ID).flush();
}
} catch (CoreException e) {
CheckstyleLog.log(e, "Error storing formatter profile");
} catch (BackingStoreException e) {
CheckstyleLog.log(e, "Error storing formatter profile");
}
}
use of org.eclipse.core.runtime.preferences.IScopeContext in project eclipse.platform.runtime by eclipse.
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;
}
Aggregations