Mercurial > projects > dwt-addons
annotate dwtx/jface/text/source/AnnotationModelEvent.d @ 153:f70d9508c95c
Fix java Collection imports
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 25 Aug 2008 00:27:31 +0200 |
parents | 53b889547456 |
children | 1a5b8f8129df |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2005 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.text.source.AnnotationModelEvent; | |
14 | |
131 | 15 import dwtx.jface.text.source.ISharedTextColors; // packageimport |
16 import dwtx.jface.text.source.ILineRange; // packageimport | |
17 import dwtx.jface.text.source.IAnnotationPresentation; // packageimport | |
18 import dwtx.jface.text.source.IVerticalRulerInfoExtension; // packageimport | |
19 import dwtx.jface.text.source.ICharacterPairMatcher; // packageimport | |
20 import dwtx.jface.text.source.TextInvocationContext; // packageimport | |
21 import dwtx.jface.text.source.LineChangeHover; // packageimport | |
22 import dwtx.jface.text.source.IChangeRulerColumn; // packageimport | |
23 import dwtx.jface.text.source.IAnnotationMap; // packageimport | |
24 import dwtx.jface.text.source.IAnnotationModelListenerExtension; // packageimport | |
25 import dwtx.jface.text.source.ISourceViewerExtension2; // packageimport | |
26 import dwtx.jface.text.source.IAnnotationHover; // packageimport | |
27 import dwtx.jface.text.source.ContentAssistantFacade; // packageimport | |
28 import dwtx.jface.text.source.IAnnotationAccess; // packageimport | |
29 import dwtx.jface.text.source.IVerticalRulerExtension; // packageimport | |
30 import dwtx.jface.text.source.IVerticalRulerColumn; // packageimport | |
31 import dwtx.jface.text.source.LineNumberRulerColumn; // packageimport | |
32 import dwtx.jface.text.source.MatchingCharacterPainter; // packageimport | |
33 import dwtx.jface.text.source.IAnnotationModelExtension; // packageimport | |
34 import dwtx.jface.text.source.ILineDifferExtension; // packageimport | |
35 import dwtx.jface.text.source.DefaultCharacterPairMatcher; // packageimport | |
36 import dwtx.jface.text.source.LineNumberChangeRulerColumn; // packageimport | |
37 import dwtx.jface.text.source.IAnnotationAccessExtension; // packageimport | |
38 import dwtx.jface.text.source.ISourceViewer; // packageimport | |
39 import dwtx.jface.text.source.AnnotationModel; // packageimport | |
40 import dwtx.jface.text.source.ILineDifferExtension2; // packageimport | |
41 import dwtx.jface.text.source.IAnnotationModelListener; // packageimport | |
42 import dwtx.jface.text.source.IVerticalRuler; // packageimport | |
43 import dwtx.jface.text.source.DefaultAnnotationHover; // packageimport | |
44 import dwtx.jface.text.source.SourceViewer; // packageimport | |
45 import dwtx.jface.text.source.SourceViewerConfiguration; // packageimport | |
46 import dwtx.jface.text.source.AnnotationBarHoverManager; // packageimport | |
47 import dwtx.jface.text.source.CompositeRuler; // packageimport | |
48 import dwtx.jface.text.source.ImageUtilities; // packageimport | |
49 import dwtx.jface.text.source.VisualAnnotationModel; // packageimport | |
50 import dwtx.jface.text.source.IAnnotationModel; // packageimport | |
51 import dwtx.jface.text.source.ISourceViewerExtension3; // packageimport | |
52 import dwtx.jface.text.source.ILineDiffInfo; // packageimport | |
53 import dwtx.jface.text.source.VerticalRulerEvent; // packageimport | |
54 import dwtx.jface.text.source.ChangeRulerColumn; // packageimport | |
55 import dwtx.jface.text.source.ILineDiffer; // packageimport | |
56 import dwtx.jface.text.source.AnnotationColumn; // packageimport | |
57 import dwtx.jface.text.source.AnnotationRulerColumn; // packageimport | |
58 import dwtx.jface.text.source.IAnnotationHoverExtension; // packageimport | |
59 import dwtx.jface.text.source.AbstractRulerColumn; // packageimport | |
60 import dwtx.jface.text.source.ISourceViewerExtension; // packageimport | |
61 import dwtx.jface.text.source.AnnotationMap; // packageimport | |
62 import dwtx.jface.text.source.IVerticalRulerInfo; // packageimport | |
63 import dwtx.jface.text.source.IAnnotationModelExtension2; // packageimport | |
64 import dwtx.jface.text.source.LineRange; // packageimport | |
65 import dwtx.jface.text.source.IAnnotationAccessExtension2; // packageimport | |
66 import dwtx.jface.text.source.VerticalRuler; // packageimport | |
67 import dwtx.jface.text.source.JFaceTextMessages; // packageimport | |
68 import dwtx.jface.text.source.IOverviewRuler; // packageimport | |
69 import dwtx.jface.text.source.Annotation; // packageimport | |
70 import dwtx.jface.text.source.IVerticalRulerListener; // packageimport | |
71 import dwtx.jface.text.source.ISourceViewerExtension4; // packageimport | |
72 import dwtx.jface.text.source.AnnotationPainter; // packageimport | |
73 import dwtx.jface.text.source.IAnnotationHoverExtension2; // packageimport | |
74 import dwtx.jface.text.source.OverviewRuler; // packageimport | |
75 import dwtx.jface.text.source.OverviewRulerHoverManager; // packageimport | |
76 | |
77 | |
129 | 78 import dwt.dwthelper.utils; |
79 | |
80 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
143
diff
changeset
|
81 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
143
diff
changeset
|
82 |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
143
diff
changeset
|
83 |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
143
diff
changeset
|
84 |
129 | 85 |
86 import dwtx.jface.text.Position; | |
87 | |
88 | |
89 /** | |
90 * Specification of changes applied to annotation models. The event carries the | |
91 * changed annotation model as well as added, removed, and modified annotations. | |
92 * <p> | |
93 * An event can be sealed. Afterwards it can not be modified. Thus, the normal | |
94 * process is that an empty event is created, filled with the changed | |
95 * information, and before it is sent to the listeners, the event is sealed. | |
96 * | |
97 * @see dwtx.jface.text.source.IAnnotationModel | |
98 * @see dwtx.jface.text.source.IAnnotationModelListenerExtension | |
99 * @since 2.0 | |
100 */ | |
101 public class AnnotationModelEvent { | |
102 | |
103 /** The model this event refers to. */ | |
104 private IAnnotationModel fAnnotationModel; | |
105 /** | |
106 * The added annotations. | |
107 * @since 3.0 | |
108 */ | |
109 private Set fAddedAnnotations= new HashSet(); | |
110 /** | |
111 * The removed annotations. | |
112 * @since 3.0 | |
113 */ | |
114 private Map fRemovedAnnotations= new HashMap(); | |
115 /** | |
116 * The changed annotations. | |
117 * @since 3.0 | |
118 */ | |
119 private Set fChangedAnnotations= new HashSet(); | |
120 /** | |
121 * Indicates that this event does not contain detailed information. | |
122 * @since 3.0 | |
123 */ | |
124 private bool fIsWorldChange; | |
125 /** | |
126 * The modification stamp. | |
127 * @since 3.0 | |
128 */ | |
129 private Object fModificationStamp; | |
130 | |
131 /** | |
132 * Creates a new annotation model event for the given model. | |
133 * | |
134 * @param model the model | |
135 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
136 public this(IAnnotationModel model) { |
129 | 137 this(model, true); |
138 } | |
139 | |
140 /** | |
141 * Creates a new annotation model event for the given model. | |
142 * | |
143 * @param model the model | |
144 * @param isWorldChange <code>true</code> if world change | |
145 * @since 3.0 | |
146 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
147 public this(IAnnotationModel model, bool isWorldChange) { |
129 | 148 fAnnotationModel= model; |
149 fIsWorldChange= isWorldChange; | |
150 } | |
151 | |
152 /** | |
153 * Returns the model this event refers to. | |
154 * | |
155 * @return the model this events belongs to | |
156 */ | |
157 public IAnnotationModel getAnnotationModel() { | |
158 return fAnnotationModel; | |
159 } | |
160 | |
161 /** | |
162 * Adds the given annotation to the set of annotations that are reported as | |
163 * being added from the model. If this event is considered a world change, | |
164 * it is no longer so after this method has successfully finished. | |
165 * | |
166 * @param annotation the added annotation | |
167 * @since 3.0 | |
168 */ | |
169 public void annotationAdded(Annotation annotation) { | |
170 fAddedAnnotations.add(annotation); | |
171 fIsWorldChange= false; | |
172 } | |
173 | |
174 /** | |
175 * Returns the added annotations. | |
176 * | |
177 * @return the added annotations | |
178 * @since 3.0 | |
179 */ | |
180 public Annotation[] getAddedAnnotations() { | |
181 int size= fAddedAnnotations.size(); | |
182 Annotation[] added= new Annotation[size]; | |
183 fAddedAnnotations.toArray(added); | |
184 return added; | |
185 } | |
186 | |
187 /** | |
188 * Adds the given annotation to the set of annotations that are reported as | |
189 * being removed from the model. If this event is considered a world | |
190 * change, it is no longer so after this method has successfully finished. | |
191 * | |
192 * @param annotation the removed annotation | |
193 * @since 3.0 | |
194 */ | |
195 public void annotationRemoved(Annotation annotation) { | |
196 annotationRemoved(annotation, null); | |
197 } | |
198 | |
199 /** | |
200 * Adds the given annotation to the set of annotations that are reported as | |
201 * being removed from the model. If this event is considered a world | |
202 * change, it is no longer so after this method has successfully finished. | |
203 * | |
204 * @param annotation the removed annotation | |
205 * @param position the position of the removed annotation | |
206 * @since 3.0 | |
207 */ | |
208 public void annotationRemoved(Annotation annotation, Position position) { | |
209 fRemovedAnnotations.put(annotation, position); | |
210 fIsWorldChange= false; | |
211 } | |
212 | |
213 /** | |
214 * Returns the removed annotations. | |
215 * | |
216 * @return the removed annotations | |
217 * @since 3.0 | |
218 */ | |
219 public Annotation[] getRemovedAnnotations() { | |
220 int size= fRemovedAnnotations.size(); | |
221 Annotation[] removed= new Annotation[size]; | |
222 fRemovedAnnotations.keySet().toArray(removed); | |
223 return removed; | |
224 } | |
225 | |
226 /** | |
227 * Returns the position of the removed annotation at that point in time | |
228 * when the annotation has been removed. | |
229 * | |
230 * @param annotation the removed annotation | |
231 * @return the position of the removed annotation or <code>null</code> | |
232 * @since 3.0 | |
233 */ | |
234 public Position getPositionOfRemovedAnnotation(Annotation annotation) { | |
134 | 235 return cast(Position) fRemovedAnnotations.get(annotation); |
129 | 236 } |
237 | |
238 /** | |
239 * Adds the given annotation to the set of annotations that are reported as | |
240 * being changed from the model. If this event is considered a world | |
241 * change, it is no longer so after this method has successfully finished. | |
242 * | |
243 * @param annotation the changed annotation | |
244 * @since 3.0 | |
245 */ | |
246 public void annotationChanged(Annotation annotation) { | |
247 fChangedAnnotations.add(annotation); | |
248 fIsWorldChange= false; | |
249 } | |
250 | |
251 /** | |
252 * Returns the changed annotations. | |
253 * | |
254 * @return the changed annotations | |
255 * @since 3.0 | |
256 */ | |
257 public Annotation[] getChangedAnnotations() { | |
258 int size= fChangedAnnotations.size(); | |
259 Annotation[] changed= new Annotation[size]; | |
260 fChangedAnnotations.toArray(changed); | |
261 return changed; | |
262 } | |
263 | |
264 /** | |
265 * Returns whether this annotation model event is empty or not. If this | |
266 * event represents a world change, this method returns <code>false</code> | |
267 * although the event does not carry any added, removed, or changed | |
268 * annotations. | |
269 * | |
270 * @return <code>true</code> if this event is empty | |
271 * @since 3.0 | |
272 */ | |
273 public bool isEmpty() { | |
274 return !fIsWorldChange && fAddedAnnotations.isEmpty() && fRemovedAnnotations.isEmpty() && fChangedAnnotations.isEmpty(); | |
275 } | |
276 | |
277 /** | |
278 * Returns whether this annotation model events contains detailed | |
279 * information about the modifications applied to the event annotation | |
280 * model or whether it represents a world change. I.e. everything in the | |
281 * model might have changed. | |
282 * | |
283 * @return <code>true</code> if world change, <code>false</code> otherwise | |
284 * @since 3.0 | |
285 */ | |
286 public bool isWorldChange() { | |
287 return fIsWorldChange; | |
288 } | |
289 | |
290 /** | |
291 * Marks this event as world change according to the given flag. | |
292 * | |
293 * @param isWorldChange <code>true</code> if this event is a world change, <code>false</code> otherwise | |
294 * @since 3.0 | |
295 */ | |
296 void markWorldChange(bool isWorldChange) { | |
297 fIsWorldChange= isWorldChange; | |
298 } | |
299 | |
300 /** | |
301 * Returns whether this annotation model event is still valid. | |
302 * | |
303 * @return <code>true</code> if this event is still valid, <code>false</code> otherwise | |
304 * @since 3.0 | |
305 */ | |
306 public bool isValid() { | |
143 | 307 if (fModificationStamp !is null && cast(IAnnotationModelExtension)fAnnotationModel ) { |
134 | 308 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fAnnotationModel; |
129 | 309 return fModificationStamp is extension.getModificationStamp(); |
310 } | |
311 return true; | |
312 } | |
313 | |
314 /** | |
315 * Seals this event. Any direct modification to the annotation model after the event has been sealed | |
316 * invalidates this event. | |
317 * | |
318 * @since 3.0 | |
319 */ | |
320 public void markSealed() { | |
138 | 321 if ( cast(IAnnotationModelExtension)fAnnotationModel ) { |
134 | 322 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fAnnotationModel; |
129 | 323 fModificationStamp= extension.getModificationStamp(); |
324 } | |
325 } | |
326 } |