Search in sources :

Example 1 with AbstractTableRowData

use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData 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 2 with AbstractTableRowData

use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData in project scout.rt by eclipse.

the class LookupRowTest method testCreateNonEmpty.

/**
 * Tests initialization of a lookup row with non-null values
 */
@Test
public void testCreateNonEmpty() {
    AbstractTableRowData bean = new AbstractTableRowData() {

        private static final long serialVersionUID = 1L;
    };
    ILookupRow<String> row = new LookupRow<>("key", "text").withIconId("testIcon").withTooltipText("testTooltip").withCssClass("cssClass").withForegroundColor("foreground").withBackgroundColor("background").withParentKey("parent").withAdditionalTableRowData(bean).withActive(false).withEnabled(false);
    assertEquals("key", row.getKey());
    assertEquals("text", row.getText());
    assertEquals("testIcon", row.getIconId());
    assertEquals("testTooltip", row.getTooltipText());
    assertEquals("cssClass", row.getCssClass());
    assertEquals("foreground", row.getForegroundColor());
    assertEquals("background", row.getBackgroundColor());
    assertEquals("parent", row.getParentKey());
    assertEquals(bean, row.getAdditionalTableRowData());
    assertFalse(row.isActive());
    assertFalse(row.isEnabled());
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData) Test(org.junit.Test)

Example 3 with AbstractTableRowData

use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData in project scout.rt by eclipse.

the class CodeRowTest method testCreateNonEmpty.

/**
 * Tests initialization of a lookup row with non-null values
 */
@Test
public void testCreateNonEmpty() {
    AbstractTableRowData bean = new AbstractTableRowData() {

        private static final long serialVersionUID = 1L;
    };
    ICodeRow<String> row = new CodeRow<>(KEY, TEXT).withIconId(TEST_ICON).withTooltipText(TEST_TOOLTIP).withCssClass(CSS_CLASS).withForegroundColor(FOREGROUND).withBackgroundColor(BACKGROUND).withParentKey(PARENT).withAdditionalTableRowData(bean).withActive(false).withEnabled(false);
    assertEquals(KEY, row.getKey());
    assertEquals(TEXT, row.getText());
    assertEquals(TEST_ICON, row.getIconId());
    assertEquals(TEST_TOOLTIP, row.getTooltipText());
    assertEquals(CSS_CLASS, row.getCssClass());
    assertEquals(FOREGROUND, row.getForegroundColor());
    assertEquals(BACKGROUND, row.getBackgroundColor());
    assertEquals(PARENT, row.getParentKey());
    assertEquals(bean, row.getAdditionalTableRowData());
    assertFalse(row.isActive());
    assertFalse(row.isEnabled());
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData) Test(org.junit.Test)

Example 4 with AbstractTableRowData

use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData in project scout.rt by eclipse.

the class AbstractTableFieldBeanData method addRow.

/**
 * Create, adds and returns a new {@link AbstractTableRowData} which row state is initialized with the given value.
 *
 * @param rowState
 * @return
 */
public AbstractTableRowData addRow(int rowState) {
    AbstractTableRowData row = createRow();
    row.setRowState(rowState);
    m_rowList.add(row);
    setValueSet(true);
    return row;
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData)

Example 5 with AbstractTableRowData

use of org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData in project scout.rt by eclipse.

the class AbstractTableFieldBeanData method setRows.

/**
 * Replaces the rows with the given array.
 *
 * @param rows
 */
public void setRows(AbstractTableRowData[] rows) {
    m_rowList.clear();
    Class<? extends AbstractTableRowData> rowType = getRowType();
    if (rowType == null) {
        throw new IllegalStateException("row type is not initialized");
    }
    for (AbstractTableRowData row : rows) {
        if (row == null) {
            continue;
        }
        if (!rowType.isInstance(row)) {
            throw new IllegalArgumentException("wrong row type. Expected [" + rowType.getName() + "], actual: [" + row.getClass().getName() + "]");
        }
        m_rowList.add(row);
    }
    setValueSet(true);
}
Also used : AbstractTableRowData(org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData)

Aggregations

AbstractTableRowData (org.eclipse.scout.rt.shared.data.basic.table.AbstractTableRowData)7 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 ITableRowDataMapper (org.eclipse.scout.rt.client.ui.basic.table.ITableRowDataMapper)1 InternalTableRow (org.eclipse.scout.rt.client.ui.basic.table.internal.InternalTableRow)1