@Override
	public boolean isEnabledForContext(ActionContext context) {
		Program program = getProgram(context);

		// This method gets called whenever the action context changes. We will insert logic
		// here to keep track of the current program context and add a listener
		// so that the action's name, description, and enablement is properly updated as the
		// user makes changes to the program.
		if (program != activeProgram) {
			removeTransactionListener(activeProgram);
			activeProgram = program;
			addTransactionListener(activeProgram);
			updateActionNameAndDescription();
		}
		return canPerformAction(activeProgram);
	}
Abstract base class for the undo and redo actions. These actions add a listener to the
current context program in order to know when to update their enabled state and description.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/progmgr/AbstractUndoRedoAction.java