Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/projection/ProjectionSupport.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 25f1f92fa3df |
children |
comparison
equal
deleted
inserted
replaced
161:f8d52b926852 | 162:1a5b8f8129df |
---|---|
59 | 59 |
60 /** | 60 /** |
61 * Key of the projection annotation model inside the visual annotation | 61 * Key of the projection annotation model inside the visual annotation |
62 * model. Also internally used as key for the projection drawing strategy. | 62 * model. Also internally used as key for the projection drawing strategy. |
63 */ | 63 */ |
64 public const static Object PROJECTION= new Object(); | 64 private static Object PROJECTION_; |
65 public static Object PROJECTION(){ | |
66 if( PROJECTION_ is null ){ | |
67 synchronized(ProjectionSupport.classinfo){ | |
68 if( PROJECTION_ is null ){ | |
69 PROJECTION_ = new Object(); | |
70 } | |
71 } | |
72 } | |
73 return PROJECTION_; | |
74 } | |
65 | 75 |
66 private static class ProjectionAnnotationsPainter : AnnotationPainter { | 76 private static class ProjectionAnnotationsPainter : AnnotationPainter { |
67 | 77 |
68 /** | 78 /** |
69 * Creates a new painter indicating the location of collapsed regions. | 79 * Creates a new painter indicating the location of collapsed regions. |
110 | 120 |
111 StyledTextContent content= textWidget.getContent(); | 121 StyledTextContent content= textWidget.getContent(); |
112 int line= content.getLineAtOffset(offset); | 122 int line= content.getLineAtOffset(offset); |
113 int lineStart= content.getOffsetAtLine(line); | 123 int lineStart= content.getOffsetAtLine(line); |
114 String text= content.getLine(line); | 124 String text= content.getLine(line); |
115 int lineLength= text is null ? 0 : text.length(); | 125 int lineLength= text is null ? 0 : text.length; |
116 int lineEnd= lineStart + lineLength; | 126 int lineEnd= lineStart + lineLength; |
117 Point p= textWidget.getLocationAtOffset(lineEnd); | 127 Point p= textWidget.getLocationAtOffset(lineEnd); |
118 | 128 |
119 Color c= gc.getForeground(); | 129 Color c= gc.getForeground(); |
120 gc.setForeground(color); | 130 gc.setForeground(color); |
311 protected void doEnableProjection() { | 321 protected void doEnableProjection() { |
312 | 322 |
313 if (fPainter is null) { | 323 if (fPainter is null) { |
314 fPainter= new ProjectionAnnotationsPainter(fViewer, fAnnotationAccess); | 324 fPainter= new ProjectionAnnotationsPainter(fViewer, fAnnotationAccess); |
315 fPainter.addDrawingStrategy(PROJECTION, getDrawingStrategy()); | 325 fPainter.addDrawingStrategy(PROJECTION, getDrawingStrategy()); |
316 fPainter.addAnnotationType(ProjectionAnnotation.TYPE, PROJECTION); | 326 fPainter.addAnnotationType(stringcast(ProjectionAnnotation.TYPE), PROJECTION); |
317 fPainter.setAnnotationTypeColor(ProjectionAnnotation.TYPE, fSharedTextColors.getColor(getColor())); | 327 fPainter.setAnnotationTypeColor(stringcast(ProjectionAnnotation.TYPE), fSharedTextColors.getColor(getColor())); |
318 fViewer.addPainter(fPainter); | 328 fViewer.addPainter(fPainter); |
319 } | 329 } |
320 | 330 |
321 if (fColumn is null) { | 331 if (fColumn is null) { |
322 fColumn= new ProjectionRulerColumn(9, fAnnotationAccess); | 332 fColumn= new ProjectionRulerColumn(9, fAnnotationAccess); |
323 fColumn.addAnnotationType(ProjectionAnnotation.TYPE); | 333 fColumn.addAnnotationType(stringcast(ProjectionAnnotation.TYPE)); |
324 fColumn.setHover(createProjectionAnnotationHover()); | 334 fColumn.setHover(createProjectionAnnotationHover()); |
325 fViewer.addVerticalRulerColumn(fColumn); | 335 fViewer.addVerticalRulerColumn(fColumn); |
326 } | 336 } |
327 | 337 |
328 fColumn.setModel(fViewer.getVisualAnnotationModel()); | 338 fColumn.setModel(fViewer.getVisualAnnotationModel()); |
348 private ProjectionSummary createProjectionSummary() { | 358 private ProjectionSummary createProjectionSummary() { |
349 ProjectionSummary summary= new ProjectionSummary(fViewer, fAnnotationAccess); | 359 ProjectionSummary summary= new ProjectionSummary(fViewer, fAnnotationAccess); |
350 if (fSummarizableTypes !is null) { | 360 if (fSummarizableTypes !is null) { |
351 int size= fSummarizableTypes.size(); | 361 int size= fSummarizableTypes.size(); |
352 for (int i= 0; i < size; i++) | 362 for (int i= 0; i < size; i++) |
353 summary.addAnnotationType(cast(String) fSummarizableTypes.get(i)); | 363 summary.addAnnotationType(stringcast(fSummarizableTypes.get(i))); |
354 } | 364 } |
355 return summary; | 365 return summary; |
356 } | 366 } |
357 | 367 |
358 private IAnnotationHover createProjectionAnnotationHover() { | 368 private IAnnotationHover createProjectionAnnotationHover() { |