Mercurial > projects > dwt-addons
annotate dwtx/jface/text/source/VisualAnnotationModel.d @ 145:02cd5f1224d3
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 22:31:00 +0200 |
parents | 51e6e63f930e |
children | f70d9508c95c |
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.VisualAnnotationModel; | |
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.IAnnotationModel; // packageimport | |
50 import dwtx.jface.text.source.ISourceViewerExtension3; // packageimport | |
51 import dwtx.jface.text.source.ILineDiffInfo; // packageimport | |
52 import dwtx.jface.text.source.VerticalRulerEvent; // packageimport | |
53 import dwtx.jface.text.source.ChangeRulerColumn; // packageimport | |
54 import dwtx.jface.text.source.ILineDiffer; // packageimport | |
55 import dwtx.jface.text.source.AnnotationModelEvent; // 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 | |
81 import java.util.ArrayList; | |
82 import java.util.Iterator; | |
83 | |
84 import dwtx.jface.text.IDocument; | |
85 import dwtx.jface.text.Position; | |
86 | |
87 | |
88 | |
89 /** | |
90 * Annotation model for visual annotations. Assume a viewer's input element is annotated with | |
91 * some semantic annotation such as a breakpoint and that it is simultaneously shown in multiple | |
92 * viewers. A source viewer, e.g., supports visual range indication for which it utilizes | |
93 * annotations. The range indicating annotation is specific to the visual presentation | |
94 * of the input element in this viewer and thus should only be visible in this viewer. The | |
95 * breakpoints however are independent from the input element's presentation and thus should | |
96 * be shown in all viewers in which the element is shown. As a viewer supports one vertical | |
97 * ruler which is based on one annotation model, there must be a visual annotation model for | |
98 * each viewer which all wrap the same element specific model annotation model. | |
99 */ | |
100 class VisualAnnotationModel : AnnotationModel , IAnnotationModelListener { | |
101 | |
102 /** The wrapped model annotation model */ | |
103 private IAnnotationModel fModel; | |
104 | |
105 /** | |
106 * Constructs a visual annotation model which wraps the given | |
107 * model based annotation model | |
108 * | |
109 * @param modelAnnotationModel the model based annotation model | |
110 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
111 public this(IAnnotationModel modelAnnotationModel) { |
129 | 112 fModel= modelAnnotationModel; |
113 } | |
114 | |
115 /** | |
116 * Returns the visual annotation model's wrapped model based annotation model. | |
117 * | |
118 * @return the model based annotation model | |
119 */ | |
120 public IAnnotationModel getModelAnnotationModel() { | |
121 return fModel; | |
122 } | |
123 | |
124 /* | |
125 * @see IAnnotationModel#addAnnotationModelListener(IAnnotationModelListener) | |
126 */ | |
127 public void addAnnotationModelListener(IAnnotationModelListener listener) { | |
128 | |
129 if (fModel !is null && fAnnotationModelListeners.isEmpty()) | |
130 fModel.addAnnotationModelListener(this); | |
131 | |
132 super.addAnnotationModelListener(listener); | |
133 } | |
134 | |
135 /* | |
136 * @see IAnnotationModel#connect(IDocument) | |
137 */ | |
138 public void connect(IDocument document) { | |
139 super.connect(document); | |
140 if (fModel !is null) | |
141 fModel.connect(document); | |
142 } | |
143 | |
144 /* | |
145 * @see IAnnotationModel#disconnect(IDocument) | |
146 */ | |
147 public void disconnect(IDocument document) { | |
148 super.disconnect(document); | |
149 if (fModel !is null) | |
150 fModel.disconnect(document); | |
151 } | |
152 | |
153 /* | |
154 * @see IAnnotationModel#getAnnotationIterator() | |
155 */ | |
156 public Iterator getAnnotationIterator() { | |
157 | |
158 if (fModel is null) | |
159 return super.getAnnotationIterator(); | |
160 | |
161 ArrayList a= new ArrayList(20); | |
162 | |
163 Iterator e= fModel.getAnnotationIterator(); | |
164 while (e.hasNext()) | |
165 a.add(e.next()); | |
166 | |
167 e= super.getAnnotationIterator(); | |
168 while (e.hasNext()) | |
169 a.add(e.next()); | |
170 | |
171 return a.iterator(); | |
172 } | |
173 | |
174 /* | |
175 * @see IAnnotationModel#getPosition(Annotation) | |
176 */ | |
177 public Position getPosition(Annotation annotation) { | |
178 | |
134 | 179 Position p= cast(Position) getAnnotationMap().get(annotation); |
129 | 180 if (p !is null) |
181 return p; | |
182 | |
183 if (fModel !is null) | |
184 return fModel.getPosition(annotation); | |
185 | |
186 return null; | |
187 } | |
188 | |
189 /* | |
190 * @see IAnnotationModelListener#modelChanged(IAnnotationModel) | |
191 */ | |
192 public void modelChanged(IAnnotationModel model) { | |
193 if (model is fModel) { | |
145 | 194 Iterator iter= (new ArrayList(fAnnotationModelListeners)).iterator(); |
129 | 195 while (iter.hasNext()) { |
134 | 196 IAnnotationModelListener l= cast(IAnnotationModelListener)iter.next(); |
129 | 197 l.modelChanged(this); |
198 } | |
199 } | |
200 } | |
201 | |
202 /* | |
203 * @see IAnnotationModel#removeAnnotationModelListener(IAnnotationModelListener) | |
204 */ | |
205 public void removeAnnotationModelListener(IAnnotationModelListener listener) { | |
206 super.removeAnnotationModelListener(listener); | |
207 | |
208 if (fModel !is null && fAnnotationModelListeners.isEmpty()) | |
209 fModel.removeAnnotationModelListener(this); | |
210 } | |
211 } |