org.apache.wicket.request.resource.ResourceReference Java Examples

The following examples show how to use org.apache.wicket.request.resource.ResourceReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SassResourceReferenceFactory.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
public ResourceReference create(ResourceReference.Key key)
{
    String name = key.getName();
    String variation = key.getVariation();
    if (ContextRelativeSassResourceReference.CONTEXT_RELATIVE_SASS_REFERENCE_VARIATION
            .equals(variation)) {
        return new ContextRelativeSassResourceReference(name); // TODO what about the min
                                                               // extension ?!
    }
    if (name != null && (name.endsWith(".scss") || name.endsWith(".sass"))) {
        return new SassResourceReference(key);
    }
    else {
        return delegate.create(key);
    }
}
 
Example #2
Source File: WicketResourceMounterImpl.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void mountResources(final WebApplication webApplication) {

    if (resources != null) {
        for (final Map.Entry<String, IResource> resource : resources.entrySet()) {
            final String key = resource.getKey();
            final IResource source = resource.getValue();
            LOG.info("Mounting url '/{}' to resource '{}'", key, source.getClass().getCanonicalName());
            webApplication.mountResource("/" + key, new ResourceReference(key){
                @Override
                public IResource getResource() {
                    return source;
                }
            });
        }
    }

}
 
Example #3
Source File: ResourceBundleReferences.java    From onedev with MIT License 6 votes vote down vote up
private Set<ResourceReference> includeSoleDependencies(Set<ResourceReference> dependents) {
	while (true) {
		Set<ResourceReference> newDependents = new HashSet<>(dependents);
		for (ResourceReference dependent: dependents) {
			for (ResourceReference dependency: dependencyMap.get(dependent).getDependencies()) {
				if (!dependency.getClass().isAnnotationPresent(ResourceBundle.class) 
						&& dependents.containsAll(dependentMap.get(dependency))) {
					newDependents.add(dependency);
				}
			}
		}
		if (!newDependents.equals(dependents)) {
			dependents = newDependents;
		} else {
			break;
		}
	}
	return dependents;
}
 
Example #4
Source File: OContentShareResource.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
protected static CharSequence urlFor(ResourceReference ref, ODocument document, String field, String contentType, Integer imageSize, Double imageQuality, boolean fullUrl) {
	PageParameters params = new PageParameters();
	params.add("rid", document.getIdentity().toString().substring(1));
	params.add("field", field);
	params.add("v", document.getVersion());
	if(!Strings.isEmpty(contentType)) params.add("type", contentType);
	if(imageSize!=null && imageSize>0) params.add("s", imageSize);
	if(imageQuality!=null && imageQuality>0 && imageQuality<1.0) params.add("q", imageQuality);
	if(fullUrl) {
		return RequestCycle.get().getUrlRenderer()
				.renderFullUrl(Url.parse(RequestCycle.get().urlFor(ref, params)));
	} else {
		return RequestCycle.get().mapUrlFor(ref, params).toString(StringMode.LOCAL);
	}
}
 
Example #5
Source File: TransactionRequestCycleListener.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isOurContent(RequestCycle cycle, IRequestHandler handler) {
	if(handler instanceof ResourceReferenceRequestHandler)
	{
		ResourceReferenceRequestHandler rrrHandler = (ResourceReferenceRequestHandler)handler;
		ResourceReference reference = rrrHandler.getResourceReference();
		return !(reference instanceof PackageResourceReference);
	}
	return true;
}
 
Example #6
Source File: WebResources.java    From etcd-viewer with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends HeaderItem> getDependencies() {

    final ResourceReference backingLibraryReference;
    if (Application.exists()) {
        backingLibraryReference = Application.get().getJavaScriptLibrarySettings().getJQueryReference();
    } else {
        backingLibraryReference = JQueryResourceReference.get();
    }

    return Arrays.asList(CssHeaderItem.forReference(BOOTSTRAP_CSS), JavaScriptHeaderItem.forReference(backingLibraryReference));
}
 
