@Override
	protected void createArray(int numElements) throws InvalidDataTypeException, UsrException {
		if (selection.getNumRanges() != 1) {
			throw new UsrException("Can only create arrays on a contiguous selection.");
		}
		int rowIndex = selection.getFieldRange(0).getStart().getIndex().intValue();
		DataTypeComponent comp = getComponent(rowIndex);
		if (comp == null) {
			throw new UsrException("A component must be selected.");
		}
		if (isEditingField()) {
			endFieldEditing();
		}

		// Get data type to make into array.
		DataType dt = comp.getDataType();

		ArrayDataType array = new ArrayDataType(dt, numElements, comp.getLength(), viewDTM);
		viewDTM.withTransaction("Create Array", () -> {
			if (getNumSelectedComponentRows() > 1) {
				replaceComponentRange(rowIndex,
					selection.getFieldRange(0).getEnd().getIndex().intValue() - 1, array,
					array.getLength());
			}
			else {
				replace(rowIndex, array, array.getLength()); // Can throw UsrException.
			}
		});
		componentEdited();
	}
Moves the components between the start index (inclusive) and the end
 index (exclusive) to the new index (relative to the initial component set).

@param startRowIndex index of the starting component to move.
@param endRowIndex index of the ending component to move.
@return true if components are moved.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompEditorModel.java