use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableSelectionEvent.
/**
* Response must not contain the selection event if the selection was triggered by the request
*/
@Test
public void testIgnorableSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
ITableRow row = table.getRow(2);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row));
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTableTest method testSelectionEvent.
/**
* Tests whether the model row gets correctly selected
*/
@Test
public void testSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
assertNull(table.getSelectedRow());
ITableRow row = table.getRow(2);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row));
jsonTable.handleUiEvent(event);
assertTrue(row.isSelected());
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class AbstractTableField method doSave.
/**
* Saves the table. The call order is as follows:
* <ol>
* <li>{@link #interceptSave(ITableRow[], ITableRow[], ITableRow[])}</li>
* <li>{@link #interceptSaveDeletedRow(ITableRow)}</li>
* <li>{@link #interceptSaveInsertedRow(ITableRow)}</li>
* <li>{@link #interceptSaveUpdatedRow(ITableRow)}</li>
* </ol>
*/
@Override
public void doSave() {
if (m_table != null && !m_tableExternallyManaged) {
try {
m_table.setTableChanging(true);
//
// 1. batch
interceptSave(m_table.getInsertedRows(), m_table.getUpdatedRows(), m_table.getDeletedRows());
// deleted rows
for (ITableRow deletedRow : m_table.getDeletedRows()) {
interceptSaveDeletedRow(deletedRow);
}
// inserted rows
for (ITableRow insertedRow : m_table.getInsertedRows()) {
interceptSaveInsertedRow(insertedRow);
insertedRow.setStatusNonchanged();
m_table.updateRow(insertedRow);
}
// updated rows
for (ITableRow updatedRow : m_table.getUpdatedRows()) {
interceptSaveUpdatedRow(updatedRow);
updatedRow.setStatusNonchanged();
m_table.updateRow(updatedRow);
}
} finally {
m_table.setTableChanging(false);
}
}
markSaved();
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class AbstractTableField method storeToXml.
@Override
public void storeToXml(Element x) {
super.storeToXml(x);
if (m_table != null) {
List<ITableRow> selectedRows = m_table.getSelectedRows();
int[] selectedRowIndices = new int[selectedRows.size()];
int i = 0;
for (ITableRow selrow : selectedRows) {
selectedRowIndices[i] = selrow.getRowIndex();
i++;
}
try {
XmlUtility.setObjectAttribute(x, "selectedRowIndices", selectedRowIndices);
} catch (Exception e) {
LOG.warn("writing attribute 'selectedRowIndices'", e);
}
Object[][] dataMatrix = m_table.getTableData();
for (int r = 0; r < dataMatrix.length; r++) {
for (int c = 0; c < dataMatrix[r].length; c++) {
Object o = dataMatrix[r][c];
if (o != null && !(o instanceof Serializable)) {
LOG.warn("ignoring not serializable value at row={}, col={}: {}[{}]", r, c, o, o.getClass());
dataMatrix[r][c] = null;
}
}
}
try {
XmlUtility.setObjectAttribute(x, "rows", dataMatrix);
} catch (Exception e) {
LOG.warn("writing attribute 'rows'", e);
}
}
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class AbstractTableField method validateContent.
@Override
public IValidateContentDescriptor validateContent() {
IValidateContentDescriptor desc = super.validateContent();
// super check
if (desc != null) {
return desc;
}
ITable table = getTable();
// check cells
ValidateTableFieldDescriptor tableDesc = null;
TreeSet<String> columnNames = new TreeSet<String>();
if (table != null) {
for (ITableRow row : table.getRows()) {
for (IColumn col : table.getColumns()) {
if (!col.isContentValid(row)) {
if (tableDesc == null) {
tableDesc = new ValidateTableFieldDescriptor(this, row, col);
}
columnNames.add(getColumnName(col));
}
}
}
table.ensureInvalidColumnsVisible();
}
if (tableDesc != null) {
tableDesc.setDisplayText(TEXTS.get("TableName") + " " + getLabel() + ": " + CollectionUtility.format(columnNames));
}
return tableDesc;
}
Aggregations