Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/Annotation.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
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 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 | |
18 /** | |
19 * Annotation managed by an | |
20 * {@link dwtx.jface.text.source.IAnnotationModel}. | |
21 * <p> | |
22 * Annotations are typed, can have an associated text and can be marked as persistent and | |
23 * deleted. Annotations which are not explicitly initialized with an annotation | |
24 * type are of type <code>"dwtx.text.annotation.unknown"</code>. | |
25 */ | |
26 public class Annotation { | |
27 | |
28 /** | |
29 * Constant for unknown annotation types.<p> | |
30 * Value: <code>"dwtx.text.annotation.unknown"</code> | |
31 * @since 3.0 | |
32 */ | |
33 public final static String TYPE_UNKNOWN= "dwtx.text.annotation.unknown"; //$NON-NLS-1$ | |
34 | |
35 | |
36 /** | |
37 * The type of this annotation. | |
38 * @since 3.0 | |
39 */ | |
40 private String fType; | |
41 /** | |
42 * Indicates whether this annotation is persistent or not. | |
43 * @since 3.0 | |
44 */ | |
45 private bool fIsPersistent= false; | |
46 /** | |
47 * Indicates whether this annotation is marked as deleted or not. | |
48 * @since 3.0 | |
49 */ | |
50 private bool fMarkedAsDeleted= false; | |
51 /** | |
52 * The text associated with this annotation. | |
53 * @since 3.0 | |
54 */ | |
55 private String fText; | |
56 | |
57 | |
58 /** | |
59 * Creates a new annotation that is not persistent and type less. | |
60 */ | |
61 protected Annotation() { | |
62 this(null, false, null); | |
63 } | |
64 | |
65 /** | |
66 * Creates a new annotation with the given properties. | |
67 * | |
68 * @param type the unique name of this annotation type | |
69 * @param isPersistent <code>true</code> if this annotation is | |
70 * persistent, <code>false</code> otherwise | |
71 * @param text the text associated with this annotation | |
72 * @since 3.0 | |
73 */ | |
74 public Annotation(String type, bool isPersistent, String text) { | |
75 fType= type; | |
76 fIsPersistent= isPersistent; | |
77 fText= text; | |
78 } | |
79 | |
80 /** | |
81 * Creates a new annotation with the given persistence state. | |
82 * | |
83 * @param isPersistent <code>true</code> if persistent, <code>false</code> otherwise | |
84 * @since 3.0 | |
85 */ | |
86 public Annotation(bool isPersistent) { | |
87 this(null, isPersistent, null); | |
88 } | |
89 | |
90 /** | |
91 * Returns whether this annotation is persistent. | |
92 * | |
93 * @return <code>true</code> if this annotation is persistent, <code>false</code> | |
94 * otherwise | |
95 * @since 3.0 | |
96 */ | |
97 public bool isPersistent() { | |
98 return fIsPersistent; | |
99 } | |
100 | |
101 /** | |
102 * Sets the type of this annotation. | |
103 * | |
104 * @param type the annotation type | |
105 * @since 3.0 | |
106 */ | |
107 public void setType(String type) { | |
108 fType= type; | |
109 } | |
110 | |
111 /** | |
112 * Returns the type of the annotation. | |
113 * | |
114 * @return the type of the annotation | |
115 * @since 3.0 | |
116 */ | |
117 public String getType() { | |
118 return fType is null ? TYPE_UNKNOWN : fType; | |
119 } | |
120 | |
121 /** | |
122 * Marks this annotation deleted according to the value of the | |
123 * <code>deleted</code> parameter. | |
124 * | |
125 * @param deleted <code>true</code> if annotation should be marked as deleted | |
126 * @since 3.0 | |
127 */ | |
128 public void markDeleted(bool deleted) { | |
129 fMarkedAsDeleted= deleted; | |
130 } | |
131 | |
132 /** | |
133 * Returns whether this annotation is marked as deleted. | |
134 * | |
135 * @return <code>true</code> if annotation is marked as deleted, <code>false</code> | |
136 * otherwise | |
137 * @since 3.0 | |
138 */ | |
139 public bool isMarkedDeleted() { | |
140 return fMarkedAsDeleted; | |
141 } | |
142 | |
143 /** | |
144 * Sets the text associated with this annotation. | |
145 * | |
146 * @param text the text associated with this annotation | |
147 * @since 3.0 | |
148 */ | |
149 public void setText(String text) { | |
150 fText= text; | |
151 } | |
152 | |
153 /** | |
154 * Returns the text associated with this annotation. | |
155 * | |
156 * @return the text associated with this annotation or <code>null</code> | |
157 * @since 3.0 | |
158 */ | |
159 public String getText() { | |
160 return fText; | |
161 } | |
162 } |