Search in sources :

Example 51 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project xtext-xtend by eclipse.

the class AbstractProfileManager method hasProjectSpecificSettings.

public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
    for (int i = 0; i < keySets.length; i++) {
        KeySet keySet = keySets[i];
        IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
        for (final Iterator keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
            final String key = (String) keyIter.next();
            Object val = preferences.get(key, null);
            if (val != null) {
                return true;
            }
        }
    }
    return false;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Iterator(java.util.Iterator)

Example 52 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project xtext-xtend by eclipse.

the class FormatterProfileStore method writeProfiles.

/*
	 * Eclipse 3.5 uses raw types thus we have to use them here, too
	 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void writeProfiles(Collection profiles, IScopeContext instanceScope) throws CoreException {
    ByteArrayOutputStream stream = new ByteArrayOutputStream(2000);
    try {
        writeProfilesToStream(profiles, stream, ENCODING, profileVersionerCopy);
        String val;
        try {
            val = stream.toString(ENCODING);
        } catch (UnsupportedEncodingException e) {
            val = stream.toString();
        }
        IEclipsePreferences uiPreferences = instanceScope.getNode(xtendNodeID);
        uiPreferences.put(XTEND_PROFILES_KEY, val);
        uiPreferences.putInt(profilesVersionKeyCopy, profileVersionerCopy.getCurrentVersion());
    } finally {
        try {
            stream.close();
        } catch (IOException e) {
        /* ignore */
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 53 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse.platform.text by eclipse.

the class HighlightStrategy method install.

public void install(ITextViewer viewer) {
    if (!(viewer instanceof ISourceViewer)) {
        return;
    }
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GENERIC_EDITOR_BUNDLE_ID);
    preferences.addPreferenceChangeListener(this);
    this.enabled = preferences.getBoolean(TOGGLE_HIGHLIGHT_PREFERENCE, true);
    this.sourceViewer = (ISourceViewer) viewer;
    this.sourceViewer.getTextWidget().addCaretListener(this);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Example 54 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse.platform.text by eclipse.

the class DefaultWordHighlightStrategy method uninstall.

public void uninstall() {
    if (sourceViewer != null) {
        sourceViewer.getTextWidget().removeCaretListener(this);
    }
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GenericEditorPlugin.BUNDLE_ID);
    preferences.removePreferenceChangeListener(this);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 55 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse.platform.text by eclipse.

the class ToggleHighlight method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Command command = event.getCommand();
    boolean oldValue = HandlerUtil.toggleCommandState(command);
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GenericEditorPlugin.BUNDLE_ID);
    preferences.putBoolean(TOGGLE_HIGHLIGHT_PREFERENCE, !oldValue);
    return null;
}
Also used : Command(org.eclipse.core.commands.Command) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)79 BackingStoreException (org.osgi.service.prefs.BackingStoreException)15 Test (org.junit.Test)11 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 ProjectScope (org.eclipse.core.resources.ProjectScope)6 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)6 After (org.junit.After)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2