Search in sources :

Example 1 with SVGSource

use of org.kie.workbench.common.stunner.svg.annotation.SVGSource in project kie-wb-common by kiegroup.

the class SVGShapeProcessor method processSvgShapeViewFactory.

private boolean processSvgShapeViewFactory(final Set<? extends TypeElement> set, final Element e, final RoundEnvironment roundEnv) throws Exception {
    final boolean isIface = e.getKind() == ElementKind.INTERFACE;
    if (isIface) {
        final TypeElement classElement = (TypeElement) e;
        final PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
        final String name = classElement.getSimpleName().toString();
        // Obtain type element information and create a new generation request into the processor's context.
        String packageName = packageElement.getQualifiedName().toString();
        String fqcn = packageName + "." + name;
        String absPkgPath = packageName.replaceAll("\\.", "/");
        note("Discovered @SVGViewFactory for type [" + fqcn + "]");
        SVGViewFactory svgViewFactoryAnn = classElement.getAnnotation(SVGViewFactory.class);
        final SVGGeneratorRequest request = new SVGGeneratorRequest(name + GENERATED_TYPE_SUFFIX, packageName, fqcn, absPkgPath + "/" + svgViewFactoryAnn.value(), processingEnv.getMessager());
        context.setGeneratorRequest(request);
        // Find and process method annotation as @SVGSource.
        List<ExecutableElement> methodElements = ElementFilter.methodsIn(classElement.getEnclosedElements());
        methodElements.forEach(methodElement -> {
            SVGSource svgSourceAnnotation = methodElement.getAnnotation(SVGSource.class);
            if (null != svgSourceAnnotation) {
                String fileName = svgSourceAnnotation.value();
                String absPath = absPkgPath + "/" + fileName;
                final String fieldName = methodElement.getSimpleName().toString();
                note("Discovered @SVGSource to be processed at path [" + absPath + "]");
                context.getGeneratorRequest().getViewSources().put(fieldName, absPath);
            }
        });
    }
    return true;
}
Also used : SVGGeneratorRequest(org.kie.workbench.common.stunner.svg.gen.SVGGeneratorRequest) SVGViewFactory(org.kie.workbench.common.stunner.svg.annotation.SVGViewFactory) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) PackageElement(javax.lang.model.element.PackageElement) SVGSource(org.kie.workbench.common.stunner.svg.annotation.SVGSource)

Aggregations

ExecutableElement (javax.lang.model.element.ExecutableElement)1 PackageElement (javax.lang.model.element.PackageElement)1 TypeElement (javax.lang.model.element.TypeElement)1 SVGSource (org.kie.workbench.common.stunner.svg.annotation.SVGSource)1 SVGViewFactory (org.kie.workbench.common.stunner.svg.annotation.SVGViewFactory)1 SVGGeneratorRequest (org.kie.workbench.common.stunner.svg.gen.SVGGeneratorRequest)1