blob: 910a59f990e81e1374414dd77e27e27ae535da74 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/******************************************************************************
* Copyright (c) 2011 GitHub Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
*****************************************************************************/
package org.eclipse.egit.ui.internal.blame;
import java.util.Date;
import org.eclipse.jface.text.revisions.Revision;
import org.eclipse.jface.text.source.LineRange;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.graphics.RGB;
/**
* Annotation revision
*/
public class BlameRevision extends Revision {
private int start;
private int lines = 1;
private RevCommit commit;
private Repository repository;
public Object getHoverInfo() {
return this;
}
public RGB getColor() {
return AuthorColors.getDefault().getCommitterRGB(getAuthor());
}
public String getId() {
return commit.abbreviate(7).name();
}
public Date getDate() {
return commit.getAuthorIdent().getWhen();
}
/**
* Register revision
*
* @return this revision
*/
public BlameRevision register() {
addRange(new LineRange(start, lines));
return this;
}
/**
* Increment line count
*
* @return this revision
*/
public BlameRevision addLine() {
lines++;
return this;
}
/**
* Reset revision
*
* @param number
* @return this revision
*/
public BlameRevision reset(int number) {
start = number;
lines = 1;
return this;
}
/**
* Set revision
*
* @param commit
* @return this
*/
public BlameRevision setCommit(RevCommit commit) {
this.commit = commit;
return this;
}
/**
* Get revision
*
* @return revision
*/
public RevCommit getCommit() {
return this.commit;
}
/**
* Set repository
*
* @param repository
* @return this
*/
public BlameRevision setRepository(Repository repository) {
this.repository = repository;
return this;
}
/**
* Get repository
*
* @return repository
*/
public Repository getRepository() {
return this.repository;
}
public String getAuthor() {
return commit.getAuthorIdent().getName();
}
}
|