Search in sources :

Example 46 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractIntegerColumnTest method testPrepareEditInternal.

@Test
public void testPrepareEditInternal() {
    AbstractIntegerColumn column = new AbstractIntegerColumn() {
    };
    column.setMandatory(true);
    ITableRow row = mock(ITableRow.class);
    IIntegerField field = (IIntegerField) column.prepareEditInternal(row);
    assertEquals("mandatory property to be progagated to field", column.isMandatory(), field.isMandatory());
}
Also used : IIntegerField(org.eclipse.scout.rt.client.ui.form.fields.integerfield.IIntegerField) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 47 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractIntegerColumnTest method testFormattingInDecorateCellInternal.

@Test
public void testFormattingInDecorateCellInternal() {
    ITableRow row = Mockito.mock(ITableRow.class);
    Cell cell = new Cell();
    Integer testValue = Integer.valueOf(-123456789);
    cell.setValue(testValue);
    for (Locale locale : DecimalFormat.getAvailableLocales()) {
        DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(locale);
        df.applyPattern(getFormat().toPattern());
        setFormat(df);
        updateDisplayText(row, cell);
        assertEquals("cell text not formatted as expected", df.format(testValue), cell.getText());
    }
}
Also used : Locale(java.util.Locale) DecimalFormat(java.text.DecimalFormat) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Cell(org.eclipse.scout.rt.client.ui.basic.cell.Cell) Test(org.junit.Test)

Example 48 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractLongColumnTest method testFormattingInDecorateCellInternal.

@Test
public void testFormattingInDecorateCellInternal() {
    ITableRow row = mock(ITableRow.class);
    Cell cell = new Cell();
    Long testValue = Long.valueOf(-123456789);
    cell.setValue(testValue);
    for (Locale locale : DecimalFormat.getAvailableLocales()) {
        DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(locale);
        df.applyPattern(getFormat().toPattern());
        setFormat(df);
        updateDisplayText(row, cell);
        assertEquals("cell text not formatted as expected", df.format(testValue), cell.getText());
    }
}
Also used : Locale(java.util.Locale) DecimalFormat(java.text.DecimalFormat) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Cell(org.eclipse.scout.rt.client.ui.basic.cell.Cell) Test(org.junit.Test)

Example 49 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractMixedSmartColumnTest method tesConvertValueToKeyCallback.

/**
 * Tests that {@link AbstractMixedSmartColumn#execPrepareLookup(ILookupCall, ITableRow)} is called when
 * {@link IMixedSmartField#prepareKeyLookup(ILookupCall, Object)} is called on the editor field.
 */
@SuppressWarnings("unchecked")
@Test
public void tesConvertValueToKeyCallback() {
    TestMixedSmartColumn column = new TestMixedSmartColumn();
    ITableRow row = Mockito.mock(ITableRow.class);
    AbstractMixedSmartField<String, Long> field = (AbstractMixedSmartField<String, Long>) column.prepareEditInternal(row);
    field.setValue("test");
    Long lookupKey = field.getValueAsLookupKey();
    assertEquals(Long.valueOf(0L), lookupKey);
    assertEquals(column.lastValue, "test");
}
Also used : AbstractMixedSmartField(org.eclipse.scout.rt.client.ui.form.fields.smartfield.AbstractMixedSmartField) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 50 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractNumberColumnTest method testPrepareEditInternal.

@Test
public void testPrepareEditInternal() {
    setGroupingUsed(false);
    String bColor = "469406";
    setBackgroundColor(bColor);
    String fColor = "FAAAF1";
    setForegroundColor(fColor);
    FontSpec fontSpec = new FontSpec("Arial", FontSpec.STYLE_ITALIC | FontSpec.STYLE_BOLD, 0);
    setFont(fontSpec);
    Integer minValue = Integer.valueOf(-42);
    setMinValue(minValue);
    Integer maxValue = Integer.valueOf(42);
    setMaxValue(maxValue);
    ITableRow row = Mockito.mock(ITableRow.class);
    AbstractIntegerField field = (AbstractIntegerField) prepareEditInternal(row);
    assertFalse("expected groupingUsed property to be propagated to field", field.isGroupingUsed());
    setGroupingUsed(true);
    field = (AbstractIntegerField) prepareEditInternal(row);
    assertTrue("expected groupingUsed property to be propagated to field", field.isGroupingUsed());
    assertEquals("expected backgroundColor property to be progagated to field", bColor, field.getBackgroundColor());
    assertEquals("expected foregroundColor property to be progagated to field", fColor, field.getForegroundColor());
    assertEquals("expected font property to be progagated to field", fontSpec, field.getFont());
    assertEquals("expected minValue property to be progagated to field", minValue, field.getMinValue());
    assertEquals("expected maxValue property to be progagated to field", maxValue, field.getMaxValue());
}
Also used : AbstractIntegerField(org.eclipse.scout.rt.client.ui.form.fields.integerfield.AbstractIntegerField) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) FontSpec(org.eclipse.scout.rt.shared.data.basic.FontSpec) Test(org.junit.Test)

Aggregations

ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)127 Test (org.junit.Test)77 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)47 ArrayList (java.util.ArrayList)23 JSONObject (org.json.JSONObject)22 TableWith3Cols (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols)16 JSONArray (org.json.JSONArray)13 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)12 ITableRowFilter (org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter)11 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)7 IProposalField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField)7 ListBoxTable (org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable)6 IMixedSmartField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField)5 Table (org.eclipse.scout.rt.ui.html.json.table.fixtures.Table)5 TableWithLongColumn (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn)5 DecimalFormat (java.text.DecimalFormat)4 List (java.util.List)4 Cell (org.eclipse.scout.rt.client.ui.basic.cell.Cell)4 ICell (org.eclipse.scout.rt.client.ui.basic.cell.ICell)4 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)4