Search in sources :

Example 21 with IColumn

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

the class TableEventBuffer method identicalEventHashCode.

/**
 * Computes a hash value for identical table events. This method must be kept in sync with
 * {@link #isIdenticalEvent(TableEvent, TableEvent)}.
 */
protected int identicalEventHashCode(TableEvent event) {
    final int prime = 31;
    int result = 1;
    result = prime * result + event.getType();
    result = prime * result + (event.isConsumed() ? 1231 : 1237);
    result = prime * result + (event.isSortInMemoryAllowed() ? 1231 : 1237);
    List<ITableRow> rows = event.getRows();
    result = prime * result + ((rows == null) ? 0 : rows.hashCode());
    List<IMenu> popupMenus = event.getPopupMenus();
    result = prime * result + ((popupMenus == null) ? 0 : popupMenus.hashCode());
    TransferObject dragObject = event.getDragObject();
    result = prime * result + ((dragObject == null) ? 0 : dragObject.hashCode());
    TransferObject dropObject = event.getDropObject();
    result = prime * result + ((dropObject == null) ? 0 : dropObject.hashCode());
    TransferObject copyObject = event.getCopyObject();
    result = prime * result + ((copyObject == null) ? 0 : copyObject.hashCode());
    Collection<IColumn<?>> columns = event.getColumns();
    result = prime * result + ((columns == null) ? 0 : columns.hashCode());
    return result;
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) TransferObject(org.eclipse.scout.rt.client.ui.dnd.TransferObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)

Example 22 with IColumn

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

the class TableRowDataMapper method exportTableRowData.

@Override
public void exportTableRowData(ITableRow row, AbstractTableRowData rowData) {
    for (IColumn column : m_columnSet.getColumns()) {
        if (m_ignoredColumns.contains(column)) {
            continue;
        }
        Object value = column.getValue(row);
        FastPropertyDescriptor propertyDesc = m_propertyDescriptorByColumn.get(column);
        if (propertyDesc != null) {
            try {
                Method columnWriteMethod = propertyDesc.getWriteMethod();
                Object dto = getDataContainer(rowData, columnWriteMethod.getDeclaringClass());
                columnWriteMethod.invoke(dto, value);
            } catch (Exception t) {
                LOG.warn("Error writing row data property for column [{}]", column.getClass().getName(), t);
            }
        } else {
            rowData.setCustomValue(column.getColumnId(), value);
        }
    }
    rowData.setRowState(row.getStatus());
    exportCustomValues(row, rowData);
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) Method(java.lang.reflect.Method) FastPropertyDescriptor(org.eclipse.scout.rt.platform.reflect.FastPropertyDescriptor)

Example 23 with IColumn

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

the class ColumnMandatoryTest method testFieldNotMandatoryInColumn.

/**
 * Tests, if a field is not mandatory in a non-mandatory column
 */
@Test
public void testFieldNotMandatoryInColumn() {
    MandatoryTestTable testTable = new MandatoryTestTable();
    testTable.addRowByArray(getTestRow());
    IColumn col = testTable.getNonMandatoryTestColumn();
    IFormField field = col.prepareEdit(testTable.getRow(0));
    assertFalse(col.isMandatory());
    assertFalse(field.isMandatory());
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) Test(org.junit.Test)

Example 24 with IColumn

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

the class ColumnMandatoryTest method testMandatoryErrorIfNoValue.

/**
 * Tests, if a field is mandatory by setting value
 */
@Test
public void testMandatoryErrorIfNoValue() {
    MandatoryTestTable testTable = new MandatoryTestTable();
    testTable.addRowByArray(getTestRow());
    IColumn mandatoryCol = testTable.getMandatoryTestColumn();
    IFormField field = mandatoryCol.prepareEdit(testTable.getRow(0));
    assertTrue(mandatoryCol.isMandatory());
    assertTrue(field.isMandatory());
    assertTrue(field.isContentValid());
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) Test(org.junit.Test)

Example 25 with IColumn

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

the class JsonTableTest method testColumnStructureChangedEvent_dispose.

/**
 * If column structure changes, old columns are disposed and the new ones attached
 */
@Test
public void testColumnStructureChangedEvent_dispose() throws JSONException {
    TableWith3Cols table = new TableWith3Cols();
    table.fill(2);
    table.initTable();
    table.resetColumns();
    IColumn column0 = table.getColumnSet().getColumn(0);
    IColumn column1 = table.getColumnSet().getColumn(1);
    IColumn column2 = table.getColumnSet().getColumn(2);
    column0.setVisible(false);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    String column0Id = jsonTable.getColumnId(column0);
    String column1Id = jsonTable.getColumnId(column1);
    String column2Id = jsonTable.getColumnId(column2);
    assertNull(column0Id);
    assertNotNull(column1Id);
    assertNotNull(column2Id);
    column0.setVisible(true);
    column2.setVisible(false);
    JsonResponse response = m_uiSession.currentJsonResponse();
    response.fireProcessBufferedEvents();
    String newColumn0Id = jsonTable.getColumnId(column0);
    String newColumn1Id = jsonTable.getColumnId(column1);
    String newColumn2Id = jsonTable.getColumnId(column2);
    assertNotNull(newColumn0Id);
    assertNotNull(newColumn1Id);
    Assert.assertNotEquals(column1Id, newColumn1Id);
    assertNull(newColumn2Id);
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TableWith3Cols(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) JsonResponse(org.eclipse.scout.rt.ui.html.json.JsonResponse) Test(org.junit.Test)

Aggregations

IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)49 ArrayList (java.util.ArrayList)10 TreeMap (java.util.TreeMap)8 CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)7 Test (org.junit.Test)6 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)5 JSONObject (org.json.JSONObject)5 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)4 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)4 INumberColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.INumberColumn)3 HashMap (java.util.HashMap)2 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 ClientUIPreferences (org.eclipse.scout.rt.client.ui.ClientUIPreferences)1 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)1