Java 类org.eclipse.xtext.preferences.IPreferenceValues 实例源码

项目:n4js    文件:N4JSSimpleFormattingPreferenceProvider.java   
@Override
public IPreferenceValues getPreferenceValues(Resource context) {

    final IPreferenceValues preferenceValues = super.getPreferenceValues(context);

    return new IPreferenceValues() {
        @Override
        public String getPreference(PreferenceKey key) {

            if (key == N4JSFormatterPreferenceKeys.FORMAT_PARENTHESIS) {
                return Boolean.TRUE.toString(); // TODO make this configurable, see super-class
            }
            if (key == N4JSFormatterPreferenceKeys.FORMAT_SURROUND_PAREN_CONTENT_WITH_SPACE) {
                return Boolean.FALSE.toString(); // TODO make this configurable, see super-class
            }

            return preferenceValues.getPreference(key);
        }
    };
}
项目:xtext-core    文件:FormatterPreferenceValuesProvider.java   
@Override
public IPreferenceValues getPreferenceValues(final Resource resource) {
    final IPreferenceValues preferenceValues = internalGetRawPreferenceValues(resource);
    final String indent = whitespaceInfo.getIndentationInformation(resource.getURI()).getIndentString();
    final String lineSep = whitespaceInfo.getLineSeparatorInformation(resource.getURI()).getLineSeparator();

    return new IPreferenceValues() {

        @Override
        public String getPreference(PreferenceKey key) {
            if (key == FormatterPreferenceKeys.indentation) {
                return indent;
            }
            if (key == FormatterPreferenceKeys.lineSeparator) {
                return lineSep;
            }
            return preferenceValues.getPreference(key);
        }

    };
}
项目:xtext-core    文件:PreferenceTaskTagProvider.java   
@Override
public TaskTags getTaskTags(final Resource resource) {
  TaskTags _xblockexpression = null;
  {
    final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource);
    final String names = prefs.getPreference(PreferenceTaskTagProvider.TAGS_KEY);
    final String priorities = prefs.getPreference(PreferenceTaskTagProvider.PRIORITIES_KEY);
    TaskTags _taskTags = new TaskTags();
    final Procedure1<TaskTags> _function = (TaskTags it) -> {
      it.setCaseSensitive((Boolean.valueOf(prefs.getPreference(PreferenceTaskTagProvider.CASE_SENSITIVE_KEY))).booleanValue());
      List<TaskTag> _taskTags_1 = it.getTaskTags();
      List<TaskTag> _parseTags = PreferenceTaskTagProvider.parseTags(names, priorities);
      Iterables.<TaskTag>addAll(_taskTags_1, _parseTags);
    };
    _xblockexpression = ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function);
  }
  return _xblockexpression;
}
项目:bts    文件:EclipsePreferencesProvider.java   
public IPreferenceValues getPreferenceValues(Resource context) {
    final IProject project = getProject(context);
    final IPreferenceStore store = project != null ?
        access.getContextPreferenceStore(project) :
        access.getPreferenceStore();

    @SuppressWarnings("deprecation")
    final Map<String, String> computingMap = new MapMaker().makeComputingMap(
            new Function<String, String>() {
                public String apply(String input) {
                    return store.getString(input);
                }
            });

    return new IPreferenceValues() {
        public String getPreference(PreferenceKey key) {
            try {
                final String string = computingMap.get(key.getId());
                return org.eclipse.jface.preference.IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(string) ? key.getDefaultValue() : string;
            } catch (Exception e) {
                log.error("Error getting preference for key '"+key.getId()+"'.", e);
                return key.getDefaultValue();
            }
        }
    };
}
项目:sadlos2    文件:SadlActionHandler.java   
protected Map<String,String> getPreferences() {
    Injector reqInjector = safeGetInjector(SadlActivator.COM_GE_RESEARCH_SADL_SADL);
    IPreferenceValuesProvider pvp = reqInjector.getInstance(IPreferenceValuesProvider.class);
    org.eclipse.emf.ecore.resource.Resource resource = new ResourceImpl();
    resource.setURI(org.eclipse.emf.common.util.URI.createFileURI("/"));

    IPreferenceValues preferenceValues = pvp.getPreferenceValues(resource);
    if (preferenceValues != null) {
        Map<String, String> map = new HashMap<String, String>();
        boolean bval = Boolean.parseBoolean(preferenceValues.getPreference(SadlPreferences.SHOW_TIMING_INFORMATION));
        if (bval) {
            map.put(SadlPreferences.SHOW_TIMING_INFORMATION.getId(), "true");
        }
        else {
            map.put(SadlPreferences.SHOW_TIMING_INFORMATION.getId(), "false");
        }
        bval = Boolean.parseBoolean(preferenceValues.getPreference(SadlPreferences.VALIDATE_BEFORE_TEST));
        if (bval) {
            map.put(SadlPreferences.VALIDATE_BEFORE_TEST.getId(), "true");
        }
        else {
            map.put(SadlPreferences.VALIDATE_BEFORE_TEST.getId(), "false");
        }           return map;
    }
    return null;
}
项目:n4js    文件:PropertiesFileBasedValuesProvider.java   
/**
 * Values are provided from loaded properties file
 *
 * @param properties
 *            the settings for the project (usually found in the preference-store) can be <code>null</code>
 */
