private void deleteExternalProgram() {
		ExternalManager externalManager = program.getExternalManager();
		StringBuilder buf = new StringBuilder();
		CompoundCmd<Program> cmd = new CompoundCmd<>("Delete External Program Name");
		for (String externalName : getSelectedExternalNames()) {
			boolean hasLocations = externalManager.getExternalLocations(externalName).hasNext();
			if (hasLocations) {
				buf.append("\n     ");
				buf.append(externalName);
			}
			else {
				cmd.add(new RemoveExternalNameCmd(externalName));
			}
		}
		if (cmd.size() > 0) {
			getTool().execute(cmd, program);
		}
		if (buf.length() > 0) {
			Msg.showError(this, mainPanel, "Delete Failure",
				"The following external reference names could not be deleted\n" +
					"because they contain external locations:\n" + buf.toString());
		}
	}
ComponentProvider that displays a table of External Programs.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/ExternalReferencesProvider.java