private Program doOpenProgram(DomainFile domainFile, Object consumer, boolean upgradeIfNeeded,
			TaskMonitor monitor) throws VersionException, IOException, CancelledException {

		try {
			return (Program) domainFile.getDomainObject(consumer, upgradeIfNeeded, false, monitor);
		}
		catch (VersionException e) {
			if (SystemUtilities.isInHeadlessMode()) {
				throw e;
			}
			if (VersionExceptionHandler.isUpgradeOK(null, domainFile, "Open ", e)) {
				return (Program) domainFile.getDomainObject(consumer, true, false, monitor);
			}
			throw e;
		}
	}
Convenience method for opening the program for the current program file value. If the program
is already open, then the consumer will be added to the program. The caller of this method is
responsible for calling {@link Program#release(Object)} with the same consumer when it is
done using this program. Program are only closed after all consumers are released. If
multiple calls are made to this method, then the consumer will be added multiple times
and must be released multiple times.
<P>
The consumer can be any object, but since the consumer's purpose is to keep the program open 
while some object is using it, the object itself is typically passed in as
the consumer. For example, when used in a script, passing in the java keyword "this" as the
consumer will make the script itself the consumer.

@param consumer the consumer to be used to open the program
@param tool optional tool that if non-null, the program will also be opened in the tool
@param upgradeIfNeeded if true, program will be upgraded if needed and possible. If false,
the program will only be upgraded after first prompting the user. In headless mode, it will
attempt to upgrade only if the parameter is true.
@param monitor task monitor for cancelling the open program.
@return a program for the currently selected program file. If no file chosen, returns null
@throws VersionException if the Program is out-of-date from the version of GHIDRA and an 
upgrade was not been performed. In non-headless mode, the user will have already been
notified via a popup dialog.
current Ghidra Program version.
@throws IOException if there is an error accessing the Program's DomainObject
@throws CancelledException if the operation is cancelled
Ghidra/Features/Base/src/main/java/ghidra/features/base/values/ProgramFileValue.java