Search in sources :

Example 96 with IEclipsePreferences

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

the class ContentBasedPreferenceGateway method getDefaultPreferences.

private static Preferences getDefaultPreferences(IContentType contentType) {
    IEclipsePreferences eclipsePreferences = Platform.getPreferencesService().getRootNode();
    // TODO: eventaully need extension mechanism to avoid these hard coded
    // mechanism.
    // The idea is to load/store based on plugin's preferences, where the
    // content type was contributed
    // Eventually, too, we could do more "dynamic lookup" to get parent
    // types for defaults, etc.
    // Get default plugin preferences
    String pluginPreferenceLocation = DefaultScope.SCOPE + IPath.SEPARATOR + getContributorPluginId(contentType);
    Preferences pluginPreferences = eclipsePreferences.node(pluginPreferenceLocation);
    return pluginPreferences;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Preferences(org.osgi.service.prefs.Preferences)

Example 97 with IEclipsePreferences

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

the class ContentBasedPreferenceGateway method getPreferences.

public static Preferences getPreferences(IContentType contentType) {
    IEclipsePreferences eclipsePreferences = Platform.getPreferencesService().getRootNode();
    // TODO: eventaully need extension mechanism to avoid these hard coded
    // mechanism.
    // The idea is to load/store based on plugin's preferences, where the
    // content type was contributed
    // Eventually, too, we could do more "dynamic lookup" to get parent
    // types for defaults, etc.
    // Get instance plugin preferences
    String pluginPreferenceLocation = Plugin.PLUGIN_PREFERENCE_SCOPE + IPath.SEPARATOR + getContributorPluginId(contentType);
    Preferences pluginPreferences = eclipsePreferences.node(pluginPreferenceLocation);
    // return contentPreferences;
    return pluginPreferences;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Preferences(org.osgi.service.prefs.Preferences)

Example 98 with IEclipsePreferences

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

the class TagModelQuery method getEmbeddedMimeType.

private String getEmbeddedMimeType(Node node) {
    String type = DEFAULT_MIMETYPE;
    if (node instanceof IDOMNode) {
        IStructuredModel model = ((IDOMNode) node).getModel();
        String baseLocation = model.getBaseLocation();
        if (!baseLocation.equals(IModelManager.UNMANAGED_MODEL)) {
            IPath path = new Path(baseLocation);
            if (path.segmentCount() > 1) {
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
                if (project.isAccessible()) {
                    String key = createPreferenceKey(path);
                    IEclipsePreferences preferences = new ProjectScope(project).getNode(JSPCorePlugin.getDefault().getBundle().getSymbolicName());
                    type = preferences.get(key, DEFAULT_MIMETYPE);
                }
            }
        }
    }
    return type;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ProjectScope(org.eclipse.core.resources.ProjectScope) IPath(org.eclipse.core.runtime.IPath) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IProject(org.eclipse.core.resources.IProject)

Example 99 with IEclipsePreferences

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

the class JSPIndexManager method isForcedFullReIndexNeeded.

/* (non-Javadoc)
	 * @see org.eclipse.wst.sse.core.indexing.AbstractIndexManager#isForcedFullReIndexNeeded()
	 * Add a versioning check so we can force a re-index if needed
	 */
protected boolean isForcedFullReIndexNeeded() {
    IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JSPCorePlugin.getDefault().getBundle().getSymbolicName());
    String stored = node.get(JSPIndexManager.class.getName(), null);
    return !INDEX_VERSION.equals(stored) || super.isForcedFullReIndexNeeded();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 100 with IEclipsePreferences

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

the class MainTab method save.

private void save() {
    IEclipsePreferences defaultPreferences = new DefaultScope().getNode(TaskTagPreferenceKeys.TASK_TAG_NODE);
    String defaultTags = defaultPreferences.get(TaskTagPreferenceKeys.TASK_TAG_TAGS, null);
    String defaultPriorities = defaultPreferences.get(TaskTagPreferenceKeys.TASK_TAG_PRIORITIES, null);
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < fTaskTags.length; i++) {
        if (i > 0) {
            // $NON-NLS-1$
            buf.append(",");
        }
        buf.append(fTaskTags[i].getTag());
    }
    String currentTags = buf.toString();
    if (currentTags.equals(defaultTags) && !fPreferencesLookupOrder[0].getName().equals(DefaultScope.SCOPE)) {
        if (_debugPreferences) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            System.out.println(getClass().getName() + " removing " + TaskTagPreferenceKeys.TASK_TAG_TAGS + " from scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
        }
        fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).remove(TaskTagPreferenceKeys.TASK_TAG_TAGS);
    } else {
        fOwner.requestRedetection();
        if (_debugPreferences) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            System.out.println(getClass().getName() + " setting " + TaskTagPreferenceKeys.TASK_TAG_TAGS + " \"" + currentTags + "\" in scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
        }
        fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).put(TaskTagPreferenceKeys.TASK_TAG_TAGS, currentTags);
    }
    StringBuffer buf2 = new StringBuffer();
    for (int i = 0; i < fTaskTags.length; i++) {
        if (i > 0) {
            // $NON-NLS-1$
            buf2.append(",");
        }
        buf2.append(String.valueOf(fTaskTags[i].getPriority()));
    }
    String priorities = buf2.toString();
    if (priorities.equals(defaultPriorities) && !fPreferencesLookupOrder[0].getName().equals(DefaultScope.SCOPE)) {
        if (_debugPreferences) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            System.out.println(getClass().getName() + " removing " + TaskTagPreferenceKeys.TASK_TAG_PRIORITIES + " from scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
        }
        fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).remove(TaskTagPreferenceKeys.TASK_TAG_PRIORITIES);
    } else {
        fOwner.requestRedetection();
        if (_debugPreferences) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            System.out.println(getClass().getName() + " setting " + TaskTagPreferenceKeys.TASK_TAG_PRIORITIES + " \"" + priorities + "\" in scope " + fPreferencesLookupOrder[0].getName() + ":" + fPreferencesLookupOrder[0].getLocation());
        }
        fPreferencesLookupOrder[0].getNode(TaskTagPreferenceKeys.TASK_TAG_NODE).put(TaskTagPreferenceKeys.TASK_TAG_PRIORITIES, priorities);
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) Point(org.eclipse.swt.graphics.Point)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)339 BackingStoreException (org.osgi.service.prefs.BackingStoreException)81 Test (org.junit.Test)37 ProjectScope (org.eclipse.core.resources.ProjectScope)24 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)24 CoreException (org.eclipse.core.runtime.CoreException)22 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)17 IStatus (org.eclipse.core.runtime.IStatus)16 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)15 IOException (java.io.IOException)13 IProject (org.eclipse.core.resources.IProject)13 Status (org.eclipse.core.runtime.Status)13 ArrayList (java.util.ArrayList)11 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)11 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)10 File (java.io.File)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 Job (org.eclipse.core.runtime.jobs.Job)8 Preferences (org.osgi.service.prefs.Preferences)8