Example usage for com.google.gwt.dev.resource ResourceOracle getResources

List of usage examples for com.google.gwt.dev.resource ResourceOracle getResources

Introduction

In this page you can find the example usage for com.google.gwt.dev.resource ResourceOracle getResources.

Prototype

Set<Resource> getResources();

Source Link

Document

Returns an unmodifiable set of unique resources with constant lookup time.

Usage

From source file:fr.putnami.pwt.core.widget.rebind.UiBinderLocalizedCreator.java

License:Open Source License

private Resource getTemplateResource(GeneratorContext context) {
    String packageResourcePath = this.targetType.getPackage().getName().replace('.', '/') + "/";
    ResourceOracle resourceOracle = context.getResourcesOracle();
    Map<String, Resource> reourceMap = new HashMap<>();
    for (Resource resource : resourceOracle.getResources()) {
        reourceMap.put(resource.getPath(), resource);
    }/*w ww .j ava 2s  . co m*/
    String templatePath = packageResourcePath + this.templateName + "_" + this.locale
            + UiBinderLocalizedCreator.TEMPLATE_SUFFIX;
    Resource templateResource = reourceMap.get(templatePath);
    if (templateResource == null) {
        this.locale = null;
        templatePath = packageResourcePath + this.templateName + UiBinderLocalizedCreator.TEMPLATE_SUFFIX;
        templateResource = reourceMap.get(templatePath);
    }
    if (templateResource != null) {
        this.templateName = templatePath.replace(packageResourcePath, "");
    }
    return templateResource;
}