129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2007 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.Annotation;
|
|
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.AnnotationModelEvent; // packageimport
|
|
57 import dwtx.jface.text.source.AnnotationColumn; // packageimport
|
|
58 import dwtx.jface.text.source.AnnotationRulerColumn; // packageimport
|
|
59 import dwtx.jface.text.source.IAnnotationHoverExtension; // packageimport
|
|
60 import dwtx.jface.text.source.AbstractRulerColumn; // packageimport
|
|
61 import dwtx.jface.text.source.ISourceViewerExtension; // packageimport
|
|
62 import dwtx.jface.text.source.AnnotationMap; // packageimport
|
|
63 import dwtx.jface.text.source.IVerticalRulerInfo; // packageimport
|
|
64 import dwtx.jface.text.source.IAnnotationModelExtension2; // packageimport
|
|
65 import dwtx.jface.text.source.LineRange; // packageimport
|
|
66 import dwtx.jface.text.source.IAnnotationAccessExtension2; // packageimport
|
|
67 import dwtx.jface.text.source.VerticalRuler; // packageimport
|
|
68 import dwtx.jface.text.source.JFaceTextMessages; // packageimport
|
|
69 import dwtx.jface.text.source.IOverviewRuler; // 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 /**
|
|
82 * Annotation managed by an
|
|
83 * {@link dwtx.jface.text.source.IAnnotationModel}.
|
|
84 * <p>
|
|
85 * Annotations are typed, can have an associated text and can be marked as persistent and
|
|
86 * deleted. Annotations which are not explicitly initialized with an annotation
|
|
87 * type are of type <code>"dwtx.text.annotation.unknown"</code>.
|
|
88 */
|
|
89 public class Annotation {
|
|
90
|
|
91 /**
|
|
92 * Constant for unknown annotation types.<p>
|
|
93 * Value: <code>"dwtx.text.annotation.unknown"</code>
|
|
94 * @since 3.0
|
|
95 */
|
|
96 public final static String TYPE_UNKNOWN= "dwtx.text.annotation.unknown"; //$NON-NLS-1$
|
|
97
|
|
98
|
|
99 /**
|
|
100 * The type of this annotation.
|
|
101 * @since 3.0
|
|
102 */
|
|
103 private String fType;
|
|
104 /**
|
|
105 * Indicates whether this annotation is persistent or not.
|
|
106 * @since 3.0
|
|
107 */
|
|
108 private bool fIsPersistent= false;
|
|
109 /**
|
|
110 * Indicates whether this annotation is marked as deleted or not.
|
|
111 * @since 3.0
|
|
112 */
|
|
113 private bool fMarkedAsDeleted= false;
|
|
114 /**
|
|
115 * The text associated with this annotation.
|
|
116 * @since 3.0
|
|
117 */
|
|
118 private String fText;
|
|
119
|
|
120
|
|
121 /**
|
|
122 * Creates a new annotation that is not persistent and type less.
|
|
123 */
|
|
124 protected Annotation() {
|
|
125 this(null, false, null);
|
|
126 }
|
|
127
|
|
128 /**
|
|
129 * Creates a new annotation with the given properties.
|
|
130 *
|
|
131 * @param type the unique name of this annotation type
|
|
132 * @param isPersistent <code>true</code> if this annotation is
|
|
133 * persistent, <code>false</code> otherwise
|
|
134 * @param text the text associated with this annotation
|
|
135 * @since 3.0
|
|
136 */
|
|
137 public Annotation(String type, bool isPersistent, String text) {
|
|
138 fType= type;
|
|
139 fIsPersistent= isPersistent;
|
|
140 fText= text;
|
|
141 }
|
|
142
|
|
143 /**
|
|
144 * Creates a new annotation with the given persistence state.
|
|
145 *
|
|
146 * @param isPersistent <code>true</code> if persistent, <code>false</code> otherwise
|
|
147 * @since 3.0
|
|
148 */
|
|
149 public Annotation(bool isPersistent) {
|
|
150 this(null, isPersistent, null);
|
|
151 }
|
|
152
|
|
153 /**
|
|
154 * Returns whether this annotation is persistent.
|
|
155 *
|
|
156 * @return <code>true</code> if this annotation is persistent, <code>false</code>
|
|
157 * otherwise
|
|
158 * @since 3.0
|
|
159 */
|
|
160 public bool isPersistent() {
|
|
161 return fIsPersistent;
|
|
162 }
|
|
163
|
|
164 /**
|
|
165 * Sets the type of this annotation.
|
|
166 *
|
|
167 * @param type the annotation type
|
|
168 * @since 3.0
|
|
169 */
|
|
170 public void setType(String type) {
|
|
171 fType= type;
|
|
172 }
|
|
173
|
|
174 /**
|
|
175 * Returns the type of the annotation.
|
|
176 *
|
|
177 * @return the type of the annotation
|
|
178 * @since 3.0
|
|
179 */
|
|
180 public String getType() {
|
|
181 return fType is null ? TYPE_UNKNOWN : fType;
|
|
182 }
|
|
183
|
|
184 /**
|
|
185 * Marks this annotation deleted according to the value of the
|
|
186 * <code>deleted</code> parameter.
|
|
187 *
|
|
188 * @param deleted <code>true</code> if annotation should be marked as deleted
|
|
189 * @since 3.0
|
|
190 */
|
|
191 public void markDeleted(bool deleted) {
|
|
192 fMarkedAsDeleted= deleted;
|
|
193 }
|
|
194
|
|
195 /**
|
|
196 * Returns whether this annotation is marked as deleted.
|
|
197 *
|
|
198 * @return <code>true</code> if annotation is marked as deleted, <code>false</code>
|
|
199 * otherwise
|
|
200 * @since 3.0
|
|
201 */
|
|
202 public bool isMarkedDeleted() {
|
|
203 return fMarkedAsDeleted;
|
|
204 }
|
|
205
|
|
206 /**
|
|
207 * Sets the text associated with this annotation.
|
|
208 *
|
|
209 * @param text the text associated with this annotation
|
|
210 * @since 3.0
|
|
211 */
|
|
212 public void setText(String text) {
|
|
213 fText= text;
|
|
214 }
|
|
215
|
|
216 /**
|
|
217 * Returns the text associated with this annotation.
|
|
218 *
|
|
219 * @return the text associated with this annotation or <code>null</code>
|
|
220 * @since 3.0
|
|
221 */
|
|
222 public String getText() {
|
|
223 return fText;
|
|
224 }
|
|
225 }
|