Search in sources :

Example 6 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project erlide_eclipse by erlang.

the class PreferencesHelperTest method nextContexts_1.

@Test
public void nextContexts_1() {
    final IScopeContext[] list = PreferencesHelperTest.ALL_SCOPE_CONTEXTS;
    final IScopeContext item = ConfigurationScope.INSTANCE;
    final IScopeContext[] val = PreferencesHelper.getNextContexts(list, item);
    Assert.assertNotNull(val);
    Assert.assertEquals(1, val.length);
    Assert.assertEquals(DefaultScope.INSTANCE, val[0]);
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) Test(org.junit.Test)

Example 7 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project erlide_eclipse by erlang.

the class PreferencesHelper method removeAllAtLowestScope.

public void removeAllAtLowestScope() {
    final IScopeContext sc = storeContext;
    final IEclipsePreferences p = sc.getNode(qualifier);
    if (p != null) {
        try {
            final String[] keys = p.keys();
            for (final String key : keys) {
                remove(key, sc);
            }
            flush();
        } catch (final BackingStoreException e) {
        }
    }
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Example 8 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.

the class WorkflowDefinitionValidator method validate.

@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
    if (resource.getType() != IResource.FILE) {
        return null;
    }
    ValidationResult result = new ValidationResult();
    IFile workflowDefinitionXml = (IFile) resource;
    if (workflowDefinitionXml.isAccessible() && CoreUtil.isLiferayProject(resource.getProject())) {
        IScopeContext[] scopes = { new InstanceScope(), new DefaultScope() };
        ProjectScope projectScope = new ProjectScope(workflowDefinitionXml.getProject());
        boolean useProjectSettings = projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(ProjectCore.USE_PROJECT_SETTINGS, false);
        if (useProjectSettings) {
            scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
        }
        try {
            Map<String, Object>[] problems = detectProblems(workflowDefinitionXml, scopes);
            for (int i = 0; i < problems.length; i++) {
                Object messageValue = problems[i].get(IMarker.MESSAGE);
                ValidatorMessage message = ValidatorMessage.create(messageValue.toString(), resource);
                message.setType(MARKER_TYPE);
                message.setAttributes(problems[i]);
                result.add(message);
            }
            if (ListUtil.isNotEmpty(problems)) {
                IResource[] resources = { workflowDefinitionXml };
                result.setDependsOn(resources);
            }
        } catch (Exception e) {
            KaleoCore.logError(e);
        }
    }
    return result;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IFile(org.eclipse.core.resources.IFile) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) ValidationResult(org.eclipse.wst.validation.ValidationResult) ValidatorMessage(org.eclipse.wst.validation.ValidatorMessage) CoreException(org.eclipse.core.runtime.CoreException) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Map(java.util.Map) IResource(org.eclipse.core.resources.IResource)

Example 9 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.

the class ModuleProjectProviderDefaultValueService method compute.

@Override
protected String compute() {
    String retval = "gradle-module";
    IScopeContext[] prefContexts = { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
    String defaultProjectBuildType = Platform.getPreferencesService().getString(ProjectCore.PLUGIN_ID, ProjectCore.PREF_DEFAULT_MODULE_PROJECT_BUILD_TYPE_OPTION, null, prefContexts);
    if (defaultProjectBuildType != null) {
        ILiferayProjectProvider provider = LiferayCore.getProvider(defaultProjectBuildType);
        if (provider != null) {
            retval = defaultProjectBuildType;
        }
    }
    return retval;
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider)

Example 10 with IScopeContext

use of org.eclipse.core.runtime.preferences.IScopeContext in project liferay-ide by liferay.

the class WorkspaceProjectProviderDefaultValueService method compute.

@Override
protected String compute() {
    String retval = "gradle-liferay-workspace";
    IScopeContext[] prefContexts = { DefaultScope.INSTANCE, InstanceScope.INSTANCE };
    String defaultProjectBuildType = Platform.getPreferencesService().getString(ProjectCore.PLUGIN_ID, ProjectCore.PREF_DEFAULT_WORKSPACE_PROJECT_BUILD_TYPE_OPTION, null, prefContexts);
    if (defaultProjectBuildType != null) {
        ILiferayProjectProvider provider = LiferayCore.getProvider(defaultProjectBuildType);
        if (provider != null) {
            retval = defaultProjectBuildType;
        }
    }
    return retval;
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) ILiferayProjectProvider(com.liferay.ide.core.ILiferayProjectProvider)

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