@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); } }; }
@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); } }; }
@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; }
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(); } } }; }
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; }
/** * 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()); } }; }
/** 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) ? " " : ""; }
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; }
@Override public IPreferenceValues getPreferenceValues(Resource context) { return values; }
@SuppressWarnings("javadoc") public N4JSIssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) { super(preferenceValues, configurableIssueCodes, converter); this.configurableIssueCodes = configurableIssueCodes; }
@Override public N4JSIssueSeverities getIssueSeverities(Resource context) { IPreferenceValues preferenceValues = valuesProvider.getPreferenceValues(context); return new N4JSIssueSeverities(preferenceValues, issueCodesProvider.getConfigurableIssueCodes(), severityConverter); }
@SuppressWarnings("javadoc") public N4MFIssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) { super(preferenceValues, configurableIssueCodes, converter); this.configurableIssueCodes = configurableIssueCodes; }
@Override public N4MFIssueSeverities getIssueSeverities(Resource context) { IPreferenceValues preferenceValues = valuesProvider.getPreferenceValues(context); return new N4MFIssueSeverities(preferenceValues, issueCodesProvider.getConfigurableIssueCodes(), severityConverter); }
public FormattingPreferenceValues(IPreferenceValues values) { super(); this.values = values; }
public IssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) { this.preferenceValues = preferenceValues; this.configurableIssueCodes = configurableIssueCodes; this.converter = converter; }
public IssueSeverities getIssueSeverities(Resource context) { IPreferenceValues preferenceValues = getValuesProvider().getPreferenceValues(context); return new IssueSeverities(preferenceValues, issueCodesProvider.getConfigurableIssueCodes(), severityConverter); }
protected IPreferenceValues internalGetRawPreferenceValues(final Resource resource) { return valuesProvider.getPreferenceValues(resource); }
public IPreferenceValues get(final String languageId) { return this.preferencesByLanguage.get(languageId); }
public IPreferenceValues put(final String languageId, final IPreferenceValues values) { return this.preferencesByLanguage.put(languageId, values); }
public IPreferenceValues getPreferenceValues(Resource resource) { return preferenceValuesProvider.getPreferenceValues(resource); }
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))); }
/** * @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); }