提交 efa437dc 编写于 作者: S Serge Rider

#1007 Refresh RSV row after insert

上级 99a758d3
......@@ -130,15 +130,17 @@ class ResultSetPersister {
return execute(monitor, generateScript, listener);
}
public boolean refreshInsertedRows(@Nullable DBRProgressMonitor monitor) throws DBCException {
public boolean refreshInsertedRows() throws DBCException {
if (!viewer.getModel().isSingleSource()) {
return false;
}
if (addedRows.isEmpty()) {
// Nothing to refresh
return false;
}
final DBDRowIdentifier rowIdentifier = getDefaultRowIdentifier();
if (rowIdentifier == null) {
if (rowIdentifier == null || rowIdentifier.getAttributes().isEmpty()) {
// No key - can't refresh
return false;
}
......@@ -147,15 +149,7 @@ class ResultSetPersister {
throw new DBCException("No execution context");
}
RowRefreshJob job = new RowRefreshJob(executionContext, viewer.getDataContainer(), rowIdentifier, addedRows);
if (monitor == null) {
job.schedule();
return true;
} else {
IStatus result = job.run(monitor);
if (!result.isOK()) {
return false;
}
}
job.schedule();
return true;
}
......
......@@ -2309,18 +2309,23 @@ public class ResultSetViewer extends Viewer
{
try {
final ResultSetPersister persister = createDataPersister(false);
return persister.applyChanges(monitor, false, new ResultSetPersister.DataUpdateListener() {
final ResultSetPersister.DataUpdateListener applyListener = new ResultSetPersister.DataUpdateListener() {
@Override
public void onUpdate(boolean success) {
if (listener != null) listener.onUpdate(success);
try {
persister.refreshInsertedRows(monitor);
} catch (Throwable e) {
log.error("Error refreshing rows after update", e);
if (listener != null) {
listener.onUpdate(success);
}
if (success) {
// Refresh updated rows
try {
persister.refreshInsertedRows();
} catch (Throwable e) {
log.error("Error refreshing rows after update", e);
}
}
}
});
};
return persister.applyChanges(monitor, false, applyListener);
} catch (DBException e) {
UIUtils.showErrorDialog(null, "Apply changes error", "Error saving changes in database", e);
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册