private DomBuilderImpl impl() { return new DomBuilderImpl(); } }
/** * Assert that the builder is in a state where an attribute can be added. * * @return the element on which the attribute can be set */ protected E assertCanAddAttribute() { /* * An explicit parameterized return type on cast() is required by some javac * compilers. */ return delegate.assertCanAddAttribute().<E> cast(); }
/** * Assert that the builder is in a state where an attribute can be added. * * @return the element on which the attribute can be set * @throw {@link IllegalStateException} if the start tag is closed */ Element assertCanAddAttribute() { assertCanAddAttributeImpl(); return getCurrentElement(); }
/** * Assert that the builder is in a state where a style property can be added. * * @return the {@link Style} on which the property can be set * @throw {@link IllegalStateException} if the style is not accessible */ Style assertCanAddStyleProperty() { assertCanAddStylePropertyImpl(); return getCurrentElement().getStyle(); }
public DomElementBuilder trustedStart(String tagName) { /* * Validate the tag before trying to create the element, or the browser may * throw a JS error and prevent us from triggering an * IllegalArgumentException. */ assertValidTagName(tagName); start(Document.get().createElement(tagName), elementBuilder); return elementBuilder; }
@Override public StylesBuilder cursor(Cursor value) { delegate.assertCanAddStyleProperty().setCursor(value); return this; }
/** * Start a child element. * * @param element the element to start * @param builder the builder used to builder the new element */ private void start(Element element, ElementBuilderBase<?> builder) { onStart(element.getTagName(), builder); // Set the root element. if (rootElement == null) { // This is the new root element. rootElement = element; } else { // Appending to the current element. getCurrentElement().appendChild(element); } // Add the element to the stack. currentElement = element; }
/** * Pop to the previous element in the stack. */ private void popElement() { currentElement = getCurrentElement().getParentElement(); }
@Override public ScriptBuilder text(String text) { assertCanAddAttribute().setText(text); /* * The HTML version appends text inline, so we prevent additional attributes * after setting the text. */ getDelegate().lockCurrentElement(); return this; }
@Override public void endStyle() { delegate.endStyle(); }
@Override public StylesBuilder floatprop(Float value) { delegate.assertCanAddStyleProperty().setFloat(value); return this; }
public DomElementBuilder trustedStart(String tagName) { /* * Validate the tag before trying to create the element, or the browser may * throw a JS error and prevent us from triggering an * IllegalArgumentException. */ assertValidTagName(tagName); start(Document.get().createElement(tagName), elementBuilder); return elementBuilder; }
/** * Assert that the builder is in a state where a style property can be added. * * @return the {@link Style} on which the property can be set * @throw {@link IllegalStateException} if the style is not accessible */ Style assertCanAddStyleProperty() { assertCanAddStylePropertyImpl(); return getCurrentElement().getStyle(); }
/** * Start a child element. * * @param element the element to start * @param builder the builder used to builder the new element */ private void start(Element element, ElementBuilderBase<?> builder) { onStart(element.getTagName(), builder); // Set the root element. if (rootElement == null) { // This is the new root element. rootElement = element; } else { // Appending to the current element. getCurrentElement().appendChild(element); } // Add the element to the stack. currentElement = element; }
@Override protected void doTextImpl(String text) { getCurrentElement().setInnerText(text); }
@Override public StyleBuilder cssText(String cssText) { assertCanAddAttribute().setCssText(cssText); /* * The HTML version appends text inline, so we prevent additional attributes * after setting the text. */ getDelegate().lockCurrentElement(); return this; }
@Override public void endStyle() { delegate.endStyle(); }
@Override public StylesBuilder lineHeight(double value, Unit unit) { delegate.assertCanAddStyleProperty().setLineHeight(value, unit); return this; }
public DomElementBuilder trustedStart(String tagName) { /* * Validate the tag before trying to create the element, or the browser may * throw a JS error and prevent us from triggering an * IllegalArgumentException. */ assertValidTagName(tagName); start(Document.get().createElement(tagName), elementBuilder); return elementBuilder; }
/** * Assert that the builder is in a state where a style property can be added. * * @return the {@link Style} on which the property can be set * @throw {@link IllegalStateException} if the style is not accessible */ Style assertCanAddStyleProperty() { assertCanAddStylePropertyImpl(); return getCurrentElement().getStyle(); }