Search in sources :

Example 26 with InstanceScope

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

the class NewXMLGenerator method applyLineDelimiter.

private String applyLineDelimiter(IFile file, String text) {
    String systemLineSeparator = System.getProperty("line.separator");
    // $NON-NLS-1$
    String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, systemLineSeparator, new IScopeContext[] { new ProjectScope(file.getProject()), new InstanceScope() });
    if (!systemLineSeparator.equals(lineDelimiter)) {
        String convertedText = StringUtils.replace(text, "\r\n", "\n");
        convertedText = StringUtils.replace(convertedText, "\r", "\n");
        convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter);
        return convertedText;
    }
    return text;
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

Example 27 with InstanceScope

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

the class XMLCorePreferencesTest method testPluginSetPreferences.

/**
 * Tests setting preference values by setting preference value to be a
 * certain value, then getting the preference value to verify it was set.
 */
public void testPluginSetPreferences() {
    IEclipsePreferences node = new InstanceScope().getNode(XMLCorePlugin.getDefault().getBundle().getSymbolicName());
    pluginSetPreferenceBoolean(node, XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES);
    pluginSetPreferenceString(node, XMLCorePreferenceNames.INDENTATION_CHAR);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope)

Example 28 with InstanceScope

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

the class XtendPreferenceStoreAccess method getContextPreferenceStore.

@SuppressWarnings("all")
@Override
public IPreferenceStore getContextPreferenceStore(Object context) {
    IProject project = getProject(context);
    if (project == null)
        return getPreferenceStore();
    IPreferenceStore store = super.getContextPreferenceStore(context);
    ProjectScope projectScope = new ProjectScope(project);
    FixedScopedPreferenceStore jdtStore = new FixedScopedPreferenceStore(projectScope, JavaCore.PLUGIN_ID);
    jdtStore.setSearchContexts(new IScopeContext[] { projectScope, new InstanceScope(), new ConfigurationScope() });
    return new ChainedPreferenceStore(new IPreferenceStore[] { store, jdtStore, PreferenceConstants.getPreferenceStore() });
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FixedScopedPreferenceStore(org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore) IProject(org.eclipse.core.resources.IProject) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 29 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project cubrid-manager by CUBRID.

the class NodeFilterManager method loadFilterSetting.

@SuppressWarnings("deprecation")
private void loadFilterSetting() {
    synchronized (this) {
        IEclipsePreferences preference = new InstanceScope().getNode(CommonUIPlugin.PLUGIN_ID);
        String xmlString = preference.get(FILTER_XML_CONTENT, "");
        if (StringUtil.isEmpty(xmlString)) {
            LOGGER.warn("The preference.get(FILTER_XML_CONTENT) has a empty string.");
            return;
        }
        try {
            ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
            IXMLMemento memento = XMLMemento.loadMemento(in);
            if (memento == null) {
                LOGGER.error("XMLMemento.loadMemento(in) is a null.");
                return;
            }
            IXMLMemento[] children = memento.getChildren("idFilter");
            for (int i = 0; i < children.length; i++) {
                String id = children[i].getString("id");
                idFilterList.add(id);
            }
            children = memento.getChildren("idGrayFilter");
            for (int i = 0; i < children.length; i++) {
                String id = children[i].getString("id");
                idGrayFilterList.add(id);
            }
            children = memento.getChildren("nameFilter");
            for (int i = 0; i < children.length; i++) {
                String pattern = children[i].getString("pattern");
                nameFilterList.add(pattern);
            }
        } catch (UnsupportedEncodingException e) {
            LOGGER.error("loadFilterSetting()", e);
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ByteArrayInputStream(java.io.ByteArrayInputStream) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 30 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project cubrid-manager by CUBRID.

the class CubridStatusMonitorInstance method removeSetting.

/**
	 * Remove the info of StatusMonInstanceData relevant to key from preference
	 * 
	 * @param key the key relevant to saving instance of StatusMonInstanceData
	 */
public void removeSetting(String key) {
    synchronized (this) {
        IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
        preference.remove(key);
        try {
            preference.flush();
        } catch (BackingStoreException ex) {
            LOGGER.error(ex.getMessage());
        }
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) BackingStoreException(org.osgi.service.prefs.BackingStoreException)

Aggregations

InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)54 ProjectScope (org.eclipse.core.resources.ProjectScope)30 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)16 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)11 BackingStoreException (org.osgi.service.prefs.BackingStoreException)9 IFile (org.eclipse.core.resources.IFile)7 ConfigurationScope (org.eclipse.core.runtime.preferences.ConfigurationScope)7 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 IResource (org.eclipse.core.resources.IResource)5 Preferences (org.osgi.service.prefs.Preferences)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 List (java.util.List)3