/** Test of renderChildren method, of class Activity. */ @Test public void testCreateChildren() throws Exception { System.out.println("renderChildren"); // Setup ChildPane childPane = new ChildPane(); childPane.setChild("Child"); VBox vbox = VBoxBuilder.create().children(childPane).build(); Parent parent = new Parent(); parent.setScene(vbox); Data data = new Data(); Map<Field, Object> fieldParams = new HashMap<Field, Object>(); for (Field field : data.getClass().getDeclaredFields()) { field.setAccessible(true); fieldParams.put(field, field.get(data)); } RenderParameter renderParam = new RenderParameter(); String id = renderParam.putParam("checkForLabel", "CheckForLabel"); childPane.setId(id); parent.createChildren(fieldParams, renderParam, ValidationResult.getEmptyResult()); // Assertoin Child child = (Child) parent.getChildActivities(Child.class).get(0); assertNotNull(child); assertNotNull(child.getScene()); assertEquals(childPane, child.getScene()); assertEquals(parent, child.getParent()); VBox cvbox = (VBox) child.getScene().getChildren().get(0); assertTrue(cvbox.getChildren().get(0) instanceof Button); assertTrue(cvbox.getChildren().get(1) instanceof Label); assertEquals(data.checkForButton, ((Button) cvbox.getChildren().get(0)).getText()); assertEquals("CheckForLabel", ((Label) cvbox.getChildren().get(1)).getText()); }
/** * Copy constructor, used to get a deep copy of the passed instance * * @param source the instance to copy */ public Dom(Dom source, Dom parent) { this(source.getHabitat(), source.document, parent, source.model); List<Child> newChildren = new ArrayList<Child>(); for (Child child : source.children) { newChildren.add(child.deepCopy(this)); } setChildren(newChildren); attributes.putAll(source.attributes); }
/** * Writes back this element. * * @param tagName The tag name of this element to be written. If null, this DOM node must be a * global element and its tag name will be used. * @param w Receives XML infoset stream. */ public void writeTo(String tagName, XMLStreamWriter w) throws XMLStreamException { if (tagName == null) tagName = model.tagName; if (tagName == null) throw new IllegalArgumentException( "Trying t write a local element " + this + " w/o a tag name"); /** * If someone has explicitly called the skipFromXml then dont write the element to domain.xml */ if (!writeToXml) { return; } w.writeStartElement(tagName); for (Map.Entry<String, String> attributeToWrite : attributesToWrite().entrySet()) { w.writeAttribute(attributeToWrite.getKey(), attributeToWrite.getValue()); } List<Child> localChildren = new ArrayList<Child>(children); for (Child c : localChildren) c.writeTo(w); w.writeEndElement(); }
public void addChild(Child child) { getChildren().add(child); child.setParent(this); }