Source:
public Object execute(final ExecutionEvent aEvent) { try { IWorkbenchPart editor = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .getActiveEditor(); if (editor instanceof CompareEditor) { String commandName = aEvent.getCommand().getId(); boolean isLeftSide = commandName.contains("selectLeftPatchSet"); GerritMultipleInput input = (GerritMultipleInput) ((CompareEditor) editor).getEditorInput(); ArrayList<RevisionInfo> revisions = new ArrayList<RevisionInfo>( input.getChangeInfo().getRevisions().values()); revisions.sort((o2, o1) -> o1.get_number() - o2.get_number()); LinkedHashMap<String, String> patchNumber = new LinkedHashMap<String, String>(); for (ListIterator<RevisionInfo> iter = revisions.listIterator(); iter.hasNext();) { RevisionInfo element = iter.next(); patchNumber.put(new Integer(element.get_number()).toString(), element.getId()); } patchNumber.put("WORKSPACE", "WORKSPACE"); if (isLeftSide) { patchNumber.put("BASE", "BASE"); } Iterator<Entry<String, String>> itr = patchNumber.entrySet().iterator(); Iterator<Entry<String, String>> first = patchNumber.entrySet().iterator(); while (itr.hasNext()) { Entry<String, String> entry = itr.next(); if (isLeftSide && (entry).getValue().compareTo(input.getLeftSide()) == 0) { if (itr.hasNext()) { entry = itr.next(); input.switchInputs(entry.getValue(), null); break; } else { entry = first.next(); input.switchInputs(entry.getValue(), null); break; } } if (!isLeftSide && (entry).getValue().compareTo(input.getRightSide()) == 0) { if (itr.hasNext()) { entry = itr.next(); input.switchInputs(null, entry.getValue()); break; } else { entry = first.next(); input.switchInputs(null, entry.getValue()); break; } } } } } finally { return Status.OK_STATUS; } }

Target:
public Object execute(final ExecutionEvent aEvent) { try { IWorkbenchPart editor = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .getActiveEditor(); if (editor instanceof CompareEditor) { String commandName = aEvent.getCommand().getId(); boolean isLeftSide = commandName.contains("selectLeftPatchSet"); GerritMultipleInput input = (GerritMultipleInput) ((CompareEditor) editor).getEditorInput(); ArrayList<RevisionInfo> revisions = new ArrayList<RevisionInfo>( input.getChangeInfo().getRevisions().values()); revisions.sort((o2, o1) -> o1.get_number() - o2.get_number()); LinkedHashMap<String, String> patchNumber = new LinkedHashMap<String, String>(); for (ListIterator<RevisionInfo> iter = revisions.listIterator(); iter.hasNext();) { RevisionInfo element = iter.next(); patchNumber.put(new Integer(element.get_number()).toString(), element.getId()); } patchNumber.put("WORKSPACE", "WORKSPACE"); if (isLeftSide) { patchNumber.put("BASE", "BASE"); } Iterator<Entry<String, String>> itr = patchNumber.entrySet().iterator(); Iterator<Entry<String, String>> first = patchNumber.entrySet().iterator(); while (itr.hasNext()) { Entry<String, String> entry = itr.next(); if (isLeftSide && entry.getValue().compareTo(input.getLeftSide()) == 0) { if (itr.hasNext()) { entry = itr.next(); input.switchInputs(entry.getValue(), null); break; } else { entry = first.next(); input.switchInputs(entry.getValue(), null); break; } } if (!isLeftSide && (entry).getValue().compareTo(input.getRightSide()) == 0) { if (itr.hasNext()) { entry = itr.next(); input.switchInputs(null, entry.getValue()); break; } else { entry = first.next(); input.switchInputs(null, entry.getValue()); break; } } } } } finally { return Status.OK_STATUS; } }