Search in sources :

Example 1 with Document

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

the class HyperlinkTest method testLinkTraversal.

public void testLinkTraversal() {
    final String testHistoryToken = TEST_HISTORY_TOKEN;
    Hyperlink link = new Hyperlink("foobar", testHistoryToken);
    HandlerRegistration registration = null;
    try {
        RootPanel.get().add(link);
        registration = History.addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                assertEquals(testHistoryToken, event.getValue());
                assertEquals(testHistoryToken, History.getToken());
            }
        });
        Document document = Document.get();
        NativeEvent event = document.createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
        link.getElement().dispatchEvent(event);
    } finally {
        RootPanel.get().remove(link);
        if (registration != null) {
            registration.removeHandler();
        }
    }
}
Also used : HandlerRegistration(org.gwtproject.event.shared.HandlerRegistration) ValueChangeEvent(org.gwtproject.event.logical.shared.ValueChangeEvent) ValueChangeHandler(org.gwtproject.event.logical.shared.ValueChangeHandler) Document(org.gwtproject.dom.client.Document) NativeEvent(org.gwtproject.dom.client.NativeEvent)

Example 2 with Document

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

the class TextBoxTest method testNoNukeTabIndex.

public void testNoNukeTabIndex() {
    Document doc = Document.get();
    DivElement div = doc.createDivElement();
    div.setInnerHTML("<input type='text' id='tb' tabindex='1'></input>");
    doc.getBody().appendChild(div);
    TextBox tb = TextBox.wrap(doc.getElementById("tb"));
    assertEquals(1, tb.getTabIndex());
}
Also used : DivElement(org.gwtproject.dom.client.DivElement) Document(org.gwtproject.dom.client.Document)

Example 3 with Document

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

the class LayoutJ2clTest method setUp.

@Before
public void setUp() throws Exception {
    // ensure enough sizes for this test
    ResizeHelper.resizeTo(800, 600);
    enableScrolling(false);
    Document doc = Document.get();
    parent = doc.createDivElement();
    child0 = doc.createDivElement();
    child1 = doc.createDivElement();
    doc.getBody().appendChild(parent);
    layout = new Layout(parent);
    layout.onAttach();
    layout.fillParent();
    layer0 = layout.attachChild(child0);
    layer1 = layout.attachChild(child1);
    wrapper0 = child0.getParentElement();
    wrapper1 = child1.getParentElement();
}
Also used : Document(org.gwtproject.dom.client.Document) Before(org.junit.Before)

Example 4 with Document

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

the class LayoutGwt2Test method testFillParent.

/**
 * Test that fillParent() works properly when the outer div is a child of another div, and that it
 * correctly follows that div's size.
 */
@DoNotRunWith(Platform.HtmlUnitLayout)
public void testFillParent() {
    // We don't use the default elements created in gwtSetUp() because we need
    // to test the behavior when the layout is contained by an element other
    // than the <body>.
    Document doc = Document.get();
    DivElement container = doc.createDivElement();
    DivElement parent = doc.createDivElement();
    DivElement child = doc.createDivElement();
    child.setInnerHTML("&nbsp;");
    doc.getBody().appendChild(container);
    container.appendChild(parent);
    // The container has to be position:relative so that it serves as an offset
    // parent.
    container.getStyle().setPosition(Position.RELATIVE);
    container.getStyle().setWidth(128, PX);
    container.getStyle().setHeight(256, PX);
    Layout layout = new Layout(parent);
    layout.onAttach();
    Layout.Layer layer = layout.attachChild(child);
    layer.setTopBottom(0, PX, 0, PX);
    layer.setLeftRight(0, PX, 0, PX);
    layout.fillParent();
    layout.layout();
    // Test 128x256.
    assertEquals(128, container.getOffsetWidth());
    assertEquals(256, container.getOffsetHeight());
    assertEquals(128, parent.getOffsetWidth());
    assertEquals(256, parent.getOffsetHeight());
    assertEquals(128, child.getOffsetWidth());
    assertEquals(256, child.getOffsetHeight());
    // Expand to 256x256. The layout should react automatically.
    container.getStyle().setWidth(256, PX);
    container.getStyle().setHeight(128, PX);
    assertEquals(256, container.getOffsetWidth());
    assertEquals(256, parent.getOffsetWidth());
    assertEquals(256, child.getOffsetWidth());
    layout.onDetach();
}
Also used : DivElement(org.gwtproject.dom.client.DivElement) Layer(org.gwtproject.layout.client.Layout.Layer) Document(org.gwtproject.dom.client.Document) DoNotRunWith(com.google.gwt.junit.DoNotRunWith)

Example 5 with Document

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

the class RichTextAreaImplStandard method execCommandAssumingFocus.

void execCommandAssumingFocus(String cmd, String param) {
    HTMLIFrameElement iframe = Js.uncheckedCast(elem);
    Document document = Js.uncheckedCast(Js.asPropertyMap(iframe.contentWindow).get("document"));
    ((ExecCommand) Js.uncheckedCast(Js.asPropertyMap(document).get("execCommand"))).onInvoke(cmd, false, param);
}
Also used : HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) Document(org.gwtproject.dom.client.Document)

Aggregations

Document (org.gwtproject.dom.client.Document)15 Element (org.gwtproject.dom.client.Element)5 DivElement (org.gwtproject.dom.client.DivElement)4 HTMLIFrameElement (elemental2.dom.HTMLIFrameElement)3 BodyElement (org.gwtproject.dom.client.BodyElement)3 Layer (org.gwtproject.layout.client.Layout.Layer)2 DoNotRunWith (com.google.gwt.junit.DoNotRunWith)1 ScheduledCommand (org.gwtproject.core.client.Scheduler.ScheduledCommand)1 AnchorElement (org.gwtproject.dom.client.AnchorElement)1 NativeEvent (org.gwtproject.dom.client.NativeEvent)1 Style (org.gwtproject.dom.client.Style)1 Text (org.gwtproject.dom.client.Text)1 ValueChangeEvent (org.gwtproject.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (org.gwtproject.event.logical.shared.ValueChangeHandler)1 HandlerRegistration (org.gwtproject.event.shared.HandlerRegistration)1 Before (org.junit.Before)1