@Override
	public DataTypeComponent add(int rowIndex, DataType dt, int dtLength) throws UsrException {
		DataTypeComponent dtc = null;
		if (rowIndex < getNumComponents()) {
			dtc = viewDTM.withTransaction("Replace Component", () -> {
				FieldRange range = getSelectedRangeContaining(rowIndex);
				if ((range == null) || (range.getStart()
						.getIndex()
						.intValue() == range.getEnd().getIndex().intValue() - 1)) {
					return replace(rowIndex, dt, dtLength);
				}
				return replaceComponentRange(range.getStart().getIndex().intValue(),
					range.getEnd().getIndex().intValue() - 1, dt, dtLength);
			});
		}
		else {
			dtc = viewDTM.withTransaction("Add Component", () -> insert(rowIndex, dt, dtLength));
		}

		fixSelection();
		//componentEdited();
		selectionChanged();
		return dtc;
	}
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 the row where the data type should be added.
@param dt the data type to add
@param dtLength datatype instance length
@return the component is added, null if it doesn't.
@throws UsrException if add fails
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorModel.java