Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: eeb1bdb6b4c7e11592d2308ecb0835a6597583c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.jface.text.source;

import java.util.Map;

import org.eclipse.jface.text.Position;


/**
 * Extends <code>IAnnotationModel</code> with the ability to attach additional
 * annotation models to it.
 * 
 * @since 3.0
 */
public interface IAnnotationModelExtension {
	
	/**
	 * Attaches <code>attachment</code> to the receiver. Connects
	 * <code>attachment</code> to the currently connected document. If
	 * <code>attachment</code> is already attached (even) under a different
	 * key), it is not attached again.
	 * 
	 * @param key the key through which the attachment is identified.
	 * @param attachment the attached <code>IAnnotationModel</code>
	 */
	void addAnnotationModel(Object key, IAnnotationModel attachment);
	
	/**
	 * Returns the attached <code>IAnnotationModel</code> for <code>key</code>,
	 * or <code>null</code> if none is attached for <code>key</code>.
	 * 
	 * @param key the key through which the attachment is identified.
	 * @return an <code>IAnnotationModel</code> attached under
	 *         <code>key</code>, or <code>null</code>
	 */
	IAnnotationModel getAnnotationModel(Object key);
	
	/**
	 * Removes and returns the attached <code>IAnnotationModel</code> for
	 * <code>key</code>.
	 * 
	 * @param key the key through which the attachment is identified.
	 * @return an <code>IAnnotationModel</code> attached under
	 *         <code>key</code>, or <code>null</code>
	 */
	IAnnotationModel removeAnnotationModel(Object key);

	/**
	 * Replaces annotations with new annotations for this annotation model. The
	 * new annotations are map entries where the annotation is the key and the
	 * value is the position for the annotation. Each position describes the
	 * range covered by the annotation. All registered annotation model
	 * listeners are informed about the change (if any). If the model is
	 * connected to a document, the positions are automatically updated on
	 * document changes. For each annotation which is already managed by this
	 * annotation model or is not associated with a valid position in the
	 * connected document nothing happens.
	 * 
	 * @param annotationsToRemove the annotations to be removed, may be
	 *            <code>null</code>
	 * @param annotationsToAdd the annotations which will be added, may be
	 *            <code>null</code> each map entry has an
	 *            <code>Annotation</code> as key and a <code>Position</code>
	 *            as value
	 * @throws ClassCastException if one of the map key or values has a wrong
	 *             type
	 */
	void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd) throws ClassCastException;
	
	/**
	 * Modifies the position associated with the given annotation to the given
	 * position. If the annotation is not yet managed by this annotation model,
	 * the annotation is added. If the given position is <code>null</code> the
	 * annotation is removed from the model. All annotation model change
	 * listeners will be informed about the change.
	 * 
	 * @param annotation the annotation whose associated position should be
	 *            modified
	 * @param position the position to whose values the associated position
	 *            should be changed
	 */
	void modifyAnnotationPosition(Annotation annotation, Position position);
	
	/**
	 * Removes all annotations from this annotation model.
	 */
	void removeAllAnnotations();
	
	/**
	 * Returns the modification stamp of this annotation model.
	 * 
	 * @return the modification stamp of this annotation model
	 */
	Object getModificationStamp();
}

Back to the top