@Override
	public DataTypeComponent replace(int rowIndex, DataType dataType, int length, String name,
			String comment) throws InvalidDataTypeException {
		checkIsAllowableDataType(dataType);
		try {
			boolean isSelected = selection.containsEntirely(BigInteger.valueOf(rowIndex));
			DataTypeComponent dtc = viewDTM.withTransaction("Replace Component", () -> {
				viewComposite.delete(rowIndex);
				return viewComposite.insert(rowIndex, dataType, length, name, comment);
			});
			if (isSelected) {
				selection.addRange(rowIndex, rowIndex + 1);
				fixSelection();
			}
			return dtc;
		}
		catch (IllegalArgumentException exc) {
			throw new InvalidDataTypeException(exc.getMessage());
		}
	}
Insert the named data type before the specified index.

@param rowIndex index of the row (component).

@throws InvalidDataTypeException if the union being edited is part
        of the data type being inserted or if inserting isn't allowed.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorModel.java