@Override
		public void actionPerformed(ActionEvent e) {

			// Get the input text and separate into groups (spaces are the delimiter), removing
			// any leading or trailing spaces.
			String[] groups = parent.getInputString().trim().split("\\s+");

			// Now get all of the whitespace in the input string. We do this so we can
			// restore the spacing from the original string when reconstructing.  We don't want
			// to have the input be "01 AF    10 01" and return "01 AF 10 01"; we want to return
			// "01 AF    10 01".
			List<String> whitespaces = InstructionSearchUtils.getWhitespace(parent.getInputString().trim());

			// Now validate each group to make sure they:
			// 1. have the proper input format (hex or binary)
			// 2. are the proper length for the input type (full bytes only)
			for (String str : groups) {
				if (!parent.validateInput(str)) {
					parent.showError();
					return;
				}
			}

			// Now determine if we're looking at hex or binary data, and set the byte length
			// as appropriate. This is used later on when getting the byte strings.
			int byteLength = 0;
			if (parent.getSelectionModeWidget().getInputMode() == InputMode.HEX) {
				byteLength = 2;
			}
			else if (parent.getSelectionModeWidget().getInputMode() == InputMode.BINARY) {
				byteLength = 8;
			}

			// Do a quick sanity check on the number of groups and the number of whitespaces
			// we have.  We should always have one more group than whitespaces (even if we had
			// spaces at the beginning or end of the input, we trimmed those out already).
			if (groups.length != whitespaces.size() + 1) {
				return;
			}

			// Finally, loop over all the groups, flipping each one in turn and reconstructing
			// the string at the end.
			StringBuilder mainString = new StringBuilder();
			int whitespaceIndex = 0;
			for (String str : groups) {

				// Break up the input string into a list of bytes that we can reverse, and 
				// reverse them.
				List<String> input = getByteStrings(str, byteLength);
				Collections.reverse(input);

				// Convert the list back into a string and append to the main string.
				for (String s : input) {
					mainString.append(s);
				}

				// Finally add the proper number of whitespace after this group.
				if (whitespaceIndex < whitespaces.size()) {
					mainString.append(whitespaces.get(whitespaceIndex));
					whitespaceIndex++;
				}
			}

			// Show the new string in the text area.
			parent.setInputString(mainString.toString());

		}
Event handler for the flip button.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/EndianFlipWidget.java