@Override
	public int getMaxElements() {
		if (getNumSelectedComponentRows() != 1) {
			return 0;
		}
		int index = getMinIndexSelected();
		if (index < 0 || index >= viewComposite.getNumComponents()) {
			setStatus("Can only create arrays on a defined stack variable.", true);
			return 0;
		}
		DataTypeComponent dtc = viewComposite.getDefinedComponentAtOrdinal(index);
		if (dtc == null) {
			setStatus("Can only create arrays on a defined stack variable.", true);
			return 0;
		}
		int max = getMaxReplaceLength(index);
		if (max == Integer.MAX_VALUE) {
			return Integer.MAX_VALUE;
		}
		// Arrays currently use aligned-length only
		return max / dtc.getDataType().getAlignedLength();
	}
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 index the component index of where to add the data type.
@param dt the data type to add

@return true if the component is added, false if it doesn't.
@throws UsrException if add fails
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorModel.java