public static RemComponent buildComponent( Node element, Orientation orientation, Stack<String> parentPath, FocusListener listener) { String elementName = DocumentHelper.getElementName(element); for (RemComponentBuilder builder : RemComponentBuilder.values()) { if (elementName.equals(builder.elementType())) { System.out.print("building component: "); System.out.println(elementName); RemComponent component = builder.build(element, orientation, parentPath, listener); return component; } } System.out.print("unknown component type: "); System.out.println(elementName); return UnknownComponentBuilder.build(element, orientation, parentPath, listener); }
@Override public RemComponent build( Node element, Orientation orientation, Stack<String> parentPath, FocusListener listener) { String groupId = DocumentHelper.getAttributeValue("elem", element).orElse(""); Stack<String> path = new Stack<String>(); path.addAll(parentPath); path.push(groupId); RemInterviewGroup group = new RemInterviewGroup(identifierFromPath(path)); group.setLabel(DocumentHelper.getAttributeValue("label", element).orElse("")); Orientation childOrientation = orientation.orthogonalOrientation(); for (Node childNode : DocumentHelper.getChildElements(element)) { RemComponent childComponent = RemComponentBuilder.buildComponent(childNode, childOrientation, path, listener); group.addSubComponent(childComponent); } return group; }