/** * Returns the width in chars required to display information. * * @return the width in chars required to display information * @since 3.3 */ public int getRequiredWidth() { if (fRequiredWidth == -1) { if (hasInformation() && (fShowRevision || fShowAuthor)) { int revisionWidth= 0; int authorWidth= 0; for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) { Revision revision= it.next(); revisionWidth= Math.max(revisionWidth, revision.getId().length()); authorWidth= Math.max(authorWidth, revision.getAuthor().length()); } fRevisionIdChars= revisionWidth + 1; if (fShowAuthor && fShowRevision) fRequiredWidth= revisionWidth + authorWidth + 2; else if (fShowAuthor) fRequiredWidth= authorWidth + 1; else fRequiredWidth= revisionWidth + 1; } else { fRequiredWidth= 0; } } return fRequiredWidth; }
/** * Adjusts the revision information to the given diff information. Any previous diff information * is discarded. <strong>Note:</strong> This is an internal framework method and must not be * called by clients. * * @param hunks the diff hunks to adjust the revision information to * @since 3.3 * @noreference This method is not intended to be referenced by clients. */ public void applyDiff(Hunk[] hunks) { fRanges= null; // mark for recomputation for (Iterator<Revision> revisions= getRevisions().iterator(); revisions.hasNext();) revisions.next().applyDiff(hunks); }
private long computeAge(Revision revision) { return revision.getDate().getTime(); }
if (revision != null) { added= new HashMap<>(); for (Iterator<RevisionRange> it= revision.getRegions().iterator(); it.hasNext();) { RevisionRange range= it.next(); try { IRegion charRegion= toCharRegion(range); Position position= new Position(charRegion.getOffset(), charRegion.getLength()); Annotation annotation= new RevisionAnnotation(revision.getId()); added.put(annotation, position); } catch (BadLocationException x) {
private void updateLabel() { List<RevisionRange> ranges = rangeProvider.getRanges(lineRange); if (ranges != null && ranges.size() > 0) { long count = ranges.stream().map(r -> r.getRevision().getAuthor()).distinct().count(); StringBuilder label = new StringBuilder(); label.append(count); label.append(" "); if (count == 1) { label.append("author"); } else { label.append("authors"); } label.append(" ("); label.append(ranges.get(0).getRevision().getAuthor()); if (count > 1) { label.append(" and others"); } label.append(")"); super.setLabel(label.toString()); } else { super.setLabel(""); } }
@Override public String toString() { return "RevisionRange [" + fRevision.toString() + ", [" + getStartLine() + "+" + getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
@Override public String toString() { return "Revision " + getId(); //$NON-NLS-1$ }
/** * Returns the line ranges of this revision information. The returned information is only valid * at the moment it is returned, and may change as the annotated document is modified. See * {@link IRevisionListener} for a way to be informed when the revision information changes. The * returned list is sorted by document offset. * * @return an unmodifiable view of the line ranges * @see IRevisionListener * @since 3.3 */ public List<RevisionRange> getRanges() { if (fRanges == null) { List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess for (Iterator<Revision> it= fRevisions.iterator(); it.hasNext();) { Revision revision= it.next(); ranges.addAll(revision.getRegions()); } // sort by start line Collections.sort(ranges, (r1, r2) -> r1.getStartLine() - r2.getStartLine()); fRanges= Collections.unmodifiableList(ranges); } return fRanges; }
@Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleNumberOfLines) { RevisionRange range= getRange(lineRange.getStartLine()); Object info= range == null ? null : range.getRevision().getHoverInfo(); return info; }
if (revision != null) { added= new HashMap<>(); for (RevisionRange range : revision.getRegions()) { try { IRegion charRegion= toCharRegion(range); Position position= new Position(charRegion.getOffset(), charRegion.getLength()); Annotation annotation= new RevisionAnnotation(revision.getId()); added.put(annotation, position); } catch (BadLocationException x) {
private void updateLabel() { try { List<RevisionRange> ranges = rangeProvider.getRanges(lineRange); if (ranges != null && ranges.size() > 0) { Revision revision = ranges.stream().map(r -> r.getRevision()) .max(Comparator.comparing(Revision::getDate)).get(); if (showDate && (revision instanceof IRevisionRangeExtension)) { super.setLabel( revision.getAuthor() + ", " + ((IRevisionRangeExtension) revision).getFormattedTime()); } else { super.setLabel(revision.getAuthor()); } if (showAvatar) { if (revision instanceof IRevisionRangeExtension) { String email = ((IRevisionRangeExtension) revision).getAuthorEmail(); if (email != null) { avatar = AvatarRepository.getInstance().getAvatarByEmail(email); } } } } } catch (Exception e) { super.setLabel(e.getMessage()); e.printStackTrace(); } }
@Override public String toString() { return "RevisionRange [" + fRevision.toString() + ", [" + getStartLine() + "+" + getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
@Override public String toString() { return "Revision " + getId(); //$NON-NLS-1$ }
/** * Returns the line ranges of this revision information. The returned information is only valid * at the moment it is returned, and may change as the annotated document is modified. See * {@link IRevisionListener} for a way to be informed when the revision information changes. The * returned list is sorted by document offset. * * @return an unmodifiable view of the line ranges * @see IRevisionListener * @since 3.3 */ public List<RevisionRange> getRanges() { if (fRanges == null) { List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess for (Revision revision : fRevisions) { ranges.addAll(revision.getRegions()); } // sort by start line Collections.sort(ranges, (r1, r2) -> r1.getStartLine() - r2.getStartLine()); fRanges= Collections.unmodifiableList(ranges); } return fRanges; }
@Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleNumberOfLines) { RevisionRange range= getRange(lineRange.getStartLine()); Object info= range == null ? null : range.getRevision().getHoverInfo(); return info; }
/** * Returns the width in chars required to display information. * * @return the width in chars required to display information * @since 3.3 */ public int getRequiredWidth() { if (fRequiredWidth == -1) { if (hasInformation() && (fShowRevision || fShowAuthor)) { int revisionWidth= 0; int authorWidth= 0; for (Revision revision : fRevisionInfo.getRevisions()) { revisionWidth= Math.max(revisionWidth, revision.getId().length()); authorWidth= Math.max(authorWidth, revision.getAuthor().length()); } fRevisionIdChars= revisionWidth + 1; if (fShowAuthor && fShowRevision) fRequiredWidth= revisionWidth + authorWidth + 2; else if (fShowAuthor) fRequiredWidth= authorWidth + 1; else fRequiredWidth= revisionWidth + 1; } else { fRequiredWidth= 0; } } return fRequiredWidth; }
@Override public String toString() { return "ChangeRegion [" + fRevision.toString() + ", [" + fLines.getStartLine() + "+" + fLines.getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
/** * Handles the selection of a revision id and informs listeners * * @param id the selected revision id */ void handleRevisionSelected(String id) { Assert.isLegal(id != null); if (fRevisionInfo == null) return; for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) { Revision revision= it.next(); if (id.equals(revision.getId())) { handleRevisionSelected(revision); return; } } // clear selection if it does not exist handleRevisionSelected((Revision) null); }