void applyDiff() {
		if (!applyIsSet()) {
			tool.setStatusInfo(
				"At least one difference type must be set to \'Replace\' or \'Merge\' in the " +
					diffApplySettingsProvider.getName() + ".",
				true);
			return;
		}

		if (primaryProgram.getCurrentTransactionInfo() != null) {
			String msg = "Cannot apply differences while another task is modifying \"" +
				primaryProgram.getName() + "\"." +
				"\nTry again when the currently executing task has completed.";
			Msg.showError(getClass(), tool.getToolFrame(), "Apply Differences", msg);
			return;
		}

		// Limit the apply to the selection in the view.
		AddressSet p2SelectionAsP1 =
			DiffUtility.getCompatibleAddressSet(p2Selection, primaryProgram);
		AddressSet p1ApplySet = p2SelectionAsP1.intersect(p1ViewAddrSet)
				.subtract(addressesOnlyInP1)
				.subtract(compatibleOnlyInP2);
		if (p1ApplySet.isEmpty()) {
			Msg.showInfo(getClass(), tool.getToolFrame(), "Apply Differences",
				(p2Selection.isEmpty()) ? "No diff selection in the current view."
						: "Nothing can be applied from the current selection.");
			return;
		}
		ApplyDiffCommand applyCmd = new ApplyDiffCommand(this, p1ApplySet, diffControl);
		tool.executeBackgroundCommand(applyCmd, primaryProgram);
	}
Callback when user changes selection in the program2 diff panel.

Note: A P2 selection is handed to this method when a selection is made in the diff listing
which displays P2.
Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/ProgramDiffPlugin.java