[ 1805503 ] UI allows changing record while new record not saved

- replacing the bad m_inserting fix
This commit is contained in:
Heng Sin Low 2008-01-15 05:04:02 +00:00
parent 503c6389fb
commit 058f7feaf3
2 changed files with 29 additions and 16 deletions

View File

@ -900,10 +900,18 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
if (isDetail() && m_parentNeedSave)
return false;
boolean retValue = m_mTable.dataNew (m_currentRow, copy);
/**
* temporary set currentrow to point to the new row to ensure even cause by m_mTable.dataNew
* is handle properly.
*/
int oldCurrentRow = m_currentRow;
m_currentRow = m_currentRow + 1;
boolean retValue = m_mTable.dataNew (oldCurrentRow, copy);
m_currentRow = oldCurrentRow;
if (!retValue)
return retValue;
setCurrentRow(m_currentRow + 1, true);
// process all Callouts (no dependency check - assumed that settings are valid)
for (int i = 0; i < getFieldCount(); i++)
processCallout(getField(i));
@ -2668,6 +2676,6 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
m_mTable.sort(lineCol, true);
}
navigate(to);
}
}
} // MTab

View File

@ -2115,10 +2115,27 @@ public class GridTable extends AbstractTableModel
m_inserting = true;
// Create default data
// Setup the buffer first so that event will be handle properly
// Create default data
int size = m_fields.size();
m_rowData = new Object[size]; // "original" data
Object[] rowData = new Object[size];
m_changed = true;
m_compareDB = true;
m_newRow = currentRow + 1;
// if there is no record, the current row could be 0 (and not -1)
if (m_buffer.size() < m_newRow)
m_newRow = m_buffer.size();
// add Data at end of buffer
MSort newSort = new MSort(m_buffer.size(), null); // index
m_buffer.add(rowData);
// add Sort pointer
m_sort.add(m_newRow, newSort);
m_rowCount++;
// fill data
if (copyCurrent)
{
@ -2164,20 +2181,8 @@ public class GridTable extends AbstractTableModel
field.setValue(rowData[i], m_inserting);
}
}
m_changed = true;
m_compareDB = true;
m_rowChanged = -1; // only changed in setValueAt
m_newRow = currentRow + 1;
// if there is no record, the current row could be 0 (and not -1)
if (m_buffer.size() < m_newRow)
m_newRow = m_buffer.size();
// add Data at end of buffer
MSort sort = new MSort(m_buffer.size(), null); // index
m_buffer.add(rowData);
// add Sort pointer
m_sort.add(m_newRow, sort);
m_rowCount++;
// inform
log.fine("Current=" + currentRow + ", New=" + m_newRow);