Search in sources :

Example 26 with Context

use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.

the class CellTreeNodeView method resetFocusOnCell.

/**
 * Reset focus on this node.
 *
 * @return true of the cell takes focus, false if not
 */
boolean resetFocusOnCell() {
    if (parentNodeInfo != null) {
        Context context = new Context(getIndex(), 0, getValueKey());
        Cell<T> cell = parentNodeInfo.getCell();
        return cell.resetFocus(context, getCellParent(), value);
    }
    return false;
}
Also used : Context(org.gwtproject.cell.client.Cell.Context)

Example 27 with Context

use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.

the class CellTestBase method testRenderNegativeIndex.

/**
 * Test rendering the cell with a negative index is handled.
 */
public void testRenderNegativeIndex() {
    Cell<T> cell = createCell();
    T value = createCellValue();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(-1, -1, null);
    cell.render(context, value, sb);
    assertEquals(getExpectedInnerHtml(), sb.toSafeHtml().asString());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 28 with Context

use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.

the class CellTestBase method testRenderNull.

/**
 * Test rendering the cell with a null value and no view data.
 */
public void testRenderNull() {
    org.gwtproject.cell.client.Cell<T> cell = createCell();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, null);
    cell.render(context, null, sb);
    assertEquals(getExpectedInnerHtmlNull(), sb.toSafeHtml().asString());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 29 with Context

use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.

the class EditTextCellTest method testRenderUnsafeHtmlWhenEditing.

/**
 * Test rendering the cell with a malicious value in edit mode.
 */
public void testRenderUnsafeHtmlWhenEditing() {
    EditTextCell cell = createCell();
    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());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) ViewData(org.gwtproject.cell.client.EditTextCell.ViewData) SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 30 with Context

use of org.gwtproject.cell.client.Cell.Context in project gwtproject by treblereel.

the class IconCellDecoratorTest method testRenderNoImage.

public void testRenderNoImage() {
    MockCell<String> innerCell = new MockCell<String>(true, "newValueFromInnerCell", "click");
    IconCellDecorator<String> cell = new IconCellDecorator<String>(Resources.prettyPiccy(), innerCell) {

        @Override
        protected boolean isIconUsed(String value) {
            return false;
        }
    };
    // Render the cell.
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, null);
    cell.render(context, "helloworld", sb);
    // Compare the expected render string.
    String expected = "<div style=\"padding-left: 64px;position:relative;zoom:1;\">";
    expected += cell.getImageHtml(Resources.prettyPiccy(), HasVerticalAlignment.ALIGN_MIDDLE, true).asString();
    expected += "<div>helloworld</div>";
    expected += "</div>";
    assertEquals(expected, sb.toSafeHtml().asString());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Aggregations

Context (org.gwtproject.cell.client.Cell.Context)33 Element (org.gwtproject.dom.client.Element)14 SafeHtmlBuilder (org.gwtproject.safehtml.shared.SafeHtmlBuilder)13 NativeEvent (org.gwtproject.dom.client.NativeEvent)9 ViewData (org.gwtproject.cell.client.EditTextCell.ViewData)3 ValueUpdater (org.gwtproject.cell.client.ValueUpdater)3 TableCellBuilder (org.gwtproject.dom.builder.shared.TableCellBuilder)2 DivElement (org.gwtproject.dom.client.DivElement)2 EventTarget (org.gwtproject.dom.client.EventTarget)2 ImageElement (org.gwtproject.dom.client.ImageElement)2 TableCellElement (org.gwtproject.dom.client.TableCellElement)2 TableElement (org.gwtproject.dom.client.TableElement)2 TableRowElement (org.gwtproject.dom.client.TableRowElement)2 TableSectionElement (org.gwtproject.dom.client.TableSectionElement)2 HorizontalAlignmentConstant (org.gwtproject.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant)2 VerticalAlignmentConstant (org.gwtproject.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant)2 HasCell (org.gwtproject.cell.client.HasCell)1 TextCell (org.gwtproject.cell.client.TextCell)1 Scheduler (org.gwtproject.core.client.Scheduler)1 DivBuilder (org.gwtproject.dom.builder.shared.DivBuilder)1