Search in sources :

Example 1 with Folder

use of org.apache.deltaspike.jsf.api.config.view.Folder in project deltaspike by apache.

the class DefaultConfigNodeConverter method convert.

@Override
public ConfigDescriptor convert(ViewConfigNode node) {
    List<Annotation> mergedMetaData = mergeMetaData(node.getMetaData(), node.getInheritedMetaData());
    //e.g. replace default placeholders needed for the merge with real default values
    mergedMetaData = preProcessMetaData(mergedMetaData, node);
    Class sourceClass = node.getSource();
    if (ViewConfigUtils.isFolderConfig(sourceClass)) {
        Folder folderAnnotation = findMetaDataByType(mergedMetaData, Folder.class);
        return new DefaultFolderConfigDescriptor(folderAnnotation.name(), node.getSource(), mergedMetaData, node.getCallbackDescriptors());
    } else if (ViewConfig.class.isAssignableFrom(sourceClass)) {
        View viewAnnotation = findMetaDataByType(mergedMetaData, View.class);
        String viewId = viewAnnotation.basePath() + viewAnnotation.name() + "." + viewAnnotation.extension();
        return new DefaultViewPathConfigDescriptor(viewId, node.getSource(), filterInheritedFolderMetaData(mergedMetaData), node.getCallbackDescriptors());
    } else {
        throw new IllegalStateException(node.getSource() + " isn't a valid view-config");
    }
}
Also used : ViewConfig(org.apache.deltaspike.core.api.config.view.ViewConfig) Folder(org.apache.deltaspike.jsf.api.config.view.Folder) View(org.apache.deltaspike.jsf.api.config.view.View) Annotation(java.lang.annotation.Annotation)

Example 2 with Folder

use of org.apache.deltaspike.jsf.api.config.view.Folder in project deltaspike by apache.

the class NamingConventionUtils method toPath.

public static String toPath(ViewConfigNode node) {
    if (//root-node
    node == null || node.getParent() == null) {
        return "/";
    }
    Folder folderMetaData = null;
    for (Annotation nodeMetaData : node.getMetaData()) {
        if (Folder.class.isAssignableFrom(nodeMetaData.annotationType())) {
            folderMetaData = (Folder) nodeMetaData;
            break;
        }
    }
    String folderName = null;
    if (folderMetaData != null) {
        folderName = folderMetaData.name();
    }
    if (".".equals(folderName)) {
        //default value -> fallback to the default naming
        folderName = null;
    }
    if (folderName == null) {
        folderName = node.getSource().getSimpleName();
        folderName = "./" + folderName.substring(0, 1).toLowerCase() + folderName.substring(1) + "/";
    }
    //@Folder found and no relative path
    if (folderMetaData != null && !folderName.startsWith(".")) {
        return folderName;
    }
    return toPath(node.getParent()) + folderName.substring(1);
}
Also used : Folder(org.apache.deltaspike.jsf.api.config.view.Folder) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)2 Folder (org.apache.deltaspike.jsf.api.config.view.Folder)2 ViewConfig (org.apache.deltaspike.core.api.config.view.ViewConfig)1 View (org.apache.deltaspike.jsf.api.config.view.View)1