blob: b03f0b756b1e29c02c2a957823f29f08fa809059 [file] [log] [blame]
package org.eclipse.nebula.widgets.nattable.core.example.index
import org.eclipse.nebula.widgets.nattable.core.example.index.node.CategoryNode
import org.eclipse.nebula.widgets.nattable.core.example.index.node.IndexNode
/**
* The examples index. The index is generated by {@link GenerateNatExamplesIndex} and stored as a properties file.
* The properties file has the following format:
* <ul>
* <li>exampleName=fully.qualified.example.class.name|Display name</li>
* </ul>
*/
class NatExamplesIndex {
public static val INDEX_FILE_NAME = "index.properties"
public static val BASE_PACKAGE = "org.eclipse.nebula.widgets.nattable.core.example.impl"
public static val BASE_PACKAGE_PATH = "/" + BASE_PACKAGE.replace('.', '/')
static IndexNode rootNode
def static getRootNode() {
if (rootNode == null)
rootNode = new CategoryNode(BASE_PACKAGE_PATH, "")
rootNode
}
/**
* @param nodePath A '/'-separated path string.
* Each segment prior to the last segment corresponds to a category node.
* The last segment of the path corresponds to a category or an example.
* @return The index node associated with the given node path.
*/
def static IndexNode getNode(String nodePath) {
if (nodePath == null)
getRootNode
else
nodePath.split('/').fold(getRootNode, [ node, pathSegment | node.getChildNode(pathSegment) ])
}
}