public PropertiesFileBasedValuesProvider(Properties properties) {
    final Properties props = new Properties(properties);
    values = new IPreferenceValues() {

        @Override
        public String getPreference(PreferenceKey key) {
            return props.getProperty(key.getId(), key.getDefaultValue());
        }
    };
}
项目:n4js    文件:ImportSpacerUserPreferenceHelper.java   
/** Compute user preference regarding space between import specifiers and curly brace. */
public String getSpacingPreference(Resource resource) {
    IPreferenceValues prefValues = formattingPreferenceProvider.getPreferenceValues(resource);
    String spacePreference = prefValues.getPreference(
            N4JSFormatterPreferenceKeys.FORMAT_SURROUND_IMPORT_LIST_WITH_SPACE);

    return Boolean.valueOf(spacePreference) ? " " : "";
}
项目:sadlos2    文件:OntologyGraphGeneratorHandler.java   
protected Map<String,Boolean> getOntologyGraphPreferences() {
    Injector sadlInjector = safeGetInjector(SadlActivator.COM_GE_RESEARCH_SADL_SADL);
    IPreferenceValuesProvider pvp = sadlInjector.getInstance(IPreferenceValuesProvider.class);
    org.eclipse.emf.ecore.resource.Resource resource = new ResourceImpl();
    resource.setURI(org.eclipse.emf.common.util.URI.createFileURI("/"));

    IPreferenceValues preferenceValues = pvp.getPreferenceValues(resource);
    if (preferenceValues != null) {
        Map<String, Boolean> map = new HashMap<String, Boolean>();
        boolean bval = Boolean.parseBoolean(preferenceValues.getPreference(SadlPreferences.GRAPH_IMPLICIT_ELEMENTS));
        if (bval) {
            map.put(SadlPreferences.GRAPH_IMPLICIT_ELEMENTS.getId(), true);
        }
        else {
            map.put(SadlPreferences.GRAPH_IMPLICIT_ELEMENTS.getId(), false);
        }
        bval = Boolean.parseBoolean(preferenceValues.getPreference(SadlPreferences.GRAPH_IMPLICIT_ELEMENT_INSTANCES));
        if (bval) {
            map.put(SadlPreferences.GRAPH_IMPLICIT_ELEMENT_INSTANCES.getId(), true);
        }
        else {
            map.put(SadlPreferences.GRAPH_IMPLICIT_ELEMENT_INSTANCES.getId(), false);
        }           
        return map;
    }
    return null;
}
项目:n4js    文件:PropertiesFileBasedValuesProvider.java   
@Override
public IPreferenceValues getPreferenceValues(Resource context) {
    return values;
}
项目:n4js    文件:N4JSIssueSeverities.java   
@SuppressWarnings("javadoc")
public N4JSIssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes,
        SeverityConverter converter) {
    super(preferenceValues, configurableIssueCodes, converter);
    this.configurableIssueCodes = configurableIssueCodes;
}
项目:n4js    文件:N4JSIssueSeveritiesProvider.java   
@Override
public N4JSIssueSeverities getIssueSeverities(Resource context) {
    IPreferenceValues preferenceValues = valuesProvider.getPreferenceValues(context);
    return new N4JSIssueSeverities(preferenceValues, issueCodesProvider.getConfigurableIssueCodes(),
            severityConverter);
}
项目:n4js    文件:N4MFIssueSeverities.java   
@SuppressWarnings("javadoc")
public N4MFIssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes,
        SeverityConverter converter) {
    super(preferenceValues, configurableIssueCodes, converter);
    this.configurableIssueCodes = configurableIssueCodes;
}
项目:n4js    文件:N4MFIssueSeveritiesProvider.java   
@Override
public N4MFIssueSeverities getIssueSeverities(Resource context) {
    IPreferenceValues preferenceValues = valuesProvider.getPreferenceValues(context);
    return new N4MFIssueSeverities(preferenceValues, issueCodesProvider.getConfigurableIssueCodes(),
            severityConverter);
}
项目:xtext-extras    文件:FormattingPreferenceValues.java   
public FormattingPreferenceValues(IPreferenceValues values) {
    super();
    this.values = values;
}
项目:xtext-core    文件:IssueSeverities.java   
public IssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) {
    this.preferenceValues = preferenceValues;
    this.configurableIssueCodes = configurableIssueCodes;
    this.converter = converter;
}
项目:xtext-core    文件:IssueSeveritiesProvider.java   
public IssueSeverities getIssueSeverities(Resource context) {
    IPreferenceValues preferenceValues = getValuesProvider().getPreferenceValues(context);
    return new IssueSeverities(preferenceValues, issueCodesProvider.getConfigurableIssueCodes(), severityConverter);
}
项目:xtext-core    文件:FormatterPreferenceValuesProvider.java   
protected IPreferenceValues internalGetRawPreferenceValues(final Resource resource) {
    return valuesProvider.getPreferenceValues(resource);
}
项目:xtext-core    文件:PreferenceValuesByLanguage.java   
public IPreferenceValues get(final String languageId) {
  return this.preferencesByLanguage.get(languageId);
}
项目:xtext-core    文件:PreferenceValuesByLanguage.java   
public IPreferenceValues put(final String languageId, final IPreferenceValues values) {
  return this.preferencesByLanguage.put(languageId, values);
}
项目:sadlos2    文件:SadlPreferencesProvider.java   
public IPreferenceValues getPreferenceValues(Resource resource) {
    return preferenceValuesProvider.getPreferenceValues(resource);
}
项目:sadlos2    文件:SadlPreferencesProvider.java   
public IPreferenceValues getPreferenceValues(IProject project) {
    if(project == null) {
        return getPreferenceValues(new ResourceImpl(URI.createURI("ws_ctx")));
    }
    return getPreferenceValues(new ResourceImpl(URI.createPlatformResourceURI(project.getName(), true)));
}
项目:n4js    文件:N4JSPreferenceAccess.java   
/**
 * @param resource
 *            the current resource, this will be used to calculate the preference store to access (e.g. if there are
 *            project specific preferences configured).
 * @param compilerID
 *            the compiler id
 * @param compilerProperty
 *            the compiler property to ask for
 * @param defaultDescriptor
 *            the descriptor containing the default values to be used as fall back if there isn't a value in the
 *            preference store
 * @return the preference value found in the preference store or any other values provider or the default value out
 *         of the default descriptor
 */
public String getPreference(Resource resource, String compilerID, CompilerProperties compilerProperty,
        CompilerDescriptor defaultDescriptor) {
    IPreferenceValues preferences = valuesProvider.getPreferenceValues(resource);
    PreferenceKey key = new PreferenceKey(compilerProperty.getKey(compilerID),
            String.valueOf(compilerProperty.getValueInCompilerDescriptor(defaultDescriptor, compilerID)));
    return preferences.getPreference(key);
}