Search in sources :

Example 41 with DefaultScope

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

the class HTMLCorePreferenceInitializer method initializeDefaultPreferences.

public void initializeDefaultPreferences() {
    IEclipsePreferences node = new DefaultScope().getNode(HTMLCorePlugin.getDefault().getBundle().getSymbolicName());
    // formatting preferences
    node.putInt(HTMLCorePreferenceNames.LINE_WIDTH, 72);
    node.putBoolean(HTMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, false);
    node.put(HTMLCorePreferenceNames.INDENTATION_CHAR, HTMLCorePreferenceNames.TAB);
    node.putInt(HTMLCorePreferenceNames.INDENTATION_SIZE, 1);
    node.putBoolean(HTMLCorePreferenceNames.SPLIT_MULTI_ATTRS, false);
    node.putBoolean(HTMLCorePreferenceNames.ALIGN_END_BRACKET, false);
    // cleanup preferences
    node.putInt(HTMLCorePreferenceNames.CLEANUP_TAG_NAME_CASE, HTMLCorePreferenceNames.ASIS);
    node.putInt(HTMLCorePreferenceNames.CLEANUP_ATTR_NAME_CASE, HTMLCorePreferenceNames.ASIS);
    // node.putBoolean(HTMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS,
    // true);
    node.putBoolean(HTMLCorePreferenceNames.INSERT_REQUIRED_ATTRS, true);
    node.putBoolean(HTMLCorePreferenceNames.INSERT_MISSING_TAGS, true);
    node.putBoolean(HTMLCorePreferenceNames.QUOTE_ATTR_VALUES, true);
    node.putBoolean(HTMLCorePreferenceNames.FORMAT_SOURCE, true);
    node.putBoolean(HTMLCorePreferenceNames.CONVERT_EOL_CODES, false);
    // code generation preferences
    // $NON-NLS-1$
    node.put(CommonEncodingPreferenceNames.INPUT_CODESET, "");
    // $NON-NLS-1$
    String defaultEnc = "UTF-8";
    // $NON-NLS-1$
    String systemEnc = System.getProperty("file.encoding");
    if (systemEnc != null) {
        // $NON-NLS-1$
        defaultEnc = CommonCharsetNames.getPreferredDefaultIanaName(systemEnc, "UTF-8");
    }
    node.put(CommonEncodingPreferenceNames.OUTPUT_CODESET, defaultEnc);
    // $NON-NLS-1$
    node.put(CommonEncodingPreferenceNames.END_OF_LINE_CODE, "");
    node.putInt(HTMLCorePreferenceNames.TAG_NAME_CASE, HTMLCorePreferenceNames.LOWER);
    node.putInt(HTMLCorePreferenceNames.ATTR_NAME_CASE, HTMLCorePreferenceNames.LOWER);
    // this could be made smarter by actually looking up the content
    // type's valid extensions
    // $NON-NLS-1$
    node.put(HTMLCorePreferenceNames.DEFAULT_EXTENSION, "html");
    node.put(HTMLCorePreferenceNames.INLINE_ELEMENTS, "a,abbr,acronym,b,basefont,big,br,cite,em,font,i,img,input,label,li,q,s,select,small,span,strike,strong,sub,sup,td,th,title,u");
    initializeValidationPreferences(node);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 42 with DefaultScope

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

the class SyntaxValidator method getExcludedElementNames.

private Set getExcludedElementNames(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_ELEMENT_NAMES, HTMLCorePreferenceNames.IGNORE_ELEMENT_NAMES_DEFAULT, fLookupOrder)) {
        String ignoreList = fPreferenceService.getString(HTMLCorePlugin.getDefault().getBundle().getSymbolicName(), HTMLCorePreferenceNames.ELEMENT_NAMES_TO_IGNORE, HTMLCorePreferenceNames.ELEMENT_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) HashSet(java.util.HashSet) Set(java.util.Set) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) HashSet(java.util.HashSet)

Example 43 with DefaultScope

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

the class AbstractValidationSettingsPage method resetSeverities.

protected void resetSeverities() {
    IEclipsePreferences defaultContext = new DefaultScope().getNode(getPreferenceNodeQualifier());
    for (int i = 0; i < _fCombos.size(); i++) {
        ComboData data = (ComboData) ((Combo) _fCombos.get(i)).getData();
        int severity = defaultContext.getInt(data.getKey(), ValidationMessage.WARNING);
        data.setSeverity(severity);
        ((Combo) _fCombos.get(i)).select(data.getIndex());
    }
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Combo(org.eclipse.swt.widgets.Combo) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope)

Example 44 with DefaultScope

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

the class JavaProjectPreferencesInitializer method addOwnFileExtensionsToJavaBuildResourceCopyFilter.

@SuppressWarnings("restriction")
@Inject
public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) {
    @SuppressWarnings("deprecation") IScopeContext defaultScope = new DefaultScope();
    // The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit
    // of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN)
    // causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely.
    // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366
    defaultScope.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN);
    IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID);
    if (dnode == null)
        return;
    Set<String> filters = Sets.newLinkedHashSet();
    for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) {
        String trimmed = filter.trim();
        if (!"".equals(trimmed))
            filters.add(trimmed);
    }
    for (String ext : extensionProvider.getFileExtensions()) filters.add("*." + ext);
    dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters));
    try {
        dnode.flush();
    } catch (BackingStoreException e) {
        log.error("Error saving preferences", e);
    }
}
Also used : IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException) DefaultScope(org.eclipse.core.runtime.preferences.DefaultScope) Inject(com.google.inject.Inject)

Aggregations

DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)44 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)24 ProjectScope (org.eclipse.core.resources.ProjectScope)17 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)7 IResource (org.eclipse.core.resources.IResource)6 HashSet (java.util.HashSet)4 Set (java.util.Set)4 IFile (org.eclipse.core.resources.IFile)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 BackingStoreException (org.osgi.service.prefs.BackingStoreException)3 IOException (java.io.IOException)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)2 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)2