private void refreshComponents() { if (currentSetup == null) { nextAction.setEnabled(false); prevAction.setEnabled(false); return; } DiffController view = currentSetup.getView(); int currentDifferenceIndex = view != null ? view.getDifferenceIndex() : -1; if (view != null) { nextAction.setEnabled(showingFileComponent() && getActiveFileComponent().hasNextNode(currentSetup.getNode()) || currentDifferenceIndex < view.getDifferenceCount() - 1); } else { nextAction.setEnabled(false); } prevAction.setEnabled(showingFileComponent() && getActiveFileComponent().hasPreviousNode(currentSetup.getNode()) || currentDifferenceIndex > 0); }
private void onPrevButton() { DiffController view = currentSetup.getView(); DiffNode prev = showingFileComponent() ? getActiveFileComponent().getPreviousNode(currentSetup.getNode()) : null; if (view != null) { int currentDifferenceIndex = view.getDifferenceIndex(); if (currentSetupDiffLengthChanged >= 0) { // jump to the previous difference only when the diffs did not change (no difference was removed) // otherwise the previous difference might be missed --currentDifferenceIndex; } currentSetupDiffLengthChanged = view.getDifferenceCount(); if (currentDifferenceIndex < 0) { if (prev != null) { setDiffIndex(prev.getSetup(), -1, true); } } else if (currentDifferenceIndex < view.getDifferenceCount()) { view.setLocation(DiffController.DiffPane.Modified, DiffController.LocationType.DifferenceIndex, currentDifferenceIndex); } } else { if (prev != null) { setDiffIndex(prev.getSetup(), -1, true); } } refreshComponents(); }
/** Next that is driven by visibility. It continues to next not yet visible difference. */ private void onNextButton() { DiffController view = currentSetup.getView(); DiffNode next = showingFileComponent() ? getActiveFileComponent().getNextNode(currentSetup.getNode()) : null; if (view != null) { int currentDifferenceIndex = view.getDifferenceIndex(); if (currentSetupDiffLengthChanged >= 0) { // jump to the next difference only when the diffs did not change (no difference was removed) // otherwise the next difference might be missed ++currentDifferenceIndex; } currentSetupDiffLengthChanged = view.getDifferenceCount(); if (currentDifferenceIndex >= view.getDifferenceCount()) { // also passes for view.getDifferenceCount() == 0 if (next != null) { setDiffIndex(next.getSetup(), 0, true); } } else { view.setLocation(DiffController.DiffPane.Modified, DiffController.LocationType.DifferenceIndex, currentDifferenceIndex); } } else { if (next != null) { setDiffIndex(next.getSetup(), 0, true); } } refreshComponents(); }