コード例 #1
0
  private void scroll(boolean leftScrolled) {
    JMRevision revision;
    FilePanel fp1;
    FilePanel fp2;
    int line;

    revision = diffPanel.getCurrentRevision();
    if (revision == null) {
      return;
    }

    if (leftScrolled) {
      fp1 = filePanelLeft;
      fp2 = filePanelRight;
    } else {
      fp1 = filePanelRight;
      fp2 = filePanelLeft;
    }

    line = getCurrentLineCenter(fp1);

    if (leftScrolled) {
      line = DiffUtil.getRevisedLine(revision, line);
    } else {
      line = DiffUtil.getOriginalLine(revision, line);
    }

    scrollToLine(fp2, line);
  }
コード例 #2
0
  void toNextDelta(boolean next) {
    int line;
    JMRevision revision;
    JMDelta previousDelta;
    JMDelta currentDelta;
    JMDelta nextDelta;
    JMDelta toDelta;
    JMChunk original;
    int currentIndex;
    int nextIndex;
    List<JMDelta> deltas;
    int i;

    revision = diffPanel.getCurrentRevision();
    if (revision == null) {
      return;
    }

    deltas = revision.getDeltas();

    line = getCurrentLineCenter(filePanelLeft);

    currentDelta = null;
    currentIndex = -1;

    i = 0;
    for (JMDelta delta : deltas) {
      original = delta.getOriginal();

      currentIndex = i;
      i++;

      if (line >= original.getAnchor()) {
        if (line <= original.getAnchor() + original.getSize()) {
          currentDelta = delta;
          break;
        }
      } else {
        break;
      }
    }

    previousDelta = null;
    nextDelta = null;
    if (currentIndex != -1) {
      if (currentIndex > 0) {
        previousDelta = deltas.get(currentIndex - 1);
      }

      nextIndex = currentIndex;
      if (currentDelta != null) {
        nextIndex++;
      }

      if (nextIndex < deltas.size()) {
        nextDelta = deltas.get(nextIndex);
      }
    }

    if (next) {
      toDelta = nextDelta;
    } else {
      toDelta = previousDelta;
    }

    if (toDelta != null) {
      scrollToLine(filePanelLeft, toDelta.getOriginal().getAnchor());
      scroll(true);
    }
  }