@Override
	public boolean apply() throws InvalidDataTypeException {

		// commit changes for any fields under edit
		if (isEditingField()) {
			endFieldEditing();
		}

		FieldSelection saveSelection = new FieldSelection(selection);
		T originalDt = getOriginalComposite();
		if (originalDt == null || originalDTM == null) {
			throw new IllegalStateException(
				"Can't apply edits without a data type or data type manager.");
		}
		boolean originalDtExists = originalDTM.contains(originalDt);
		boolean renamed = false;
		if (originalDtExists) {
			String origName = originalDt.getName();
			String editName = getCompositeName();
			renamed = !origName.equals(editName);
		}
		String action = originalDtExists ? "Edit" : "Create";
		if (renamed) {
			action += "/Rename";
		}
		int transactionID = originalDTM.startTransaction(action + " " + getTypeName());
		try {
			if (originalDtExists) {
				// Update the original structure.
				if (renamed) {
					String editName = getCompositeName();
					try {
						originalDt.setName(editName);
					}
					catch (InvalidNameException e) {
						String msg =
							"Apply failed. The data type name \"" + editName + "\" is not valid.";
						throw new InvalidDataTypeException(msg);
					}
					catch (DuplicateNameException e) {
						String msg =
							"Apply failed. A data type named \"" + editName + "\" already exists.";
						throw new InvalidDataTypeException(msg);
					}
				}
				originalDt.setDescription(getDescription());
				replaceOriginalComponents();
				updateOriginalComponentSettings(viewComposite, originalDt);
				load(originalDt);
			}
			else {
				@SuppressWarnings("unchecked")
				T dt = (T) originalDTM.resolve(viewComposite, null);
				load(dt);
			}
			return true;
		}
		finally {
			provider.updateTitle();
			setSelection(saveSelection);
			originalDTM.endTransaction(transactionID, true);
		}
	}
Apply the changes for the current edited composite back to the
original composite.

@return true if apply succeeds
@throws InvalidDataTypeException if this structure has a component that it is part of.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorModel.java