use of com.github.cameltooling.idea.service.CamelPreferenceService in project camel-idea-plugin by camel-tooling.
the class CamelDebuggerRunner method canRun.
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
CamelPreferenceService preferenceService = ServiceManager.getService(CamelPreferenceService.class);
if (!preferenceService.isEnableCamelDebugger()) {
return false;
}
if (profile instanceof RunConfigurationBase) {
try {
final RunConfigurationBase base = (RunConfigurationBase) profile;
final Project project = base.getProject();
final CamelService camelService = project.getService(CamelService.class);
if (camelService != null) {
boolean isDebug = executorId.equals(DefaultDebugExecutor.EXECUTOR_ID);
boolean isCamelPresent = camelService.isCamelPresent();
boolean canRun = isDebug && isCamelPresent;
LOG.debug("Executor ID is " + executorId + " ; Camel present = " + camelService.isCamelPresent() + " ; canRun is " + canRun);
return canRun;
}
} catch (Exception e) {
LOG.debug("Camel Debugger cannot run", e);
return false;
}
}
LOG.debug("Camel Debugger cannot run, profile is not RunConfiguration");
return false;
}
use of com.github.cameltooling.idea.service.CamelPreferenceService in project camel-idea-plugin by camel-tooling.
the class PropertiesPropertyPlaceholdersSmartCompletion method isValidExtension.
@Override
public boolean isValidExtension(String filename) {
final CamelPreferenceService preferenceService = ServiceManager.getService(CamelPreferenceService.class);
final boolean present = preferenceService.getExcludePropertyFiles().stream().anyMatch(s -> !s.isEmpty() && FilenameUtils.wildcardMatch(filename, s));
return (!present) && (filename.endsWith(".properties"));
}
use of com.github.cameltooling.idea.service.CamelPreferenceService in project camel-idea-plugin by camel-tooling.
the class CamelIgnoreAndExcludePage method apply.
@Override
public void apply() throws ConfigurationException {
CamelPreferenceService service = getCamelPreferenceService();
service.setExcludePropertyFiles(myExcludedProperties);
service.setIgnorePropertyList(myIgnoredProperties);
setModified(false);
}
use of com.github.cameltooling.idea.service.CamelPreferenceService in project camel-idea-plugin by camel-tooling.
the class CamelEndpointAnnotator method validateText.
/**
* Validate endpoint options list aka properties. eg "timer:trigger?delay=1000&bridgeErrorHandler=true"
* if the URI is not valid a error annotation is created and highlight the invalid value.
*/
void validateText(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull String uri) {
if (QueryUtils.isQueryContainingCamelComponent(element.getProject(), uri)) {
CamelCatalog catalogService = ServiceManager.getService(element.getProject(), CamelCatalogService.class).get();
IElementType type = element.getNode().getElementType();
LOG.trace("Element " + element + " of type: " + type + " to validate endpoint uri: " + uri);
// skip special values such as configuring ActiveMQ brokerURL
if (getCamelIdeaUtils().skipEndpointValidation(element)) {
LOG.debug("Skipping element " + element + " for validation with text: " + uri);
return;
}
// camel catalog expects & as & when it parses so replace all & as &
String camelQuery = getIdeaUtils().getInnerText(uri);
camelQuery = camelQuery.replaceAll("&", "&");
// strip up ending incomplete parameter
if (camelQuery.endsWith("&") || camelQuery.endsWith("?")) {
camelQuery = camelQuery.substring(0, camelQuery.length() - 1);
}
boolean stringFormat = getCamelIdeaUtils().isFromStringFormatEndpoint(element);
if (stringFormat) {
// if the node is fromF or toF, then replace all %X with {{%X}} as we cannot parse that value
camelQuery = camelQuery.replaceAll("%s", "\\{\\{\\%s\\}\\}");
camelQuery = camelQuery.replaceAll("%d", "\\{\\{\\%d\\}\\}");
camelQuery = camelQuery.replaceAll("%b", "\\{\\{\\%b\\}\\}");
}
boolean consumerOnly = getCamelIdeaUtils().isConsumerEndpoint(element);
boolean producerOnly = getCamelIdeaUtils().isProducerEndpoint(element);
if (producerOnly) {
validateEndpointReference(element, camelQuery, holder);
}
try {
CamelPreferenceService preference = getCamelPreferenceService();
EndpointValidationResult result = catalogService.validateEndpointProperties(camelQuery, false, consumerOnly, producerOnly);
extractMapValue(result, result.getInvalidBoolean(), uri, element, holder, new BooleanErrorMsg());
extractMapValue(result, result.getInvalidEnum(), uri, element, holder, new EnumErrorMsg());
extractMapValue(result, result.getInvalidInteger(), uri, element, holder, new IntegerErrorMsg());
extractMapValue(result, result.getInvalidNumber(), uri, element, holder, new NumberErrorMsg());
extractMapValue(result, result.getInvalidReference(), uri, element, holder, new ReferenceErrorMsg());
extractSetValue(result, result.getUnknown(), uri, element, holder, new UnknownErrorMsg(), false);
extractSetValue(result, result.getLenient(), uri, element, holder, new LenientOptionMsg(preference.isHighlightCustomOptions()), true);
extractSetValue(result, result.getNotConsumerOnly(), uri, element, holder, new NotConsumerOnlyErrorMsg(), false);
extractSetValue(result, result.getNotProducerOnly(), uri, element, holder, new NotProducerOnlyErrorMsg(), false);
} catch (Throwable e) {
LOG.warn("Error validating Camel endpoint: " + uri, e);
}
}
}
use of com.github.cameltooling.idea.service.CamelPreferenceService in project camel-idea-plugin by camel-tooling.
the class YamlPropertyPlaceholdersSmartCompletion method isValidExtension.
@Override
public boolean isValidExtension(String filename) {
final CamelPreferenceService preferenceService = ServiceManager.getService(CamelPreferenceService.class);
final boolean present = preferenceService.getExcludePropertyFiles().stream().anyMatch(s -> !s.isEmpty() && FilenameUtils.wildcardMatch(filename, s));
return (!present) && (filename.endsWith(".yaml") || filename.endsWith(".yml"));
}
Aggregations