Mercurial > projects > dwt-addons
comparison dwtx/jface/text/revisions/Revision.d @ 158:25f1f92fa3df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 26 Aug 2008 02:46:34 +0200 |
parents | f70d9508c95c |
children | 3678e4f1a766 |
comparison
equal
deleted
inserted
replaced
157:7f75eaa8103a | 158:25f1f92fa3df |
---|---|
19 import dwtx.jface.text.revisions.RevisionEvent; // packageimport | 19 import dwtx.jface.text.revisions.RevisionEvent; // packageimport |
20 import dwtx.jface.text.revisions.RevisionInformation; // packageimport | 20 import dwtx.jface.text.revisions.RevisionInformation; // packageimport |
21 | 21 |
22 | 22 |
23 import dwt.dwthelper.utils; | 23 import dwt.dwthelper.utils; |
24 | |
25 import dwtx.dwtxhelper.Collection; | 24 import dwtx.dwtxhelper.Collection; |
26 | 25 import dwtx.dwtxhelper.Date; |
27 import java.util.Date; | |
28 | |
29 | |
30 | 26 |
31 import dwt.graphics.RGB; | 27 import dwt.graphics.RGB; |
32 import dwtx.jface.internal.text.revisions.ChangeRegion; | 28 import dwtx.jface.internal.text.revisions.ChangeRegion; |
33 import dwtx.jface.internal.text.revisions.Hunk; | 29 import dwtx.jface.internal.text.revisions.Hunk; |
34 import dwtx.jface.text.IInformationControlCreator; | 30 import dwtx.jface.text.IInformationControlCreator; |
37 /** | 33 /** |
38 * Describes a revision of a document. A revision consists of one ore more {@link ILineRange}s. | 34 * Describes a revision of a document. A revision consists of one ore more {@link ILineRange}s. |
39 * <p> | 35 * <p> |
40 * Clients may subclass. | 36 * Clients may subclass. |
41 * </p> | 37 * </p> |
42 * | 38 * |
43 * @since 3.2 | 39 * @since 3.2 |
44 */ | 40 */ |
45 public abstract class Revision { | 41 public abstract class Revision { |
46 /** The original list of change regions, element type: {@link ChangeRegion}. */ | 42 /** The original list of change regions, element type: {@link ChangeRegion}. */ |
47 private const List fChangeRegions= new ArrayList(); | 43 private const List fChangeRegions= new ArrayList(); |
48 /** | 44 /** |
49 * The cached list of adjusted ranges, element type: {@link RevisionRange}. <code>null</code> | 45 * The cached list of adjusted ranges, element type: {@link RevisionRange}. <code>null</code> |
50 * if the list must be re-computed. Unmodifiable. | 46 * if the list must be re-computed. Unmodifiable. |
51 * | 47 * |
52 * @since 3.3 | 48 * @since 3.3 |
53 */ | 49 */ |
54 private List fRanges= null; | 50 private List fRanges= null; |
55 | 51 |
56 /** | 52 /** |
60 } | 56 } |
61 | 57 |
62 /** | 58 /** |
63 * Adds a line range to this revision. The range must be non-empty and have a legal start line | 59 * Adds a line range to this revision. The range must be non-empty and have a legal start line |
64 * (not -1). | 60 * (not -1). |
65 * | 61 * |
66 * @param range a line range that was changed with this revision | 62 * @param range a line range that was changed with this revision |
67 * @throws IndexOutOfBoundsException if the line range is empty or has a negative start line | 63 * @throws IndexOutOfBoundsException if the line range is empty or has a negative start line |
68 */ | 64 */ |
69 public final void addRange(ILineRange range) { | 65 public final void addRange(ILineRange range) { |
70 fChangeRegions.add(new ChangeRegion(this, range)); | 66 fChangeRegions.add(new ChangeRegion(this, range)); |
72 | 68 |
73 /** | 69 /** |
74 * Returns the contained {@link RevisionRange}s adapted to the current diff state. The returned | 70 * Returns the contained {@link RevisionRange}s adapted to the current diff state. The returned |
75 * information is only valid at the moment it is returned, and may change as the annotated | 71 * information is only valid at the moment it is returned, and may change as the annotated |
76 * document is modified. | 72 * document is modified. |
77 * | 73 * |
78 * @return an unmodifiable view of the contained ranges (element type: {@link RevisionRange}) | 74 * @return an unmodifiable view of the contained ranges (element type: {@link RevisionRange}) |
79 */ | 75 */ |
80 public final List getRegions() { | 76 public final List getRegions() { |
81 if (fRanges is null) { | 77 if (fRanges is null) { |
82 List ranges= new ArrayList(fChangeRegions.size()); | 78 List ranges= new ArrayList(fChangeRegions.size()); |
93 } | 89 } |
94 | 90 |
95 /** | 91 /** |
96 * Adjusts the revision information to the given diff information. Any previous diff information | 92 * Adjusts the revision information to the given diff information. Any previous diff information |
97 * is discarded. | 93 * is discarded. |
98 * | 94 * |
99 * @param hunks the diff hunks to adjust the revision information to | 95 * @param hunks the diff hunks to adjust the revision information to |
100 * @since 3.3 | 96 * @since 3.3 |
101 */ | 97 */ |
102 final void applyDiff(Hunk[] hunks) { | 98 final void applyDiff(Hunk[] hunks) { |
103 fRanges= null; // mark for recomputation | 99 fRanges= null; // mark for recomputation |
117 * <p> | 113 * <p> |
118 * <strong>Note:</strong> The hover information control which is used to display the information | 114 * <strong>Note:</strong> The hover information control which is used to display the information |
119 * must be able process the given object. If the default information control creator is used | 115 * must be able process the given object. If the default information control creator is used |
120 * the supported format is simple text, full HTML or an HTML fragment. | 116 * the supported format is simple text, full HTML or an HTML fragment. |
121 * </p> | 117 * </p> |
122 * | 118 * |
123 * @return the hover information for this revision or <code>null</code> for no hover | 119 * @return the hover information for this revision or <code>null</code> for no hover |
124 * @see RevisionInformation#setHoverControlCreator(IInformationControlCreator) | 120 * @see RevisionInformation#setHoverControlCreator(IInformationControlCreator) |
125 */ | 121 */ |
126 public abstract Object getHoverInfo(); | 122 public abstract Object getHoverInfo(); |
127 | 123 |
129 * Returns the author color for this revision. This color can be used to visually distinguish | 125 * Returns the author color for this revision. This color can be used to visually distinguish |
130 * one revision from another, for example as background color. | 126 * one revision from another, for example as background color. |
131 * <p> | 127 * <p> |
132 * Revisions from the same author must return the same color and revisions from different authors | 128 * Revisions from the same author must return the same color and revisions from different authors |
133 * must return distinct colors.</p> | 129 * must return distinct colors.</p> |
134 * | 130 * |
135 * @return the RGB color for this revision's author | 131 * @return the RGB color for this revision's author |
136 */ | 132 */ |
137 public abstract RGB getColor(); | 133 public abstract RGB getColor(); |
138 | 134 |
139 /** | 135 /** |
140 * Returns the unique (within the document) id of this revision. This may be the version string | 136 * Returns the unique (within the document) id of this revision. This may be the version string |
141 * or a different identifier. | 137 * or a different identifier. |
142 * | 138 * |
143 * @return the id of this revision | 139 * @return the id of this revision |
144 */ | 140 */ |
145 public abstract String getId(); | 141 public abstract String getId(); |
146 | 142 |
147 /** | 143 /** |
148 * Returns the modification date of this revision. | 144 * Returns the modification date of this revision. |
149 * | 145 * |
150 * @return the modification date of this revision | 146 * @return the modification date of this revision |
151 */ | 147 */ |
152 public abstract Date getDate(); | 148 public abstract Date getDate(); |
153 | 149 |
154 /* | 150 /* |
161 /** | 157 /** |
162 * Returns the display string for the author of this revision. | 158 * Returns the display string for the author of this revision. |
163 * <p> | 159 * <p> |
164 * Subclasses should replace - the default implementation returns the empty string. | 160 * Subclasses should replace - the default implementation returns the empty string. |
165 * </p> | 161 * </p> |
166 * | 162 * |
167 * @return the author name | 163 * @return the author name |
168 * @since 3.3 | 164 * @since 3.3 |
169 */ | 165 */ |
170 public String getAuthor() { | 166 public String getAuthor() { |
171 return ""; //$NON-NLS-1$ | 167 return ""; //$NON-NLS-1$ |