private File chooseToolFile(ToolTemplate tool) {
		GhidraFileChooser fileChooser = getFileChooser();

		File exportFile = null;
		while (exportFile == null) {
			exportFile = fileChooser.getSelectedFile(); // show the chooser
			if (exportFile == null) {
				return null; // user cancelled
			}

			Preferences.setProperty(Preferences.LAST_TOOL_EXPORT_DIRECTORY, exportFile.getParent());
			if (!exportFile.getName().endsWith(ToolUtils.TOOL_EXTENSION)) {
				exportFile = new File(exportFile.getAbsolutePath() + ToolUtils.TOOL_EXTENSION);
			}

			if (exportFile.exists()) {
				int result = OptionDialog.showOptionDialog(null, "Overwrite?",
					"Overwrite existing file: '" + exportFile.getName() + "'?", "Overwrite",
					OptionDialog.QUESTION_MESSAGE);
				if (result != OptionDialog.OPTION_ONE) {
					exportFile = null; // user chose not to overwrite
				}
			}
		}
		fileChooser.dispose();
		return exportFile;
	}
Implementation of service used to manipulate tools.
Ghidra/Framework/Project/src/main/java/ghidra/framework/project/tool/ToolServicesImpl.java