Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/AnnotationRulerColumn.d @ 159:7926b636c282
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 01:57:58 +0200 |
parents | f70d9508c95c |
children | 1a5b8f8129df |
comparison
equal
deleted
inserted
replaced
158:25f1f92fa3df | 159:7926b636c282 |
---|---|
208 /** Cache for the actual scroll position in pixels */ | 208 /** Cache for the actual scroll position in pixels */ |
209 private int fScrollPos; | 209 private int fScrollPos; |
210 /** The buffer for double buffering */ | 210 /** The buffer for double buffering */ |
211 private Image fBuffer; | 211 private Image fBuffer; |
212 /** The internal listener */ | 212 /** The internal listener */ |
213 private InternalListener fInternalListener= new InternalListener(); | 213 private InternalListener fInternalListener; |
214 /** The width of this vertical ruler */ | 214 /** The width of this vertical ruler */ |
215 private int fWidth; | 215 private int fWidth; |
216 /** Switch for enabling/disabling the setModel method. */ | 216 /** Switch for enabling/disabling the setModel method. */ |
217 private bool fAllowSetModel= true; | 217 private bool fAllowSetModel= true; |
218 /** | 218 /** |
219 * The list of annotation types to be shown in this ruler. | 219 * The list of annotation types to be shown in this ruler. |
220 * @since 3.0 | 220 * @since 3.0 |
221 */ | 221 */ |
222 private Set fConfiguredAnnotationTypes= new HashSet(); | 222 private Set fConfiguredAnnotationTypes; |
223 /** | 223 /** |
224 * The list of allowed annotation types to be shown in this ruler. | 224 * The list of allowed annotation types to be shown in this ruler. |
225 * An allowed annotation type maps to <code>true</code>, a disallowed | 225 * An allowed annotation type maps to <code>true</code>, a disallowed |
226 * to <code>false</code>. | 226 * to <code>false</code>. |
227 * @since 3.0 | 227 * @since 3.0 |
228 */ | 228 */ |
229 private Map fAllowedAnnotationTypes= new HashMap(); | 229 private Map fAllowedAnnotationTypes; |
230 /** | 230 /** |
231 * The annotation access extension. | 231 * The annotation access extension. |
232 * @since 3.0 | 232 * @since 3.0 |
233 */ | 233 */ |
234 private IAnnotationAccessExtension fAnnotationAccessExtension; | 234 private IAnnotationAccessExtension fAnnotationAccessExtension; |
239 private IAnnotationHover fHover; | 239 private IAnnotationHover fHover; |
240 /** | 240 /** |
241 * The cached annotations. | 241 * The cached annotations. |
242 * @since 3.0 | 242 * @since 3.0 |
243 */ | 243 */ |
244 private List fCachedAnnotations= new ArrayList(); | 244 private List fCachedAnnotations; |
245 /** | 245 /** |
246 * The comparator for sorting annotations according to the offset of their position. | 246 * The comparator for sorting annotations according to the offset of their position. |
247 * @since 3.0 | 247 * @since 3.0 |
248 */ | 248 */ |
249 private Comparator fTupleComparator= new TupleComparator(); | 249 private Comparator fTupleComparator; |
250 /** | 250 /** |
251 * The hit detection cursor. | 251 * The hit detection cursor. |
252 * @since 3.0 | 252 * @since 3.0 |
253 */ | 253 */ |
254 private Cursor fHitDetectionCursor; | 254 private Cursor fHitDetectionCursor; |
261 * This ruler's mouse listener. | 261 * This ruler's mouse listener. |
262 * @since 3.0 | 262 * @since 3.0 |
263 */ | 263 */ |
264 private MouseListener fMouseListener; | 264 private MouseListener fMouseListener; |
265 | 265 |
266 private void instanceInit(){ | |
267 fInternalListener= new InternalListener(); | |
268 fConfiguredAnnotationTypes= new HashSet(); | |
269 fAllowedAnnotationTypes= new HashMap(); | |
270 fCachedAnnotations= new ArrayList(); | |
271 fTupleComparator= new TupleComparator(); | |
272 } | |
266 /** | 273 /** |
267 * Constructs this column with the given arguments. | 274 * Constructs this column with the given arguments. |
268 * | 275 * |
269 * @param model the annotation model to get the annotations from | 276 * @param model the annotation model to get the annotations from |
270 * @param width the width of the vertical ruler | 277 * @param width the width of the vertical ruler |
284 * @param width the width of the vertical ruler | 291 * @param width the width of the vertical ruler |
285 * @param annotationAccess the annotation access | 292 * @param annotationAccess the annotation access |
286 * @since 3.0 | 293 * @since 3.0 |
287 */ | 294 */ |
288 public this(int width, IAnnotationAccess annotationAccess) { | 295 public this(int width, IAnnotationAccess annotationAccess) { |
296 instanceInit(); | |
289 fWidth= width; | 297 fWidth= width; |
290 if ( cast(IAnnotationAccessExtension)annotationAccess ) | 298 if ( cast(IAnnotationAccessExtension)annotationAccess ) |
291 fAnnotationAccessExtension= cast(IAnnotationAccessExtension) annotationAccess; | 299 fAnnotationAccessExtension= cast(IAnnotationAccessExtension) annotationAccess; |
292 } | 300 } |
293 | 301 |
296 * | 304 * |
297 * @param model the annotation model to get the annotations from | 305 * @param model the annotation model to get the annotations from |
298 * @param width the width of the vertical ruler | 306 * @param width the width of the vertical ruler |
299 */ | 307 */ |
300 public this(IAnnotationModel model, int width) { | 308 public this(IAnnotationModel model, int width) { |
309 instanceInit(); | |
301 fWidth= width; | 310 fWidth= width; |
302 fAllowSetModel= false; | 311 fAllowSetModel= false; |
303 fModel= model; | 312 fModel= model; |
304 fModel.addAnnotationModelListener(fInternalListener); | 313 fModel.addAnnotationModelListener(fInternalListener); |
305 } | 314 } |
308 * Constructs this column with the given width. | 317 * Constructs this column with the given width. |
309 * | 318 * |
310 * @param width the width of the vertical ruler | 319 * @param width the width of the vertical ruler |
311 */ | 320 */ |
312 public this(int width) { | 321 public this(int width) { |
322 instanceInit(); | |
313 fWidth= width; | 323 fWidth= width; |
314 } | 324 } |
315 | 325 |
316 /* | 326 /* |
317 * @see IVerticalRulerColumn#getControl() | 327 * @see IVerticalRulerColumn#getControl() |
487 IRegion line; | 497 IRegion line; |
488 try { | 498 try { |
489 IDocument d= fCachedTextViewer.getDocument(); | 499 IDocument d= fCachedTextViewer.getDocument(); |
490 if (d is null) | 500 if (d is null) |
491 return false; | 501 return false; |
492 | 502 |
493 line= d.getLineInformation(lineNumber); | 503 line= d.getLineInformation(lineNumber); |
494 } catch (BadLocationException ex) { | 504 } catch (BadLocationException ex) { |
495 return false; | 505 return false; |
496 } | 506 } |
497 | 507 |
598 * @return document offset of the upper left corner including partially visible lines | 608 * @return document offset of the upper left corner including partially visible lines |
599 */ | 609 */ |
600 protected int getInclusiveTopIndexStartOffset() { | 610 protected int getInclusiveTopIndexStartOffset() { |
601 if (fCachedTextWidget is null || fCachedTextWidget.isDisposed()) | 611 if (fCachedTextWidget is null || fCachedTextWidget.isDisposed()) |
602 return -1; | 612 return -1; |
603 | 613 |
604 IDocument document= fCachedTextViewer.getDocument(); | 614 IDocument document= fCachedTextViewer.getDocument(); |
605 if (document is null) | 615 if (document is null) |
606 return -1; | 616 return -1; |
607 | 617 |
608 int top= JFaceTextUtil.getPartialTopIndex(fCachedTextViewer); | 618 int top= JFaceTextUtil.getPartialTopIndex(fCachedTextViewer); |
609 try { | 619 try { |
610 return document.getLineOffset(top); | 620 return document.getLineOffset(top); |
611 } catch (BadLocationException x) { | 621 } catch (BadLocationException x) { |
612 return -1; | 622 return -1; |
620 * @return the first invisible document offset of the lower right corner of the view port | 630 * @return the first invisible document offset of the lower right corner of the view port |
621 */ | 631 */ |
622 private int getExclusiveBottomIndexEndOffset() { | 632 private int getExclusiveBottomIndexEndOffset() { |
623 if (fCachedTextWidget is null || fCachedTextWidget.isDisposed()) | 633 if (fCachedTextWidget is null || fCachedTextWidget.isDisposed()) |
624 return -1; | 634 return -1; |
625 | 635 |
626 IDocument document= fCachedTextViewer.getDocument(); | 636 IDocument document= fCachedTextViewer.getDocument(); |
627 if (document is null) | 637 if (document is null) |
628 return -1; | 638 return -1; |
629 | 639 |
630 int bottom= JFaceTextUtil.getPartialBottomIndex(fCachedTextViewer); | 640 int bottom= JFaceTextUtil.getPartialBottomIndex(fCachedTextViewer); |
631 try { | 641 try { |
632 if (bottom >= document.getNumberOfLines()) | 642 if (bottom >= document.getNumberOfLines()) |
633 bottom= document.getNumberOfLines() - 1; | 643 bottom= document.getNumberOfLines() - 1; |
634 return document.getLineOffset(bottom) + document.getLineLength(bottom); | 644 return document.getLineOffset(bottom) + document.getLineLength(bottom); |
723 startLine -= topLine; | 733 startLine -= topLine; |
724 endLine -= topLine; | 734 endLine -= topLine; |
725 | 735 |
726 r.x= 0; | 736 r.x= 0; |
727 r.y= JFaceTextUtil.computeLineHeight(fCachedTextWidget, 0, startLine, startLine) - fScrollPos; | 737 r.y= JFaceTextUtil.computeLineHeight(fCachedTextWidget, 0, startLine, startLine) - fScrollPos; |
728 | 738 |
729 r.width= dimension.x; | 739 r.width= dimension.x; |
730 int lines= endLine - startLine; | 740 int lines= endLine - startLine; |
731 | 741 |
732 r.height= JFaceTextUtil.computeLineHeight(fCachedTextWidget, startLine, endLine + 1, lines + 1); | 742 r.height= JFaceTextUtil.computeLineHeight(fCachedTextWidget, startLine, endLine + 1, lines + 1); |
733 | 743 |
734 if (r.y < dimension.y && fAnnotationAccessExtension !is null) // annotation within visible area | 744 if (r.y < dimension.y && fAnnotationAccessExtension !is null) // annotation within visible area |
735 fAnnotationAccessExtension.paint(annotation, gc, fCanvas, r); | 745 fAnnotationAccessExtension.paint(annotation, gc, fCanvas, r); |
736 | 746 |
822 if (endLine is -1) | 832 if (endLine is -1) |
823 continue; | 833 continue; |
824 | 834 |
825 r.x= 0; | 835 r.x= 0; |
826 r.y= JFaceTextUtil.computeLineHeight(fCachedTextWidget, 0, startLine, startLine) - fScrollPos; | 836 r.y= JFaceTextUtil.computeLineHeight(fCachedTextWidget, 0, startLine, startLine) - fScrollPos; |
827 | 837 |
828 r.width= dimension.x; | 838 r.width= dimension.x; |
829 int lines= endLine - startLine; | 839 int lines= endLine - startLine; |
830 r.height= JFaceTextUtil.computeLineHeight(fCachedTextWidget, startLine, endLine + 1, lines + 1); | 840 r.height= JFaceTextUtil.computeLineHeight(fCachedTextWidget, startLine, endLine + 1, lines + 1); |
831 | 841 |
832 if (r.y < dimension.y && fAnnotationAccessExtension !is null) // annotation within visible area | 842 if (r.y < dimension.y && fAnnotationAccessExtension !is null) // annotation within visible area |
931 * @since 3.0 | 941 * @since 3.0 |
932 */ | 942 */ |
933 public int toDocumentLineNumber(int y_coordinate) { | 943 public int toDocumentLineNumber(int y_coordinate) { |
934 return fParentRuler.toDocumentLineNumber(y_coordinate); | 944 return fParentRuler.toDocumentLineNumber(y_coordinate); |
935 } | 945 } |
936 | 946 |
937 /** | 947 /** |
938 * Removes the given annotation type from this annotation ruler column. | 948 * Removes the given annotation type from this annotation ruler column. |
939 * Annotations of the given type are no longer shown in this annotation | 949 * Annotations of the given type are no longer shown in this annotation |
940 * ruler column. | 950 * ruler column. |
941 * | 951 * |