@Override public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException { // Do not fire the event in the H2 thread in order to not raise // org.h2.jdbc.JdbcSQLException: Timeout trying to lock table XXX fireEvent(new TableEditEvent(tableIdentifier)); }
@Override public void remove() throws SQLException { // Do not fire the event in the H2 thread in order to not raise // org.h2.jdbc.JdbcSQLException: Timeout trying to lock table XXX fireEvent(new TableEditEvent(tableIdentifier)); }
@Override public void remove() throws SQLException { // Do not fire the event in the H2 thread in order to not raise // org.h2.jdbc.JdbcSQLException: Timeout trying to lock table XXX fireEvent(new TableEditEvent(tableIdentifier, TableModelEvent.ALL_COLUMNS, null, null, TableModelEvent.DELETE)); }
@Override public void fire(Connection conn, Object[] oldRow, Object[] newRow) throws SQLException { // Do not fire the event in the H2 thread in order to not raise // org.h2.jdbc.JdbcSQLException: Timeout trying to lock table XXX int type = TableModelEvent.DELETE; if(oldRow == null && newRow != null) { type = TableModelEvent.INSERT; } else if(oldRow != null && newRow != null) { type = TableModelEvent.UPDATE; } Long pk = null; if(pkColumn != -1 && newRow != null && newRow.length > pkColumn - 1 && newRow[pkColumn - 1] instanceof Long) { pk = (Long)newRow[pkColumn - 1]; } fireEvent(new TableEditEvent(tableIdentifier, TableModelEvent.ALL_COLUMNS, pk, pk, type)); }
protected void doUndo(boolean callListeners) throws SQLException { if(primaryKey != null) { try(Connection connection = dataManager.getDataSource().getConnection(); PreparedStatement st = connection.prepareStatement("DELETE FROM "+tableLocation+" WHERE "+pkName+" = ?")) { st.setLong(1, primaryKey); st.execute(); primaryKey = null; } if(callListeners) { dataManager.fireTableEditHappened(new TableEditEvent(tableLocation.toString(isH2), TableModelEvent.ALL_COLUMNS, null, null, TableModelEvent.DELETE)); } } }
public void onMenuRefresh() { tableChange(new TableEditEvent(tableEditableElement.getTableReference())); }
private void doUpdate(Long pk, Object value, boolean callListeners) throws SQLException { try(Connection connection = dataManager.getDataSource().getConnection(); PreparedStatement st = connection.prepareStatement("UPDATE "+tableLocation+" SET "+TableLocation.quoteIdentifier(columnName, isH2)+" = ? WHERE "+pkName+" = ?")) { st.setObject(1, value); st.setLong(2, pk); st.execute(); if(callListeners) { try (Statement stat = connection.createStatement(); ResultSet rs = stat.executeQuery("SELECT * from " + tableLocation.toString(isH2) + " LIMIT 0")) { // Fire with the new PK Value Long pkToFire = pk; if( columnName.equals(pkName)) { pkToFire = Long.valueOf(value.toString()); } dataManager.fireTableEditHappened(new TableEditEvent(tableLocation.toString(isH2), JDBCUtilities.getFieldIndex(rs.getMetaData(), columnName), pkToFire, pkToFire, TableModelEvent.UPDATE)); } } } }
dataManager.fireTableEditHappened(new TableEditEvent(tableLocation.toString(isH2), TableModelEvent.ALL_COLUMNS, primaryKey, primaryKey, TableModelEvent.INSERT));
@Override public void insertRow() throws SQLException { if(insertRow == null) { throw new SQLException(I18N.tr("RowSet not moved to insert row")); } insertRow.redo(false); cachedRowCount++; manager.fireTableEditHappened(new TableEditEvent(location.toString(isH2), insertRow, TableModelEvent.ALL_COLUMNS, insertRow.getPrimaryKey(), insertRow.getPrimaryKey(), TableModelEvent.INSERT)); moveToInsertRow(); }
if(update != null && updateColumn != pkColumnId ) { update.redo(false); manager.fireTableEditHappened(new TableEditEvent(location.toString(isH2), update, updateColumn, getPk(), getPk(), TableModelEvent.DELETE)); refreshRow(); updateRow = null; manager.fireTableEditHappened(new TableEditEvent(location.toString(isH2), update, pkColumnId, getPk() , getPk() , TableModelEvent.DELETE)); } else {
@Override public void deleteRow() throws SQLException { checkCurrentRow(); TableUndoableDelete deleteEvt = new TableUndoableDelete(manager, location, pk_name, isH2); for(int idColumn = 0; idColumn < currentRow.row.length; idColumn++) { deleteEvt.setValue(getColumnLabel(idColumn + 1), currentRow.row[idColumn]); } deleteEvt.redo(false); cachedRowCount--; refreshRow(); manager.fireTableEditHappened(new TableEditEvent(location.toString(isH2), deleteEvt, TableModelEvent .ALL_COLUMNS, deleteEvt.getPrimaryKey(), deleteEvt.getPrimaryKey(), TableModelEvent.DELETE)); }