Search in sources :

Example 1 with IMixedSmartField

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField in project scout.rt by eclipse.

the class AbstractMixedSmartColumnTest method testResetParsingError.

/**
 * An unparsable error should be reset, if a valid value is entered
 */
@Test
public void testResetParsingError() {
    P_Table table = new P_Table();
    table.addRowsByArray(new Object[] { 1L });
    ITableRow testRow = table.getRow(0);
    @SuppressWarnings("unchecked") IMixedSmartField<Long, Long> field = (IMixedSmartField<Long, Long>) table.getEditableSmartColumn().prepareEdit(testRow);
    field.parseAndSetValue("-1L");
    table.getEditableSmartColumn().completeEdit(testRow, field);
    field.parseAndSetValue(TestCodeType.TestCode.TEXT);
    table.getEditableSmartColumn().completeEdit(testRow, field);
    assertNull(field.getErrorStatus());
    assertTrue(testRow.getCellForUpdate(table.getEditableSmartColumn()).isContentValid());
}
Also used : ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) IMixedSmartField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField) Test(org.junit.Test)

Example 2 with IMixedSmartField

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField in project scout.rt by eclipse.

the class AbstractMixedSmartColumnTest method testEditingValidValue.

/**
 * Tests successful editing of a table cell
 */
@Test
public void testEditingValidValue() {
    P_Table table = new P_Table();
    table.addRowsByArray(new Object[] { 1L });
    ITableRow testRow = table.getRow(0);
    @SuppressWarnings("unchecked") IMixedSmartField<Long, Long> field = (IMixedSmartField<Long, Long>) table.getEditableSmartColumn().prepareEdit(testRow);
    field.parseAndSetValue(TestCodeType.TestCode.TEXT);
    table.getEditableSmartColumn().completeEdit(testRow, field);
    assertNull(field.getErrorStatus());
    assertTrue(testRow.getCellForUpdate(table.getEditableSmartColumn()).isContentValid());
}
Also used : ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) IMixedSmartField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField) Test(org.junit.Test)

Example 3 with IMixedSmartField

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField in project scout.rt by eclipse.

the class AbstractMixedSmartColumnTest method testSetUnparsableValue.

/**
 * An unparsable error should lead to an error on the column
 */
@Test
public void testSetUnparsableValue() {
    P_Table table = new P_Table();
    table.addRowsByArray(new Object[] { 1L });
    ITableRow testRow = table.getRow(0);
    @SuppressWarnings("unchecked") IMixedSmartField<Long, Long> field = (IMixedSmartField<Long, Long>) table.getEditableSmartColumn().prepareEdit(testRow);
    field.parseAndSetValue("-1L");
    table.getEditableSmartColumn().completeEdit(testRow, field);
    assertNotNull(field.getErrorStatus());
    assertFalse(testRow.getCellForUpdate(table.getEditableSmartColumn()).isContentValid());
}
Also used : ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) IMixedSmartField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField) Test(org.junit.Test)

Example 4 with IMixedSmartField

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField in project scout.rt by eclipse.

the class AbstractMixedSmartColumnTest method assertCompleteEditWithErrors.

private void assertCompleteEditWithErrors(boolean useUiFacade, Class<? extends ScoutFieldStatus> statusClass) throws Exception {
    P_Table table = new P_Table();
    table.addRowsByArray(new Long[] { 3L });
    IMixedSmartField<?, ?> field = (IMixedSmartField<?, ?>) table.getEditableSmartColumn().prepareEdit(table.getRow(0));
    waitUntilLookupRowsLoaded();
    if (useUiFacade) {
        field.getUIFacade().acceptProposalFromUI("invalid Text", false, false);
    } else {
        field.parseAndSetValue("invalid Text");
    }
    table.getEditableSmartColumn().completeEdit(table.getRow(0), field);
    ICell c = table.getCell(0, 0);
    assertEquals("invalid Text", c.getText());
    assertNotNull(String.format("The invalid cell should have an error status: value '%s'", c.getValue(), c.getErrorStatus()));
    assertTrue(c.getErrorStatus().containsStatus(statusClass));
}
Also used : IMixedSmartField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField) ICell(org.eclipse.scout.rt.client.ui.basic.cell.ICell)

Example 5 with IMixedSmartField

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField in project scout.rt by eclipse.

the class AbstractMixedSmartColumnTest method testPrepareEditInternal.

@Test
@SuppressWarnings("deprecation")
public void testPrepareEditInternal() {
    AbstractMixedSmartColumn<Long, Long> column = new AbstractMixedSmartColumn<Long, Long>() {
    };
    column.setCodeTypeClass(TestCodeType.class);
    column.setMandatory(true);
    ITableRow row = mock(ITableRow.class);
    @SuppressWarnings("unchecked") IMixedSmartField<Long, Long> field = (IMixedSmartField<Long, Long>) column.prepareEditInternal(row);
    assertEquals("mandatory property to be progagated to field", column.isMandatory(), field.isMandatory());
    assertEquals("code type class property to be progagated to field", column.getCodeTypeClass(), field.getCodeTypeClass());
    assertEquals("browse new text to be progagated to field", column.getConfiguredBrowseNewText(), field.getBrowseNewText());
}
Also used : ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) IMixedSmartField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField) Test(org.junit.Test)

Aggregations

IMixedSmartField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField)6 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)5 Test (org.junit.Test)5 ICell (org.eclipse.scout.rt.client.ui.basic.cell.ICell)1 ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)1