Search in sources :

Example 1 with Element

use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.

the class GwtElementBuilderImplTestBase method testStyleProperties.

/**
 * Element with style properties.
 *
 * <pre>
 * <div style="color:red;position:absolute;">hello world</div>.
 * </pre>
 */
public void testStyleProperties() {
    DivBuilder divBuilder = factory.createDivBuilder();
    divBuilder.style().trustedColor("red").position(Position.ABSOLUTE).endStyle();
    Element div = divBuilder.text("hello world").finish();
    assertTrue("div".equalsIgnoreCase(div.getTagName()));
    assertEquals("hello world", div.getInnerText());
    assertEquals("red", div.getStyle().getColor());
    assertEquals("absolute", div.getStyle().getPosition());
}
Also used : TableElement(org.gwtproject.dom.client.TableElement) TableCellElement(org.gwtproject.dom.client.TableCellElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) Element(org.gwtproject.dom.client.Element)

Example 2 with Element

use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.

the class GwtElementBuilderImplTestBase method testNestedChildElements.

/**
 * Children nested at multiple levels.
 *
 * <pre>
 * <div id="root">
 *   <div id="child">
 *     <div id="grandchild">grandchild</div>
 *   </div>
 * </div>
 * </pre>
 */
public void testNestedChildElements() {
    DivBuilder builder = factory.createDivBuilder().id("root");
    builder.startDiv().id("child").startDiv().id("grandchild").text("grandchild");
    Element div = builder.finish();
    assertTrue("div".equalsIgnoreCase(div.getTagName()));
    assertEquals("root", div.getId());
    assertEquals(1, div.getChildCount());
    Element child = div.getFirstChildElement();
    assertTrue("div".equalsIgnoreCase(child.getTagName()));
    assertEquals("child", child.getId());
    assertEquals(1, child.getChildCount());
    Element grandchild = child.getFirstChildElement();
    assertTrue("div".equalsIgnoreCase(grandchild.getTagName()));
    assertEquals("grandchild", grandchild.getId());
    assertNull(grandchild.getFirstChildElement());
}
Also used : TableElement(org.gwtproject.dom.client.TableElement) TableCellElement(org.gwtproject.dom.client.TableCellElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) Element(org.gwtproject.dom.client.Element)

Example 3 with Element

use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.

the class J2clElementBuilderImplTestBase method testNestedChildElements.

/**
 * Children nested at multiple levels.
 *
 * <pre>
 * <div id="root">
 *   <div id="child">
 *     <div id="grandchild">grandchild</div>
 *   </div>
 * </div>
 * </pre>
 */
@Test
public void testNestedChildElements() {
    DivBuilder builder = factory.createDivBuilder().id("root");
    builder.startDiv().id("child").startDiv().id("grandchild").text("grandchild");
    Element div = builder.finish();
    assertTrue("div".equalsIgnoreCase(div.getTagName()));
    assertEquals("root", div.getId());
    assertEquals(1, div.getChildCount());
    Element child = div.getFirstChildElement();
    assertTrue("div".equalsIgnoreCase(child.getTagName()));
    assertEquals("child", child.getId());
    assertEquals(1, child.getChildCount());
    Element grandchild = child.getFirstChildElement();
    assertTrue("div".equalsIgnoreCase(grandchild.getTagName()));
    assertEquals("grandchild", grandchild.getId());
    assertNull(grandchild.getFirstChildElement());
}
Also used : TableElement(org.gwtproject.dom.client.TableElement) TableCellElement(org.gwtproject.dom.client.TableCellElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) Element(org.gwtproject.dom.client.Element) Test(org.junit.Test)

Example 4 with Element

use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.

the class J2clElementBuilderImplTestBase method testAttributes.

/**
 * Attributes on an element.
 *
 * <pre>
 * <div id="myId" title="myTitle">hello world</div>
 * </pre>
 */
@Test
public void testAttributes() {
    Element div = factory.createDivBuilder().id("myId").title("myTitle").text("hello world").finish();
    assertTrue("div".equalsIgnoreCase(div.getTagName()));
    assertEquals("hello world", div.getInnerText());
    assertEquals("myId", div.getId());
    assertEquals("myTitle", div.getTitle());
}
Also used : TableElement(org.gwtproject.dom.client.TableElement) TableCellElement(org.gwtproject.dom.client.TableCellElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) Element(org.gwtproject.dom.client.Element) Test(org.junit.Test)

Example 5 with Element

use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.

the class J2clElementBuilderImplTestBase method testNestedSiblingElements.

/**
 * Multiple children beneath root.
 *
 * <pre>
 * <div>
 *   <div>div0</div>
 *   <div>div1</div>
 *   <div>div2</div>
 * </div>
 * </pre>
 */
@Test
public void testNestedSiblingElements() {
    DivBuilder builder = factory.createDivBuilder();
    for (int i = 0; i < 3; i++) {
        builder.startDiv().text("div" + i).endDiv();
    }
    Element div = builder.finish();
    assertTrue("div".equalsIgnoreCase(div.getTagName()));
    assertEquals(3, div.getChildCount());
    Element child = div.getFirstChildElement();
    assertEquals("div0", child.getInnerText());
    child = child.getNextSiblingElement();
    assertEquals("div1", child.getInnerText());
    child = child.getNextSiblingElement();
    assertEquals("div2", child.getInnerText());
}
Also used : TableElement(org.gwtproject.dom.client.TableElement) TableCellElement(org.gwtproject.dom.client.TableCellElement) TableRowElement(org.gwtproject.dom.client.TableRowElement) Element(org.gwtproject.dom.client.Element) Test(org.junit.Test)

Aggregations

Element (org.gwtproject.dom.client.Element)233 TableCellElement (org.gwtproject.dom.client.TableCellElement)37 TableRowElement (org.gwtproject.dom.client.TableRowElement)34 DivElement (org.gwtproject.dom.client.DivElement)19 InputElement (org.gwtproject.dom.client.InputElement)18 TableElement (org.gwtproject.dom.client.TableElement)16 NativeEvent (org.gwtproject.dom.client.NativeEvent)15 Context (org.gwtproject.cell.client.Cell.Context)14 SpanElement (org.gwtproject.dom.client.SpanElement)12 BodyElement (org.gwtproject.dom.client.BodyElement)9 AnchorElement (org.gwtproject.dom.client.AnchorElement)7 EventTarget (org.gwtproject.dom.client.EventTarget)7 TableSectionElement (org.gwtproject.dom.client.TableSectionElement)6 Event (org.gwtproject.user.client.Event)6 Test (org.junit.Test)6 ViewData (org.gwtproject.cell.client.EditTextCell.ViewData)5 Document (org.gwtproject.dom.client.Document)5 HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)4 ImageElement (org.gwtproject.dom.client.ImageElement)4 EventListener (org.gwtproject.user.client.EventListener)4