private void cycleData(ListingActionContext context) {
		Listing listing = context.getProgram().getListing();
		ProgramSelection selection = context.getSelection();
		ProgramLocation location = context.getLocation();

		// Handle selection case
		if (selection != null && !selection.isEmpty()) {
			BackgroundCommand<Program> cmd = null;
			DataType dt = null;
			Address addr = selection.getMinAddress();
			Data data = listing.getDataContaining(addr);
			InteriorSelection intSel = selection.getInteriorSelection();
			if (intSel == null) {
				dt = cycleGroup.getNextDataType(data.getDataType(), true);
				if (dt == null) {
					return;
				}
				cmd = new CreateDataBackgroundCmd(selection, dt);
			}
			else {
				int[] fromPath = intSel.getFrom().getComponentPath();
				long selectionLength = selection.getNumAddresses();
				if (selectionLength > Integer.MAX_VALUE) {
					Msg.showInfo(this, null, "Selection Too Big",
						"This operation does not support selection size > 0x7fffffff byte addresses.");
					return;
				}
				int length = (int) selectionLength;
				Data compData = data.getComponent(fromPath);
				if (compData == null) {
					return;
				}
				dt = cycleGroup.getNextDataType(compData.getDataType(), true);
				if (dt == null) {
					return;
				}
				cmd = new CreateDataInStructureBackgroundCmd(addr, fromPath, length, dt);
			}
			if (selection.getNumAddresses() < DataPlugin.BACKGROUND_SELECTION_THRESHOLD) {
				plugin.getPluginTool().execute(cmd, context.getProgram());
			}
			else {
				plugin.getPluginTool().executeBackgroundCommand(cmd, context.getProgram());
			}

			plugin.updateRecentlyUsed(dt);
		}

		// Handle single location case
		else if (location != null) {
			Address addr = location.getAddress();
			Data data = listing.getDataContaining(addr);
			if (data == null) {
				return;
			}
			int compPath[] = location.getComponentPath();
			if (compPath == null || compPath.length <= 0) {
				DataType dt = cycleGroup.getNextDataType(data.getDataType(), true);
				if (dt != null) {
					plugin.getPluginTool().execute(new CreateDataCmd(addr, dt, true, false),
						context.getProgram());
					plugin.updateRecentlyUsed(dt);
				}
			}
			else {
				Data compData = data.getComponent(compPath);
				if (compData != null) {
					DataType dt = cycleGroup.getNextDataType(compData.getDataType(), true);
					if (dt != null) {
						plugin.getPluginTool().execute(
							new CreateDataInStructureCmd(addr, compPath, dt), context.getProgram());
						plugin.updateRecentlyUsed(dt);
					}
				}
			}
		}
	}
Cycle the data type for the current selection or location.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/data/CycleGroupAction.java