Search in sources :

Example 21 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-openshift by jbosstools.

the class ServerUtils method getProjectNode.

public static IEclipsePreferences getProjectNode(String nodeQualifier, IProject project) {
    IScopeContext context = new ProjectScope(project);
    IEclipsePreferences node = context.getNode(nodeQualifier);
    return node;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 22 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project jbosstools-openshift by jbosstools.

the class OpenShiftCorePreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    IEclipsePreferences defaultPreferences = ((IScopeContext) DefaultScope.INSTANCE).getNode(OpenShiftCoreActivator.PLUGIN_ID);
    String location = OCBinary.getInstance().getSystemPathLocation();
    if (!StringUtils.isEmpty(location)) {
        defaultPreferences.put(IOpenShiftCoreConstants.OPENSHIFT_CLI_LOC, location);
    }
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 23 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project mdw-designer by CenturyLinkCloud.

the class WorkspaceConfigurator method setFormatter.

protected void setFormatter() {
    IScopeContext instanceScope = InstanceScope.INSTANCE;
    IEclipsePreferences uiPrefs = instanceScope.getNode(JavaUI.ID_PLUGIN);
    if (getWorkspaceConfig().getCodeFormatter().equals(WorkspaceConfig.CODE_FORMATTERS[0]))
        uiPrefs.put("formatter_profile", "_CenturyLinkIT");
    else
        uiPrefs.put("formatter_profile", "_MDWCodeFormatter");
    try {
        uiPrefs.flush();
        uiPrefs.sync();
        IProfileVersioner profileVersioner = new ProfileVersioner();
        ProfileStore profileStore = new FormatterProfileStore(profileVersioner);
        List<ProfileManager.Profile> profiles = profileStore.readProfiles(instanceScope);
        if (profiles == null)
            profiles = profileStore.readProfiles(DefaultScope.INSTANCE);
        if (profiles == null)
            profiles = new ArrayList<>();
        WorkingCopyManager workingCopyManager = new WorkingCopyManager();
        PreferencesAccess access = PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
        ProfileManager profileManager = new FormatterProfileManager(profiles, instanceScope, access, profileVersioner);
        profileManager.commitChanges(instanceScope);
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Set Code Formatter");
    }
}
Also used : FormatterProfileManager(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager) ProfileManager(org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ArrayList(java.util.ArrayList) PreferencesAccess(org.eclipse.jdt.internal.ui.preferences.PreferencesAccess) ProfileStore(org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore) FormatterProfileStore(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileStore) FormatterProfileStore(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileStore) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) WorkingCopyManager(org.eclipse.ui.preferences.WorkingCopyManager) ProfileVersioner(org.eclipse.jdt.internal.ui.preferences.formatter.ProfileVersioner) IProfileVersioner(org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner) FormatterProfileManager(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager) IProfileVersioner(org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner)

Example 24 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project webtools.sourceediting by eclipse.

the class HTMLAttributeValidator method getExcludedAttributeNames.

private Set getExcludedAttributeNames(IProject project) {
    IScopeContext[] fLookupOrder = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
    if (project != null) {
        ProjectScope projectScope = new ProjectScope(project);
        if (projectScope.getNode(HTMLCorePlugin.getDefault().getBundle().getSymbolicName()).getBoolean(HTMLCorePreferenceNames.USE_PROJECT_SETTINGS, false))
            fLookupOrder = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
    }
    Set result = new HashSet();
    if (fPreferenceService.getBoolean(HTMLCorePlugin.getDefault().getBundle().getSymbolicName(), HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES, HTMLCorePreferenceNames.IGNORE_ATTRIBUTE_NAMES_DEFAULT, fLookupOrder)) {
        String ignoreList = fPreferenceService.getString(HTMLCorePlugin.getDefault().getBundle().getSymbolicName(), HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE, HTMLCorePreferenceNames.ATTRIBUTE_NAMES_TO_IGNORE_DEFAULT, fLookupOrder);
        if (ignoreList.trim().length() == 0)
            return result;
        // $NON-NLS-1$
        String[] names = ignoreList.split(",");
        for (int i = 0; names != null && i < names.length; i++) {
            String name = names[i] == null ? null : names[i].trim();
            if (name != null && name.length() > 0)
                result.add(name.toLowerCase());
        }
    }
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) Set(java.util.Set) HashSet(java.util.HashSet) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) HashSet(java.util.HashSet)

Example 25 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project eclipse-integration-commons by spring-projects.

the class SpringCoreUtils method getLineSeparator.

/**
 * Returns the line separator found in the given text. If it is null, or not
 * found return the line delimiter for the given project. If the project is
 * null, returns the line separator for the workspace. If still null, return
 * the system line separator.
 * @since 2.2.2
 */
public static String getLineSeparator(String text, IProject project) {
    String lineSeparator = null;
    // line delimiter in given text
    if (text != null && text.length() != 0) {
        lineSeparator = findLineSeparator(text.toCharArray());
        if (lineSeparator != null) {
            return lineSeparator;
        }
    }
    // line delimiter in project preference
    IScopeContext[] scopeContext;
    if (project != null) {
        scopeContext = new IScopeContext[] { new ProjectScope(project) };
        lineSeparator = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
        if (lineSeparator != null) {
            return lineSeparator;
        }
    }
    // line delimiter in workspace preference
    scopeContext = new IScopeContext[] { new InstanceScope() };
    lineSeparator = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
    if (lineSeparator != null) {
        return lineSeparator;
    }
    // system line delimiter
    return LINE_SEPARATOR;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

Aggregations

IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)73 ProjectScope (org.eclipse.core.resources.ProjectScope)42 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)17 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)16 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)15 BackingStoreException (org.osgi.service.prefs.BackingStoreException)15 Preferences (org.osgi.service.prefs.Preferences)14 IProject (org.eclipse.core.resources.IProject)13 CoreException (org.eclipse.core.runtime.CoreException)8 ArrayList (java.util.ArrayList)6 IResource (org.eclipse.core.resources.IResource)6 ILiferayProjectProvider (com.liferay.ide.core.ILiferayProjectProvider)5 Iterator (java.util.Iterator)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Set (java.util.Set)4 IFile (org.eclipse.core.resources.IFile)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 PreferencesAccess (org.eclipse.jdt.internal.ui.preferences.PreferencesAccess)4 FormatterProfileStore (org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileStore)4