use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class JavaScriptModule method setupBaseModules.
@Contribute(ModuleManager.class)
public static void setupBaseModules(MappedConfiguration<String, Object> configuration, @Path("${tapestry.asset.root}/underscore-shim.js") Resource underscoreShim, @Path("${tapestry.asset.root}/jquery-shim.js") Resource jqueryShim, @Path("${tapestry.asset.root}/typeahead.js") Resource typeahead, @Path("${tapestry.asset.root}/moment-2.15.1.js") Resource moment, @Path("${tapestry.asset.root}/bootstrap/js/transition.js") Resource transition, @Path("${tapestry.asset.root}/bootstrap4/js/bootstrap-util.js") Resource bootstrapUtil, Compatibility compatibility) {
// The underscore shim module allows Underscore to be injected
configuration.add("underscore", new JavaScriptModuleConfiguration(underscoreShim));
configuration.add("jquery", new JavaScriptModuleConfiguration(jqueryShim));
if (compatibility.enabled(Trait.BOOTSTRAP_3)) {
final String[] modules = new String[] { "affix", "alert", "button", "carousel", "collapse", "dropdown", "modal", "scrollspy", "tab", "tooltip" };
addBootstrap3Modules(configuration, transition, modules);
Resource popover = transition.forFile("popover.js");
configuration.add("bootstrap/popover", new AMDWrapper(popover).require("bootstrap/tooltip").asJavaScriptModuleConfiguration());
}
if (compatibility.enabled(Trait.BOOTSTRAP_4)) {
configuration.add("bootstrap/bootstrap-util", new JavaScriptModuleConfiguration(bootstrapUtil));
configuration.add("bootstrap/popper", new JavaScriptModuleConfiguration(bootstrapUtil.forFile("popper.js")));
for (String name : new String[] { "alert", "button", "carousel", "collapse", "dropdown", "modal", "scrollspy", "tab", "tooltip" }) {
Resource lib = bootstrapUtil.forFile(name + ".js");
if (lib.exists()) {
configuration.add("bootstrap/" + name, new JavaScriptModuleConfiguration(lib).dependsOn("bootstrap/bootstrap-util").dependsOn("bootstrap/popper"));
}
}
}
// is completely disabled
if (!compatibility.enabled(Trait.BOOTSTRAP_3) && !compatibility.enabled(Trait.BOOTSTRAP_4)) {
final String[] modules = new String[] { "alert", "dropdown", "collapse" };
addBootstrap3Modules(configuration, transition, modules);
}
configuration.add("t5/core/typeahead", new JavaScriptModuleConfiguration(typeahead).dependsOn("jquery"));
configuration.add("moment", new JavaScriptModuleConfiguration(moment));
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class AssetsModule method provideBuiltinAssetDispatchers.
/**
* Contributes an handler for each mapped classpath alias, as well handlers for context assets
* and stack assets (combined {@link org.apache.tapestry5.services.javascript.JavaScriptStack} files).
*/
@Contribute(Dispatcher.class)
@AssetRequestDispatcher
public static void provideBuiltinAssetDispatchers(MappedConfiguration<String, AssetRequestHandler> configuration, @ContextProvider AssetFactory contextAssetFactory, @Autobuild StackAssetRequestHandler stackAssetRequestHandler, ClasspathAssetAliasManager classpathAssetAliasManager, ResourceStreamer streamer, AssetSource assetSource, ClasspathAssetProtectionRule classpathAssetProtectionRule) {
Map<String, String> mappings = classpathAssetAliasManager.getMappings();
for (String folder : mappings.keySet()) {
String path = mappings.get(folder);
configuration.add(folder, new ClasspathAssetRequestHandler(streamer, assetSource, path, classpathAssetProtectionRule));
}
configuration.add(RequestConstants.CONTEXT_FOLDER, new ContextAssetRequestHandler(streamer, contextAssetFactory.getRootResource()));
configuration.add(RequestConstants.STACK_FOLDER, stackAssetRequestHandler);
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class JpaGridDataSource method prepare.
/**
* {@inheritDoc}
*/
@Override
public void prepare(final int startIndex, final int endIndex, final List<SortConstraint> sortConstraints) {
final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
final CriteriaQuery<E> criteria = builder.createQuery(entityType);
final Root<E> root = criteria.from(entityType);
applyAdditionalConstraints(criteria.select(root), root, builder);
for (final SortConstraint constraint : sortConstraints) {
final String propertyName = constraint.getPropertyModel().getPropertyName();
final Path<Object> propertyPath = root.get(propertyName);
switch(constraint.getColumnSort()) {
case ASCENDING:
criteria.orderBy(builder.asc(propertyPath));
break;
case DESCENDING:
criteria.orderBy(builder.desc(propertyPath));
break;
default:
}
}
final TypedQuery<E> query = entityManager.createQuery(criteria);
query.setFirstResult(startIndex);
query.setMaxResults(endIndex - startIndex + 1);
this.startIndex = startIndex;
preparedResults = query.getResultList();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class JavaScriptStackPathConstructorImpl method combinedStackURL.
private List<String> combinedStackURL(String stackName, JavaScriptStack stack) {
try {
StreamableResource assembled = assembler.assembleJavaScriptResourceForStack(stackName, compressionAnalyzer.isGZipSupported(), stack.getJavaScriptAggregationStrategy());
String path = threadLocale.getLocale().toString() + '/' + stackName + ".js";
String stackURL = assetPathConstructor.constructAssetPath(RequestConstants.STACK_FOLDER, path, assembled);
return CollectionFactory.newList(stackURL);
} catch (IOException ex) {
throw new RuntimeException(String.format("Unable to construct path for '%s' JavaScript stack: %s", stackName, ExceptionUtils.toMessage(ex)), ex);
}
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class DefaultOpenApiDescriptionGenerator method getPath.
private String getPath(Method method, Class<?> pageClass) {
final StringBuilder builder = new StringBuilder();
builder.append(pageRenderLinkSource.createPageRenderLink(pageClass).toString());
for (Parameter parameter : method.getParameters()) {
if (!isIgnored(parameter)) {
builder.append("/");
final StaticActivationContextValue staticValue = parameter.getAnnotation(StaticActivationContextValue.class);
if (staticValue != null) {
builder.append(staticValue.value());
} else {
builder.append("{");
builder.append(getParameterName(parameter));
builder.append("}");
}
}
}
String path = builder.toString();
if (!path.startsWith(basePath)) {
throw new RuntimeException(String.format("Method %s has path %s, which " + "doesn't start with base path %s. It's likely you need to adjust the " + "base path and/or the endpoint paths", method, path, basePath));
} else {
// keep the slash
path = path.substring(basePath.length() - 1);
// remove possible double slashes
path = path.replace("//", "/");
}
return path;
}
Aggregations