private <E extends Exception> void txSwing(ExceptionalCallback<E> c) {

		int txId = program.startTransaction("Test - Function in Transaction");
		boolean commit = true;
		try {
			runSwingWithException(c);
			program.flushEvents();
		}
		catch (Exception e) {
			commit = false;
			failWithException("Exception modifying program '" + program.getName() + "'", e);
		}
		finally {
			program.endTransaction(txId, commit);
		}

		waitForSwing();
	}
Test editing in the Byte Viewer.
Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java