@Override public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) { List<ValueHint> result = new ArrayList<>(); if (ClassUtils.isPresent(property.getType(), classLoader)) { Class<?> clazz = ClassUtils.resolveClassName(property.getType(), classLoader); if (clazz.isEnum()) { for (Object o : clazz.getEnumConstants()) { ValueHint hint = new ValueHint(); hint.setValue(o); result.add(hint); } } } return result; }
@Override public String getText() { ValueHint valueHint = item.getHint(); StringBuilder sb = new StringBuilder(); // name and type sb.append("<b>").append(valueHint.getValue()).append("</b>"); final String description = valueHint.getDescription(); if (description != null) { sb.append("<br/>").append(simpleHtmlEscape(description)); } return sb.toString(); }
for (int i = 0; i < values.length(); i++) { JSONObject value = values.getJSONObject(i); ValueHint valueHint = new ValueHint(); valueHint.setValue(readItemValue(value.get("value"))); String description = value.optString("description", null); valueHint.setDescription(description); valueHint.setShortDescription( this.sentenceExtractor.getFirstSentence(description)); hint.getValueHints().add(valueHint);
.map(RequiresModule.class::cast) .get(); val valueHint = new ValueHint(); valueHint.setValue(Stream.of(RequiresModule.class.getName(), annotation.automated()).collect(Collectors.toList())); valueHint.setDescription(annotation.name()); hint.getValues().add(valueHint); val valueHint = new ValueHint(); valueHint.setValue(RequiredProperty.class.getName()); hint.getValues().add(valueHint);
String candidate = String.valueOf(valueHint.getValue()); if (!candidate.equals(alreadyTyped) && candidate.startsWith(alreadyTyped)) { collector.add(proposals.withSuffix(candidate.substring(alreadyTyped.length()), valueHint.getShortDescription()));
public String getText() { return hint.getValue().toString(); }
void addValueHintsProposals(final String dsl, AppRegistration appRegistration, final List<CompletionProposal> collector, final String propertyName, final ValueHintProvider[] valueHintProviders){ final Resource metadataResource = this.appRegistry.getAppMetadataResource(appRegistration); if (metadataResource != null) { final URLClassLoader classLoader = metadataResolver.createAppClassLoader(metadataResource); this.doWithClassLoader(classLoader, () -> { CompletionProposal.Factory proposals = CompletionProposal.expanding(dsl); List<ConfigurationMetadataProperty> whiteList = metadataResolver.listProperties(metadataResource); for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource, true)) { if (CompletionUtils.isMatchingProperty(propertyName, property, whiteList)) { for (ValueHintProvider valueHintProvider : valueHintProviders) { for (ValueHint valueHint : valueHintProvider.generateValueHints(property, classLoader)) { collector.add(proposals.withSuffix(String.valueOf(valueHint.getValue()), valueHint.getShortDescription())); } } } } return null; }); } }
@Override public List<ValueHint> queryHintMetadata(String propertyName, String filter) { if (cpExec == null) { init(); } List<ValueHint> ret = new LinkedList<>(); ConfigurationMetadataProperty cfgMeta = getPropertyMetadata(propertyName); if (cfgMeta != null) { for (ValueHint valueHint : cfgMeta.getHints().getValueHints()) { if (filter == null || valueHint.getValue().toString().contains(filter)) { ret.add(valueHint); } } } return ret; }
@Override public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) { List<ValueHint> result = new ArrayList<>(); if (ClassUtils.isPresent(property.getType(), classLoader)) { Class<?> clazz = ClassUtils.resolveClassName(property.getType(), classLoader); if (clazz.isEnum()) { for (Object o : clazz.getEnumConstants()) { ValueHint hint = new ValueHint(); hint.setValue(o); result.add(hint); } } } return result; }
sb.append("<br/><br/><table><tr><td><i>Value</i></td><td><i>Description</i></td></tr>"); for (ValueHint vHint : valueHints) { sb.append("<tr><td>").append(vHint.getValue()).append("</td><td>"); final String vDesc = vHint.getDescription(); if (vDesc != null) { sb.append(simpleHtmlEscape(vDesc)).append("</th></tr>");
public ConfigurationMetadataSearchResult(final ConfigurationMetadataProperty prop, final CasConfigurationMetadataRepository repository) { try { setDefaultValue(prop.getDefaultValue()); setDeprecation(prop.getDeprecation()); setDescription(cleanUpDescription(prop.getDescription())); setShortDescription(cleanUpDescription(prop.getShortDescription())); setId(prop.getId()); setName(prop.getName()); setType(prop.getType()); setGroup(CasConfigurationMetadataRepository.getPropertyGroupId(prop)); setOrder(CasConfigurationMetadataRepository.isCasProperty(prop) ? Ordered.HIGHEST_PRECEDENCE : Ordered.LOWEST_PRECEDENCE); val valueHints = prop.getHints().getValueHints(); valueHints.forEach(hint -> { val values = CollectionUtils.toCollection(hint.getValue()); if (values.contains(RequiresModule.class.getName())) { setRequiredModule(hint.getDescription()); setRequiredModuleAutomated(values.contains(Boolean.TRUE)); } if (values.contains(RequiredProperty.class.getName())) { setRequiredProperty(true); } }); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } }