@Override
	public void actionPerformed(ActionContext context) {

		DataTypeTreeNode node = getSelectedDataTypeTreeNode(context);
		String name = node.getName();

		PluginTool tool = plugin.getTool();
		int noSizeRestriction = -1;
		DataTypeSelectionDialog selectionDialog = new DataTypeSelectionDialog(tool,
			plugin.getProgram().getDataTypeManager(), noSizeRestriction, AllowedDataTypes.ALL) {

			@Override
			protected JComponent createEditorPanel(DataTypeSelectionEditor dtEditor) {

				setTitle("Replace '" + name + "'");

				JPanel updatedPanel = new JPanel();
				updatedPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 0));
				updatedPanel.setLayout(new VerticalLayout(5));

				GLabel label = new GLabel("Choose the replacement data type: ");
				label.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
				updatedPanel.add(label);

				updatedPanel.add(dtEditor.getEditorComponent());

				return updatedPanel;
			}

		};
		selectionDialog.setHelpLocation(getHelpLocation());
		tool.showDialog(selectionDialog);
		DataType newDt = selectionDialog.getUserChosenDataType();
		if (newDt == null) {
			return; // cancelled
		}

		DataTypeManagerHandler dtmHandler = plugin.getDataTypeManagerHandler();
		DataTypeManager newDtm = newDt.getDataTypeManager();
		Archive sourceArchive = dtmHandler.getArchive(newDtm);
		Archive destinationArchive = findArchive(node);

		DataType oldDt = ((DataTypeNode) node).getDataType();
		DataTypeManager dtm = oldDt.getDataTypeManager();
		if (sourceArchive != destinationArchive) {
			oldDt = oldDt.clone(oldDt.getDataTypeManager());
		}

		int txId = dtm.startTransaction("Replace Data Type");
		try {
			dtm.replaceDataType(oldDt, newDt, true);
		}
		catch (DataTypeDependencyException e) {
			Msg.showError(this, null, "Replace Failed", "Replace failed.  Existing type " + newDt +
				"; replacement type " + oldDt + ". " + e.getMessage());
		}
		finally {
			dtm.endTransaction(txId, true);
		}
	}
Replace the selected data type with the chosen data type
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/ReplaceDataTypeAction.java