@Override
	public void actionPerformed(ActionEvent e) {
		GhidraFileChooser fileChooser = new GhidraFileChooser(component);

		fileChooser.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY);
		fileChooser.setTitle("Select Pattern File");
		String baseDir = Preferences.getProperty(XML_IMPORT_DIR_PROPERTY);
		if (baseDir != null) {
			File dir = new File(baseDir);
			if (dir.isDirectory()) {
				fileChooser.setCurrentDirectory(dir);
			}
		}
		ExtensionFileFilter xmlFilter = new ExtensionFileFilter("xml", "XML Files");
		fileChooser.setFileFilter(xmlFilter);
		File patternFile = fileChooser.getSelectedFile();
		String lastDirPath = fileChooser.getCurrentDirectory().getAbsolutePath();
		fileChooser.dispose();
		if (fileChooser.wasCancelled() || patternFile == null) {
			return;
		}

		Preferences.setProperty(XML_IMPORT_DIR_PROPERTY, lastDirPath);
		Preferences.store();
		//only clear the patterns if new patterns are loaded from a file
		ResourceFile resource = new ResourceFile(patternFile);
		try {
			PatternPairSet pairSet = ClipboardPanel.parsePatternPairSet(resource);
			if (pairSet == null) {
				return;
			}
			plugin.clearPatterns();
			for (DittedBitSequence pre : pairSet.getPreSequences()) {
				PatternInfoRowObject preRow = new PatternInfoRowObject(PatternType.PRE, pre, null);
				plugin.addPattern(preRow);
			}
			//post patterns can have alignment and context register restrictions
			processPostPatterns(pairSet);
		}
		catch (IOException | SAXException e1) {
			Msg.showError(this, component, "Import Error",
				"Error Importing file " + patternFile.getAbsolutePath(), e1);
		}
		plugin.updateClipboard();
	}
Constructs an {@link ActionListener} for importing XML files
@param plugin associated {@link FunctionBitPatternsExplorerPlugin}
@param component parent
Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ImportPatternFileActionListener.java