throw new RuntimeException("Document Element must be '"
+ LAYOUT_DEFINITION_ELEMENT + "'");
}
// Create a new LayoutDefinition (the id is not propagated here)
LayoutDefinition ld = new LayoutDefinition("");
// Do "resources" first, they are defined at the top of the document
List<Node> childElements = getChildElements(node, RESOURCES_ELEMENT);
Iterator<Node> it = childElements.iterator();
if (it.hasNext()) {
// Found the RESOURCES_ELEMENT, there is at most 1
addResources(ld, it.next());
}
// Do "types", they need to be defined before parsing the layout
childElements = getChildElements(node, TYPES_ELEMENT);
it = childElements.iterator();
if (it.hasNext()) {
// Found the TYPES_ELEMENT, there is at most 1
addTypes(ld, it.next());
}
// Do "handlers" next, they need to be defined before parsing the layout
childElements = getChildElements(node, HANDLERS_ELEMENT);
it = childElements.iterator();
if (it.hasNext()) {
// Found the HANDLERS_ELEMENT, there is at most 1
cacheHandlerDefs(it.next());
}
// Look to see if there is an EVENT_ELEMENT defined
childElements = getChildElements(node, EVENT_ELEMENT);
it = childElements.iterator();
if (it.hasNext()) {
// Found the EVENT_ELEMENT, there is at most 1
// Get the event type
Node eventNode = it.next();
String type = getAttributes(eventNode).get(TYPE_ATTRIBUTE);
// Set the Handlers for the given event type (name)
List<Handler> handlers = ld.getHandlers(type);
ld.setHandlers(type, getHandlers(eventNode, handlers));
}
// Next look for "layout", there is exactly 1
childElements = getChildElements(node, LAYOUT_ELEMENT);
it = childElements.iterator();