Mercurial > projects > dwt-addons
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwtx/jface/text/source/Annotation.d Sat Aug 23 19:10:48 2008 +0200 @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> + *******************************************************************************/ +module dwtx.jface.text.source.Annotation; + +import dwt.dwthelper.utils; + + +/** + * Annotation managed by an + * {@link dwtx.jface.text.source.IAnnotationModel}. + * <p> + * Annotations are typed, can have an associated text and can be marked as persistent and + * deleted. Annotations which are not explicitly initialized with an annotation + * type are of type <code>"dwtx.text.annotation.unknown"</code>. + */ +public class Annotation { + + /** + * Constant for unknown annotation types.<p> + * Value: <code>"dwtx.text.annotation.unknown"</code> + * @since 3.0 + */ + public final static String TYPE_UNKNOWN= "dwtx.text.annotation.unknown"; //$NON-NLS-1$ + + + /** + * The type of this annotation. + * @since 3.0 + */ + private String fType; + /** + * Indicates whether this annotation is persistent or not. + * @since 3.0 + */ + private bool fIsPersistent= false; + /** + * Indicates whether this annotation is marked as deleted or not. + * @since 3.0 + */ + private bool fMarkedAsDeleted= false; + /** + * The text associated with this annotation. + * @since 3.0 + */ + private String fText; + + + /** + * Creates a new annotation that is not persistent and type less. + */ + protected Annotation() { + this(null, false, null); + } + + /** + * Creates a new annotation with the given properties. + * + * @param type the unique name of this annotation type + * @param isPersistent <code>true</code> if this annotation is + * persistent, <code>false</code> otherwise + * @param text the text associated with this annotation + * @since 3.0 + */ + public Annotation(String type, bool isPersistent, String text) { + fType= type; + fIsPersistent= isPersistent; + fText= text; + } + + /** + * Creates a new annotation with the given persistence state. + * + * @param isPersistent <code>true</code> if persistent, <code>false</code> otherwise + * @since 3.0 + */ + public Annotation(bool isPersistent) { + this(null, isPersistent, null); + } + + /** + * Returns whether this annotation is persistent. + * + * @return <code>true</code> if this annotation is persistent, <code>false</code> + * otherwise + * @since 3.0 + */ + public bool isPersistent() { + return fIsPersistent; + } + + /** + * Sets the type of this annotation. + * + * @param type the annotation type + * @since 3.0 + */ + public void setType(String type) { + fType= type; + } + + /** + * Returns the type of the annotation. + * + * @return the type of the annotation + * @since 3.0 + */ + public String getType() { + return fType is null ? TYPE_UNKNOWN : fType; + } + + /** + * Marks this annotation deleted according to the value of the + * <code>deleted</code> parameter. + * + * @param deleted <code>true</code> if annotation should be marked as deleted + * @since 3.0 + */ + public void markDeleted(bool deleted) { + fMarkedAsDeleted= deleted; + } + + /** + * Returns whether this annotation is marked as deleted. + * + * @return <code>true</code> if annotation is marked as deleted, <code>false</code> + * otherwise + * @since 3.0 + */ + public bool isMarkedDeleted() { + return fMarkedAsDeleted; + } + + /** + * Sets the text associated with this annotation. + * + * @param text the text associated with this annotation + * @since 3.0 + */ + public void setText(String text) { + fText= text; + } + + /** + * Returns the text associated with this annotation. + * + * @return the text associated with this annotation or <code>null</code> + * @since 3.0 + */ + public String getText() { + return fText; + } +}