Example #7
Source File: EmbeddableImage.java    From webanno with Apache License 2.0 5 votes vote down vote up
public EmbeddableImage(String aComponentId, ResourceReference aResource)
{
    super(aComponentId);
    add(new Image("image", aResource) {
        private static final long serialVersionUID = 1L;

        @Override
        protected boolean shouldAddAntiCacheParameter()
        {
            return false;
        }
    });
}
 
Example #8
Source File: ImageLink.java    From webanno with Apache License 2.0 5 votes vote down vote up
public ImageLink(String aId, ResourceReference aImageRes, IModel<String> aUrl)
{
    super(aId, aUrl);
    ExternalLink link = new ExternalLink("link", aUrl);
    link.add(new Image("image", aImageRes));
    add(link);
}
 
Example #9
Source File: ResourceBundleReferences.java    From onedev with MIT License 5 votes vote down vote up
private DependencyAware<ResourceReference> getDependencyAware(ResourceReference resource) {
	return new DependencyAware<ResourceReference>() {

		@Override
		public ResourceReference getId() {
			return resource;
		}

		@Override
		public int hashCode() {
			return getId().hashCode();
		}

		@SuppressWarnings("unchecked")
		@Override
		public boolean equals(Object obj) {
			return getId().equals(((DependencyAware<ResourceReference>)obj).getId());
		}

		@Override
		public Set<ResourceReference> getDependencies() {
			Set<ResourceReference> dependencies = new LinkedHashSet<>();
			for (HeaderItem item: resource.getDependencies()) {
				if (item instanceof IReferenceHeaderItem) {
					ResourceReference reference = ((IReferenceHeaderItem) item).getReference();
					if (reference.canBeRegistered()) {
						dependencies.add(reference);
					}
				}
			}
			return dependencies;
		}
		
	};
}
 
Example #10
Source File: ResourceBundleReferences.java    From onedev with MIT License 5 votes vote down vote up
private void createBundles(Class<?> scope, Set<ResourceReference> resourceReferences) {
	/*
	 * Some bundled css file may contain resources relative to parent paths of the css url, 
	 * for instance, a css may define below style:
	 * 
	 * background: url(../images/clock.png)),
	 *  
	 * if we use a resource name for instance "bundle" here, the generated resource 
	 * path will be something like "http://<server>:<port>/wicket/resource/org.apache.wicket.Application/bundle-ver-1472816165384.css", 
	 * and browser will resolve image url above as "http://<server>:<port>/wicket/resource/images/clock.png", which will cause Wicket
	 * resource loading not working at all. However if we use a long path here for resource name, for instance 
	 * "a/l/o/n/g/p/a/t/h/bundle", the resolved image url will be "http://<server>:<port>/wicket/resource/org.apache.wicket.Application/a/l/o/n/g/p/a/t/clock.png",  
	 * which will be resolved to the correct image with help of our BundleAwareResourceReferenceFactory
	 */
	String name = "a/l/o/n/g/p/a/t/h/bundle";
	
	List<ResourceReference> resourceReferenceList = new ArrayList<>(resourceReferences);
	resourceReferenceList.sort((o1, o2)->sorted.indexOf(o1)-sorted.indexOf(o2));
	
	List<JavaScriptReferenceHeaderItem> javaScriptResourceReferences = new ArrayList<>();
	List<CssReferenceHeaderItem> cssResourceReferences = new ArrayList<>();
	for (ResourceReference resourceReference: resourceReferenceList) {
		if (resourceReference instanceof JavaScriptResourceReference) {
			javaScriptResourceReferences.add(JavaScriptReferenceHeaderItem.forReference(resourceReference));
		} else if (resourceReference instanceof CssResourceReference) {
			cssResourceReferences.add(CssReferenceHeaderItem.forReference(resourceReference));
		}
	}
	
	if (!javaScriptResourceReferences.isEmpty()) {
		javaScriptBundleReferences.add(new JavaScriptConcatResourceBundleReference(
				scope, name + ".js", javaScriptResourceReferences));			
	}
	
	if (!cssResourceReferences.isEmpty()) {
		cssBundleReferences.add(new CssConcatResourceBundleReference(
				scope, name + ".css", cssResourceReferences));			
	}
}
 
