129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2008 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.projection.AnnotationBag;
|
|
14
|
131
|
15 import dwtx.jface.text.source.projection.ProjectionViewer; // packageimport
|
|
16 import dwtx.jface.text.source.projection.ProjectionSupport; // packageimport
|
|
17 import dwtx.jface.text.source.projection.IProjectionPosition; // packageimport
|
|
18 import dwtx.jface.text.source.projection.ProjectionSummary; // packageimport
|
|
19 import dwtx.jface.text.source.projection.ProjectionAnnotationHover; // packageimport
|
|
20 import dwtx.jface.text.source.projection.ProjectionRulerColumn; // packageimport
|
|
21 import dwtx.jface.text.source.projection.ProjectionAnnotationModel; // packageimport
|
|
22 import dwtx.jface.text.source.projection.SourceViewerInformationControl; // packageimport
|
|
23 import dwtx.jface.text.source.projection.IProjectionListener; // packageimport
|
|
24 import dwtx.jface.text.source.projection.ProjectionAnnotation; // packageimport
|
|
25
|
|
26
|
129
|
27 import dwt.dwthelper.utils;
|
|
28
|
|
29 import java.util.HashSet;
|
|
30 import java.util.Iterator;
|
|
31 import java.util.Set;
|
|
32
|
|
33 import dwtx.jface.text.source.Annotation;
|
|
34
|
|
35 /**
|
|
36 * A bag of annotations.
|
|
37 * <p>
|
|
38 * This class is not intended to be subclassed.
|
|
39 * </p>
|
|
40 *
|
|
41 * @since 3.0
|
|
42 * @noextend This class is not intended to be subclassed by clients.
|
|
43 */
|
|
44 public class AnnotationBag : Annotation {
|
|
45
|
|
46 private Set fAnnotations;
|
|
47
|
|
48 /**
|
|
49 * Creates a new annotation bag.
|
|
50 *
|
|
51 * @param type the annotation type
|
|
52 */
|
|
53 public AnnotationBag(String type) {
|
|
54 super(type, false, null);
|
|
55 }
|
|
56
|
|
57 /**
|
|
58 * Adds the given annotation to the annotation bag.
|
|
59 *
|
|
60 * @param annotation the annotation to add
|
|
61 */
|
|
62 public void add(Annotation annotation) {
|
|
63 if (fAnnotations is null)
|
|
64 fAnnotations= new HashSet(2);
|
|
65 fAnnotations.add(annotation);
|
|
66 }
|
|
67
|
|
68 /**
|
|
69 * Removes the given annotation from the annotation bag.
|
|
70 *
|
|
71 * @param annotation the annotation to remove
|
|
72 */
|
|
73 public void remove(Annotation annotation) {
|
|
74 if (fAnnotations !is null) {
|
|
75 fAnnotations.remove(annotation);
|
|
76 if (fAnnotations.isEmpty())
|
|
77 fAnnotations= null;
|
|
78 }
|
|
79 }
|
|
80
|
|
81 /**
|
|
82 * Returns whether the annotation bag is empty.
|
|
83 *
|
|
84 * @return <code>true</code> if the annotation bag is empty, <code>false</code> otherwise
|
|
85 */
|
|
86 public bool isEmpty() {
|
|
87 return fAnnotations is null;
|
|
88 }
|
|
89
|
|
90 /**
|
|
91 * Returns an iterator for all annotation inside this
|
|
92 * annotation bag or <code>null</code> if the bag is empty.
|
|
93 *
|
|
94 * @return an iterator for all annotations in the bag or <code>null</code>
|
|
95 * @since 3.1
|
|
96 */
|
|
97 public Iterator iterator() {
|
|
98 if (!isEmpty())
|
|
99 return fAnnotations.iterator();
|
|
100 return null;
|
|
101 }
|
|
102 }
|