Package com.google.gwt.cell.client.Cell

Examples of com.google.gwt.cell.client.Cell.Context


    Event.setEventListener(parent, new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        try {
          DOM.setEventListener(parent, null);
          Context context = new Context(0, 0, DEFAULT_KEY);
          cell.onBrowserEvent(context, parent, value, event, valueUpdater);
          parent.removeFromParent();
        } catch (Exception e) {
          // We are in an event loop, so events may not propagate out to JUnit.
          fail("An exception occured while handling the event: "
View Full Code Here


  public void testIsEditingFalse() {
    List<HasCell<String, ?>> cells = createHasCells(3);
    CompositeCell<String> cell = new CompositeCell<String>(cells);
    Element parent = Document.get().createDivElement();
    parent.setInnerHTML(getExpectedInnerHtml());
    assertFalse(cell.isEditing(new Context(0, 0, null), parent, "test"));
  }
View Full Code Here

    };
    addCell(mock, cells);
    CompositeCell<String> cell = new CompositeCell<String>(cells);
    Element parent = Document.get().createDivElement();
    parent.setInnerHTML(getExpectedInnerHtml());
    assertTrue(cell.isEditing(new Context(0, 0, null), parent, "test"));
  }
View Full Code Here

    // Add an event listener.
    EventListener listener = new EventListener() {
      @Override
      public void onBrowserEvent(Event event) {
        Context context = new Context(3, 4, "key");
        cell.onBrowserEvent(context, parent, "test-x", event, null);
      }
    };
    DOM.sinkEvents(parent, Event.ONCLICK);
    DOM.setEventListener(parent, listener);

    // Fire the event on one of the inner cells.
    NativeEvent event = Document.get().createClickEvent(0, 0, 0, 0, 0, false,
        false, false, false);
    Element.as(parent.getChild(2)).dispatchEvent(event);
    innerCell.assertLastEventValue("test-x");
    innerCell.assertLastParentElement(Element.as(parent.getChild(2)));
    Context innerContext = innerCell.getLastContext();
    assertEquals("key", innerContext.getKey());
    assertEquals(3, innerContext.getIndex());
    assertEquals(4, innerContext.getColumn());

    // Fire the event to another cell that doesn't consume this event. Shouldn't respond
    // to the event
    MockCell<String> innerCell2 = (MockCell<String>) cells.get(1).getCell();
    Element.as(parent.getChild(1)).dispatchEvent(event);
View Full Code Here

  public void testSetValue() {
    Cell<String> cell = createCell();
    Element parent = Document.get().createDivElement();
    parent.setInnerHTML(getExpectedInnerHtml());
    Context context = new Context(0, 0, null);
    cell.setValue(context, parent, "test");

    assertEquals(3, parent.getChildCount());
    assertEquals("test-0", Element.as(parent.getChild(0)).getInnerHTML());
    assertEquals("test-1", Element.as(parent.getChild(1)).getInnerHTML());
View Full Code Here

   * Test rendering the cell with a malicious value.
   */
  public void testRenderUnsafeHtml() {
    Cell<String> cell = createCell();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, null);
    cell.render(context, "<script>malicious</script>", sb);
    assertEquals(
        "<input type=\"text\" value=\"&lt;script&gt;malicious&lt;/script&gt;\" tabindex=\"-1\">"
            + "</input>", sb.toSafeHtml().asString());
  }
View Full Code Here

    Element parent = Document.get().createDivElement();
    parent.setInnerHTML("<input type='text' value='editing'></input>");
    ViewData viewData = new ViewData("originalValue");
    viewData.setText("newValue");
    cell.setViewData(DEFAULT_KEY, viewData);
    Context context = new Context(0, 0, DEFAULT_KEY);
    cell.edit(context, parent, "originalValue");

    // Verify the input element.
    Element child = parent.getFirstChildElement();
    assertTrue(InputElement.is(child));
View Full Code Here

    ViewData viewData = new ViewData("originalValue");
    viewData.setText("newValue");
    viewData.setEditing(false);
    cell.setViewData(DEFAULT_KEY, viewData);
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, DEFAULT_KEY);
    cell.render(context, "originalValue", sb);
    assertEquals("newValue", sb.toSafeHtml().asString());
  }
View Full Code Here

   * Test rendering the cell with a malicious value.
   */
  public void testRenderUnsafeHtml() {
    EditTextCell cell = createCell();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, null);
    cell.render(context, "<script>malicious</script>", sb);
    assertEquals("&lt;script&gt;malicious&lt;/script&gt;", sb.toSafeHtml().asString());
  }
View Full Code Here

    ViewData viewData = new ViewData("originalValue");
    viewData.setText("<script>malicious</script>");
    viewData.setEditing(true);
    cell.setViewData(DEFAULT_KEY, viewData);
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, DEFAULT_KEY);
    cell.render(context, "<script>malicious</script>", sb);
    assertEquals("<input type=\"text\" value=\"&lt;script&gt;malicious&lt;/script&gt;\" "
        + "tabindex=\"-1\"></input>", sb.toSafeHtml().asString());
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.cell.client.Cell.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.