Example #11
Source File: BundleAwareResourceReferenceFactory.java    From onedev with MIT License 5 votes vote down vote up
@Override
public ResourceReference create(Key key) {
	if (PackageResource.exists(key)) {
		return new PackageResourceReference(key);
	} else {
		for (ConcatResourceBundleReference<? extends IReferenceHeaderItem> bundle: bundles) {
			if (bundle.getScope().getName().equals(key.getScope())) {
				String bundleParentPath = getParentPath(bundle.getName());
				String relativePath;
				if (bundleParentPath != null)
					relativePath = PathUtils.relativize(bundleParentPath, key.getName());
				else
					relativePath = key.getName();
				for (IReferenceHeaderItem headerItem: bundle.getProvidedResources()) {
					String referenceParentPath = getParentPath(headerItem.getReference().getName());
					String possibleName;
					if (referenceParentPath != null)
						possibleName = PathUtils.resolve(referenceParentPath, relativePath);
					else
						possibleName = relativePath.toString();
					possibleName = PathUtils.normalizeDots(possibleName);
					if (possibleName != null) {
						Key possibleKey = new Key(headerItem.getReference().getScope().getName(), possibleName, 
								key.getLocale(), key.getStyle(), key.getVariation());
						if (PackageResource.exists(possibleKey)) {
							return new PackageResourceReference(possibleKey);
						}
					}
				}
			}
		}
		return null;
	}
}
 
Example #12
Source File: SidebarTabbedPanel.java    From webanno with Apache License 2.0 4 votes vote down vote up
public StaticImage(String aId, final ResourceReference aResourceReference)
{
    super(aId, aResourceReference);
}
 
Example #13
Source File: ActiveLearningSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon() {
    return ICON;
}
 
Example #14
Source File: RegistrationComponentTest.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
private ResourceReference getRegistrationResourceReference() {
    return tester.getApplication().getSharedResources().get(RegistrationResource.RES_KEY);
}
 
Example #15
Source File: AbstractJavaScriptLibrarySettings.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getWicketAjaxDebugReference() {
    return WicketAjaxDebugJQueryResourceReference.get();
}
 
Example #16
Source File: AbstractJavaScriptLibrarySettings.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getWicketAjaxReference() {
    return WicketAjaxJQueryResourceReference.get();
}
 
Example #17
Source File: AbstractJavaScriptLibrarySettings.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getWicketEventReference() {
    return WicketEventJQueryResourceReference.get();
}
 
Example #18
Source File: AbstractJavaScriptLibrarySettings.java    From AppStash with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getJQueryReference() {
    return JQueryResourceReference.get();
}
 
Example #19
Source File: CurationSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #20
Source File: RecommendationSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #21
Source File: DocumentMetadataSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #22
Source File: SidebarTab.java    From webanno with Apache License 2.0 4 votes vote down vote up
public ResourceReference getIcon()
{
    return icon;
}
 
Example #23
Source File: SidebarTab.java    From webanno with Apache License 2.0 4 votes vote down vote up
public SidebarTab(IModel<String> aTitle, ResourceReference aIcon)
{
    super(aTitle);
    icon = aIcon;
}
 
Example #24
Source File: DocumentInfoSidebarFactory.java    From webanno with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #25
Source File: SearchAnnotationSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #26
Source File: ImageSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #27
Source File: WbWebSocketHelper.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
private static CharSequence urlFor(final ResourceReference ref, PageParameters params) {
	RequestCycle rc = RequestCycle.get();
	ResourceReferenceRequestHandler handler = new ResourceReferenceRequestHandler(ref, params);
	return rc.getUrlRenderer().renderContextRelativeUrl(rc.mapUrlFor(handler).toString());
}
 
Example #28
Source File: ExternalSearchAnnotationSidebarFactory.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getIcon()
{
    return ICON;
}
 
Example #29
Source File: AbstractJavaScriptLibrarySettings.java    From the-app with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getWicketAjaxDebugReference() {
    return WicketAjaxDebugJQueryResourceReference.get();
}
 
Example #30
Source File: AbstractJavaScriptLibrarySettings.java    From the-app with Apache License 2.0 4 votes vote down vote up
@Override
public ResourceReference getWicketAjaxReference() {
    return WicketAjaxJQueryResourceReference.get();
}