private void handleSelection(byte whichAction) {
		// if nothing selected, nothing to do
		if (selectedInList == null) {
			enableButtons(false);
			return;
		}

		// confirm removal of plugin path entries, since this may cause
		// previously saved tools to not be able to load their plugins
		if (whichAction == REMOVE) {

			// for each selected entry, do the specified action
			List<String> tempList = new ArrayList<>(selectedInList);
			for (String pathName : tempList) {
				int index = listModel.indexOf(pathName);
				if (index >= 0) {
					listModel.remove(index);
				}
			}
		}
		else {
			int newIndex = -1;
			int selIndex = pluginPathsList.getSelectedIndex();
			int size = listModel.size();
			String path = listModel.remove(selIndex);
			if (selIndex == 0) {
				// if UP, then place this index last,
				if (whichAction == UP) {
					listModel.add(listModel.size(), path);
					newIndex = size - 1;
				}
				else {
					// 	else place it 2nd
					listModel.add(1, path);
					newIndex = 1;
				}
			}
			else {
				// if UP, place selectedIndex at previous.
				if (whichAction == UP) {
					listModel.add(selIndex - 1, path);
					newIndex = selIndex - 1;
				}
				else {
					if (selIndex == size - 1) {
						// place this item first
						listModel.add(0, path);
						newIndex = 0;
					}
					else {
						// else place selected Index at next
						listModel.add(selIndex + 1, path);
						newIndex = selIndex + 1;
					}
				}
			}
			if (newIndex >= 0) {
				pluginPathsList.setSelectedIndex(newIndex);
			}
		}

		// alert user that something changed
		setApplyEnabled(true);

		if (whichAction == REMOVE) {
			enableButtons(false);
		}

	}
done here so can be handled in a separate thread
Ghidra/Framework/Project/src/main/java/ghidra/framework/main/EditPluginPathDialog.java