GP-3122 Added AutoCloseable Transaction API to DBHandle and

UndoableDomainObject.  Performed renaming of some internal classes.
This commit is contained in:
ghidra1
2023-02-28 14:16:25 -05:00
parent b4de95f4f5
commit 1795c35dfc
209 changed files with 1892 additions and 2054 deletions

View File

@@ -28,6 +28,7 @@ import ghidra.feature.vt.api.impl.*;
import ghidra.feature.vt.api.main.*;
import ghidra.framework.data.DomainObjectAdapterDB;
import ghidra.framework.model.*;
import ghidra.framework.model.TransactionInfo.Status;
import ghidra.framework.options.Options;
import ghidra.framework.store.LockException;
import ghidra.program.database.DBObjectCache;
@@ -695,9 +696,9 @@ public class VTSessionDB extends DomainObjectAdapterDB implements VTSession, VTC
@Override
public void endTransaction(int transactionID, boolean commit) {
Transaction transaction = getCurrentTransaction();
TransactionInfo transaction = getCurrentTransactionInfo();
super.endTransaction(transactionID, commit);
if (changeSetsModified && transaction.getStatus() == Transaction.COMMITTED) {
if (changeSetsModified && transaction.getStatus() == Status.COMMITTED) {
changeSetsModified = false;
}
}

View File

@@ -15,6 +15,11 @@
*/
package ghidra.feature.vt.api.util;
import java.io.File;
import java.io.IOException;
import java.util.*;
import db.Transaction;
import ghidra.feature.vt.api.main.*;
import ghidra.framework.model.*;
import ghidra.framework.options.Options;
@@ -24,10 +29,6 @@ import ghidra.util.exception.AssertException;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
import java.io.File;
import java.io.IOException;
import java.util.*;
public class EmptyVTSession implements VTSession {
@Override
@@ -159,7 +160,7 @@ public class EmptyVTSession implements VTSession {
}
@Override
public Transaction getCurrentTransaction() {
public TransactionInfo getCurrentTransactionInfo() {
return null;
}
@@ -178,6 +179,11 @@ public class EmptyVTSession implements VTSession {
// do nothing
}
@Override
public Transaction openTransaction(String description) throws IllegalStateException {
throw new UnsupportedOperationException();
}
@Override
public int startTransaction(String description) {
return 0;

View File

@@ -20,7 +20,7 @@ import ghidra.feature.vt.api.db.VTSessionDB;
import ghidra.feature.vt.api.main.VTMatchTag;
import ghidra.feature.vt.api.main.VTSession;
import ghidra.feature.vt.gui.editors.TagEditorDialog.TagState.Action;
import ghidra.framework.model.Transaction;
import ghidra.framework.model.TransactionInfo;
import ghidra.program.model.listing.Program;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
@@ -348,7 +348,7 @@ public class TagEditorDialog extends DialogComponentProvider {
private boolean hasTransactionsOpen(VTSessionDB sessionDB) {
Program program = sessionDB.getDestinationProgram();
Transaction transaction = program.getCurrentTransaction();
TransactionInfo transaction = program.getCurrentTransactionInfo();
if (transaction != null) {
Msg.showWarn(this, null, "Unable to Set Match Tag",
"The program \"" + program.getName() + "\"already has a transaction open: " +
@@ -356,7 +356,7 @@ public class TagEditorDialog extends DialogComponentProvider {
return true;
}
Transaction matchSetTransaction = sessionDB.getCurrentTransaction();
TransactionInfo matchSetTransaction = sessionDB.getCurrentTransactionInfo();
if (matchSetTransaction != null) {
Msg.showWarn(this, null, "Unable to Set Match Tag",
"Transaction already open for the Match Set Manager ");

View File

@@ -493,7 +493,7 @@ public class VTControllerImpl
}
private boolean hasTransactionsOpen(Program program, VtTask task) {
Transaction transaction = program.getCurrentTransaction();
TransactionInfo transaction = program.getCurrentTransactionInfo();
if (transaction != null) {
Msg.showWarn(this, null, "Unable to " + task.getTaskTitle(),
"The program \"" + program.getName() + "\"already has a transaction open: " +
@@ -501,7 +501,7 @@ public class VTControllerImpl
return true;
}
Transaction matchSetTransaction = session.getCurrentTransaction();
TransactionInfo matchSetTransaction = session.getCurrentTransactionInfo();
if (matchSetTransaction != null) {
Msg.showWarn(this, null, "Unable to " + task.getTaskTitle(),
"Transaction already open for the Match Set Manager ");
@@ -576,7 +576,7 @@ public class VTControllerImpl
}
@Override
public void transactionStarted(DomainObjectAdapterDB domainObj, Transaction tx) {
public void transactionStarted(DomainObjectAdapterDB domainObj, TransactionInfo tx) {
// don't care
}

View File

@@ -17,7 +17,7 @@ package ghidra.feature.vt.gui.task;
import ghidra.feature.vt.api.db.VTSessionDB;
import ghidra.feature.vt.api.main.*;
import ghidra.framework.model.Transaction;
import ghidra.framework.model.TransactionInfo;
import ghidra.program.model.listing.Program;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
@@ -72,7 +72,7 @@ public class SetMatchTagTask extends Task {
private boolean hasTransactionsOpen() {
Program program = sessionDB.getDestinationProgram();
Transaction transaction = program.getCurrentTransaction();
TransactionInfo transaction = program.getCurrentTransactionInfo();
if (transaction != null) {
Msg.showWarn(this, null, "Unable to Set Match Tag",
"The program \"" + program.getName() + "\"already has a transaction open: " +
@@ -80,7 +80,7 @@ public class SetMatchTagTask extends Task {
return true;
}
Transaction matchSetTransaction = sessionDB.getCurrentTransaction();
TransactionInfo matchSetTransaction = sessionDB.getCurrentTransactionInfo();
if (matchSetTransaction != null) {
Msg.showWarn(this, null, "Unable to Set Match Tag",
"Transaction already open for the Match Set Manager ");