Search in sources :

Example 16 with ITableRow

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

the class AbstractBigIntegerColumnTest method testFormattingInDecorateCellInternal.

@Test
public void testFormattingInDecorateCellInternal() {
    ITableRow row = Mockito.mock(ITableRow.class);
    Cell cell = new Cell();
    BigInteger testValue = BigInteger.valueOf(-123456789);
    cell.setValue(testValue);
    DecimalFormat df = BEANS.get(NumberFormatProvider.class).getNumberInstance(Locale.CANADA_FRENCH);
    setFormat(df);
    updateDisplayText(row, cell);
    assertEquals("cell text not formatted as expected", df.format(testValue), cell.getText());
}
Also used : DecimalFormat(java.text.DecimalFormat) NumberFormatProvider(org.eclipse.scout.rt.platform.util.NumberFormatProvider) BigInteger(java.math.BigInteger) 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 17 with ITableRow

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

the class AbstractBooleanColumnWithTriStateTest method testToggle.

@Test
public void testToggle() {
    TestTable table = new TestTable();
    TestTable.TestBooleanColumn column = table.getTestBooleanColumn();
    ITableRow row = table.addRowByArray(new Object[] { null });
    Boolean value = column.getValue(0);
    assertNull(value);
    column.setEditable(true);
    // toggle
    IBooleanField checkbox = (IBooleanField) table.getTestBooleanColumn().prepareEdit(row);
    checkbox.toggleValue();
    table.getTestBooleanColumn().completeEdit(row, checkbox);
    value = table.getTestBooleanColumn().getValue(0);
    assertNotNull(value);
    assertFalse(value);
    // toggle
    checkbox = (IBooleanField) table.getTestBooleanColumn().prepareEdit(row);
    checkbox.toggleValue();
    table.getTestBooleanColumn().completeEdit(row, checkbox);
    value = table.getTestBooleanColumn().getValue(0);
    assertNotNull(value);
    assertTrue(value);
}
Also used : IBooleanField(org.eclipse.scout.rt.client.ui.form.fields.booleanfield.IBooleanField) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 18 with ITableRow

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

the class ContentAssistFieldTable method setLookupRows.

@Override
public void setLookupRows(List<? extends ILookupRow<LOOKUP_KEY>> lookupRows) {
    List<ITableRow> rows = new ArrayList<ITableRow>();
    for (ILookupRow<LOOKUP_KEY> lookupRow : lookupRows) {
        ITableRow row = createRow();
        // Note: we should use a ComparableLookupRow here because restoreSelection does not work
        // since LookupRow does not implement equals/hashCode [awe]
        row.getCellForUpdate(getKeyColumn()).setValue(lookupRow);
        rows.add(row);
        row.setEnabled(lookupRow.isEnabled());
        AbstractTableRowData tableRowBean = lookupRow.getAdditionalTableRowData();
        if (tableRowBean != null) {
            ITableRowDataMapper mapper = createTableRowDataMapper(tableRowBean.getClass());
            mapper.importTableRowData(row, tableRowBean);
        }
    }
    try {
        setTableChanging(true);
        replaceRows(rows);
    } finally {
        setTableChanging(false);
    }
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData) ArrayList(java.util.ArrayList) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) ITableRowDataMapper(org.eclipse.scout.rt.client.ui.basic.table.ITableRowDataMapper)

Example 19 with ITableRow

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

the class AbstractListBox method syncTableToValue.

private void syncTableToValue() {
    if (m_valueTableSyncActive) {
        return;
    }
    boolean resync = false;
    try {
        m_valueTableSyncActive = true;
        m_table.setTableChanging(true);
        // 
        Collection<ITableRow> checkedRows;
        if (getTable().isCheckable()) {
            checkedRows = getTable().getCheckedRows();
        } else {
            checkedRows = getTable().getSelectedRows();
        }
        List<KEY> checkedKeys = getKeyColumnInternal().getValues(checkedRows);
        checkKeys(checkedKeys);
        // Due to validate logic, the actual value
        // may differ now, making a resync of the value is necessary
        Set<KEY> validatedCheckedKeys = getCheckedKeys();
        if (!CollectionUtility.equalsCollection(checkedKeys, validatedCheckedKeys)) {
            resync = true;
        }
        if (!getTable().isCheckable()) {
            // checks follow selection
            for (ITableRow row : m_table.getRows()) {
                row.setChecked(row.isSelected());
            }
        }
        getTable().applyRowFilters();
    } finally {
        getTable().setTableChanging(false);
        m_valueTableSyncActive = false;
    }
    if (resync) {
        // The value of the treeBox is different
        // from the one represented in the tree.
        // Need to sync.
        syncValueToTable();
    }
}
Also used : ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 20 with ITableRow

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

the class AbstractListBox method getCheckedLookupRows.

@SuppressWarnings("unchecked")
@Override
public Set<ILookupRow<KEY>> getCheckedLookupRows() {
    Collection<ITableRow> checkedRows = getTable().getCheckedRows();
    Set<ILookupRow<KEY>> result = new HashSet<ILookupRow<KEY>>(checkedRows.size());
    for (ITableRow row : checkedRows) {
        ICell cell = row.getCell(1);
        result.add(new LookupRow<KEY>((KEY) row.getCellValue(0), cell.getText()).withIconId(cell.getIconId()).withTooltipText(cell.getTooltipText()).withBackgroundColor(cell.getBackgroundColor()).withForegroundColor(cell.getForegroundColor()).withFont(cell.getFont()).withEnabled(row.isEnabled()));
    }
    return result;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) HashSet(java.util.HashSet) ICell(org.eclipse.scout.rt.client.ui.basic.cell.ICell)

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