public DataTypeComponent replace(int rowIndex, DataType dt) throws UsrException {
		return viewDTM.withTransaction("Replace Component", () -> {
			DataTypeInstance dti =
				DataTypeHelper.getFixedLength(this, rowIndex, dt, usesAlignedLengthComponents());
			if (dti == null) {
				return null; // User cancelled from size dialog.
			}
			if (rowIndex < getNumComponents()) {
				FieldRange range = getSelectedRangeContaining(rowIndex);
				if ((range == null) || (range.getStart()
						.getIndex()
						.intValue() == range.getEnd().getIndex().intValue() - 1)) {
					return replace(rowIndex, dti.getDataType(), dti.getLength());
				}
				return replaceComponentRange(range.getStart().getIndex().intValue(),
					range.getEnd().getIndex().intValue() - 1, dti.getDataType(), dti.getLength());
			}
			return null;
		});
	}
Adds the specified data type at the specified component index. Whether
an insert or replace occurs depends on whether the indicated index is
in a selection and whether in locked or unlocked mode.

@param rowIndex the index of row where the data type should be replaced.
@param dt the new data type

@return component added, null or exception if it does not
@throws UsrException if add error occurs
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorModel.java